LumiSpy / lumispy

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

Failure with numpy dev #157

Closed ericpre closed 2 years ago

ericpre commented 2 years ago

From https://github.com/hyperspy/hyperspy-extensions-list/pull/28

=================================== 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/3362966097/jobs/5575418400#step:16:28).22222222, [32](https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/3362966097/jobs/5575418400#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/3362966097/jobs/5575418400#step:16:34): AttributeError

During handling of the above exception, another exception occurred:

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

    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/3362966097/jobs/5575418400#step:16:36): ValueError
=============================== warnings summary ===============================
ericpre commented 2 years ago

Was already reported in #153! ;)