atoms.vm error: The truth value of an array with more than one element is ambiguous
The vre-language examples can be simply run using the vre-language/scripts/run_model.py
script:
python run_model.py -m instant -f ../examples/SomeExampleFile.vm
In particular the atoms.vm
file gave the attached arror message atoms_error.txt, which contains the lines:
File "/home/rodri/vre-language/src/virtmat/language/utilities/errors.py", line 41, in wrapper
raise TextXError(str(err), **loc, context=con) from err
textx.exceptions.TextXError: /home/rodri/vre-language/examples/atoms_test/env_testing/p39_pint19_pintpds4/water-3.vm:10:10: 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])'
During handling of the above exception, another exception occurred:
File "/home/rodri/Programs/miniconda3/envs/p39_pint19_pintpds4/lib/python3.9/site-packages/pint_pandas/pint_array.py", line 739, in <listcomp>self._Q(item, self._dtype.units) if not pd.isna(item) else item
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
After some reading I found that there seems to be some problem concerning the use of boolean operators in pandas: "This error occurs any time that the code attempts to convert a Numpy array to boolean (i.e., to check its truth value, as described in the error message). For a given array a, this can occur" https://stackoverflow.com/a/75338248 https://pandas.pydata.org/docs/user_guide/gotchas.html#using-if-truth-statements-with-pandas
However, considering the version conflicts with python and pint, reported in issue #138 (closed) and merge request !95 (merged), I did some further testing using different virtual environment setups in two separate host machines.
The results from these tests indicate that the correct function of the vre-language strictly requires the pint-0.19.2 and pint-pandas-0.2 package versions.
If an environment with the aforementioned pint
and pint-pandas
versions is used, the atoms.mv
example runs without the error message.
In contrast, other version combinations of the pint
and pint-pandas
packages result in the error message reported above.
For example, the first observation of the error occurred while employing pint-0.19.2
and pint-pandas-0.4
.
The investigation of the conflicts between versions of pint
and pint-pandas
will be addressed in a separate issue.