In response to your messages on my previous PR (https://github.com/msel-source/pymef/pull/31): Yeah, I've noticed the failed tests as well. Sorry I didn't check into them before.
They are caused by the asserts that check the number of warnings:
self.assertEqual(len(w), 1)
which should have only one warning (as the test expects), but instead end up with two.
The second warning for all of these is actually:
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
This warning is the root of the problem and is thrown by the most recent version of NumPy in the tests. These are thrown because the PyArray_NewFromDescr in most of the create_* functions (in pymef3_file.c) create an ndarray with one element in a single dimension. Before Numpy 1.25, you could simply refer to the whole ndarray and if there was only one value then it would convert that to a scalar. However, as of Numpy 1.25 we will have to be explicit about picking the scalar from the ndarray, which in our case is simply to add [0].
Fixing these ndim > 0 to a scalar warnings in both pymef_test.py and mef_session.py allowed the tests to complete succesfully again, as you can hopefully see in this PR :)
Hey Jan,
In response to your messages on my previous PR (https://github.com/msel-source/pymef/pull/31): Yeah, I've noticed the failed tests as well. Sorry I didn't check into them before.
They are caused by the asserts that check the number of warnings:
self.assertEqual(len(w), 1)
which should have only one warning (as the test expects), but instead end up with two. The second warning for all of these is actually:
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
This warning is the root of the problem and is thrown by the most recent version of NumPy in the tests. These are thrown because the
PyArray_NewFromDescr
in most of thecreate_*
functions (in pymef3_file.c) create an ndarray with one element in a single dimension. Before Numpy 1.25, you could simply refer to the whole ndarray and if there was only one value then it would convert that to a scalar. However, as of Numpy 1.25 we will have to be explicit about picking the scalar from the ndarray, which in our case is simply to add[0]
.Fixing these
ndim > 0 to a scalar
warnings in bothpymef_test.py
andmef_session.py
allowed the tests to complete succesfully again, as you can hopefully see in this PR :)Best, Max