-
Notifications
You must be signed in to change notification settings - Fork 8
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
Changes basis inheritance of evaluate / evaluate_on_grid #60
Conversation
changes where the public method evaluate is defined, so that the user-facing docstring for the simple basis objects (i.e., not Additive or Multiplicative) is clearer
Failing tests are due to two reasons:
Assuming everyone's okay with these changes, I'll update tests accordingly. The main question is -- do we want The argument against it is that it's possible that if somebody called |
hei Billy, I do think this is the right choice, the code gets slightly longer but the evaluate is much more clear with informative docstrings. I would say you should go ahead and fix the tests! |
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 already commented in the response section. I think all the chages are sensible and I think this is the best we can do if we want to have informative docstrings in the evaluation methods. I really like how the code looks now for this module, very satisfied.
Thanks for working this out! You can go ahead with the tests
basis.evaluate now supports single int inputs, update tests to reflect that
this way the error raised here (which can only be hit by AdditiveBasis or MultiplicativeBasis) matches the error raised by the single bases objects: MSplineBasis(5).evaluate(5, 5) raises typeError (MSplineBasis(5)+MSplineBasis(5)).evaluate(5) also raises typeError
This PR is an implementation of #30 : it changes where the public instantiation of the basis
evaluate
/evaluate_on_grid
happens so that the user-facing docstring and function signature are more transparent.Previously, the docstring that showed up for these two methods was the one from the super class, which was generic and suggested that they could accept an arbitrary number of inputs, but e.g., the following:
fails. Now, the docstring for
evaluate
andevaluate_on_grid
make it clear that they expect a single input.This required renaming the superclass
evaluate
to_check_evaluate_input
, and then all the subclasses call that method first.The superclass
evaluate_on_grid
method is still public, and it's the one used directly byAdditiveBasis
andMultiplicativeBasis
Also:
sample_pts
directly, instead we see if it can be cast to a numpy array with floating point type, of at least 1d.I'm not super happy about:
AdditiveBasis
andMultiplicativeBasis
still have the less informative docstring. Given their recursive nature, I'm not sure there's a way around this without doing something real weird like settingself.evaluate.__func__.__doc__
during initialization, which seems ... badevaluate_on_grid
: whereas every concrete class had an_evaluate
method that just got promoted toevaluate
, none of them had anything like that forevaluate_on_grid
. So now each has a newevaluate_on_grid
whose entire point is just to define the docstring -- the only thing it does is callsuper().evaluate_on_grid(n_samples)
. I still think this is better than previously, because the docstring and function signature are clear, but ... it's ugly.I also think the new docstrings can probably be made more informative. Happy to go and do that if people think this is worth doing.