Skip to content

Nexus: Update pseudopotential.py to accept pathlib.Path objects#5933

Merged
prckent merged 6 commits into
QMCPACK:developfrom
brockdyer03:pseudopotential-accept-path
May 21, 2026
Merged

Nexus: Update pseudopotential.py to accept pathlib.Path objects#5933
prckent merged 6 commits into
QMCPACK:developfrom
brockdyer03:pseudopotential-accept-path

Conversation

@brockdyer03
Copy link
Copy Markdown
Contributor

Proposed changes

This just updates pseudopotential.py to accept pathlib.Path objects where necessary. It passes current testing, and seems to pass through a set of small tests where I use pathlib.Path objects.

This contributes to #5881.

What type(s) of changes does this code introduce?

  • New feature

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Laptop, Fedora 43 KDE Plasma
Python 3.14.4
uv 0.11.8
Numpy 2.4.4
Pytest 9.0.3

Checklist

    • I have read the pull request guidance and develop docs
    • This PR is up to date with the current state of 'develop'

@brockdyer03 brockdyer03 requested review from jtkrogel and prckent April 28, 2026 22:33
@brockdyer03 brockdyer03 self-assigned this Apr 28, 2026
@brockdyer03 brockdyer03 added nexus python Pull requests that update python code labels Apr 28, 2026
Comment thread nexus/nexus/pseudopotential.py Outdated
self.error('incorrect use of ppset\nnon-filename provided with set labeled "{0}" for simulation code "{1}"\neach pseudopential file name must be a string\nreceived type: {2}\nwith value: {3}'.format(label,code,pp.__class__.__name__,pp))
#end if
elem_label,symbol,is_elem = pp_elem_label(pp)
if isinstance(pp, str):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not keep a single line?

elem_label,symbol,is_elem = pp_elem_label(str(pp))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the file path is a fully resolved path then that would include everything, not just the file name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just use pp=path_string(pp) under an isinstance(pp,str|Path)

@brockdyer03 brockdyer03 requested a review from jtkrogel May 1, 2026 00:23
Copy link
Copy Markdown
Contributor

@jtkrogel jtkrogel left a comment

Choose a reason for hiding this comment

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

OK

@prckent
Copy link
Copy Markdown
Contributor

prckent commented May 1, 2026

Test this please

Copy link
Copy Markdown
Contributor

@jtkrogel jtkrogel left a comment

Choose a reason for hiding this comment

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

Halt Path additions until fundamental compatibility problems are addressed

@jtkrogel
Copy link
Copy Markdown
Contributor

jtkrogel commented May 7, 2026

Approach again after #5944

Comment thread nexus/nexus/pseudopotential.py Outdated
self.error('incorrect use of ppset\nnon-filename provided with set labeled "{0}" for simulation code "{1}"\neach pseudopential file name must be a string\nreceived type: {2}\nwith value: {3}'.format(label,code,pp.__class__.__name__,pp))
#end if
elem_label,symbol,is_elem = pp_elem_label(pp)
if isinstance(pp, str):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just use pp=path_string(pp) under an isinstance(pp,str|Path)

Comment thread nexus/nexus/pseudopotential.py
Comment thread nexus/nexus/pseudopotential.py Outdated
Copy link
Copy Markdown
Contributor

@jtkrogel jtkrogel left a comment

Choose a reason for hiding this comment

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

Good

Comment thread nexus/nexus/pseudopotential.py Outdated
@prckent prckent enabled auto-merge May 21, 2026 11:13
@ye-luo
Copy link
Copy Markdown
Contributor

ye-luo commented May 21, 2026

Test this please

@prckent prckent merged commit c39cc93 into QMCPACK:develop May 21, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nexus python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants