jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.29k stars 590 forks source link

[BUG] Test Suite does not pass on either NixOS or Fedora #1029

Closed savyajha closed 1 year ago

savyajha commented 1 year ago

Describe the bug pytest fails on 13 tests on both Fedora and NixOS (both on WSL2) on my systems. Here is a summary of the errors:

FAILED tests/test_bayesian_network.py::test_learn_structure_chow_liu - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network.py::test_learn_structure_exact - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_chow_liu - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_chow_liu_weighted - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_chow_liu_large - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_chow_liu_large_pseudocount - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_exact - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_exact_weighted - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_exact_exclude_parents - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_exact_large - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_exact_large_pseudocount - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_learn_structure_chow_liu - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...
FAILED tests/test_bayesian_network_structure_learning.py::test_categorical_learn_structure_exact - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape...

To Reproduce

Within a fresh venv, the following triggers this:

git clone --depth=1 https://github.com/jmschrei/pomegranate
cd pomegranate
pip install pytest
pip install -r requirements.txt
pip install -e .
pytest -m "not sample"
jmschrei commented 1 year ago

I do not have either of these operating systems and so cannot provide support for them. If you would like to submit a PR I'm happy to be conscious of the issues in the future.

savyajha commented 1 year ago

I will try and do that.

jmschrei commented 1 year ago

Thanks!

jmschrei commented 1 year ago

Looks like these errors are not OS related after all. Rather, they are related to upgrading from pytest v7.1.2 to 7.3.1. That's why the GitHub actions are failing as well. I can look into this now and will fix soon. Thanks for bringing this to my attention.

jmschrei commented 1 year ago

This latest version was unhappy compared the Bayesian network structures because it was a tuple/list of tuples where the inner tuples can have different numbers of elements in it. I assume that in the latest version they tried to streamline the test_array_equal function by first casting everything as a numpy array or something which is why the error was raised. I replaced this with a custom function that simply iterates through two tuples/lists and checks to make sure that each inner element is the same.

savyajha commented 1 year ago

Great to see you got to the bottom of this! Sorry I was unable to work on this before you got to it, my schedule has not been allowing me to work on very much right now.