Open SylvainCorlay opened 6 years ago
I understand this would be a backward-incompatible change.
I'm a little unsure what behavior you intend:
I meant version 2.
Then, as long as it is compatible with the API of the JS ndarray library I would be for it. I would consider making a flag for the wanted behavior though (I'll have to look at it in detail).
I appears to be supporting strides in the constructors.
Note that strides in numpy
are in number of bytes, instead of number of elements (unlike JS ndarray and xtensor).
@vidartf instead of using flags, you can use a coercing custom validator.
http://traittypes.readthedocs.io/en/latest/usage.html#example-validating-the-shape-of-a-numpy-array
PS: Any code on the JS side that uses the underlying typed array will likely need the contiguous array, so we should probably also implement a utility function on the JS side for getting a typed array of a certain order.
Is this a feature of the JS ndarray library?
No, but it should be a simple for loop for C-contiguous, I think. Things like threejs require the raw data, so I don't want to upset that too much.
Would it be possible to drop the
ascontiguousarray
in theto_json
, and specify strides instead in the wire format?In doing so, we should be able to prevent an extra copy in the case of non-contiguous arrays / strided views.
cc @maartenbreddels @wolfv @gouarin.