Repository navigation
Stream sampling [merge after chunk loading] - #45
Conversation
| class SampledEventData(dict[str, np.ndarray]): | ||
| """Sampled event arrays and the total weight of the input stream.""" | ||
|
|
||
| def __init__(self, event_data: dict[str, np.ndarray], total_weight: float): |
There was a problem hiding this comment.
event_data can be broken into multiple keywords or sth more clear?
There was a problem hiding this comment.
I have added doc string to better explain whats going on here! We could make it take arbitrary keyword arguments like a dict() constructor, but it will be more or less the same thing in the end. This class is only constructed as a way to report the data back to the user, so it's not something we expect the user to be able to init ever
YooSunYoung
left a comment
There was a problem hiding this comment.
Looks good to me...! I just had a minor question, and it's not a blocker I think.
Let's merge/release it and then I'll try making a code shelf notebook with it...!
| square=True, banana=True, id_overlap=False, id_gap=False, non_zero_id_start=False | ||
| ): | ||
| instr = ms.McStas_instr("test") | ||
| instr = ms.McStas_instr(f"test_{os.getpid()}") |
There was a problem hiding this comment.
Is this to make the instrument unique?
Then we can use uuid instead maybe.
There was a problem hiding this comment.
Since multiple documentation notebooks build that instrument and execute it in parallel, it is to avoid the data files being named the same. In sequence, it is detected and avoided, but not in parallel.
I think this problem can be solved in a nicer way by only making the data folder name funny, not also the instrument name. Would be nice to merge and get it in a later round!
Aaron has used a really nice solution for sampling McStas weighted events to unit events while working with simulated data for NMX. He has verbally agreed to me sharing the code by adding it to this package.
His work can be found here: https://github.com/aaronfinke/stream_sampling_mcstas
This implementation support the chunk loading, and should be merged after that pull request is accepted.