Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporated pathlib.Path compatibility #99

Merged
merged 3 commits into from
Jan 28, 2022

Conversation

jgd10
Copy link
Contributor

@jgd10 jgd10 commented Jan 19, 2022

In this PR I have added input (and explicit output) compatibility
between pymapdl-reader and the pathlib.Path class. All file path-input
arguments should now be accepted as either strings or pathlib.Path
objects. Additionally there is no breaking change regarding the filename
properties. These will continue to return strings. Wherever possible I
have made it so that internally we store paths as pathlib.Path objects
and they are returned as strings through properties. Setters
additionally will accept strings or pathlib.Path objects.

Users can access the pathlib.Path objects via new pathlib_filename properties.
I could not think of a better name, but suggestions are welcome.

Unfortunately i have not been able to get the test suite working on my
local machine and so have not been able to write tests to go with these
changes. I would appreciate input from others regarding how to get the
tests running and if my changes do break any existing tests. I do not
believe so but I am very limited in how I can check.

With the latest commits and #103 I have managed to get my development version
working and confirmed the changes work as well as adding tests for them.

This PR is ready for review and merging.

(closes #98)

In this commit I have added input (and explicit output) compatibility
between pymapdl-reader and the pathlib.Path class. All file path-input
arguments should now be accepted as either strings or pathlib.Path
objects. Additionally there is no breaing change regarding the filename
properties. These will continue to return strings. Wherever possible I
have made it so that internally we store paths as pathlib.Path objects
and they are returned as strings through properties. Setters
additionally will accept strings or pathlib.Path objects.

Unfortunately i have not been able to get the test suite working on my
local machine and so have not been able to write tests to go with these
changes. I would appreciate input from others regarding how to get the
tests running and if my changes do break any existing tests. I do not
believe so but I am very limited in how I can check.
@jgd10 jgd10 added the help wanted Extra attention is needed label Jan 19, 2022
@jgd10 jgd10 requested a review from akaszynski January 19, 2022 14:56
@akaszynski
Copy link
Collaborator

Unfortunately i have not been able to get the test suite working on my
local machine and so have not been able to write tests to go with these
changes. I would appreciate input from others regarding how to get the
tests running and if my changes do break any existing tests. I do not
believe so but I am very limited in how I can check.

Let's open a separate PR to decouple the testing requirements of ansys-mapdl-core by caching the expected results to *.npy arrays within testfiles.

Changed the suffix comparison to include the leading '.' because
pathlib.Path.suffix does include it. Made sure that AnsysFile converts
any potential paths to string before they are passed as arguments.

Additionally split thermal test up until multiple tests within a class
to make it easier to read.

All existing tests pass with pathlib changes.
Added additional tests to check the input and output is correct for the
4 classes that use pathlib.Path now.
@jgd10 jgd10 removed the help wanted Extra attention is needed label Jan 26, 2022
@jgd10
Copy link
Contributor Author

jgd10 commented Jan 26, 2022

Ready for review!

Comment on lines +142 to +144
def filename(self) -> str:
"""String form of the filename. Accepts ``pathlib.Path`` and string objects when set."""
return str(self._filename)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this for backwards compatibility.

Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good work here.

@akaszynski akaszynski merged commit 4480491 into main Jan 28, 2022
@akaszynski akaszynski deleted the fix/issue_98_adding_pathlib_support branch January 28, 2022 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate pathlib compatibility
2 participants