Skip to content

ImageStreamIOWrap in Python fails on C-order arrays in confusing way #22

Description

@joseph-long

We just installed the dev branch on MagAO-X for testing and found what might be a regression.

import ImageStreamIOWrap
img = ImageStreamIOWrap.Image()
img.open('test')
import numpy as np
to_arr = np.array(img)  # works
x = img.copy() # works
img.write(x) # works

new0 = np.ones(x.shape, dtype=x.dtype)
img.write(new0)  # fails
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [31], in <module>
----> 1 img.write(new0)

ValueError: incompatible type

It appears that this has something to do with C-contiguous vs. Fortran-contiguous arrays:

x.flags

  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False
new0.flags

  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False

@kvangorkom reported and I helped debug. Not sure where to go from here, but we can use fortran order explicitly as a workaround in the meantime.

cc @jaredmales

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions