Skip to content

Structure.from_file() fails if frac_tolerance argument supplied and file is POSCAR #4551

@lnaglecocco

Description

@lnaglecocco

Python version

3.12.3

Pymatgen version

2024.11.13

Operating system version

Windows 11

Current behavior

Structure.from_file() takes an argument frac_tolerance. This works fine when loading a CIF. However, when the structure file is a POSCAR I get this error:

Traceback (most recent call last):
  File "C:\Users\lnc\Documents\GitHub\2025-11-20_MD_LSCF_analysis\code\tilts-and-correlations.py", line 859, in <module>
    main(sys.argv[1])
  File "C:\Users\lnc\Documents\GitHub\2025-11-20_MD_LSCF_analysis\code\tilts-and-correlations.py", line 479, in main
    struct = Structure.from_file(cif_path, frac_tolerance=0.0)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\lnc\AppData\Local\anaconda3\envs\materials-analysis\Lib\site-packages\pymatgen\core\structure.py", line 3187, in from_file
    struct = cls.from_str(
             ^^^^^^^^^^^^^
  File "C:\Users\lnc\AppData\Local\anaconda3\envs\materials-analysis\Lib\site-packages\pymatgen\core\structure.py", line 3087, in from_str
    struct = Poscar.from_str(input_string, default_names=None, read_velocities=False, **kwargs).structure
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Poscar.from_str() got an unexpected keyword argument 'frac_tolerance'

Expected Behavior

It should successfully load the structure with frac_tolerance=0

Minimal example

Structure.from_file("POSCAR")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions