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

Flumpy doesn't gracefully handle non-contiguous arrays #405

Closed
ndevenish opened this issue Jul 15, 2021 · 2 comments
Closed

Flumpy doesn't gracefully handle non-contiguous arrays #405

ndevenish opened this issue Jul 15, 2021 · 2 comments
Assignees

Comments

@ndevenish
Copy link
Collaborator

>>> data = np.zeros((256,256,256))
>>> flumpy.from_numpy(data)[0:1,1:255,1:255]
double([[[0., 0., 0., ..., 0., 0., 0.],
        [0., 0., 0., ..., 0., 0., 0.],
        [0., 0., 0., ..., 0., 0., 0.],
        ...,
        [0., 0., 0., ..., 0., 0., 0.],
        [0., 0., 0., ..., 0., 0., 0.],
        [0., 0., 0., ..., 0., 0., 0.]]])
>>> flumpy.from_numpy(data[0:1,1:255,1:255])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'numpy.ndarray' object has no attribute 'obj'

This should either throw an explicit error, or try to safely derive the originating object and apply that via array_family focus (in this case, a focus on data[0:1,1:255,1:255].base)

@ndevenish ndevenish self-assigned this Jul 15, 2021
@ndevenish
Copy link
Collaborator Author

Apparently I've confused the array_family focus and origin features. A combination of origin and array sizes appears like it might do what we want to map to (with caveats....) https://github.com/cctbx/cctbx_project/blob/c989249e67daf3f790f28586adc292c2c8114f77/scitbx/array_family/accessors/flex_grid.h#L384-L399

@ndevenish
Copy link
Collaborator Author

No, this appears not possible - although you can set the origin of a flex.grid you can't change the presented width of the data - so it'd only work with data sliced off the front, and flex_grid isn't very amenable to subclassing. Can still make it have a better error though.

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

No branches or pull requests

1 participant