Skip to content

astype method lost its order parameter #4644

@rhkleijn

Description

@rhkleijn

What happened:
I upgraded from xarray 0.15.1 to 0.16.2 and the astype method seems to have lost the order parameter.

In [1]: import xarray as xr

In [2]: xr.__version__
Out[2]: '0.16.2'

In [3]: xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-208ab49008ef> in <module>
----> 1 xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides

TypeError: astype() got an unexpected keyword argument 'order'

What you expected to happen:
I was expecting to get the same result as with xarray 0.15.1:

In [1]: import xarray as xr

In [2]: xr.__version__
Out[2]: '0.15.1'

In [3]: xr.DataArray([[1.0, 2.0], [3.0, 4.0]]).astype(dtype='d', order='F').values.strides
Out[3]: (8, 16)

Anything else we need to know?:
Looking at the documentation it seems it disappeared between 0.16.0 and 0.16.1. The documentation at http://xarray.pydata.org/en/v0.16.0/generated/xarray.DataArray.astype.html
still has this snippet

order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.

(which was identical to the documentation from numpy.ndarray.astype at https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html)

while http://xarray.pydata.org/en/v0.16.1/generated/xarray.DataArray.astype.html seems to lack that part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtopic-arraysrelated to flexible array support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions