Implement custom_model_2d#1763
Conversation
|
No, it's trivial. I'm actually thinking of replacing |
|
Same goes, by the way, for the |
|
@embray Issue #2274 would probably best be fixed by the generalisations you describe above. And here's another bug in the current implementation of |
|
Okay, I'll take a look at it. The fix for parameter-less models should be straightforward. I have a slew of other modeling changes in the pipeline that are working toward bashing down unnecessary complexities and distilling the functionality of the core model classes. See #2276 for one of the first in this series, but there are more on the way. It should make issues like this a little easier to deal with. |
|
Since this is a feature request, I'm re-scheduling to 1.0.0 |
|
Attached to this a PR to implement a See the docstring for This may seem frivolous to some, but it's a preview of other related changes to come. This PR depends on #2580 which should be merged first. |
|
Rebased, hopefully, with doc fixes. |
|
Not sure why the doc build is failing but I don't think it's this PR's fault? |
|
You can read an updated example of using The API docs for |
|
@embray - very nice! A few notes from trying this out - not all have to be acted on, but just reporting my experience:
and the error message was: which is fine, but maybe it would be nice to get a more explicit error message? (the correct call is shown in the example below)
when I did this, I got the warning: but as a user, I don't know what Other than that, this works great, so 👍 from me! The issues above may be unrelated to this pull request, and just more general comments. |
There was a problem hiding this comment.
I like the way that you use custom_model as a function in the first example and as a decorator here. Out would be even better if there was a sentence in the text that both uses are possible.
There was a problem hiding this comment.
Yes, that's worth clarifying. I think I might also go ahead and make it so that the decorator can take arguments too (for example @custom_model(fit_deriv=...)
|
@astrofrog Those are issues in the fitter--totally unrelated to the |
|
@astrofrog Or are you saying something in the sample documentation needs to be fixed too? |
|
@embray - if it's unrelated to this PR then ignore for now. Should I open issues for those or will they become moot once you rework the fitters anyway? |
534bb0c to
92f61ba
Compare
… to take arguments when used as a decorator as well. I also clarified in the documentation that it can be used either as a decorator or a normal factory function.
|
You can open an issue if you want. |
There was a problem hiding this comment.
(Minor) This should be six.callable
|
Not sure why I didn't merge this already, but now it needs to be rebased.. |
….core, in the process updating it to support creating custom N-dimensional models. custom_model_1d is still kept for backward compat but will be deprecated.
…or subclasses, because then self.__class__ is not longer the correct base class in the super chain (in fact it leads to an infinite recursion). Turns it it suffices to attach __init__ and __call__ to the class after it has been created. Adds a test to ensure that this works.
…onger needs to include its own copy of the make_func_with_sig utility. I also renamed make_func_with_sig to make_function_with_signature as suggested here: astropy#2835 (comment) Previously I thought the unabbreviated name was a little on the long side. But on second thought I prefer the clarity here.
… to take arguments when used as a decorator as well. I also clarified in the documentation that it can be used either as a decorator or a normal factory function.
92c3590 to
37d7c51
Compare
|
Rebased. Waiting on Travis... |
|
Docs build failed due to #2914 , but I confirmed locally that the docs built without warning (and prior the rebase the build passed) so I'm going ahead and merging. |
Since we have
custom_model_1d, is there any reason we can't havecustom_model_2d?