muon-spectroscopy-computational-project / pymuon-suite

Collection of scripts and utilities for muon spectroscopy
GNU General Public License v3.0
8 stars 7 forks source link

CRLF line endings can't be loaded with calls to AtomsCollection.load_tree #63

Closed elichad closed 2 years ago

elichad commented 2 years ago

Not sure if this is a problem with Soprano or with the pymuon-suite ReadWrite classes

/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py:889: OSError
--------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------Generating defect configurations...
17 configurations generated
================================================================= warnings summary ==================================================================pymuonsuite/test/test_muairss.py: 28 warnings
    WARNING:  Generating CASTEP keywords JSON file... hang on.
      The CASTEP keywords JSON file contains abstractions for CASTEP input
      parameters (for both .cell and .param input files), including some
      format checks and descriptions. The latter are extracted from the
      internal online help facility of a CASTEP binary, thus allowing to
      easily keep the calculator synchronized with (different versions of)
      the CASTEP code. Consequently, avoiding licensing issues (CASTEP is
      distributed commercially by accelrys), we consider it wise not to
      provide the file in the first place. (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/ase/calculators/castep.py, line: 3092)

pymuonsuite/test/test_muairss.py: 28 warnings
    WARNING:  Could not determine the version of your CASTEP binary
  This usually means one of the following
     * you do not have CASTEP installed
     * you have not set the CASTEP_COMMAND to call it
     * you have provided a wrong CASTEP_COMMAND.
       Make sure it is in your PATH

   (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/ase/calculators/castep.py, line: 512)

pymuonsuite/test/test_muairss.py: 19 warnings
    WARNING:  read_cell: Warning - Was not able to validate CASTEP input. This may be due to a non-existing "castep_keywords.json" file or a non-existing CASTEP installation. Parsing will go on but keywords will not be validated and may cause problems if incorrect during a CASTEP run. (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/ase/io/castep.py, line: 418)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  ERROR: Invalid file: Si2_1.castep, due to error: local variable 'positions_frac' referenced before assignment (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py, line: 877)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  No regular end found in castep-results/castep/Si2_2/Si2_2.castep file. None (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/ase/calculators/castep.py, line: 932)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  ERROR: Invalid file: Si2_2.castep, due to error: 'NoneType' object has no attribute 'info' (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py, line: 877)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  No regular end found in castep-results/castep/Si2_3/Si2_3.castep file. None (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/ase/calculators/castep.py, line: 932)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  ERROR: Invalid file: Si2_3.castep, due to error: 'NoneType' object has no attribute 'info' (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py, line: 877)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  ERROR: Invalid file: Si2_4.castep, due to error: local variable 'positions_frac' referenced before assignment (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py, line: 877)

pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle
    WARNING:  ERROR: Invalid file: Si2_5.castep, due to error: local variable 'positions_frac' referenced before assignment (/mnt/c/Users/qci88181/Documents/Muons/pymuon-suite/.venv3.8_wsl/lib/python3.8/site-packages/soprano/collection/collection.py, line: 877)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================== short test summary info ==============================================================FAILED pymuonsuite/test/test_muairss.py::TestMuairss::testCASTEP_custom_particle - OSError: 100.00% of structures could not be loaded.

Converting the files to use LF endings fixed the error.

elichad commented 2 years ago

This is specifically a problem with .castep files having CRLF endings. Our use of load_tree calls back to ReadWriteCastep.read which in turn calls ase.io.read, so it's an ASE incompatibility.

However, realistically, .castep files are never written with CRLF, and it's unlikely that they will be mutated to have CRLF through normal copy processes. Git is an unusual case because it can mess with line endings depending on machine configuration; I think when I initially cloned this repo on Windows, Git flipped everything to CRLF when it shouldn't have done. I fixed that locally so I'll close this issue.

TL;DR for anyone experiencing this same error in future: make sure your .castep files are using LF line endings.