Skip to content

Commit

Permalink
fixed last method renames to lattice
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Mar 14, 2023
1 parent 2edce3f commit 2d45aad
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions sisl/io/gulp/got.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def read_lattice(self, key=None, **kwargs):
raise ValueError(
'SileGULP tries to lookup the Lattice vectors '
'using key "' + self._keys['lattice'] + '". \n'
'Use ".set_supercell_key(...)" to search for different name.\n'
'Use ".set_lattice_key(...)" to search for different name.\n'
'This could not be found found in file: "' + self.file + '".')

# skip 1 line
Expand Down Expand Up @@ -107,7 +107,7 @@ def read_geometry(self, **kwargs):
if not f and ki == 0:
raise ValueError('SileGULP tries to lookup the Lattice vectors '
'using key "' + self._keys['lattice'] + '". \n'
'Use ".set_supercell_key(...)" to search for different name.\n'
'Use ".set_lattice_key(...)" to search for different name.\n'
'This could not be found found in file: "' + self.file + '".')
elif f and ki == 0:
# supercell
Expand Down
16 changes: 8 additions & 8 deletions sisl/io/openmx/omx.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ def read_basis(self, *args, **kwargs):
Parameters
----------
output: bool, optional
whether to read supercell from output files (default to read from
whether to read lattice from output files (default to read from
the input file).
order: {'dat', 'omx'}
the order of which to try and read the supercell.
the order of which to try and read the lattice
If `order` is present `output` is disregarded.
"""
order = kwargs.pop('order', ['dat', 'omx'])
Expand Down Expand Up @@ -339,31 +339,31 @@ def decompose_basis(l):
return atom

def read_lattice(self, output=False, *args, **kwargs):
""" Reads supercell
""" Reads lattice
One can limit the tried files to only one file by passing
only a single file ending.
Parameters
----------
output: bool, optional
whether to read supercell from output files (default to read from
whether to read lattice from output files (default to read from
the input file).
order: {'dat', 'omx'}
the order of which to try and read the supercell.
the order of which to try and read the lattice.
If `order` is present `output` is disregarded.
"""
if output:
order = kwargs.pop('order', ['dat', 'omx'])
else:
order = kwargs.pop('order', ['dat', 'omx'])
for f in order:
v = getattr(self, '_r_supercell_{}'.format(f.lower()))(*args, **kwargs)
v = getattr(self, '_r_lattice_{}'.format(f.lower()))(*args, **kwargs)
if v is not None:
return v
return None

def _r_supercell_omx(self, *args, **kwargs):
def _r_lattice_omx(self, *args, **kwargs):
""" Returns `Lattice` object from the omx file """
conv = self.get('Atoms.UnitVectors.Unit', default='Ang')
if conv.upper() == 'AU':
Expand All @@ -384,7 +384,7 @@ def _r_supercell_omx(self, *args, **kwargs):

return Lattice(cell)

_r_supercell_dat = _r_supercell_omx
_r_lattice_dat = _r_lattice_omx

def read_geometry(self, output=False, *args, **kwargs):
""" Returns Geometry object
Expand Down
34 changes: 17 additions & 17 deletions sisl/io/siesta/fdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,24 +644,24 @@ def read_lattice_nsc(self, *args, **kwargs):
"""
order = _listify_str(kwargs.pop("order", ["nc", "ORB_INDX"]))
for f in order:
v = getattr(self, f"_r_supercell_nsc_{f.lower()}")(*args, **kwargs)
v = getattr(self, f"_r_lattice_nsc_{f.lower()}")(*args, **kwargs)
if v is not None:
_track(self.read_lattice_nsc, f"found file {f}")
return v
warn("number of supercells could not be read from output files. Assuming molecule cell "
"(no supercell connections)")
return _a.onesi(3)

def _r_supercell_nsc_nc(self, *args, **kwargs):
def _r_lattice_nsc_nc(self, *args, **kwargs):
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".nc")
_track_file(self._r_supercell_nsc_nc, f)
_track_file(self._r_lattice_nsc_nc, f)
if f.is_file():
return ncSileSiesta(f).read_lattice_nsc()
return None

def _r_supercell_nsc_orb_indx(self, *args, **kwargs):
def _r_lattice_nsc_orb_indx(self, *args, **kwargs):
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".ORB_INDX")
_track_file(self._r_supercell_nsc_orb_indx, f)
_track_file(self._r_lattice_nsc_orb_indx, f)
if f.is_file():
return orbindxSileSiesta(f).read_lattice_nsc()
return None
Expand Down Expand Up @@ -695,13 +695,13 @@ def read_lattice(self, output=False, *args, **kwargs):
else:
order = _listify_str(kwargs.pop("order", ["fdf"]))
for f in order:
v = getattr(self, f"_r_supercell_{f.lower()}")(*args, **kwargs)
v = getattr(self, f"_r_lattice_{f.lower()}")(*args, **kwargs)
if v is not None:
_track(self.read_lattice, f"found file {f}")
return v
return None

def _r_supercell_fdf(self, *args, **kwargs):
def _r_lattice_fdf(self, *args, **kwargs):
""" Returns `Lattice` object from the FDF file """
s = self.get("LatticeConstant", unit="Ang")
if s is None:
Expand Down Expand Up @@ -731,47 +731,47 @@ def _r_supercell_fdf(self, *args, **kwargs):

return Lattice(cell, nsc=nsc)

def _r_supercell_nc(self):
def _r_lattice_nc(self):
# Read supercell from <>.nc file
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".nc")
_track_file(self._r_supercell_nc, f)
_track_file(self._r_lattice_nc, f)
if f.is_file():
return ncSileSiesta(f).read_lattice()
return None

def _r_supercell_xv(self, *args, **kwargs):
def _r_lattice_xv(self, *args, **kwargs):
""" Returns `Lattice` object from the XV file """
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".XV")
_track_file(self._r_supercell_xv, f)
_track_file(self._r_lattice_xv, f)
if f.is_file():
nsc = self.read_lattice_nsc()
lattice = xvSileSiesta(f).read_lattice()
lattice.set_nsc(nsc)
return lattice
return None

def _r_supercell_struct(self, *args, **kwargs):
def _r_lattice_struct(self, *args, **kwargs):
""" Returns `Lattice` object from the STRUCT files """
for end in ["STRUCT_NEXT_ITER", "STRUCT_OUT", "STRUCT_IN"]:
f = self.dir_file(self.get("SystemLabel", default="siesta") + f".{end}")
_track_file(self._r_supercell_struct, f)
_track_file(self._r_lattice_struct, f)
if f.is_file():
nsc = self.read_lattice_nsc()
lattice = structSileSiesta(f).read_lattice()
lattice.set_nsc(nsc)
return lattice
return None

def _r_supercell_tshs(self, *args, **kwargs):
def _r_lattice_tshs(self, *args, **kwargs):
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".TSHS")
_track_file(self._r_supercell_tshs, f)
_track_file(self._r_lattice_tshs, f)
if f.is_file():
return tshsSileSiesta(f).read_lattice()
return None

def _r_supercell_onlys(self, *args, **kwargs):
def _r_lattice_onlys(self, *args, **kwargs):
f = self.dir_file(self.get("SystemLabel", default="siesta") + ".onlyS")
_track_file(self._r_supercell_onlys, f)
_track_file(self._r_lattice_onlys, f)
if f.is_file():
return onlysSileSiesta(f).read_lattice()
return None
Expand Down
8 changes: 4 additions & 4 deletions sisl/io/siesta/out.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def read_basis(self):

return [Atom(**atoms[tag]) for tag in order]

def _r_supercell_outcell(self):
def _r_lattice_outcell(self):
""" Wrapper for reading the unit-cell from the outcoor block """

# Read until outcell is found
found, line = self.step_to("outcell: Unit cell vectors")
if not found:
raise ValueError(f"{self.__class__.__name__}._r_supercell_outcell did not find outcell key")
raise ValueError(f"{self.__class__.__name__}._r_lattice_outcell did not find outcell key")

Ang = 'Ang' in line

Expand Down Expand Up @@ -168,7 +168,7 @@ def _r_geometry_outcoor(self, line, atoms=None):
# Retrieve the unit-cell (but do not skip file-descriptor position)
# This is because the current unit-cell is not always written.
pos = self.fh.tell()
cell = self._r_supercell_outcell()
cell = self._r_lattice_outcell()
if is_final and self.fh.tell() < pos:
# we have wrapped around the file
self.fh.seek(pos, os.SEEK_SET)
Expand Down Expand Up @@ -207,7 +207,7 @@ def _r_geometry_atomic(self, line, atoms=None):
# Retrieve the unit-cell (but do not skip file-descriptor position)
# This is because the current unit-cell is not always written.
pos = self.fh.tell()
cell = self._r_supercell_outcell()
cell = self._r_lattice_outcell()
self.fh.seek(pos, os.SEEK_SET)

# Convert xyz
Expand Down
6 changes: 3 additions & 3 deletions sisl/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .shape.prism4 import Cuboid
from .quaternion import Quaternion
from ._math_small import cross3, dot3
from ._supercell import cell_invert, cell_reciprocal
from ._lattice import cell_invert, cell_reciprocal


__all__ = ["Lattice", "SuperCell", "LatticeChild"]
Expand Down Expand Up @@ -1042,7 +1042,7 @@ def angle(self, i, j, rad=False):

@staticmethod
def read(sile, *args, **kwargs):
""" Reads the supercell from the `Sile` using ``Sile.read_supercell``
""" Reads the supercell from the `Sile` using ``Sile.read_lattice``
Parameters
----------
Expand All @@ -1054,7 +1054,7 @@ def read(sile, *args, **kwargs):
# have been imported previously
from sisl.io import get_sile, BaseSile
if isinstance(sile, BaseSile):
return sile.read_supercell(*args, **kwargs)
return sile.read_lattice(*args, **kwargs)
else:
with get_sile(sile, mode='r') as fh:
return fh.read_lattice(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion sisl/viz/plots/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from ..plotutils import values_to_colors
from sisl._dispatcher import AbstractDispatch
from sisl._supercell import cell_invert
from sisl._lattice import cell_invert


class BoundGeometry(AbstractDispatch):
Expand Down
2 changes: 1 addition & 1 deletion sisl/viz/plots/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import sisl
from sisl.messages import warn
from sisl._supercell import cell_invert
from sisl._lattice import cell_invert
from sisl import _array as _a
from ..plot import Plot, entry_point
from ..input_fields import (
Expand Down

0 comments on commit 2d45aad

Please sign in to comment.