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

in to raise ValueError(f"Invalid format: {str(fmt)}") #26

Closed
JTaozhang opened this issue Feb 20, 2023 · 1 comment
Closed

in to raise ValueError(f"Invalid format: {str(fmt)}") #26

JTaozhang opened this issue Feb 20, 2023 · 1 comment

Comments

@JTaozhang
Copy link

Hi, There,
when I test your example file(gen_example.py) and specified all the proper execution paths, I meet a bug (File "/public/home/ZT/software/DeepH-pack-main/gen_example.py", line 118, in
stru_shift_pert.to('poscar', f'../example/work_dir/dataset/raw/{shift_index}/POSCAR')
File "/public/home/ZT/.conda/envs/ZT-py39/lib/python3.9/site-packages/pymatgen/core/structure.py", line 2561, in to
raise ValueError(f"Invalid format: {str(fmt)}")
ValueError: Invalid format: `../example/work_dir/dataset/raw/0/poscar), it seems the code in gen_example.py can't be recognized by pymatgen. pymatgen can't understand your code and my pymatgen version is pymatgen-2023.1.30. if you can test it or give me some advise, I would greatly appreciate your help.

best regards,
ZT

@mzjb
Copy link
Owner

mzjb commented Feb 20, 2023

Thank you for your report.

This function has two input parameters (fmt and filename). I found that the order of these two parameters changed in different pymatgen versions.

New pyatmgen version: https://github.com/materialsproject/pymatgen/blob/ee52d534cad86abab07a82a34b3877eef5c2385b/pymatgen/core/structure.py#L2475

Old pyatmgen version:
https://github.com/materialsproject/pymatgen/blob/b202b3b6d6a5fc7275c3f552615c912d6c2279e6/pymatgen/core/structure.py#L2338

This change caused the error: The path to the structure file is fed to the parameter representing the format of the structure file.

I fixed it in this commit.

@mzjb mzjb closed this as completed Feb 21, 2023
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

No branches or pull requests

2 participants