SugiharaLab/pyEDM

Unit tests fail to run

erooke opened this issue · 3 comments

I'm running into an issue where the test_smap and test_PredictionNonlinear tests are failing to run locally. In particular they are all mad about numpy._ArrayFunctionDispatcher not having the attribute fit. I don't know if this is an issue on my end or if the test suite is currently broken.

Test output

       [ 0.73860721, -0.01166999,  0.03493612],
       [ 0.69250174, -...0954571, -0.00957925],
       [ 0.00954234,  0.00951848,  0.00954234],
       [ 0.00952299,  0.00952299,  0.00950871]])
wB = array([ 8.56494188e-01, -7.36317529e-01, -6.85507475e-01,  6.32406220e-01,
       -6.24965953e-01,  5.56211446e-01, -5...3, -1.91024006e-03,
       -7.64882007e-05,  2.28019954e-04,  1.43156958e-03, -1.27676504e-03,
       -6.76132313e-04])

    def Solver( self, A, wB ) :
    #-------------------------------------------------------------------
        # print( f'{self.name}: Solver.' )
        '''Call SMap solver. Default is numpy.lstsq'''

        if self.solver.__class__.__name__ == 'function' and \
           self.solver.__name__ == 'lstsq' :
            # numpy default lstsq or scipy lstsq
            C, residuals, rank, SV = self.solver( A, wB, rcond = None )
            return C, SV

        # Otherwise, sklearn.linear_model passed as solver
        # Coefficient matrix A has weighted unity vector in the first
        # column to create a bias (intercept) term. sklearn.linear_model's
        # include an intercept term by default. Ignore first column of A.
>       LM = self.solver.fit( A[:,1:], wB )
E       AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'

/nix/store/h46zk0d2d7y86ysjrak6q45g9ma6an5r-python3.11-pyedm-2.0.2/lib/python3.11/site-packages/pyEDM/SMap.py:209: AttributeError
=============================== warnings summary ===============================
src/pyEDM/tests/tests.py: 1145 warnings
  /nix/store/h46zk0d2d7y86ysjrak6q45g9ma6an5r-python3.11-pyedm-2.0.2/lib/python3.11/site-packages/pyEDM/Formatting.py:49: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in >
    observations[ i ] = self.targetVec[ t ]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests.py::test_EDM::test_PredictNonlinear - AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'
FAILED tests.py::test_EDM::test_smap - AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'
FAILED tests.py::test_EDM::test_smap2 - AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'
FAILED tests.py::test_EDM::test_smap3 - AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'
FAILED tests.py::test_EDM::test_smap4 - AttributeError: 'numpy._ArrayFunctionDispatcher' object has no attribute 'fit'
================= 5 failed, 26 passed, 1145 warnings in 6.22s ==================

Python Environment

Package         Version
--------------- ------------
contourpy       1.2.0
cycler          0.12.1
defusedxml      0.7.1
fonttools       4.51.0
iniconfig       2.0.0
installer       0.7.0
joblib          1.4.0
kiwisolver      1.4.5
lz4             4.3.3
matplotlib      3.8.4
numpy           1.26.4
olefile         0.47
packaging       24.0
pandas          2.2.1
pillow          10.3.0
pip             24.0
pluggy          1.4.0
psutil          5.9.8
pyEDM           2.0.2
pyparsing       3.1.2
pytest          8.1.1
python-dateutil 2.9.0.post0
pytz            2024.1
scikit-learn    1.4.2
scipy           1.13.0
setuptools      69.5.1.post0
six             1.16.0
threadpoolctl   3.4.0
tzdata          2024.1
wheel           0.43.0

Hi Ethan,

Sorry for the problem. This was fixed June 7 in version 2.0.3. I haven't pushed a new PyPI release yet. You can install 2.0.3 from github as a workaround.

I'll work to push a release to PyPI.

Thanks.

Please see the Version v2.0.3 release at PyPI, it should address this issue.

Ah, yes it did. Thanks!