File: test_Plotter.py

package info (click to toggle)
python-mcstasscript 0.0.46%2Bgit20250402111921.bfa5a26-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,440 kB
  • sloc: python: 13,421; makefile: 14
file content (648 lines) | stat: -rw-r--r-- 25,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
import unittest
import unittest.mock

import matplotlib
matplotlib.use('Agg')

import numpy as np
import matplotlib.pyplot as plt

from mcstasscript.data.data import McStasDataBinned
from mcstasscript.data.data import McStasMetaData
from mcstasscript.interface.plotter import _find_min_max_I
from mcstasscript.interface.plotter import _handle_kwargs
from mcstasscript.interface.plotter import _plot_fig_ax
from mcstasscript.interface.plotter import make_plot, make_sub_plot, make_animation


def get_dummy_MetaDataBinned_1d():
    meta_data = McStasMetaData()
    meta_data.component_name = "component for 1d"
    meta_data.dimension = 50
    meta_data.limits = [0.1, 1.1]
    meta_data.title = "test"
    meta_data.xlabel = "test x"
    meta_data.ylabel = "test y"

    return meta_data


def get_dummy_McStasDataBinned_1d():
    meta_data = get_dummy_MetaDataBinned_1d()

    intensity = np.arange(20) + 5
    error = 0.5 * np.arange(20)
    ncount = 2 * np.arange(20)
    axis = np.arange(20)*5.0

    return McStasDataBinned(meta_data, intensity, error, ncount, xaxis=axis)


def get_dummy_MetaDataBinned_2d():
    meta_data = McStasMetaData()
    meta_data.component_name = "test a component"
    meta_data.dimension = [5, 4]
    meta_data.limits = [0.1, 1.1, 2.0, 4.0]
    meta_data.title = "test"
    meta_data.xlabel = "test x"
    meta_data.ylabel = "test y"

    return meta_data


def get_dummy_McStasDataBinned_2d():
    meta_data = get_dummy_MetaDataBinned_2d()

    intensity = np.arange(20).reshape(4, 5) + 5
    error = 0.5 * np.arange(20).reshape(4, 5)
    ncount = 2 * np.arange(20).reshape(4, 5)

    return McStasDataBinned(meta_data, intensity, error, ncount)


class TestPlotterHelpers(unittest.TestCase):
    """
    Tests of plotter help functions
    """

    def test_find_min_max_I_simple_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5)
        self.assertEqual(found_max, 19 + 5)

    def test_find_min_max_I_cut_max_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_max is used to limit the maximum plotted.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.set_plot_options(cut_max=0.8)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5)
        self.assertEqual(found_max, (19 + 5)*0.8)

    def test_find_min_max_I_cut_min_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_min is used to limit the minimum plotted.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.set_plot_options(cut_min=0.2)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5 + (24-5)*0.2)
        self.assertEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_with_zero_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here a bin contains zero intensity and log mode is enabled,
        since log(0) is not allowed, this data point should be
        ignored.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.Intensity[5] = 0
        dummy_data.set_plot_options(log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5)
        self.assertAlmostEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_cut_max_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_max is used to limit the maximum plotted while
        log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.set_plot_options(cut_max=0.8, log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5)
        self.assertAlmostEqual(found_max, (19 + 5)*0.8)

    def test_find_min_max_I_log_cut_min_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_min is used to limit the minimum plotted while
        log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.set_plot_options(cut_min=0.2, log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5 + (24-5)*0.2)
        self.assertAlmostEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_orders_of_mag_1D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here orders_of_mag is used to limit the minimum plotted
        while log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.Intensity[5] = 10**6
        dummy_data.set_plot_options(log=True, orders_of_mag=3)
        found_min, found_max = _find_min_max_I(dummy_data)

        self.assertAlmostEqual(found_min, 10**3)
        self.assertAlmostEqual(found_max, 10**6)

    def test_find_min_max_I_log_orders_of_mag_1D_with_zero_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here orders_of_mag is used to limit the minimum plotted
        while log mode is enabled. A bin in the data contains
        zero intensity, which should be ignored.
        """

        dummy_data = get_dummy_McStasDataBinned_1d()
        dummy_data.Intensity[5] = 10**6
        dummy_data.Intensity[6] = 0
        dummy_data.set_plot_options(log=True, orders_of_mag=3)
        found_min, found_max = _find_min_max_I(dummy_data)

        self.assertAlmostEqual(found_min, 10**3)
        self.assertAlmostEqual(found_max, 10**6)

    def test_find_min_max_I_simple_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5)
        self.assertEqual(found_max, 19 + 5)

    def test_find_min_max_I_cut_max_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_max is used to limit the maximum plotted.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.set_plot_options(cut_max=0.8)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5)
        self.assertEqual(found_max, (19 + 5)*0.8)

    def test_find_min_max_I_cut_min_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_min is used to limit the minimum plotted.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.set_plot_options(cut_min=0.2)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertEqual(found_min, 5 + (24-5)*0.2)
        self.assertEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_with_zero_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here a bin contains zero intensity and log mode is enabled,
        since log(0) is not allowed, this data point should be
        ignored.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.Intensity[2, 2] = 0
        dummy_data.set_plot_options(log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5)
        self.assertAlmostEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_cut_max_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_max is used to limit the maximum plotted while
        log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.set_plot_options(cut_max=0.8, log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5)
        self.assertAlmostEqual(found_max, (19 + 5)*0.8)

    def test_find_min_max_I_log_cut_min_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here cut_min is used to limit the minimum plotted while
        log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.set_plot_options(cut_min=0.2, log=True)
        found_min, found_max = _find_min_max_I(dummy_data)

        # np.arange(20) + 5: min = 5, max = 5+19 = 24
        self.assertAlmostEqual(found_min, 5 + (24-5)*0.2)
        self.assertAlmostEqual(found_max, 19 + 5)

    def test_find_min_max_I_log_orders_of_mag_2D_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here orders_of_mag is used to limit the minimum plotted
        while log mode is enabled.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.Intensity[2, 2] = 10**6
        dummy_data.set_plot_options(log=True, orders_of_mag=3)
        found_min, found_max = _find_min_max_I(dummy_data)

        self.assertAlmostEqual(found_min, 10**3)
        self.assertAlmostEqual(found_max, 10**6)

    def test_find_min_max_I_log_orders_of_mag_2D_with_zero_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here orders_of_mag is used to limit the minimum plotted
        while log mode is enabled. A bin in the data contains
        zero intensity, which should be ignored.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.Intensity[2, 2] = 10**6
        dummy_data.Intensity[2, 3] = 0
        dummy_data.set_plot_options(log=True, orders_of_mag=3)
        found_min, found_max = _find_min_max_I(dummy_data)

        self.assertAlmostEqual(found_min, 10**3)
        self.assertAlmostEqual(found_max, 10**6)

    def test_find_min_max_I_fail_case(self):
        """
        test _find_min_max_I for a 1D case, it finds the minimum
        and maximum value to plot for a given McStasData set.
        Here orders_of_mag is used to limit the minimum plotted
        while log mode is enabled. A bin in the data contains
        zero intensity, which should be ignored.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        dummy_data.Intensity = np.zeros((5, 5))
        dummy_data.set_plot_options(log=True, orders_of_mag=3)
        found_min, found_max = _find_min_max_I(dummy_data)

        self.assertEqual(found_min, 0)
        self.assertEqual(found_max, 0)

    def test_handle_kwargs_log(self):
        """
        Tests handle_kwargs with log option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.log, False)
        self.assertEqual(dummy_data2.plot_options.log, False)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, log=True)
        self.assertEqual(dummy_data1.plot_options.log, True)
        self.assertEqual(dummy_data2.plot_options.log, True)

        _handle_kwargs(data_list, log=[False, True])
        self.assertEqual(dummy_data1.plot_options.log, False)
        self.assertEqual(dummy_data2.plot_options.log, True)

    def test_handle_kwargs_oders_of_mag(self):
        """
        Tests handle_kwargs with orders_of_mag option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.orders_of_mag, 300)
        self.assertEqual(dummy_data2.plot_options.orders_of_mag, 300)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, orders_of_mag=12)
        self.assertEqual(dummy_data1.plot_options.orders_of_mag, 12)
        self.assertEqual(dummy_data2.plot_options.orders_of_mag, 12)

        _handle_kwargs(data_list, orders_of_mag=[50, 10])
        self.assertEqual(dummy_data1.plot_options.orders_of_mag, 50)
        self.assertEqual(dummy_data2.plot_options.orders_of_mag, 10)

    def test_handle_kwargs_all_simple(self):
        """
        Tests handle_kwargs with all simple options option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """

        known_plot = ["log", "orders_of_mag",
                      "cut_min", "cut_max",
                      "colormap", "show_colorbar",
                      "x_axis_multiplier",
                      "y_axis_multiplier"]

        kwargs_to_attr = {"x_axis_multiplier": "x_limit_multiplier",
                          "y_axis_multiplier": "y_limit_multiplier"}

        defaults = {"log": False, "orders_of_mag": 300,
                    "cut_min": 0, "cut_max": 1,
                    "colormap": "jet", "show_colorbar": True,
                    "x_limit_multiplier": 1, "y_limit_multiplier": 1}

        test_value = {"log": True, "orders_of_mag": 15,
                      "cut_min": 0.25, "cut_max": 0.8,
                      "colormap": "hot", "show_colorbar": False,
                      "x_limit_multiplier": 2.8, "y_limit_multiplier": 0.8}

        for option in known_plot:

            if option in kwargs_to_attr:
                kw_option = kwargs_to_attr[option]
            else:
                kw_option = option

            default_value = defaults[kw_option]

            dummy_data1 = get_dummy_McStasDataBinned_2d()
            data1_value = dummy_data1.plot_options.__getattribute__(kw_option)
            self.assertEqual(data1_value, default_value)

            dummy_data2 = get_dummy_McStasDataBinned_2d()
            data2_value = dummy_data2.plot_options.__getattribute__(kw_option)
            self.assertEqual(data2_value, default_value)

            data_list = [dummy_data1, dummy_data2]

            set_value = test_value[kw_option]
            given_option = {option: set_value}
            _handle_kwargs(data_list, **given_option)

            data1_value = dummy_data1.plot_options.__getattribute__(kw_option)
            self.assertEqual(data1_value, set_value)

            data2_value = dummy_data2.plot_options.__getattribute__(kw_option)
            self.assertEqual(data2_value, set_value)

            given_option = {option: [set_value, default_value]}
            _handle_kwargs(data_list, **given_option)

            data_1_value = dummy_data1.plot_options.__getattribute__(kw_option)
            self.assertEqual(data_1_value, set_value)
            data_2_value = dummy_data2.plot_options.__getattribute__(kw_option)
            self.assertEqual(data_2_value, default_value)

    def test_handle_kwargs_left_lim(self):
        """
        Tests handle_kwargs with left_lim option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.custom_xlim_left, False)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_left, False)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, left_lim=0.08)
        self.assertEqual(dummy_data1.plot_options.left_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.left_lim, 0.08)
        self.assertEqual(dummy_data1.plot_options.custom_xlim_left, True)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_left, True)

        _handle_kwargs(data_list, left_lim=[0.08, 1.08])
        self.assertEqual(dummy_data1.plot_options.left_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.left_lim, 1.08)
        self.assertEqual(dummy_data1.plot_options.custom_xlim_left, True)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_left, True)

    def test_handle_kwargs_right_lim(self):
        """
        Tests handle_kwargs with right_lim option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.custom_xlim_right, False)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_right, False)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, right_lim=0.08)
        self.assertEqual(dummy_data1.plot_options.right_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.right_lim, 0.08)
        self.assertEqual(dummy_data1.plot_options.custom_xlim_right, True)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_right, True)

        _handle_kwargs(data_list, right_lim=[0.08, 1.08])
        self.assertEqual(dummy_data1.plot_options.right_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.right_lim, 1.08)
        self.assertEqual(dummy_data1.plot_options.custom_xlim_right, True)
        self.assertEqual(dummy_data2.plot_options.custom_xlim_right, True)

    def test_handle_kwargs_top_lim(self):
        """
        Tests handle_kwargs with top_lim option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.custom_ylim_top, False)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_top, False)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, top_lim=0.08)
        self.assertEqual(dummy_data1.plot_options.top_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.top_lim, 0.08)
        self.assertEqual(dummy_data1.plot_options.custom_ylim_top, True)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_top, True)

        _handle_kwargs(data_list, top_lim=[0.08, 1.08])
        self.assertEqual(dummy_data1.plot_options.top_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.top_lim, 1.08)
        self.assertEqual(dummy_data1.plot_options.custom_ylim_top, True)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_top, True)

    def test_handle_kwargs_bottom_lim(self):
        """
        Tests handle_kwargs with bottom_lim option

        Keyword args can be set for all by normal use, or individual
        data sets by using a list. Both are checked here.
        """
        dummy_data1 = get_dummy_McStasDataBinned_2d()
        dummy_data2 = get_dummy_McStasDataBinned_2d()
        self.assertEqual(dummy_data1.plot_options.custom_ylim_bottom, False)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_bottom, False)

        data_list = [dummy_data1, dummy_data2]
        _handle_kwargs(data_list, bottom_lim=0.08)
        self.assertEqual(dummy_data1.plot_options.bottom_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.bottom_lim, 0.08)
        self.assertEqual(dummy_data1.plot_options.custom_ylim_bottom, True)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_bottom, True)

        _handle_kwargs(data_list, bottom_lim=[0.08, 1.08])
        self.assertEqual(dummy_data1.plot_options.bottom_lim, 0.08)
        self.assertEqual(dummy_data2.plot_options.bottom_lim, 1.08)
        self.assertEqual(dummy_data1.plot_options.custom_ylim_bottom, True)
        self.assertEqual(dummy_data2.plot_options.custom_ylim_bottom, True)

    @unittest.mock.patch("matplotlib.pyplot.subplots")
    def test_handle_kwargs_figsize_default(self, mock_subplots):
        """
        Tests handle_kwargs delivers default figsize
        """

        # Ensures subplots returns a tuple with two objects
        mock_fig = unittest.mock.MagicMock()
        mock_ax = unittest.mock.MagicMock()
        mock_subplots.return_value = (mock_fig, mock_ax)

        # Actual test
        dummy_data = get_dummy_McStasDataBinned_2d()
        make_plot(dummy_data)
        mock_subplots.assert_called_with(figsize=(13, 7), tight_layout=True)

    @unittest.mock.patch("matplotlib.pyplot.subplots")
    def test_handle_kwargs_figsize_tuple(self, mock_subplots):
        """
        Tests handle_kwargs with figsize keyword argument, here
        using tuple as input
        """

        # Ensures subplots returns a tuple with two objects
        mock_fig = unittest.mock.MagicMock()
        mock_ax = unittest.mock.MagicMock()
        mock_subplots.return_value = (mock_fig, mock_ax)

        # Actual test
        dummy_data = get_dummy_McStasDataBinned_2d()
        make_plot(dummy_data, figsize=(5, 9))
        mock_subplots.assert_called_with(figsize=(5, 9), tight_layout=True)

    @unittest.mock.patch("matplotlib.pyplot.subplots")
    def test_handle_kwargs_figsize_list(self, mock_subplots):
        """
        Tests handle_kwargs with figsize keyword argument, here
        using tuple as input
        """

        # Ensures subplots returns a tuple with two objects
        mock_fig = unittest.mock.MagicMock()
        mock_ax = unittest.mock.MagicMock()
        mock_subplots.return_value = (mock_fig, mock_ax)

        # Actual test
        dummy_data = get_dummy_McStasDataBinned_2d()
        make_plot(dummy_data, figsize=[5, 9])
        mock_subplots.assert_called_with(figsize=(5, 9), tight_layout=True)

    def test_handle_kwargs_single_element_to_list(self):
        """
        Test handle_kwargs will grab a single McStasData element
        and turn it into a list.
        """

        dummy_data = get_dummy_McStasDataBinned_2d()
        self.assertFalse(isinstance(dummy_data, list))
        data_list = _handle_kwargs(dummy_data)
        self.assertTrue(isinstance(data_list, list))

    def test_plot_function_1D_normal(self):
        """
        Run the plot function with 1D data set without showing the
        result.

        """
        dummy_data = get_dummy_McStasDataBinned_1d()

        fig, ax0 = plt.subplots()
        _plot_fig_ax(dummy_data, fig, ax0)

    def test_plot_function_1D_log(self):
        """
        Run the plot function with 1D data set without showing the
        result. Here with logarithmic y axis.

        """
        dummy_data = get_dummy_McStasDataBinned_1d()

        fig, ax0 = plt.subplots()
        _plot_fig_ax(dummy_data, fig, ax0, log=True)

    def test_plot_function_2D_normal(self):
        """
        Run the plot function with 2D data set without showing the
        result.

        """
        dummy_data = get_dummy_McStasDataBinned_2d()

        fig, ax0 = plt.subplots()
        _plot_fig_ax(dummy_data, fig, ax0)

    def test_plot_function_2D_log(self):
        """
        Run the plot function with 2D data set without showing the
        result. Here the intensity coloraxis is logarithmic.

        """
        dummy_data = get_dummy_McStasDataBinned_2d()

        fig, ax0 = plt.subplots()
        _plot_fig_ax(dummy_data, fig, ax0, log=True)