-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: deduplicate fromroots in np.polynomial #13078
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
Conversation
e3a3a4a
to
248ff61
Compare
248ff61
to
d84cbcc
Compare
LGTM doesn't seem to pick this up as deduplicating - maybe it will after its merged |
There is a very old PR, #6071, that adds a |
Should be pretty trivial to merge |
Hmm, this breaks the intended organization of the code. The original idea was to implement a bunch of building blocks from which higher level objects could be built, the polynomial classes being one group of higher level objects, but there could be others. Moving some base code into the polynomial classes breaks that structure. and changes the result type. I think the common code can still be separated without using the class. |
This isn't true. I could rewrite
This line of reasoning makes sense to me, but all of those higher-level objects are going to want some way to know that
|
d84cbcc
to
820fe97
Compare
I thought about something like that back in the beginning, also removing the prefixes as the functions are pretty much all duplicates in function. I'm certainly open to suggestions but need to sit down and think about it. Multivariable versions of the classes are a conundrum, the single variable polynomials have a lot of special properties. For a multivariable class my own common uses have been fitting, evaluation, and differentiation, but I don't know what would be wanted by other folks. Masked coefficients could also be useful. |
That crossed my mind too. I'm not really setting out to try and solve these problems right now though - my motivation was just to reduce the LGTM warnings and de-duplicate some code. Do you want me to adjust this PR to use |
Maybe it still thinks the functions are duplicates? Thinking about this some more, sounds like you are using the class only because all the functions are available without prefixes. If you could gather the relevant functions into a base object and use it in the creation of the current classes, that would be OK with me. Not sure what the best way to do that is, I'm not a big fan of mixins or multiple inheritance, but doing that must be some sort of common design pattern. |
I think this is opening a bunch of worm-cans I didn't want to touch. I'll go the polyutils route, since I don't think this case is any different to the Vander one. Whatever approach we use to clean this up down the line, it'll apply equally to both sets of methods, |
820fe97
to
4dfc868
Compare
…polyutils Every implementation is the same right now, other than calling different line / mul functions. Found by LGTM.
4dfc868
to
1bb279a
Compare
Thanks Eric. |
This merges together the identical implementations of:
*fromroots
*vander2d
(moved to MAINT: Merge duplicate implementations of*vander3d
*vander2d
and*vander3d
functions #13079)as detected by LGTM.