GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MaskedNDArray.sort() got an unexpected keyword argument 'descending' + array compare failure · Issue #19760 · astropy/astropy

MaskedNDArray.sort() got an unexpected keyword argument 'descending' + array compare failure #19760

New issue
Copy link
New issue
Copy link
Closed
Closed
MaskedNDArray.sort() got an unexpected keyword argument 'descending' + array compare failure#19760
Copy link
Labels
Upstream Action RequiredWas: Upstream Fix Requirednumpy-devutils.masked

Description

@pllim
pllim
opened on May 18, 2026
Issue body actions

Suspect upstream PR:

  • ENH: Descending sorts with built-in dtype implementations numpy/numpy#31345
________________________ TestArgFunctions.test_argsort _________________________

self = <astropy.units.tests.test_quantity_non_ufuncs.TestArgFunctions object at 0x7f1c67637e10>

    def test_argsort(self):
>       self.check(np.argsort)

astropy/units/tests/test_quantity_non_ufuncs.py:209: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <astropy.units.tests.test_quantity_non_ufuncs.TestArgFunctions object at 0x7f1c67637e10>
func = <function argsort at 0x7f1c97d829f0>, args = (), kwargs = {}
out = <Quantity [[0, 1, 2],
           [0, 1, 2],
           [0, 1, 2]] m>
expected = array([[0, 1, 2],
       [0, 1, 2],
       [0, 1, 2]])
@py_assert2 = <class 'astropy.units.quantity.Quantity'>
@py_assert7 = <class 'numpy.ndarray'>, @py_assert4 = False
@py_format9 = "<class 'astropy.units.quantity.Quantity'>\n{<class 'astropy.units.quantity.Quantity'> = type(<Quantity [[0, 1, 2],\\n...class 'numpy.ndarray'>\n{<class 'numpy.ndarray'> = type(array([[0, 1, 2],\\n       [0, 1, 2],\\n       [0, 1, 2]]))\n}"
@py_format11 = "assert <class 'astropy.units.quantity.Quantity'>\n{<class 'astropy.units.quantity.Quantity'> = type(<Quantity [[0, 1,...class 'numpy.ndarray'>\n{<class 'numpy.ndarray'> = type(array([[0, 1, 2],\\n       [0, 1, 2],\\n       [0, 1, 2]]))\n}"

    def check(self, func, *args, **kwargs):
        out = func(self.q, *args, **kwargs)
        expected = func(self.q.value, *args, *kwargs)
>       assert type(out) is type(expected)
E       AssertionError: assert <class 'astropy.units.quantity.Quantity'> is <class 'numpy.ndarray'>
E        +  where <class 'astropy.units.quantity.Quantity'> = type(<Quantity [[0, 1, 2],\n           [0, 1, 2],\n           [0, 1, 2]] m>)
E        +  and   <class 'numpy.ndarray'> = type(array([[0, 1, 2],\n       [0, 1, 2],\n       [0, 1, 2]]))

astropy/units/tests/test_quantity_non_ufuncs.py:93: AssertionError
________________________ TestArgFunctions.test_argsort _________________________

self = <astropy.utils.masked.tests.test_function_helpers.TestArgFunctions object at 0x7f1c6b1d63f0>

    def test_argsort(self):
>       self.check(np.argsort, fill_value=np.nan)

astropy/utils/masked/tests/test_function_helpers.py:177: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <astropy.utils.masked.tests.test_function_helpers.TestArgFunctions object at 0x7f1c6b1d63f0>
function = <function argsort at 0x7f1c97d829f0>, fill_value = nan, args = ()
kwargs = {}, o = MaskedNDArray([[0, 1, 2],
               [0, 1, 2]])
a_filled = array([[nan,  1.,  2.],
       [ 3., nan,  5.]])
expected = array([[1, 2, 0],
       [0, 2, 1]])

    def check(self, function, *args, fill_value=np.nan, **kwargs):
        o = function(self.ma, *args, **kwargs)
        a_filled = self.ma.filled(fill_value=fill_value)
        expected = function(a_filled, *args, **kwargs)
>       assert_array_equal(o, expected)
E       AssertionError: 
E       Arrays are not equal
E       
E       Mismatched elements: 5 / 6 (83.3%)
E       Mismatch at indices:
E        [0, 0]: 0 (ACTUAL), 1 (DESIRED)
E        [0, 1]: 1 (ACTUAL), 2 (DESIRED)
E        [0, 2]: 2 (ACTUAL), 0 (DESIRED)
E        [1, 1]: 1 (ACTUAL), 2 (DESIRED)
E        [1, 2]: 2 (ACTUAL), 1 (DESIRED)
E       Max absolute difference among violations: 2
E       Max relative difference among violations: 1.
E        ACTUAL: MaskedNDArray([[0, 1, 2],
E                      [0, 1, 2]])
E        DESIRED: array([[1, 2, 0],
E              [0, 2, 1]])

astropy/utils/masked/tests/test_function_helpers.py:168: AssertionError
_________________________ TestSortFunctions.test_sort __________________________

self = <astropy.utils.masked.tests.test_function_helpers.TestSortFunctions object at 0x7f1c6a9db250>

    def test_sort(self):
>       o = np.sort(self.ma)
            ^^^^^^^^^^^^^^^^

astropy/utils/masked/tests/test_function_helpers.py:1199: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/utils/masked/core.py:1015: in __array_function__
    return super().__array_function__(function, types, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = MaskedNDArray([[——, 1., 2.],
               [3., ——, 5.]]), axis = -1
kind = None, order = None

    @array_function_dispatch(_sort_dispatcher)
    def sort(a, axis=-1, kind=None, order=None, *, stable=None, descending=None):
...
        if axis is None:
            # flatten returns (1, N) for np.matrix, so always use the last axis
            a = asanyarray(a).flatten()
            axis = -1
        else:
            a = asanyarray(a).copy(order="K")
>       a.sort(axis=axis, kind=kind, order=order, stable=stable, descending=descending)
E       TypeError: MaskedNDArray.sort() got an unexpected keyword argument 'descending'

numpy/_core/fromnumeric.py:1101: TypeError

Activity

  1. pllim
    added
    numpy-dev
    utils.masked
    on May 18, 2026
  2. pllim commented on May 18, 2026

    @pllim
    pllim
    on May 18, 2026 · Hidden as resolved
    Author
    show commentMore actions
  3. mhvk commented on May 19, 2026

    @mhvk
    mhvk
    on May 19, 2026
    Contributor
    More actions

    I think the problem is indeed upstream (though we should adjust appropriately later), thanks for tackling it!

    Reacted by P. L. Lim
  4. pllim
    added
    Upstream Action RequiredWas: Upstream Fix Required
    on May 19, 2026
  5. pllim commented on May 19, 2026

    @pllim
    pllim
    on May 19, 2026
    MemberAuthor
    More actions

    I am afraid to build numpy from source. Do you think numpy/numpy#31458 would completely fix everything here without further action from us?

  6. pllim commented on May 19, 2026

    @pllim
    pllim
    on May 19, 2026
    MemberAuthor
    More actions

    Upstream PR was merged, so now we wait for the "nightly" wheel to land and see if devdeps would be green again. 🤞

  7. pllim commented on May 20, 2026

    @pllim
    pllim
    on May 20, 2026
    MemberAuthor
    More actions

    devdeps is green!

  8. pllim
    closed this as completedon May 20, 2026
  9. mhvk commented on May 20, 2026

    @mhvk
    mhvk
    on May 20, 2026
    Contributor
    More actions

    Hurray!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Upstream Action RequiredWas: Upstream Fix Requirednumpy-devutils.masked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.