-
Notifications
You must be signed in to change notification settings - Fork 280
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
ENH: improve error messages when add_field receives a malformed function argument #3921
ENH: improve error messages when add_field receives a malformed function argument #3921
Conversation
2f63eaf
to
c08c55d
Compare
switched to draft because I realised that in my tests, I was adding fields that are inaccessible since I provided neither dimensions or units. I feel like the |
9fd15ba
to
366130b
Compare
Failures are unrelated and likely to be caused by pypa/pip#11116 |
2c73acd
to
186ef7e
Compare
I have found the |
6298bb7
to
67c111a
Compare
Kinda. I'm not sure what you mean by "descriptive rather than prescriptive", and I'm not sure that I can say that it doesn't allow for silent failures: with the new behaviour, validation can be omitted completely (but you do get a warning) |
I guess what I mean is, validation will fail, but you still get the units that come out of the field. i.e., it still tracks, but does not do validation against a priori values |
Yes I think that's correct. |
590cb6b
to
cae71c2
Compare
cae71c2
to
9e6d845
Compare
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 generally OK with this. I have a question though: without passing judgment on them, can you estimate how many people might have their derived fields broken by this? 0, a few, or lots?
I would naively assume none to a few, but we may want to be slightly more cautious and raise a warning instead of an error for a while (and explicitly state that it'll be an error in the future). Your call :) |
I don't think that is necessary. |
PR Summary
This makes life easier for clumsy users like myself who can never remember what argument goes first in a derived field function, so you get a clear error message instead of whatever happens when the malformed function gets called with reversed arguments. Incidentally adds support and tests for passing arbitrary callables as the
function
argument.edit: I also reworked the way
units="auto"
works to make thedimensions
argument optional even in that case. This is an opinionated change but I think it's reasonable as long as a warning is displayed when needed.