Skip to content

Commit 1c17f49

Browse files
General: Renamed base -> basis
1 parent a0c79e2 commit 1c17f49

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

tests/t_crystal/t_calculation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def to_clustered_pymatgen(crystal : CrystalStructure) -> Structure:
8181
alpha, beta, gamma = crystal.angles
8282
lattice = Lattice.from_parameters(a, b, c, alpha, beta, gamma)
8383

84-
non_void_sites = crystal.base.get_non_void_sites()
84+
non_void_sites = crystal.basis.get_non_void_sites()
8585

8686
EPSILON = 0.001
8787
clusters: list[list[AtomSite]] = []

tests/t_crystal/t_properties.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_angles(self):
2525
def test_num_atoms(self):
2626
expected_atom_counts = [4*4, 6]
2727
for crystal, num_atoms_exp in zip(self.custom_structures, expected_atom_counts):
28-
self.assertEqual(len(crystal.base), num_atoms_exp)
28+
self.assertEqual(len(crystal.basis), num_atoms_exp)
2929

3030

3131
def test_to_cif(self):
@@ -34,10 +34,10 @@ def test_to_cif(self):
3434
print(f'CIF = \n{cif}')
3535

3636
def test_standardize(self):
37-
phase = CrystalStructure(lengths=(5.801, 11.272, 5.57), angles=(90, 90, 90), base=CrystalBasis.empty())
37+
phase = CrystalStructure(lengths=(5.801, 11.272, 5.57), angles=(90, 90, 90), basis=CrystalBasis.empty())
3838
new_phase = phase.get_standardized()
3939

40-
self.assertTrue(len(new_phase.base) == 0)
40+
self.assertTrue(len(new_phase.basis) == 0)
4141

4242
if __name__ == "__main__":
4343
TestCifParsing.execute_all()

xrdpattern/crystal/components/crystal.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@dataclass
2323
class CrystalStructure(JsonDataclass):
2424
lattice : Lattice
25-
base : CrystalBasis
25+
basis : CrystalBasis
2626
spacegroup : Optional[int] = None
2727
chemical_composition : Optional[str] = None
2828
wyckoff_symbols : Optional[list[str]] = None
@@ -47,7 +47,7 @@ def from_pymatgen(cls, pymatgen_structure: Structure) -> CrystalStructure:
4747
atomic_site = AtomSite(x, y, z, occupancy=occupancy, species_str=str(species))
4848
base.append(atomic_site)
4949

50-
crystal_str = cls(lattice=lattice, base=base)
50+
crystal_str = cls(lattice=lattice, basis=base)
5151

5252
return crystal_str
5353

@@ -59,7 +59,7 @@ def to_cif(self) -> str:
5959
return pymatgen_structure.to(filename='', fmt='cif')
6060

6161
def to_pymatgen(self) -> Structure:
62-
non_void_sites = self.base.atom_sites
62+
non_void_sites = self.basis.atom_sites
6363
atoms = [site.atom.as_pymatgen for site in non_void_sites]
6464
positions = [(site.x, site.y, site.z) for site in non_void_sites]
6565

@@ -72,14 +72,14 @@ def to_pymatgen(self) -> Structure:
7272
def get_view(self) -> str:
7373
the_dict = asdict(self)
7474
the_dict = {str(key) : str(value) for key, value in the_dict.items() if not isinstance(value, Structure)}
75-
the_dict['base'] = f'{self.base[0]}, ...'
75+
the_dict['base'] = f'{self.basis[0]}, ...'
7676
return json.dumps(the_dict, indent='-')
7777

7878
# ---------------------------------------------------------
7979
# properties
8080

8181
def calculate_properties(self):
82-
if len(self.base) == 0:
82+
if len(self.basis) == 0:
8383
raise ValueError('Base is empty! Cannot calculate properties of empty crystal. Aborting ...')
8484

8585
pymatgen_structure = self.to_pymatgen()
@@ -91,11 +91,11 @@ def calculate_properties(self):
9191
self.chemical_composition = pymatgen_structure.composition.formula
9292

9393
def get_standardized(self) -> CrystalStructure:
94-
struct = self.to_pymatgen() if len(self.base) > 0 else Structure(self.lattice, ["H"], [[0, 0, 0]])
94+
struct = self.to_pymatgen() if len(self.basis) > 0 else Structure(self.lattice, ["H"], [[0, 0, 0]])
9595
analzyer = SpacegroupAnalyzer(structure=struct)
9696
std_struct = analzyer.get_conventional_standard_structure()
97-
if len(self.base) == 0:
98-
return CrystalStructure(lattice=std_struct.lattice, base=CrystalBasis.empty())
97+
if len(self.basis) == 0:
98+
return CrystalStructure(lattice=std_struct.lattice, basis=CrystalBasis.empty())
9999
else:
100100
return CrystalStructure.from_pymatgen(pymatgen_structure=std_struct)
101101

@@ -106,12 +106,12 @@ def scale(self, target_density: float):
106106
@cached_property
107107
def packing_density(self) -> float:
108108
volume_uc = self.volume_uc
109-
atomic_volume = self.base.calculate_atomic_volume()
109+
atomic_volume = self.basis.calculate_atomic_volume()
110110
return atomic_volume/volume_uc
111111

112112
@cached_property
113113
def num_atoms(self) -> int:
114-
return len(self.base)
114+
return len(self.basis)
115115

116116
@cached_property
117117
def volume_uc(self) -> float:

xrdpattern/crystal/examples/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_crystal(num: int, verbose: bool = False):
1717
@staticmethod
1818
def get_base(num : int = 1, verbose : bool = False) -> CrystalBasis:
1919
crystal_stucture = CrystalExamples.get_crystal(num=num, verbose=verbose)
20-
return crystal_stucture.base
20+
return crystal_stucture.basis
2121

2222
@staticmethod
2323
def get_cif_content(num : int = 1) -> str:

xrdpattern/xrd/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def has_label(self, label_type: LabelType) -> bool:
8888
if label_type == LabelType.lattice:
8989
return all(not math.isnan(x) for x in self.primary_phase.lengths) and all(not math.isnan(x) for x in self.primary_phase.angles)
9090
if label_type == LabelType.atom_coords:
91-
return len(self.primary_phase.base) > 0
91+
return len(self.primary_phase.basis) > 0
9292
if label_type == LabelType.spg:
9393
spg_explicit = self.primary_phase.spacegroup is not None
9494
spg_implicit = self.has_label(label_type=LabelType.lattice) and self.has_label(

xrdpattern/xrd/experiment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def make_empty(cls, is_simulated : bool = False, num_phases : int = 1) -> Powder
4040
angles = (float('nan'),float('nan'), float('nan'))
4141
base = CrystalBasis.empty()
4242

43-
p = CrystalStructure(lengths=lengths, angles=angles, base=base)
43+
p = CrystalStructure(lengths=lengths, angles=angles, basis=base)
4444
phases.append(p)
4545

4646
xray_info = XrayInfo.mk_empty()
@@ -90,7 +90,7 @@ def is_nonempty(self) -> bool:
9090
a,b,c = primary_phase.lengths
9191
alpha, beta, gamma = primary_phase.angles
9292
lattice_params_nonempty = not all(math.isnan(x) for x in [a, b, c, alpha, beta, gamma])
93-
crystal_basis_nonempty = len(primary_phase.base) > 0
93+
crystal_basis_nonempty = len(primary_phase.basis) > 0
9494
return xray_info_nonemtpy or composition_nonempty or lattice_params_nonempty or crystal_basis_nonempty
9595

9696
@property
@@ -110,7 +110,7 @@ def get_list_repr(self) -> list:
110110
lattice_params = [a, b, c, alpha, beta, gamma]
111111
list_repr += lattice_params
112112

113-
base = structure.base
113+
base = structure.basis
114114
padded_base = self.get_padded_base(base=base, nan_padding=base.is_empty())
115115
for atomic_site in padded_base:
116116
list_repr += atomic_site.as_list()

0 commit comments

Comments
 (0)