@mat3ra/made 2026.4.2-0 → 2026.4.2-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -128,6 +128,20 @@ class Lattice(RoundNumericValuesMixin, LatticeSchemaVectorless, InMemoryEntityPy
|
|
|
128
128
|
def cell_volume_rounded(self) -> float:
|
|
129
129
|
return self.vectors.volume_rounded
|
|
130
130
|
|
|
131
|
+
@property
|
|
132
|
+
def reciprocal_vectors(self):
|
|
133
|
+
return np.linalg.inv(np.array(self.vector_arrays, dtype=float)).T.tolist()
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def reciprocal_vector_norms(self) -> List[float]:
|
|
137
|
+
return [float(np.linalg.norm(vector)) for vector in self.reciprocal_vectors]
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def reciprocal_vector_ratios(self) -> List[float]:
|
|
141
|
+
norms = self.reciprocal_vector_norms
|
|
142
|
+
max_norm = max(norms)
|
|
143
|
+
return [round(float(value / max_norm), 3) for value in norms]
|
|
144
|
+
|
|
131
145
|
def get_hash_string(self, is_scaled: bool = False) -> str:
|
|
132
146
|
"""Mirrors JS Lattice.getHashString(isScaled). Rounds to HASH_TOLERANCE decimal places."""
|
|
133
147
|
scale = self.a if is_scaled else 1
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
from mat3ra.code.vector import RoundedVector3D
|
|
2
4
|
from mat3ra.made.lattice import Lattice
|
|
3
5
|
from mat3ra.utils import assertion as assertion_utils
|
|
@@ -75,5 +77,28 @@ def test_lattice_get_scaled_by_matrix():
|
|
|
75
77
|
assertion_utils.assert_deep_almost_equal(lattice.vector_arrays, expected_vector_values)
|
|
76
78
|
|
|
77
79
|
|
|
80
|
+
def test_reciprocal_vectors():
|
|
81
|
+
lattice = Lattice(a=2.0, b=3.0, c=4.0)
|
|
82
|
+
expected_vectors = [[0.5, 0.0, 0.0], [0.0, 1 / 3, 0.0], [0.0, 0.0, 0.25]]
|
|
83
|
+
assertion_utils.assert_deep_almost_equal(lattice.reciprocal_vectors, expected_vectors)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_reciprocal_vector_norms():
|
|
87
|
+
lattice = Lattice(a=2.0, b=3.0, c=4.0)
|
|
88
|
+
expected_norms = [0.5, 1 / 3, 0.25]
|
|
89
|
+
assertion_utils.assert_deep_almost_equal(lattice.reciprocal_vector_norms, expected_norms)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize(
|
|
93
|
+
"lattice, expected",
|
|
94
|
+
[
|
|
95
|
+
(Lattice(a=2.0, b=3.0, c=4.0), [1.0, 0.667, 0.5]),
|
|
96
|
+
(Lattice(a=5.43, b=5.43, c=5.43), [1.0, 1.0, 1.0]),
|
|
97
|
+
],
|
|
98
|
+
)
|
|
99
|
+
def test_reciprocal_vector_ratios(lattice, expected):
|
|
100
|
+
assert lattice.reciprocal_vector_ratios == expected
|
|
101
|
+
|
|
102
|
+
|
|
78
103
|
# to test: create, calculate_vectors, from_vectors, get_lattice_type, clone
|
|
79
104
|
# from_vectors, to_dict, cell, cell_volume, scale_by_matrix, update_from_lattice,
|