Commit 21a75860 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Adapted code for numpy>1.20.0. #493

parent fca57924
Pipeline #92630 passed with stages
in 32 minutes and 31 seconds
Subproject commit 56eb84fffa3ae25a4b8dc10aa56da85a4fe6584d Subproject commit 4c35bae7f2834e9657eea438c0a98f8810ac415b
...@@ -21,7 +21,8 @@ import fractions ...@@ -21,7 +21,8 @@ import fractions
import itertools import itertools
from math import gcd as gcd from math import gcd as gcd
from functools import reduce from functools import reduce
from typing import List, Dict, Tuple, Any, Union from typing import List, Dict, Tuple, Any, Union, cast
from nptyping import NDArray
from ase.utils import pbc2pbc from ase.utils import pbc2pbc
import ase.geometry import ase.geometry
...@@ -34,7 +35,7 @@ from nomad.aflow_prototypes import aflow_prototypes ...@@ -34,7 +35,7 @@ from nomad.aflow_prototypes import aflow_prototypes
from nomad.constants import atomic_masses from nomad.constants import atomic_masses
def get_summed_atomic_mass(atomic_numbers: np.ndarray) -> float: def get_summed_atomic_mass(atomic_numbers: NDArray[Any]) -> float:
"""Calculates the summed atomic mass for the given atomic numbers. """Calculates the summed atomic mass for the given atomic numbers.
Args: Args:
...@@ -48,7 +49,7 @@ def get_summed_atomic_mass(atomic_numbers: np.ndarray) -> float: ...@@ -48,7 +49,7 @@ def get_summed_atomic_mass(atomic_numbers: np.ndarray) -> float:
return mass return mass
def get_volume(basis: np.ndarray) -> float: def get_volume(basis: NDArray[Any]) -> float:
"""Calculates the volume of the given parallelepiped. """Calculates the volume of the given parallelepiped.
Args: Args:
...@@ -61,11 +62,11 @@ def get_volume(basis: np.ndarray) -> float: ...@@ -61,11 +62,11 @@ def get_volume(basis: np.ndarray) -> float:
def wrap_positions( def wrap_positions(
positions: np.ndarray, positions: NDArray[Any],
cell: np.ndarray = None, cell: NDArray[Any] = None,
pbc: Union[bool, np.ndarray] = True, pbc: Union[bool, NDArray[Any]] = True,
center: np.ndarray = [0.5, 0.5, 0.5], center: NDArray[Any] = [0.5, 0.5, 0.5],
eps: float = 1e-7) -> np.ndarray: eps: float = 1e-7) -> NDArray[Any]:
"""Wraps the given position so that they are within the unit cell. If no """Wraps the given position so that they are within the unit cell. If no
cell is given, scaled positions are assumed. For wrapping cartesian cell is given, scaled positions are assumed. For wrapping cartesian
positions you also need to provide the cell. positions you also need to provide the cell.
...@@ -106,8 +107,8 @@ def wrap_positions( ...@@ -106,8 +107,8 @@ def wrap_positions(
def to_scaled( def to_scaled(
positions: np.ndarray, positions: NDArray[Any],
cell: np.ndarray = None) -> np.ndarray: cell: NDArray[Any] = None) -> NDArray[Any]:
"""Converts cartesian positions into scaled position one using the given """Converts cartesian positions into scaled position one using the given
cell lattice vectors as a basis. cell lattice vectors as a basis.
...@@ -122,8 +123,8 @@ def to_scaled( ...@@ -122,8 +123,8 @@ def to_scaled(
def to_cartesian( def to_cartesian(
positions: np.ndarray, positions: NDArray[Any],
cell: np.ndarray = None) -> np.ndarray: cell: NDArray[Any] = None) -> NDArray[Any]:
"""Converts scaled positions into cartesian one using the given cell """Converts scaled positions into cartesian one using the given cell
lattice vectors as a basis. lattice vectors as a basis.
...@@ -138,7 +139,7 @@ def to_cartesian( ...@@ -138,7 +139,7 @@ def to_cartesian(
return cartesian_positions return cartesian_positions
def complete_cell(cell: np.ndarray) -> np.ndarray: def complete_cell(cell: NDArray[Any]) -> NDArray[Any]:
"""Creates placeholder axes for cells with zero-dimensional lattice vectors """Creates placeholder axes for cells with zero-dimensional lattice vectors
in order to do linear algebra. in order to do linear algebra.
...@@ -152,7 +153,7 @@ def complete_cell(cell: np.ndarray) -> np.ndarray: ...@@ -152,7 +153,7 @@ def complete_cell(cell: np.ndarray) -> np.ndarray:
return ase.geometry.complete_cell(cell) return ase.geometry.complete_cell(cell)
def reciprocal_cell(cell: np.ndarray) -> np.ndarray: def reciprocal_cell(cell: NDArray[Any]) -> NDArray[Any]:
"""Returns the reciprocal cell without the factor or 2*Pi. """Returns the reciprocal cell without the factor or 2*Pi.
Args: Args:
...@@ -164,7 +165,7 @@ def reciprocal_cell(cell: np.ndarray) -> np.ndarray: ...@@ -164,7 +165,7 @@ def reciprocal_cell(cell: np.ndarray) -> np.ndarray:
return np.linalg.pinv(cell).transpose() return np.linalg.pinv(cell).transpose()
def find_match(pos: np.array, positions: np.array, eps: float) -> Union[int, None]: def find_match(pos: NDArray[Any], positions: NDArray[Any], eps: float) -> Union[int, None]:
"""Attempts to find a position within a larger list of positions. """Attempts to find a position within a larger list of positions.
Args: Args:
...@@ -180,12 +181,12 @@ def find_match(pos: np.array, positions: np.array, eps: float) -> Union[int, Non ...@@ -180,12 +181,12 @@ def find_match(pos: np.array, positions: np.array, eps: float) -> Union[int, Non
min_arg = np.argmin(distances) min_arg = np.argmin(distances)
min_value = distances[min_arg] min_value = distances[min_arg]
if min_value <= eps: if min_value <= eps:
return min_arg return cast(int, min_arg)
else: else:
return None return None
def cellpar_to_cell(cellpar: np.ndarray, ab_normal: np.ndarray = [0, 0, 1], a_direction: np.ndarray = None, degrees=False) -> np.ndarray: def cellpar_to_cell(cellpar: NDArray[Any], ab_normal: NDArray[Any] = [0, 0, 1], a_direction: NDArray[Any] = None, degrees=False) -> NDArray[Any]:
"""Creates a 3x3 cell from the given lattice_parameters. """Creates a 3x3 cell from the given lattice_parameters.
The returned cell is orientated such that a and b are normal to `ab_normal` The returned cell is orientated such that a and b are normal to `ab_normal`
...@@ -220,7 +221,7 @@ def cellpar_to_cell(cellpar: np.ndarray, ab_normal: np.ndarray = [0, 0, 1], a_di ...@@ -220,7 +221,7 @@ def cellpar_to_cell(cellpar: np.ndarray, ab_normal: np.ndarray = [0, 0, 1], a_di
return ase.geometry.cell.cellpar_to_cell(cellpar, ab_normal, a_direction) return ase.geometry.cell.cellpar_to_cell(cellpar, ab_normal, a_direction)
def cell_to_cellpar(cell: np.ndarray, degrees=False) -> np.ndarray: def cell_to_cellpar(cell: NDArray[Any], degrees=False) -> NDArray[Any]:
"""Returns lattice parameters for the given cell. """Returns lattice parameters for the given cell.
Args: Args:
...@@ -290,7 +291,7 @@ def get_symmetry_string(space_group: int, wyckoff_sets: List[WyckoffSet], is_2d: ...@@ -290,7 +291,7 @@ def get_symmetry_string(space_group: int, wyckoff_sets: List[WyckoffSet], is_2d:
return string return string
def get_hill_decomposition(atom_labels: np.ndarray, reduced: bool = False) -> Tuple[List[str], List[int]]: def get_hill_decomposition(atom_labels: NDArray[Any], reduced: bool = False) -> Tuple[List[str], List[int]]:
"""Given a list of atomic labels, returns the chemical formula using the """Given a list of atomic labels, returns the chemical formula using the
Hill system (https://en.wikipedia.org/wiki/Hill_system) with an exception Hill system (https://en.wikipedia.org/wiki/Hill_system) with an exception
for binary ionic compounds where the cation is always given first. for binary ionic compounds where the cation is always given first.
...@@ -401,7 +402,7 @@ def get_formula_string(symbols: List[str], counts: List[int]) -> str: ...@@ -401,7 +402,7 @@ def get_formula_string(symbols: List[str], counts: List[int]) -> str:
return formula return formula
def get_normalized_wyckoff(atomic_numbers: np.array, wyckoff_letters: np.array) -> Dict[str, Dict[str, int]]: def get_normalized_wyckoff(atomic_numbers: NDArray[Any], wyckoff_letters: NDArray[Any]) -> Dict[str, Dict[str, int]]:
"""Returns a normalized Wyckoff sequence for the given atomic numbers and """Returns a normalized Wyckoff sequence for the given atomic numbers and
corresponding wyckoff letters. In a normalized sequence the chemical corresponding wyckoff letters. In a normalized sequence the chemical
species are "anonymized" by replacing them with upper case alphabets. species are "anonymized" by replacing them with upper case alphabets.
...@@ -502,7 +503,7 @@ def search_aflow_prototype(space_group: int, norm_wyckoff: dict) -> dict: ...@@ -502,7 +503,7 @@ def search_aflow_prototype(space_group: int, norm_wyckoff: dict) -> dict:
return structure_type_info return structure_type_info
def get_brillouin_zone(reciprocal_lattice: np.array) -> dict: def get_brillouin_zone(reciprocal_lattice: NDArray[Any]) -> dict:
"""Calculates the Brillouin Zone information from the given reciprocal """Calculates the Brillouin Zone information from the given reciprocal
lattice. lattice.
......
...@@ -185,7 +185,7 @@ class IdealizedStructure(MSection): ...@@ -185,7 +185,7 @@ class IdealizedStructure(MSection):
""" """
) )
periodicity = Quantity( periodicity = Quantity(
type=np.bool, type=np.bool_,
shape=[3], shape=[3],
description=""" description="""
Automatically detected true periodicity of each lattice direction. May Automatically detected true periodicity of each lattice direction. May
......
...@@ -452,7 +452,7 @@ class IdealizedStructure(MSection): ...@@ -452,7 +452,7 @@ class IdealizedStructure(MSection):
""" """
) )
periodicity = Quantity( periodicity = Quantity(
type=np.bool, type=np.bool_,
shape=[3], shape=[3],
description=""" description="""
Automatically detected true periodicity of each lattice direction. May Automatically detected true periodicity of each lattice direction. May
......
import numpy as np # pylint: disable=unused-import import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from nptyping import NDArray
from nomad.metainfo import ( # pylint: disable=unused-import from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy, MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference, MEnum, derived) Reference, MEnum, derived)
...@@ -6285,7 +6286,7 @@ class ThermodynamicalProperties(MSection): ...@@ -6285,7 +6286,7 @@ class ThermodynamicalProperties(MSection):
a_legacy=LegacyDefinition(name='specific_heat_capacity'), a_legacy=LegacyDefinition(name='specific_heat_capacity'),
cached=True cached=True
) )
def specific_heat_capacity(self) -> np.array: def specific_heat_capacity(self) -> NDArray:
"""Returns the specific heat capacity by dividing the heat capacity per """Returns the specific heat capacity by dividing the heat capacity per
cell with the mass of the atoms in the cell. cell with the mass of the atoms in the cell.
""" """
......
...@@ -5427,7 +5427,7 @@ class section_thermodynamical_properties(MSection): ...@@ -5427,7 +5427,7 @@ class section_thermodynamical_properties(MSection):
a_legacy=LegacyDefinition(name='specific_heat_capacity'), a_legacy=LegacyDefinition(name='specific_heat_capacity'),
cached=True cached=True
) )
def specific_heat_capacity(self) -> np.array: def specific_heat_capacity(self):
"""Returns the specific heat capacity by dividing the heat capacity per """Returns the specific heat capacity by dividing the heat capacity per
cell with the mass of the atoms in the cell. cell with the mass of the atoms in the cell.
""" """
...@@ -5471,7 +5471,7 @@ class section_thermodynamical_properties(MSection): ...@@ -5471,7 +5471,7 @@ class section_thermodynamical_properties(MSection):
a_legacy=LegacyDefinition(name='specific_vibrational_free_energy_at_constant_volume'), a_legacy=LegacyDefinition(name='specific_vibrational_free_energy_at_constant_volume'),
cached=True cached=True
) )
def specific_vibrational_free_energy_at_constant_volume(self) -> np.array: def specific_vibrational_free_energy_at_constant_volume(self):
"""Returns the specific vibrational free energy by dividing the vibrational free energy per """Returns the specific vibrational free energy by dividing the vibrational free energy per
cell with the mass of the atoms in the cell. cell with the mass of the atoms in the cell.
""" """
......
...@@ -213,7 +213,7 @@ class OptimadeEntry(MSection): ...@@ -213,7 +213,7 @@ class OptimadeEntry(MSection):
''') ''')
lattice_vectors = Quantity( lattice_vectors = Quantity(
type=np.dtype('f8'), shape=[3, 3], unit=ureg.angstrom, type=np.dtype('float64'), shape=[3, 3], unit=ureg.angstrom,
links=optimade_links('h.6.2.9'), links=optimade_links('h.6.2.9'),
a_optimade=Optimade(query=False, entry=True, sortable=False, type='list'), a_optimade=Optimade(query=False, entry=True, sortable=False, type='list'),
description=''' description='''
...@@ -221,7 +221,7 @@ class OptimadeEntry(MSection): ...@@ -221,7 +221,7 @@ class OptimadeEntry(MSection):
''') ''')
cartesian_site_positions = Quantity( cartesian_site_positions = Quantity(
type=np.dtype('f8'), shape=['nsites', 3], unit=ureg.angstrom, type=np.dtype('float64'), shape=['nsites', 3], unit=ureg.angstrom,
links=optimade_links('h.6.2.10'), links=optimade_links('h.6.2.10'),
a_optimade=Optimade(query=False, entry=True, sortable=False, type='list'), description=''' a_optimade=Optimade(query=False, entry=True, sortable=False, type='list'), description='''
Cartesian positions of each site. A site is an atom, a site potentially occupied by Cartesian positions of each site. A site is an atom, a site potentially occupied by
......
...@@ -55,7 +55,7 @@ def generate_metainfo_code(metainfo_pkg: Package, python_package_path: str): ...@@ -55,7 +55,7 @@ def generate_metainfo_code(metainfo_pkg: Package, python_package_path: str):
for i, p in enumerate(paragraphs) if p != '']) for i, p in enumerate(paragraphs) if p != ''])
def format_type(pkg, mi_type): def format_type(pkg, mi_type):
if type(mi_type) == np.dtype: if isinstance(mi_type, np.dtype):
if mi_type == np.dtype('U'): if mi_type == np.dtype('U'):
return 'np.dtype(\'U\')' return 'np.dtype(\'U\')'
......
...@@ -193,7 +193,7 @@ class LegacyMetainfoEnvironment(Environment): ...@@ -193,7 +193,7 @@ class LegacyMetainfoEnvironment(Environment):
def_name(definition.type.target_section_def.m_resolved())] def_name(definition.type.target_section_def.m_resolved())]
elif isinstance(definition.type, MEnum): elif isinstance(definition.type, MEnum):
dtype_str = 'C' dtype_str = 'C'
elif type(definition.type) == np.dtype: elif isinstance(definition.type, np.dtype):
dtype_str = definition.type.name[0] dtype_str = definition.type.name[0]
elif definition.type == Any: elif definition.type == Any:
dtype_str = 'D' dtype_str = 'D'
......
...@@ -50,7 +50,7 @@ _placeholder_quantity: 'Quantity' = property() # type: ignore ...@@ -50,7 +50,7 @@ _placeholder_quantity: 'Quantity' = property() # type: ignore
if True: if True:
_placeholder_quantity: 'Quantity' = None # type: ignore _placeholder_quantity: 'Quantity' = None # type: ignore
_primitive_types = {str: str, int: int, float: float, bool: bool} _primitive_types = {str: str, int: int, float: float, bool: bool, np.bool_: bool}
# Metainfo errors # Metainfo errors
...@@ -261,7 +261,7 @@ class _QuantityType(DataType): ...@@ -261,7 +261,7 @@ class _QuantityType(DataType):
''' '''
def set_normalize(self, section, quantity_def, value): def set_normalize(self, section, quantity_def, value):
if value in [str, int, float, bool]: if value in _primitive_types:
return value return value
if isinstance(value, MEnum): if isinstance(value, MEnum):
...@@ -270,7 +270,7 @@ class _QuantityType(DataType): ...@@ -270,7 +270,7 @@ class _QuantityType(DataType):
raise TypeError('MEnum value %s is not a string.' % enum_value) raise TypeError('MEnum value %s is not a string.' % enum_value)
return value return value
if type(value) == np.dtype: if isinstance(value, np.dtype):
return value return value
if isinstance(value, Section): if isinstance(value, Section):
...@@ -303,13 +303,13 @@ class _QuantityType(DataType): ...@@ -303,13 +303,13 @@ class _QuantityType(DataType):
(value, quantity_def)) (value, quantity_def))
def serialize(self, section, quantity_def, value): def serialize(self, section, quantity_def, value):
if value is str or value is int or value is float or value is bool: if value in _primitive_types:
return dict(type_kind='python', type_data=value.__name__) return dict(type_kind='python', type_data=value.__name__)
if isinstance(value, MEnum): if isinstance(value, MEnum):
return dict(type_kind='Enum', type_data=list(value)) return dict(type_kind='Enum', type_data=list(value))
if type(value) == np.dtype: if isinstance(value, np.dtype):
return dict(type_kind='numpy', type_data=str(value)) return dict(type_kind='numpy', type_data=str(value))
if isinstance(value, Reference): if isinstance(value, Reference):
...@@ -952,7 +952,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas ...@@ -952,7 +952,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
self.__dict__.pop(quantity_def.name, None) self.__dict__.pop(quantity_def.name, None)
return return
if type(quantity_def.type) == np.dtype: if isinstance(quantity_def.type, np.dtype):
value = self.__to_np(quantity_def, value) value = self.__to_np(quantity_def, value)
else: else:
...@@ -1237,7 +1237,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas ...@@ -1237,7 +1237,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
elif quantity_type in _primitive_types: elif quantity_type in _primitive_types:
serialize = _primitive_types[quantity_type] serialize = _primitive_types[quantity_type]
elif type(quantity_type) == np.dtype: elif isinstance(quantity_type, np.dtype):
is_scalar = quantity.is_scalar is_scalar = quantity.is_scalar
def serialize_dtype(value): def serialize_dtype(value):
...@@ -1260,7 +1260,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas ...@@ -1260,7 +1260,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
elif quantity_type == Any: elif quantity_type == Any:
def _serialize(value: Any): def _serialize(value: Any):
if type(value) not in [str, int, float, bool, list, dict, type(None)]: if type(value) not in [str, int, float, bool, np.bool_, list, dict, type(None)]:
raise MetainfoError( raise MetainfoError(
'Only python primitives are allowed for Any typed non ' 'Only python primitives are allowed for Any typed non '
'virtual quantities: %s of quantity %s in section %s' % 'virtual quantities: %s of quantity %s in section %s' %
...@@ -1282,7 +1282,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas ...@@ -1282,7 +1282,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
else: else:
value = quantity.default value = quantity.default
if type(quantity_type) == np.dtype: if isinstance(quantity_type, np.dtype):
return serialize(value) return serialize(value)
elif len(quantity.shape) == 0: elif len(quantity.shape) == 0:
return serialize(value) return serialize(value)
...@@ -1375,7 +1375,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas ...@@ -1375,7 +1375,7 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
if name in dct: if name in dct:
quantity_value = dct[name] quantity_value = dct[name]
if type(quantity_def.type) == np.dtype: if isinstance(quantity_def.type, np.dtype):
quantity_value = np.asarray(quantity_value) quantity_value = np.asarray(quantity_value)
if isinstance(quantity_def.type, DataType): if isinstance(quantity_def.type, DataType):
...@@ -2040,7 +2040,7 @@ class Quantity(Property): ...@@ -2040,7 +2040,7 @@ class Quantity(Property):
is_primitive = not self.derived is_primitive = not self.derived
is_primitive = is_primitive and len(self.shape) <= 1 is_primitive = is_primitive and len(self.shape) <= 1
is_primitive = is_primitive and self.type in [str, bool, float, int] is_primitive = is_primitive and self.type in [str, bool, float, int]
is_primitive = is_primitive and type(self.type) != np.dtype is_primitive = is_primitive and not isinstance(self.type, np.dtype)
if is_primitive: if is_primitive:
self._default = self.default self._default = self.default
self._name = self.name self._name = self.name
...@@ -2090,7 +2090,7 @@ class Quantity(Property): ...@@ -2090,7 +2090,7 @@ class Quantity(Property):
'Only numpy arrays and dtypes can be used for higher dimensional ' 'Only numpy arrays and dtypes can be used for higher dimensional '
'quantities.') 'quantities.')
elif type(self.type) == np.dtype: elif isinstance(self.type, np.dtype):
if self.unit is not None: if self.unit is not None:
value = value * self.unit value = value * self.unit
...@@ -2131,7 +2131,7 @@ class Quantity(Property): ...@@ -2131,7 +2131,7 @@ class Quantity(Property):
@constraint @constraint
def higher_shapes_require_dtype(self): def higher_shapes_require_dtype(self):
if len(self.shape) > 1: if len(self.shape) > 1:
assert type(self.type) == np.dtype, \ assert isinstance(self.type, np.dtype), \
'Higher dimensional quantities (%s) need a dtype and will be treated as ' \ 'Higher dimensional quantities (%s) need a dtype and will be treated as ' \
'numpy arrays.' % self 'numpy arrays.' % self
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# limitations under the License. # limitations under the License.
# #
from nptyping import NDArray
import numpy as np import numpy as np
import ase import ase
...@@ -134,7 +135,7 @@ class BandStructureNormalizer(Normalizer): ...@@ -134,7 +135,7 @@ class BandStructureNormalizer(Normalizer):
section_bz.vertices = brillouin_zone_data["vertices"] section_bz.vertices = brillouin_zone_data["vertices"]
section_bz.faces = brillouin_zone_data["faces"] section_bz.faces = brillouin_zone_data["faces"]
def get_k_space_distance(self, reciprocal_cell: np.array, point1: np.array, point2: np.array) -> float: def get_k_space_distance(self, reciprocal_cell: NDArray, point1: NDArray, point2: NDArray) -> float:
"""Used to calculate the Euclidean distance of two points in k-space, """Used to calculate the Euclidean distance of two points in k-space,
given relative positions in the reciprocal cell. given relative positions in the reciprocal cell.
...@@ -151,7 +152,7 @@ class BandStructureNormalizer(Normalizer): ...@@ -151,7 +152,7 @@ class BandStructureNormalizer(Normalizer):
return k_point_distance return k_point_distance
def add_band_gaps(self, band: section_k_band, energy_reference: np.array) -> None: def add_band_gaps(self, band: section_k_band, energy_reference: NDArray) -> None:
"""Given the band structure and an energy reference, calculates the band gap """Given the band structure and an energy reference, calculates the band gap
separately for all spin channels. separately for all spin channels.
""" """
...@@ -167,8 +168,8 @@ class BandStructureNormalizer(Normalizer): ...@@ -167,8 +168,8 @@ class BandStructureNormalizer(Normalizer):
# Gather the energies and k points from each segment into one big # Gather the energies and k points from each segment into one big
# array # array
reciprocal_cell = reciprocal_cell.magnitude reciprocal_cell = reciprocal_cell.magnitude
path: np.array = [] path: NDArray = []
energies: np.array = [] energies: NDArray = []
for segment in band.section_k_band_segment: for segment in band.section_k_band_segment:
seg_k_points = segment.band_k_points seg_k_points = segment.band_k_points
seg_energies = segment.band_energies seg_energies = segment.band_energies
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# #
from typing import Dict, List from typing import Dict, List
from nptyping import NDArray
from math import gcd, isnan from math import gcd, isnan
from functools import reduce from functools import reduce
from abc import abstractmethod from abc import abstractmethod
...@@ -272,7 +273,7 @@ class MaterialBulkNormalizer(MaterialNormalizer): ...@@ -272,7 +273,7 @@ class MaterialBulkNormalizer(MaterialNormalizer):
material.material_name = name material.material_name = name
def periodicity(self, ideal: IdealizedStructure) -> None: def periodicity(self, ideal: IdealizedStructure) -> None:
ideal.periodicity = np.array([True, True, True], dtype=np.bool) ideal.periodicity = np.array([True, True, True], dtype=np.bool_)