-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Change argument order of NonlinearOperator #3468
Conversation
I'm not in favor of this. Adding lots of shortcuts for the sake of saving a few characters typing is not worth the trade-off. Constructing new operators with the constructor will be used very rarely. Also, we shouldn't be advising people to use the If needed at all, surely this just requires the method: NonlinearOperator(f::Function) = NonlinearOperator(Symbol(f), f) |
I also think that, as a rule, we should be considering only breaking changes right now. Quality of life changes that can be added as feature additions can wait until this is out in the wild and we see how people are using it. |
It's breaking if we reorder the fields.
I think that's where we disagree. If you're not planning to set the |
Why do we need to do that?
Who is going to be using |
I guess swapping the order is in the style guide, which says that functions should go as the first argument. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3468 +/- ##
=======================================
Coverage 98.09% 98.09%
=======================================
Files 37 37
Lines 5501 5501
=======================================
Hits 5396 5396
Misses 105 105
☔ View full report in Codecov by Sentry. |
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 okay with this. But I don't think we need an optional argument.
It's not about saving the space, it's about removing the possibility to make a typo where you miss a character in the symbol for instance. Again, any non-AD usage would require that because we hardcode the list of operators to be exactly AD. Since we have |
This also changes the order between the two because when one of the two has a default value depending on the other one it's usually the second positional argument.
It also allows to write
NonlinearOperator(func::Function, head::Symbol = Symbol(func))
in the docstring which wouldn't be possible if the order was reversed.This change only matters when
NonlinearOperator
is called directly and not through@operator
.It seems to me that when
NonlinearOperator
is called directly, you would want the symbol to be the function name 99% of the time so having this default value makes sense. It's also the default in the@operator
macro so it's consistent.