glasgowcompbio / vimms

A programmable and modular LC/MS simulator in Python
MIT License
19 stars 6 forks source link

fix to ms to make timing dictionaries more general dictionaries can n… #20

Closed sdrogers closed 4 years ago

sdrogers commented 4 years ago

…ow take single values as arguments (all scans will be the same time) or callable objects, in which case it is called (to e.g. have random times)

RonanDaly commented 4 years ago

Any reason not to have all values callable? Efficiency?

sdrogers commented 4 years ago

Two reasons:

  1. Regression - old stuff will stop working.
  2. It's useful to be able to supply constants (although that could be callable)
RonanDaly commented 4 years ago

Make it a property! No need to have parentheses.

class duration:
 @property
 def value(self):
  return 42

>>> d = duration()
>>> c = d.value
>>> c
42
sdrogers commented 4 years ago

guess that's fine if they are our own methods, but say we want to use something like: np.random.rand()? We'd have to wrap it up in another class?

RonanDaly commented 4 years ago

Yes, and delegate. But one class will do for everything if methods are passed in - otherwise, more complex calculations could be done ahead of time and released as needed.

sdrogers commented 4 years ago

Sorry - don't follow. Can you give an example of how I'd populate the dictionary where I wanted ms1 scans to get times drawn from np.random.rand? e.g. di = {1: ????} Thanks!

RonanDaly commented 4 years ago

On further thoughts, looks like it might not be possible (easily). Need to brush up on my python!

sdrogers commented 4 years ago

ok, going to merge