Skip to content

Commit 6092cef

Browse files
committed
Refactor: Fix tests and bring to 100%
1 parent 48376cb commit 6092cef

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

diffsims/generators/simulation_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def calculate_diffraction1d(
310310

311311
# Scale intensities so that the max intensity is 100.
312312

313-
max_intensity = max([v[0] for v in peaks.values()])
313+
max_intensity = max([v[1][0] for v in peaks])
314314
reciporical_spacing = []
315315
intensities = []
316316
hkls = []

diffsims/tests/generators/test_simulation_generator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ def test_multiphase_multirotation_simulation():
246246
)
247247

248248

249+
def test_multiphase_multirotation_simulation_error():
250+
generator = SimulationGenerator(300)
251+
silicon = make_phase(5)
252+
big_silicon = make_phase(10)
253+
rot = Rotation.from_euler([[0, 0, 0], [0.1, 0.1, 0.1]])
254+
rot2 = Rotation.from_euler([[0, 0, 0], [0.1, 0.1, 0.1], [0.2, 0.2, 0.2]])
255+
with pytest.raises(ValueError):
256+
sim = generator.calculate_diffraction2d([silicon, big_silicon], rotation=[rot])
257+
258+
249259
@pytest.mark.parametrize("scattering_param", ["lobato", "xtables"])
250260
def test_param_check(scattering_param):
251261
generator = SimulationGenerator(300, scattering_params=scattering_param)

diffsims/tests/simulations/test_simulations2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_get_simulation(self, multi_simulation):
213213
assert phase == 0
214214

215215
def test_get_current_rotation(self, multi_simulation):
216-
rot = multi_simulation.get_current_rotation()
216+
rot = multi_simulation.get_current_rotation_matrix()
217217
np.testing.assert_array_equal(rot, multi_simulation.rotations[0].to_matrix()[0])
218218

219219
def test_init(self, multi_simulation):

0 commit comments

Comments
 (0)