Closed sdrogers closed 4 years ago
Any reason not to have all values callable? Efficiency?
Two reasons:
Make it a property! No need to have parentheses.
class duration:
@property
def value(self):
return 42
>>> d = duration()
>>> c = d.value
>>> c
42
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?
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.
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!
On further thoughts, looks like it might not be possible (easily). Need to brush up on my python!
ok, going to merge
…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)