-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Path.replace bug #2535
Path.replace bug #2535
Conversation
*beep* *bop* Hi, human. The Click here to see your results. |
@wkerzendorf @atharva-2001 Can you please review this request? Thanks. |
That's a great catch @Sumit112192 ! I think another way is that instead of manually replacing ".h5" with "" (which seems a slightly dirty thing to do), we stick to Path object, as use
Of course we'll have to make sure that this change is backward compatible, i.e. the function |
Could you instead ensure that |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2535 +/- ##
==========================================
- Coverage 68.06% 68.06% -0.01%
==========================================
Files 166 166
Lines 14161 14164 +3
==========================================
+ Hits 9639 9641 +2
- Misses 4522 4523 +1 ☔ View full report in Codecov by Sentry. |
In the below code snippet, tardis/tardis/simulation/base.py Lines 661 to 667 in f515d16
In the tardis/tardis/io/atom_data/util.py Lines 13 to 36 in f515d16
It's supposed to have str as input and str as output. Should I instead convert the Path object on line 666 to a |
I would prefer if you modify |
@andrewfullard Okay, I will do that. |
@Sumit112192 do you have an expected timeline for this PR? |
I am really sorry for the delay. I had some college work to do this week. I will start working on it from Friday night. @andrewfullard |
Please run |
Updated using black suggestion
@andrewfullard Done as suggested by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix!
Thanks for spotting the bug and the fix! I think this fix the case when the atom data file in the same directory as the config file, however I still get error when I only specific the name of the atom_data file (not the absolute path) that exist in the tardis_data folder, which should still work as one of the check in the linked part of code below: tardis/tardis/io/atom_data/util.py Lines 31 to 36 in ab869ea
Could you attempt to fix those cases as well? Thanks! |
tardis/io/atom_data/util.py
Outdated
@@ -35,9 +35,9 @@ def resolve_atom_data_fname(fname): | |||
) | |||
return fpath | |||
|
|||
atom_data_name = fname.replace(".h5", "") | |||
atom_data_name = fname.with_suffix("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since fname is an absolute path coming from "atom_data_fname" in simulation/base.py instead of the file name only, should we use fname.stem
here as suggested by #2535 (comment)?
Sure, why not !!! |
@DeerWhale Are the changes good? |
We have documented this function in certain parts of the documentation to use str. So, I have used explicit type conversion to be compatible with those.
If we have the file in data_repo and the user just gives atom_data name without .h5, we should check in the data repo.
Look great! Thanks a lot for the fix! |
📝 In file tardis/io/atom_data/util.py
fname
sometimes becomes a path object causing the bug, and on line 38, we seem to apply thereplace
method ofstr
on the path object, which has its ownreplace
method.In the file
tardis/simulation/base.py
on line 665, atom_data_fname becomes a path object, causing this error. A better way would be to make atom_data_fname str here. Could anyone suggest a better wat to fix this bug?tardis/tardis/simulation/base.py
Lines 660 to 667 in 39c128a
Type: 🪲
bugfix
📌 Resources
Examples, notebooks, and links to useful references.