LumiSpy / lumispy

Luminescence data analysis with HyperSpy.
https://lumispy.org
GNU General Public License v3.0
26 stars 17 forks source link

Failure with numpy 1.24.dev #153

Closed ericpre closed 1 year ago

ericpre commented 1 year ago

From https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3119041322/jobs/5058746331

=================================== FAILURES ===================================
______________________ TestLumiSpectrum.test_errors_raise ______________________

a = [array([ 0.        ,  5.44444444, 10.88888889, 16.33333333, 21.77777778,
       [27](https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3119041322/jobs/5058746331#step:16:28).22222222, [32](https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3119041322/jobs/5058746331#step:16:33).66666667, 38.11111111,...., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])]

    @array_function_dispatch(_shape_dispatcher)
    def shape(a):
        """
        Return the shape of an array.

        Parameters
        ----------
        a : array_like
            Input array.

        Returns
        -------
        shape : tuple of ints
            The elements of the shape tuple give the lengths of the
            corresponding array dimensions.

        See Also
        --------
        len : ``len(a)`` is equivalent to ``np.shape(a)[0]`` for N-D arrays with
              ``N>=1``.
        ndarray.shape : Equivalent array method.

        Examples
        --------
        >>> np.shape(np.eye(3))
        (3, 3)
        >>> np.shape([[1, 3]])
        (1, 2)
        >>> np.shape([0])
        (1,)
        >>> np.shape(0)
        ()

        >>> a = np.array([(1, 2), (3, 4), (5, 6)],
        ...              dtype=[('x', 'i4'), ('y', 'i4')])
        >>> np.shape(a)
        (3,)
        >>> a.shape
        (3,)

        """
        try:
>           result = a.shape
E           AttributeError: 'list' object has no attribute 'shape'

/usr/share/miniconda3/lib/python3.10/site-packages/numpy/core/fromnumeric.py:20[33](https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3119041322/jobs/5058746331#step:16:34): AttributeError

During handling of the above exception, another exception occurred:

self = <lumispy.tests.signals.test_luminescence_spectrum.TestLumiSpectrum object at 0x7f5d5c5a2500>

    def test_errors_raise(self):
        s = LumiSpectrum(np.ones(50))
        for bkg, error in error_backgrounds:
            with pytest.raises(error):
>               s.remove_background_from_file(bkg)

/usr/share/miniconda3/lib/python3.10/site-packages/lumispy/tests/signals/test_luminescence_spectrum.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/share/miniconda3/lib/python3.10/site-packages/lumispy/signals/luminescence_spectrum.py:553: in remove_background_from_file
    if np.shape(background_xy)[0] == 1:
<__array_function__ internals>:200: in shape
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = [array([ 0.        ,  5.44444444, 10.88888889, 16.33333333, 21.77777778,
       27.22222222, 32.66666667, 38.11111111,...., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])]

    @array_function_dispatch(_shape_dispatcher)
    def shape(a):
        """
        Return the shape of an array.

        Parameters
        ----------
        a : array_like
            Input array.

        Returns
        -------
        shape : tuple of ints
            The elements of the shape tuple give the lengths of the
            corresponding array dimensions.

        See Also
        --------
        len : ``len(a)`` is equivalent to ``np.shape(a)[0]`` for N-D arrays with
              ``N>=1``.
        ndarray.shape : Equivalent array method.

        Examples
        --------
        >>> np.shape(np.eye(3))
        (3, 3)
        >>> np.shape([[1, 3]])
        (1, 2)
        >>> np.shape([0])
        (1,)
        >>> np.shape(0)
        ()

        >>> a = np.array([(1, 2), (3, 4), (5, 6)],
        ...              dtype=[('x', 'i4'), ('y', 'i4')])
        >>> np.shape(a)
        (3,)
        >>> a.shape
        (3,)

        """
        try:
            result = a.shape
        except AttributeError:
>           result = asarray(a).shape
E           ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

/usr/share/miniconda3/lib/python3.10/site-packages/numpy/core/fromnumeric.py:20[35](https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3119041322/jobs/5058746331#step:16:36): ValueError