ansys / pyrocky

A Python API for Ansys Rocky
https://rocky.docs.pyansys.com/
MIT License
4 stars 0 forks source link

Unhashable type : 'dict' error is returned when running the examples #16

Open viniciusdaroz opened 7 months ago

viniciusdaroz commented 7 months ago

πŸ” Before submitting the issue

🐞 Description of the bug

The examples are running fine, but matplotlib is not able to plot the results from the GetNumpyCurve method.

The issue is that the GetNumpyCurve returns a dictionary instead of a numpy array. I was able to run one of the examples once, after rebooting my computer. However, after trying it again, it raised the same error.

The same commands run fine inside Rocky's Python shell.

My Python version is 3.11.5

βœ… Expected behavior

The expected behavior would be the matplotlib plot to show up.

πŸ“ Steps to reproduce

In my case, I just cloned the repository, installed pyRocky, and executed the examples.

πŸ“ƒ Relevant log output

This is the output and traceback for the particle_wall_interaction_with_motion.py example.

Download successful. File path: C:\Users\\AppData\Local\Temp\pyrocky_etw0hy1l\Lshape_tube.stl Traceback (most recent call last): File "C:\\pyrocky\examples\basic_examples\particle_wall_interaction_with_motion.py", line 104, in ax.plot(times, mass_flow_in, "b", label="Mass Flow In") File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\axes_axes.py", line 1721, in plot lines = [self._get_lines(self, args, data=data, **kwargs)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\axes_base.py", line 303, in call yield from self._plot_args( ^^^^^^^^^^^^^^^^ File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\axes_base.py", line 494, in _plot_args axes.xaxis.update_units(x) File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\axis.py", line 1712, in update_units default = self.converter.default_units(data, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\category.py", line 105, in default_units axis.set_units(UnitData(data)) ^^^^^^^^^^^^^^ File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\category.py", line 181, in init self.update(data) File "C:\Users\.ansys_python_venvs\Rocky\Lib\site-packages\matplotlib\category.py", line 214, in update for val in OrderedDict.fromkeys(data): ^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unhashable type: 'dict'

igortg commented 5 months ago

Thanks for the report @viniciusdaroz

Which version of Rocky you are using? Which version of matplotlib you are using?

I tested with the following toolchain, and it's working:

matplotlib                3.8.3
numpy                     1.26.4