Skip to content
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

[QUESTION] Transpose nodes to (npts, ndim) instead of (ndim, npts) #153

Closed
dhermes opened this issue Oct 24, 2019 · 2 comments
Closed

[QUESTION] Transpose nodes to (npts, ndim) instead of (ndim, npts) #153

dhermes opened this issue Oct 24, 2019 · 2 comments

Comments

@dhermes
Copy link
Owner

dhermes commented Oct 24, 2019

See:

cc @anntzer


Some notes:

  • This would be a breaking change and hence painful for users
  • I used to have the orientation this way and switched it since Fortran order made grabbing an entire point / column at once important to happen with data locality
  • The data-contiguous argument goes away if we internally use C-order (for Python mode) instead of F-order
@dhermes
Copy link
Owner Author

dhermes commented Feb 26, 2021

So I just don't have the bandwidth to make a change like this (especially since it'll be such a breaking change).

For anyone that comes across here, you can use C-ordered NumPy arrays (the default ordering in most situations) and just pass in the transpose of those arrays with copy=False. For example:

In [1]: import bezier

In [2]: bezier.__version__
Out[2]: '2021.2.12'

In [3]: import numpy as np

In [4]: nodes_T = np.array([
   ...:     [0.0, 0.0],
   ...:     [0.5, 1.0],
   ...:     [1.0, 0.0],
   ...: ], order="C")

In [5]: curve = bezier.Curve.from_nodes(nodes_T.T, copy=False)

In [6]: curve._nodes.base is nodes_T
Out[6]: True

In [7]: curve._nodes.flags
Out[7]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False

@dhermes dhermes closed this as completed Feb 26, 2021
@anntzer
Copy link
Contributor

anntzer commented Feb 27, 2021

No worries, thanks for considering the proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants