Skip to content

Astropy grouped table aggregation with columns of non-native endianness is broken in Numpy 1.22 #12706

@lpsinger

Description

@lpsinger

Description

With numpy 1.22, astropy fails to aggregate table columns of non-native endianness. This works with numpy 1.21.

Expected behavior

With numpy 1.21.5:

>>> import numpy as np
>>> from astropy.table import Table
>>> table = Table({'foo': np.arange(10, dtype='>f8')})
>>> table['bar'] = table['foo'] % 2
>>> table.group_by('bar').groups.aggregate(np.sum)
<Table length=2>
  foo     bar  
float64 float64
------- -------
   20.0     0.0
   25.0     1.0

Actual behavior

With numpy 1.22.0:

>>> import numpy as np
>>> from astropy.table import Table
>>> table = Table({'foo': np.arange(10, dtype='>f8')})
>>> table['bar'] = table['foo'] % 2
>>> table.group_by('bar').groups.aggregate(np.sum)
WARNING: Cannot aggregate column 'foo' with type '>f8' [astropy.table.groups]
<Table length=2>
  bar  
float64
-------
    0.0
    1.0

Steps to Reproduce

(see example code above)

System Details

>>> import platform; print(platform.platform())
macOS-11.6.2-x86_64-i386-64bit
>>> import sys; print("Python", sys.version)
Python 3.8.12 (default, Nov 13 2021, 08:16:46) 
[Clang 12.0.5 (clang-1205.0.22.11)]
>>> import numpy; print("Numpy", numpy.__version__)
Numpy 1.22.0
>>> import erfa; print("pyerfa", erfa.__version__)
pyerfa 2.0.0.1
>>> import astropy; print("astropy", astropy.__version__)
astropy 5.0
>>> import scipy; print("Scipy", scipy.__version__)
Scipy 1.7.3
>>> import matplotlib; print("Matplotlib", matplotlib.__version__)
Matplotlib 3.5.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions