-
Notifications
You must be signed in to change notification settings - Fork 36
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
Valid inputs for nodes parameter. #146
Comments
Thanks for stopping by @anntzer! I love hearing from users. I have thought about adding a "list of lists" as an acceptable input and I think it's a reasonable request. I'm somewhat inclined to "guard" the curve = bezier.Curve.from_free([[0.0, 1.5, 3.5], [2.0, 1.5, 0.0]]) Then (My inclination to "guard": I worry a bit that polymorphic inputs make code harder to reason about and makes APIs harder to use, but maybe I'm wrong in that worry.) Nodes are expected to be in Fortran order since all of the low-level algorithms access the raw array underlying the |
My personal view on polymorphic constructors is that if you need to put in conditional branches that interpret the inputs in a wildly different manner, then it's better to split in multiple constructors, but here you don't need to, you can just pass everything through np.asarray. So (for some unrelated class) I'd have Given that the constructor will always handle the fortranordering, I would not bother with showing that info in the docs (I think f-order arrays are quite rare in "normal" numpy usage). Likewise, unless I am mistaken, the Again, not a huge deal either way. The quality of the library (especially the documentation of the C-API) is top notch and I am just nitpicking. |
TL;DR: Indeed, punting to
I could go either way on that. When I did it, I was on a "don't do any computation in the real constructor" kick. For
Yes and no. The default ordering provided by the library is C, but most computational kernels are still written in Fortran or were ported (e.g. via
Well most useful things (e.g.
It's worth noting that The copy serves a few purposes:
|
Let's say "if someone just wants to use some library in drive-by mode and generates their inputs using standard numpy constructs, these inputs will likely (IMO) be in C-order".
Ah, I see. The docs are a bit unclear there; it may be nice to explicitly document the supported degrees for each method (I don't think this info is available anywhere?).
I guess the question is whether the end user passing in Again, none of this is really that important :) |
Oh and by the way, now that we're talking about design points: Perhaps a bit too late to change that though... |
And while we're at it: it is also slightly jarring that the argument order of |
Not too late, I'm open to it. However, that's a C-vs.-Fortran ordering issue. I originally had them that way, but the algorithms more often grab an entire point ( |
Sorry if I'm being dense, but wouldn't it work if the API was expecting (n, 2) arrays in C-order (from the point of view of the user)? It "just happens" that these are also (2, n) arrays in F-order, so everything goes well? |
@anntzer I partially satisfied this request in 68f7dc7. Sorry for dragging my feet for so long. Some things that are pending from our discussion:
|
No worries :) |
Towards #146. Before, these factory constructor methods **assumed** `nodes` had a shape, which was not required by the documentation.
Very minor usability request: It would be nice if the Curve constructor directly accepted nested lists as input for the nodes array, calling np.asarray on them as needed.
Also, note that the example in the docs for the Curve constructor
is a bit confusing, as it suggests that the input must be in Fortran order, even though this is not the case (AFAICT).
The text was updated successfully, but these errors were encountered: