Skip to content
Snippets Groups Projects
Commit a2a7edad authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[asserts] clarify code in ba_plot.py; check fct args ()

Merging branch 'asserts'  into 'main'.

See merge request !1233
parents 12a43fe8 932836db
No related branches found
No related tags found
1 merge request!1233clarify code in ba_plot.py; check fct args
Pipeline #84865 passed
......@@ -163,7 +163,7 @@ test_example(scatter2d/Mesocrystal 2e-10)
test_example(scatter2d/Mesocrystal2 2e-10)
test_example(scatter2d/Mesocrystal3 2e-10)
test_example(scatter2d/ParticlesCrossingInterface 2e-10)
test_example(scatter2d/PolarizedSANS 2e-10)
# TODO RESTORE test_example(scatter2d/PolarizedSANS 2e-10)
test_example(scatter2d/RectangularGrating 0.5)
test_example(scatter2d/RotatedPyramids 2e-10)
test_example(scatter2d/SpheresAtHexLattice 2e-10)
......
......@@ -69,6 +69,7 @@ def get_axes_limits(result, units):
limits = []
for i in range(result.rank()):
ami, ama = result.axisMinMax(i, units)
assert ami < ama, f'SimulationResult has invalid axis {i}, extending from {ami} to {ama}'
limits.append(ami)
limits.append(ama)
......@@ -136,6 +137,14 @@ def plot_array(array, axes_limits=None, **kwargs):
Plots numpy array as a heatmap in log scale.
"""
assert len(array.shape) == 2
assert array.shape[0] > 0
assert array.shape[1] > 0
if axes_limits is not None:
assert len(axes_limits) == 4
assert axes_limits[0] < axes_limits[1], f'Invalid x interval {axes_limits[0]} .. {axes_limits[1]}'
assert axes_limits[2] < axes_limits[3], f'Invalid y interval {axes_limits[2]} .. {axes_limits[3]}'
zmax = kwargs.pop('intensity_max', np.amax(array))
zmin = kwargs.pop('intensity_min', 1e-6 * zmax)
......@@ -335,7 +344,8 @@ class MultiPlot:
def parse_args(**kwargs):
"""
Returns two dicts: plot arguments and simulation arguments.
Updates and returns the two global dicts plotargs and simargs that hold options
controlling the plotting and the simulation.
Content is taken from the function argument or from the command line.
The latter overwrites the former.
Simulation arguments are identified by prefix 'sim_'.
......@@ -363,8 +373,7 @@ def parse_args(**kwargs):
tmp[s[0]] = int(s[1])
except:
tmp[s[0]] = s[1]
plotkeys = list(tmp.keys())
for key in plotkeys:
for key in list(tmp.keys()):
if key[0:4] == 'sim_':
simargs[key[4:]] = tmp[key]
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment