@@ -372,83 +372,89 @@ def test_dump(tmp_path, mocker):
372372 assert actual == expected
373373
374374
375-
376- @pytest .mark .parametrize ("init_args, expected_do_dict" , [
377- ( # instantiate just array attributes
378- {
379- "xarray" : np .array ([0.0 , 90.0 , 180.0 ]),
380- "yarray" : np .array ([1.0 , 2.0 , 3.0 ]),
381- "xtype" : "tth" ,
382- "wavelength" : 4.0 * np .pi ,
383- },
384- {
385- "_all_arrays" : np .array (
386- [
387- [1.0 , 0.0 , 0.0 , np .float64 (np .inf )],
388- [2.0 , 1.0 / np .sqrt (2 ), 90.0 , np .sqrt (2 ) * 2 * np .pi ],
389- [3.0 , 1.0 , 180.0 , 1.0 * 2 * np .pi ],
390- ]
391- ),
392- "metadata" : {},
393- "_input_xtype" : "tth" ,
394- "name" : "" ,
395- "scat_quantity" : "" ,
396- "qmin" : np .float64 (0.0 ),
397- "qmax" : np .float64 (1.0 ),
398- "tthmin" : np .float64 (0.0 ),
399- "tthmax" : np .float64 (180.0 ),
400- "dmin" : np .float64 (2 * np .pi ),
401- "dmax" : np .float64 (np .inf ),
402- "wavelength" : 4.0 * np .pi ,
403- },
404- ),
405- ( # instantiate just array attributes
406- {
407- "xarray" : np .array ([np .inf , 2 * np .sqrt (2 ) * np .pi , 2 * np .pi ]),
408- "yarray" : np .array ([1.0 , 2.0 , 3.0 ]),
409- "xtype" : "d" ,
410- "wavelength" : 4.0 * np .pi ,
411- "scat_quantity" : "x-ray" ,
412- },
413- {
414- "_all_arrays" : np .array (
415- [
416- [1.0 , 0.0 , 0.0 , np .float64 (np .inf )],
417- [2.0 , 1.0 / np .sqrt (2 ), 90.0 , np .sqrt (2 ) * 2 * np .pi ],
418- [3.0 , 1.0 , 180.0 , 1.0 * 2 * np .pi ],
419- ]
420- ),
421- "metadata" : {},
422- "_input_xtype" : "d" ,
423- "name" : "" ,
424- "scat_quantity" : "x-ray" ,
425- "qmin" : np .float64 (0.0 ),
426- "qmax" : np .float64 (1.0 ),
427- "tthmin" : np .float64 (0.0 ),
428- "tthmax" : np .float64 (180.0 ),
429- "dmin" : np .float64 (2 * np .pi ),
430- "dmax" : np .float64 (np .inf ),
431- "wavelength" : 4.0 * np .pi ,
432- },
433- ),
434- ])
375+ @pytest .mark .parametrize (
376+ "init_args, expected_do_dict" ,
377+ [
378+ ( # instantiate just array attributes
379+ {
380+ "xarray" : np .array ([0.0 , 90.0 , 180.0 ]),
381+ "yarray" : np .array ([1.0 , 2.0 , 3.0 ]),
382+ "xtype" : "tth" ,
383+ "wavelength" : 4.0 * np .pi ,
384+ },
385+ {
386+ "_all_arrays" : np .array (
387+ [
388+ [1.0 , 0.0 , 0.0 , np .float64 (np .inf )],
389+ [2.0 , 1.0 / np .sqrt (2 ), 90.0 , np .sqrt (2 ) * 2 * np .pi ],
390+ [3.0 , 1.0 , 180.0 , 1.0 * 2 * np .pi ],
391+ ]
392+ ),
393+ "metadata" : {},
394+ "_input_xtype" : "tth" ,
395+ "name" : "" ,
396+ "scat_quantity" : "" ,
397+ "qmin" : np .float64 (0.0 ),
398+ "qmax" : np .float64 (1.0 ),
399+ "tthmin" : np .float64 (0.0 ),
400+ "tthmax" : np .float64 (180.0 ),
401+ "dmin" : np .float64 (2 * np .pi ),
402+ "dmax" : np .float64 (np .inf ),
403+ "wavelength" : 4.0 * np .pi ,
404+ },
405+ ),
406+ ( # instantiate just array attributes
407+ {
408+ "xarray" : np .array ([np .inf , 2 * np .sqrt (2 ) * np .pi , 2 * np .pi ]),
409+ "yarray" : np .array ([1.0 , 2.0 , 3.0 ]),
410+ "xtype" : "d" ,
411+ "wavelength" : 4.0 * np .pi ,
412+ "scat_quantity" : "x-ray" ,
413+ },
414+ {
415+ "_all_arrays" : np .array (
416+ [
417+ [1.0 , 0.0 , 0.0 , np .float64 (np .inf )],
418+ [2.0 , 1.0 / np .sqrt (2 ), 90.0 , np .sqrt (2 ) * 2 * np .pi ],
419+ [3.0 , 1.0 , 180.0 , 1.0 * 2 * np .pi ],
420+ ]
421+ ),
422+ "metadata" : {},
423+ "_input_xtype" : "d" ,
424+ "name" : "" ,
425+ "scat_quantity" : "x-ray" ,
426+ "qmin" : np .float64 (0.0 ),
427+ "qmax" : np .float64 (1.0 ),
428+ "tthmin" : np .float64 (0.0 ),
429+ "tthmax" : np .float64 (180.0 ),
430+ "dmin" : np .float64 (2 * np .pi ),
431+ "dmax" : np .float64 (np .inf ),
432+ "wavelength" : 4.0 * np .pi ,
433+ },
434+ ),
435+ ],
436+ )
435437def test_init_valid (init_args , expected_do_dict ):
436438 actual_do_dict = DiffractionObject (** init_args ).__dict__
437- diff = DeepDiff (actual_do_dict , expected_do_dict , ignore_order = True , significant_digits = 13 , exclude_paths = "root['_id']" )
439+ diff = DeepDiff (
440+ actual_do_dict , expected_do_dict , ignore_order = True , significant_digits = 13 , exclude_paths = "root['_id']"
441+ )
438442 assert diff == {}
439443
440444
441-
442- @pytest .mark .parametrize ("init_args, error_message" , [
443- ( # UC1: no arguments provided
444- {},
445- "missing 3 required positional arguments: 'xarray', 'yarray', and 'xtype'" ,
446- ),
447- ( # UC2: only xarray and yarray provided
448- {"xarray" : np .array ([0.0 , 90.0 ]), "yarray" : np .array ([0.0 , 90.0 ])},
449- "missing 1 required positional argument: 'xtype'" ,
450- ),
451- ])
445+ @pytest .mark .parametrize (
446+ "init_args, error_message" ,
447+ [
448+ ( # UC1: no arguments provided
449+ {},
450+ "missing 3 required positional arguments: 'xarray', 'yarray', and 'xtype'" ,
451+ ),
452+ ( # UC2: only xarray and yarray provided
453+ {"xarray" : np .array ([0.0 , 90.0 ]), "yarray" : np .array ([0.0 , 90.0 ])},
454+ "missing 1 required positional argument: 'xtype'" ,
455+ ),
456+ ],
457+ )
452458def test_init_invalid_args (init_args , error_message ):
453459 with pytest .raises (TypeError , match = error_message ):
454460 DiffractionObject (** init_args )
0 commit comments