Skip to content

Commit

Permalink
Try to fix breaking changes introduced in pymatgenv2023.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Oct 4, 2023
1 parent 73ff33e commit d172fb8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions abipy/iotools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
from __future__ import annotations

import numpy as np
import pymatgen.io.abinit.netcdf as ionc
from pymatgen.io.abinit.netcdf import as_etsfreader
try:
from pymatgen.io.abinit.netcdf import ETSF_Reader
except ImportError:
from pymatgen.io.abinit.netcdf import EtsfReader as ETSF_Reader

from monty.functools import lazy_property
from pymatgen.core.periodic_table import Element
from .xsf import *
from .visualizer import *


as_etsfreader = ionc.as_etsfreader
#as_etsfreader = ionc.as_etsfreader


class ETSF_Reader(ionc.ETSF_Reader):
class ETSF_Reader(ETSF_Reader):
"""
Provides high-level API to read data from netcdf files written
following the ETSF-IO specifications described in :cite:`Caliste2008`
Expand All @@ -28,6 +32,10 @@ def read_structure(self):
from abipy.core.structure import Structure
return Structure.from_file(self.path)

def typeidx_from_symbol(self, symbol: str) -> int:
"""Returns the type index from the chemical symbol. Note python convention."""
return self.chemical_symbols.index(symbol)

# Must overwrite implementation of pymatgen.io.abinit.netcdf
# due to a possible bug introduced by initial whitespaces in symbol
@lazy_property
Expand Down

0 comments on commit d172fb8

Please sign in to comment.