-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow scalar input for 't', 'E' and 'data' arguments of Container class #301
Allow scalar input for 't', 'E' and 'data' arguments of Container class #301
Conversation
Even worse—before, you needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, on second thought, one thing gives me pause:
In addition to giving scalars for all arguments, this would also enable using a mix of scalars and vectors. E.g.
# pass array of energies, scalars for all quantities
Flux(data = [1, 1, 1] << u.Unit('1/(MeV s cm**2)'),
flavor=Flavor.NU_E,
time=1<<u.s,
energy=[1, 2, 3]<<u.MeV)
# pass array of times, scalars for all other quantities
Flux(data = [1, 1, 1] << u.Unit('1/(MeV s cm**2)'),
flavor=Flavor.NU_E,
time=[1, 2, 3]<<u.s,
energy=1<<u.MeV)
Both would produce the same 3D data array, but the intended physics meaning is different. I wonder if this makes it too easy to introduce mistakes?
Thanks, you're right! I didn't think about that. That's definitely against what the user would expect. |
I added:
Maybe it still doesn't cover all the possible corner cases. But I need to think of more strict conditions, when to use this reshaping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not quite sure about corner cases either; but this certainly adds useful guard rails for the intuitive(-seeming) case. And for all other cases, one has to consciously think about the array shape anyway; so having no extra guard rails is probably fine.
Thanks!
Fixing problem if a user passes a scalar value to container.
Example: