-
Couldn't load subscription status.
- Fork 23
Description
The pathlib library is a convenient way to manipulate paths in Python.
This library provides several objects to manipulate these paths. It is commonly used across libraries the Path object.
However there are more like PurePosixPath and PureWindowsPath. I just did realised that PureXXXPath objects (PurePosixPath, PureWindowsPath, and PurePath) are not supported by DPF.
from ansys.dpf.core import Model
from pathlib import Path, PurePosixPath
path_str = "file.rst"
Model(path_str).metadata.mesh_info # Works
Model(Path(path_str)).metadata.mesh_info # works
Model(PurePosixPath(path_str)).metadata.mesh_info # It doesn't work. It does not read the RST fileI am kind of shocked this didn't work. I guess the Path object is supported by DPF, but not the PurePath object. I would expect that DPF convert the Path object to a string behind the scenes. If that is the case, PureXXXPath object should work. So I presume DPF is doing something more exotic with the paths, which might hide something or not.
The solution is quite simple if you need to deal with PureXXXPath objects:
Model(str(PurePosixPath(path_str))).metadata.mesh_infoI am opening this issue for awareness mainly. Since the fix is quite easy, but it might take time to figure out.