causal-learn icon indicating copy to clipboard operation
causal-learn copied to clipboard

use of deprecated `np.mat`

Open Alex-Markham opened this issue 1 year ago • 1 comments

Numpy 2.0 was released less than a month ago, resulting in some deprecated code in causal-learn. For example, see Line 42 of causal-learn/utils/ScoreUtils.py which uses the deprecated np.mat. This should be a quick fix, so I'll try to make a (backwards-compatible) pull request in the next week or so, unless someone else gets to it first.

It could also be worth considering adding compatible release version specifiers in setup.py to ensure automatically installed requirements are compatible with versions that devs have used in tests.

Alex-Markham avatar Jul 10 '24 07:07 Alex-Markham

Aha, thank you so much for the reminder and your proposal to address it. The recent PR for GRaSP and BOSS (#188) removed some 'np.mat' in the local score functions, but there are likely still instances elsewhere. Please feel free to submit a PR, and let us know if you have any questions.

kunwuz avatar Jul 18 '24 20:07 kunwuz

I went through and removed every instance of np.mat, specifying the dimensions of the arrays and updating the surrounding code as needed. All of the tests are passing now except for test_local_score_general in TestLocalScore.py. I've done what I can, and hope it helps, but I think it still needs someone else to carefully go through LocalScoreFunction.py to fix the last failing test and address some related runtime warnings.

Alex-Markham avatar Sep 09 '24 12:09 Alex-Markham

Many thanks for your PR!! :)

kunwuz avatar Sep 21 '24 12:09 kunwuz