wolverton-research-group / qmpy

A suite of computational materials science tools.
https://oqmd.org
MIT License
129 stars 45 forks source link

PhaseData's `read_file` function relies on old version of `fractions` #141

Open jayspendlove opened 2 years ago

jayspendlove commented 2 years ago

I am trying to read phase data from a .txt file into a PhaseData object, which throws an error AttributeError: module 'fractions' has no attribute 'gcd'. This is because the reduce_by_gcd function in qmpy/utils/string.py relies on a function fractions.gcd, which no longer exists in the fractions package. gcd is only in fractions<3.9, now you must use math.gcd. Here is a code example to replicate this bug.

from qmpy import PhaseData

pd = PhaseData()
pd.read_file("test_phase_data.txt") #this file is attached to this comment

test_phase_data.txt

For reference, I am using Python 3.9.13 and qmpy 1.4.0. Thank you!

jayspendlove commented 2 years ago

I switched to using Python 3.7 in my environment which is supported, and it is working. So I suppose this comment is for a future upgrade.