Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_faith_pd_none_observed fails: type numpy.ndarray doesn't define __round__ method #156

Open
nteodosio opened this issue Sep 5, 2023 · 4 comments

Comments

@nteodosio
Copy link

The test fails in Ubuntu 23.10:

170s ERROR: test_faith_pd_none_observed (tests.test_api.FaithPDEdgeCasesTests.test_faith_pd_none_observed)
170s ----------------------------------------------------------------------
170s Traceback (most recent call last):
170s   File "/tmp/autopkgtest.6CMmWo/build.B7P/src/unifrac/tests/test_api.py", line 717, in test_faith_pd_none_observed
170s     self.assertAlmostEqual(actual.values, expected)
170s   File "/usr/lib/python3.11/unittest/case.py", line 918, in assertAlmostEqual
170s     if round(diff, places) == 0:
170s        ^^^^^^^^^^^^^^^^^^^
170s TypeError: type numpy.ndarray doesn't define __round__ method

Full log.

@wasade
Copy link
Member

wasade commented Sep 5, 2023

Thanks, @nteodosio. What version of python and numpy, and how was this installed? We currently test in CI up to py311 without an explicit pin on numpy (

python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, linux-gpu-cuda]
exclude:
- os: macos-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.10'
- os: linux-gpu-cuda
python-version: '3.8'
- os: linux-gpu-cuda
python-version: '3.9'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install
shell: bash -l {0}
run: |
conda create --yes -n unifrac -c conda-forge -c bioconda python=${{ matrix.python-version }}
conda activate unifrac
conda config --add channels conda-forge
conda config --add channels bioconda
if [[ "$(uname -s)" == "Linux" ]];
then
conda install --yes -c conda-forge -c bioconda gxx_linux-64
else
conda install --yes -c conda-forge -c bioconda clangxx_osx-64
fi
conda install --yes -c conda-forge -c bioconda "unifrac-binaries>=1.2"
conda install --yes -c conda-forge -c bioconda cython biom-format numpy "h5py>3.3.0" "scikit-bio>=0.5.8" nose
).

@nteodosio
Copy link
Author

Hi @wasade, Python 3.11 and Numpy 1.24.2 according to the log. It was installed via Apt.

And by the way we test in ARM and x86, and interestingly the test only failed in x86. Apologies for failing to mention this bit of information.

For what it's worth, given the error message I just submitted another run with a print statement and it says the array is [6.25], so really nothing close to 0.

@wasade
Copy link
Member

wasade commented Sep 6, 2023

Hi @nteodosio, thank you for the additional detail. I'm unable to construct an environment from conda with Python 3.11 and NumPy 1.24.2 on Linux x86_64 due to unsatisfied constraints on the Python version, which I'm puzzled by. But, relaxing that, I was able to install and run tests without issue.

@sfiligoi, any unusual stand out to you with the error logs?

$ mamba create --name unifrac-test -c conda-forge -c bioconda unifrac unifrac-binaries python numpy=1.24.2
...snip...
$ pytest
============================================================================== test session starts ==============================================================================
platform linux -- Python 3.10.12, pytest-7.4.1, pluggy-1.3.0
rootdir: /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/unifrac
collected 49 items                                                                                                                                                              

tests/test_api.py ........................................                                                                                                                [ 81%]
tests/test_methods.py .........                                                                                                                                           [100%]

=============================================================================== warnings summary ================================================================================
__init__.py:9
  /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/unifrac/__init__.py:9: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../pkg_resources/__init__.py:2871
  /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

tests/test_api.py::FaithPDEdgeCasesTests::test_faith_pd_root_not_observed
  /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/unifrac/tests/test_api.py:814: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
    self.assertAlmostEqual(actual[0], expected)

tests/test_api.py::FaithPDEdgeCasesTests::test_faith_pd_root_not_observed
  /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/unifrac/tests/test_api.py:820: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
    self.assertAlmostEqual(actual[0], expected)

tests/test_api.py::FaithPDEdgeCasesTests::test_faith_pd_zero_branches_omitted
  /home/mcdonadt/miniconda3/envs/unifrac-test/lib/python3.10/site-packages/unifrac/tests/test_api.py:711: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
    self.assertAlmostEqual(actual[0], expected)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================== 49 passed, 5 warnings in 13.86s ========================================================================
$ mamba list | egrep "numpy|unifrac|python|pandas"
# packages in environment at /home/mcdonadt/miniconda3/envs/unifrac-test:
brotli-python             1.1.0           py310hc6cd4ac_0    conda-forge
ipython                   8.15.0             pyh0d859eb_0    conda-forge
msgpack-python            1.0.5           py310hdf3cbec_0    conda-forge
numpy                     1.24.2          py310h8deb116_0    conda-forge
pandas                    2.1.0           py310hcc13569_0    conda-forge
python                    3.10.12         hd12c33a_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-tzdata             2023.3             pyhd8ed1ab_0    conda-forge
python_abi                3.10                    3_cp310    conda-forge
unifrac                   1.2             py310h1425a21_0    bioconda
unifrac-binaries          1.4                  h1d423cb_0    bioconda

@vpa1977
Copy link

vpa1977 commented Oct 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants