Skip to content

Commit

Permalink
Use the correct Mantid algorithm. (#122)
Browse files Browse the repository at this point in the history
Note that matplotlib.pyplot.tight_layout() will only adjust the subplot params when it is called. In order to perform this adjustment each time the figure is redrawn, you can call fig.set_tight_layout(True)
  • Loading branch information
AndreiSavici committed Dec 1, 2023
1 parent 234aad7 commit ce27c80
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/shiver/models/refine_ub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
mtd,
CalculateUMatrix,
FindUBUsingIndexedPeaks,
SelectCellOfType,
OptimizeLatticeForCellType,
SetUB,
SliceMDHisto,
IndexPeaks,
Expand Down Expand Up @@ -125,7 +125,7 @@ def refine(self, rows, lattice_type):
try:
FindUBUsingIndexedPeaks(subset)
if lattice_type:
SelectCellOfType(subset, CellType=lattice_type, Apply=True)
OptimizeLatticeForCellType(subset, CellType=lattice_type, Apply=True)
except (RuntimeError, ValueError) as err:
logger.error(str(err))
if self.error_callback:
Expand Down
1 change: 1 addition & 0 deletions src/shiver/views/refine_ub.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def _setup_ui(self):
plot_layout = QHBoxLayout()
self.figure, self.axes = plt.subplots(1, 3, subplot_kw={"projection": "mantid"}, figsize=(8, 2))
self.figure.tight_layout(w_pad=4)
self.figure.set_layout_engine("tight")
self.canvas = FigureCanvas(self.figure)
plot_layout.addWidget(self.canvas)
vlayout.addLayout(plot_layout)
Expand Down
12 changes: 5 additions & 7 deletions tests/models/test_refine_ub.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ def test_refine_ub_model():

assert peak_table_model.ws.sample().getOrientedLattice().a() == pytest.approx(1)
assert peak_table_model.ws.sample().getOrientedLattice().b() == pytest.approx(1)
assert peak_table_model.ws.sample().getOrientedLattice().c() == pytest.approx(0.99968383)
assert peak_table_model.ws.sample().getOrientedLattice().alpha() == pytest.approx(89.99976216)
assert peak_table_model.ws.sample().getOrientedLattice().beta() == pytest.approx(89.99987616)
assert peak_table_model.ws.sample().getOrientedLattice().c() == pytest.approx(1)
assert peak_table_model.ws.sample().getOrientedLattice().alpha() == pytest.approx(90)
assert peak_table_model.ws.sample().getOrientedLattice().beta() == pytest.approx(90)
assert peak_table_model.ws.sample().getOrientedLattice().gamma() == pytest.approx(90)
assert peak_table_model.ws.sample().getOrientedLattice().getuVector() == pytest.approx([0, 1, 0])
assert peak_table_model.ws.sample().getOrientedLattice().getvVector() == pytest.approx(
[2.16143683e-06, 4.15107836e-06, 0.99968383]
)
assert peak_table_model.ws.sample().getOrientedLattice().getuVector() == pytest.approx([1, 0, 0])
assert peak_table_model.ws.sample().getOrientedLattice().getvVector() == pytest.approx([0, 1, 0])

0 comments on commit ce27c80

Please sign in to comment.