Conflicts between versions of pint and pint-pandas
Description
In issue #142 (closed) it was reported that, apparently, the correct function of the vre-language strictly requires packages pint-0.19.2 and pint-pandas-0.2.
Particularly, running the atoms.vm
example with a virtual environment which included the pint-0.19.2
and pint-pandas-0.4
packages resulted in the error message:
The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all() => '(cell: [[5., 0., 0.], [0., 5., 0.], [0., 0., 5.]] [bohr])'
On the other hand, a virtual environment with pint-0.19.2
and pint-pandas-0.2
managed to run the example without this error.
In this issue, a comparison between virtual environments set up using different versions of the python interpreter, and the pint
and pint-pandas
packages is made.
The test environments were created in two different host machines, employing both conda
and pip
installation methods described in the README.md file of the project.
Of course, different versions of the python interpreter can lead to the installation of different versions of other additional packages.
This situation was partially assessed in this investigation.
Test Setup
The main testing was done in a local, non-HPC host.
Initial testing showed no noticeable effect/influence in the set up between the conda
and pip
installations.
Due to ease of use, the conda
installation method was preferred.
For the creation of each test environment, the conda-setup.yml
and setup.cfg
files were adapted to pin the versions of pint
and pint-pandas
as needed.
The python interpreter version was set similarly for each environment.
Depending on the python interpreter version (which can determine the version of the pip
package manager), the "default" versions of pint
and 'pint-pandas` can vary:
- python-3.8 installs by default
pint 0.21
andpint-pandas 0.3
- python-3.9 installs by default
pint-0.22
andpint-pandas-0.4
Thus the need for version pinning.
The ramainder of the required packages and dependencies were left untouched, so that pip
would install the default versions.
The setup of the virtual environments used for testing is summarized in the table:
p38_pint21_ppds3 | p38_pint19_ppds2 | p39_pint19_ppds2 | p39_pint19_ppds3 | p39_pint19_ppds4 | p39_pint22_ppds4 | |
---|---|---|---|---|---|---|
Python | 3.8.17 | 3.8.17 | 3.9.17 | 3.9.17 | 3.9.17 | 3.9.17 |
Pint | 0.21.1 | 0.19.2 | 0.19.2 | 0.19.2 | 0.19.2 | 0.22 |
Pint-Pandas | 0.3 | 0.2 | 0.2 | 0.3 | 0.4 | 0.4 |
ipython | 8.12.2 | 8.12.2 | 8.14.0 | - | 8.14.0 | 8.14.0 |
numpy | 1.24.4 | 1.24.4 | 1.25.0 | - | 1.25.0 | 1.25.0 |
scipy | 1.10.1 | 1.10.1 | 1.11.1 | - | 1.11.1 | 1.11.1 |
----------------- | -------------------- | ----------------- | ------------------ | ------------------ | ------------------ | ------------------ |
installation | ok:major pkg diffs | ok | ok | FAIL:pkg conflict | ok | ok |
pip list out | p38p21ppd3.txt | p38p19ppd2.txt | p39p19ppd2.txt | - | p39p19ppd4.txt | p39p22ppd4.txt |
----------------- | -------------------- | ----------------- | ------------------ | ------------------ | ------------------ | ------------------ |
run tests | FAIL | all pass w/warning | 3 fail | - | 11 fail | 16 fail |
run atoms.vm | FAIL | runs ok | runs ok | - | error msg | error msg |
The header shows the name of the environments.
The rows highlighted with bold-faced labels indicate the python
, pint
and pint-pandas
versions.
Additionally, rows showing the ipython
, numpy
, and scipy
package versions are included.
This was done because, aside of p38_pint21_ppds3
, the rest of the environments differ only in these packages.
The remaining 114 installed packages are the same across p38_pint19_ppds2
and all p39_pintX_ppdsY
environments.
The default ipython, numpy, and scipy versions are the same for the python-3.8
interpreter.
This is also valid across all python-3.9
environments.
In case of p38_pint21_ppds3
, versions of 28 packages differ with respect to the rest of the environments.
For the detailed package lists see the attached pip list out files.
The results
A brief description of the outcomes of the tests, performed with each of the environments, is included in the following.
a) p38_pint21_pintpds3
-
Installation: differs in the versions of 28 packages with respect to the rest of the environments (see table "pip listout"). No version pinning
-
Tests: None of the test scripts pass. The error message printed at the bottom of the stack is
AttributeError: module 'pint.compat' has no attribute 'upcast_types'
for all test scripts. Test log available in file p38p21ppd3-tests.log -
Examples: All example scripts fail. The same error message from the test runs is printed in all cases.
-
It seems like pint-0.21.1 has serious compatibility issues with several other dependencies as well as the project itself.
Full log from example files: p38p21ppd3-examples.log
b) p38_pint19_pintpds2
-
Installation: Installation is completed without any apparent problems. Requires pinning of pint-0.19.1
-
Tests: For full tests log see file p38p19ppd2-tests.log
Test FAIL PASS Warnings conftest.py 0 - 5 test_amml.py 0 14 110 test_builtins.py 0 108 77 test_cyclic.py 0 8 5 test_datastructures.py 0 204 310 test_functions.py 0 93 67 test_imports.py 0 33 27 test_io.py 0 84 75 test_recursion.py 0 2 5 test_resources.py 0 12 53 test_session.py 0 26 57 test_typechecks.py 0 22 5 test_units.py 0 45 37 -
Examples: All examples run. There are some warning messages printed. In particular, for the atoms.vm example these warnings are:
- UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
- UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
- RuntimeWarning: pint-pandas does not support magnitudes of <class 'list'>. Converting magnitudes to float.
- RuntimeWarning: pint-pandas does not support magnitudes of <class 'numpy.ndarray'> . Converting magnitudes to float.
- UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
- UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
- RuntimeWarning: pint-pandas does not support magnitudes of <class 'list'>. Converting magnitudes to float.
- RuntimeWarning: pint-pandas does not support magnitudes of <class 'numpy.ndarray'> . Converting magnitudes to float.
Despite the warnings, most example scripts seem to successfully finish their runs. Some error messages include:
- comments.vm
AttributeError: 'str' object has no attribute 'value'
- constraints.vm
ase.calculators.calculator.CalculatorSetupError: Please set either command in calculator or one of the following environment variables (prioritized as follows): ASE_VASP_COMMAND, VASP_COMMAND, VASP_SCRIPT
- empty.vm
AttributeError: 'str' object has no attribute 'value'
- property.vm
ase.calculators.calculator.CalculatorSetupError: Please set either command in calculator or one of the following environment variables (prioritized as follows): ASE_VASP_COMMAND, VASP_COMMAND, VASP_SCRIPT
- recursion.vm
assert not any(d in args_uniq_names for d in call_dummies) AssertionError
- series_units.vm
textx.exceptions.TextXError: /home/rodri/vre-language/examples/series_units.vm:5:1: => 'print(s_len1)'
For full log from examples, see file p38p19ppd2-examples.log
c) p39_pint19_pintpds2
-
Installation: Installation is successful. Required pinning of pint-0.19.1 and pint-pandas-0.2
-
Tests: Full log of tests in file p39p19ppd2-tests.log
-
Test FAIL PASS Warnings conftest.py 0 - 5 test_amml.py 0 14 110 test_builtins.py 0 108 77 test_cyclic.py 0 8 5 test_datastructures.py 3 201 301 test_functions.py 0 93 67 test_imports.py 0 33 27 test_io.py 0 84 75 test_recursion.py 0 2 5 test_resources.py 0 12 53 test_session.py 0 26 57 test_typechecks.py 0 22 5 test_units.py 0 45 37 -
Examples: Same as with the previous case with some warnings but most example scipts complete their runs and print the corresponding output. Full examples log in file p39p19ppd2-examples.log
d) p39_pint19_pintpds3
- Installation: The environment could not be created due to some conflict between pint and pint-pandas
- vre-language[test] 0.1.0 depends on pint==0.19.2
- pint-pandas 0.3 depends on pint>=0.20.1
- Tests: Unable to test
- Examples: Unable to run examples
e) p39_pint19_pintpds4
-
Installation: Requires pinning of pint-0.19.2. Creation of this environment seems to go without any conflict (no errors in installation log)
-
Tests: Full test log in file p39p19ppd4-tests.log
Test FAIL PASS Warnings conftest.py 0 - 5 test_amml.py 8 6 63 test_builtins.py 0 108 77 test_cyclic.py 0 8 5 test_datastructures.py 3 201 301 test_functions.py 0 93 67 test_imports.py 0 33 27 test_io.py 0 84 71 test_recursion.py 0 2 5 test_resources.py 0 12 53 test_session.py 0 26 57 test_typechecks.py 0 22 5 test_units.py 0 45 37 -
Examples: None of the example scripts involving definition of atoms/molecules pass (argon_singlepoint_simple.vm, argon_singlepoint.vm, atoms.vm, constraints.vm, property.vm, structure_references.vm, ). In particular, whenever the
cell
parameter is encountered, the following error message arises (though the numerical values change depending of the definitions):The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() => '(cell: [[10., 0., 0.], [0., 10., 0.], [0., 0., 10.]] [angstrom])'
Other errors include:- comments.vm
AttributeError: 'str' object has no attribute 'value'
- data_structure_builtins.vm:
Syntax error: /home/rodri/vre-language/examples/data_structure_builtins.vm:74:16 --> (s_num[0] *in s_num, <-- 607 Expected '.' or '[' or ':array' or ':columns' or ':name' or 'if' or ',' or ')
- empty.vm
AttributeError: 'str' object has no attribute 'value'
- recursion.vm
raise RuntimeError('non-handled exception') from err RuntimeError: non-handled exception
- series_units.vm
raise TextXError(str(err), **loc, context=con) from err textx.exceptions.TextXError: /home/rodri/vre-language/examples/series_units.vm:5:1: => 'print(s_len1)'
The full examples log is given in file p39p19ppd4-examples.log
- comments.vm
f) p39_pint22_pintpds4
-
Installation: No package versions are pinned. The environment is created and packages and dependencies installed without any aparent problems.
-
Tests: Complete log of tests run in file p39p22ppd4-tests.log
Test FAIL PASS Warnings conftest.py 0 - 5 test_amml.py 8 6 63 test_builtins.py 0 108 77 test_cyclic.py 0 8 5 test_datastructures.py 4 200 301 test_functions.py 0 93 67 test_imports.py 0 33 27 test_io.py 3 81 71 test_recursion.py 0 2 5 test_resources.py 0 12 53 test_session.py 1 25 57 test_typechecks.py 0 22 5 test_units.py 0 45 37 -
Examples: Similar outcomes as the P39_pint19_pintpds4 case
Full log of the examples in file p39p22ppd4-examples.log
For comparison, the p38_pint19_ppds2
, p39_pint19_ppds2
, and p39_pint22_ppds4
environments were also tested in a remote HPC host.
These were set up using both conda
and pip
methods.
The results from running the example and test scripts are similar to the tests in the local host.
Takeaway
From the results of this assessment it seem like pint-0.19.2 and pint-pandas-0.2 are vital for the correct function of the vre-language project.
The only environment that managed to complete all tests without any error/failure messages is p38_pint19_pintpds2 (which employs python 3.8
, pint-0.19.2
, and pint-pandas-0.2
).
The p39_pint19_pintpds2
environment might also work, since the examples outputs are rather similar to those of p38_pint19_pintpds2
.
Nonetheless, the failed tests from test_datastructures.py
should be assessed first.