@@ -24,14 +24,15 @@ def generate_apogee_hdu(observatory="APO",
2424
2525 columns = [
2626 fits .Column (name = "spectrum_pk_id" , array = [159783564 ], format = "K" ),
27- fits .Column (name = "release" , array = [b"sdss5" ]* nvisits , format = "5A" ),
28- fits .Column (name = "v_astra" , array = [b"0.5.0" ]* nvisits , format = "5A" ),
27+ fits .Column (name = "release" , array = [b"sdss5" ] * nvisits , format = "5A" ),
28+ fits .Column (name = "v_astra" , array = [b"0.5.0" ] * nvisits , format = "5A" ),
2929 fits .Column (name = "healpix" , array = [3 ], format = "J" ),
30- fits .Column (name = "sdss_id" , array = [42 ]* nvisits , format = "K" ),
31- fits .Column (name = "apred" , array = [b"1.2" ]* nvisits , format = "3A" ),
30+ fits .Column (name = "sdss_id" , array = [42 ] * nvisits , format = "K" ),
31+ fits .Column (name = "apred" , array = [b"1.2" ] * nvisits , format = "3A" ),
3232 fits .Column (name = "obj" , array = [b"2M19534321+6705175" ], format = "18A" ),
33- fits .Column (name = "telescope" , array = [b"apo25m" ]* nvisits , format = "6A" ),
34- fits .Column (name = "snr" , array = [50 ]* nvisits , format = "E" ),
33+ fits .Column (name = "telescope" , array = [b"apo25m" ] * nvisits ,
34+ format = "6A" ),
35+ fits .Column (name = "snr" , array = [50 ] * nvisits , format = "E" ),
3536 ]
3637 if with_wl :
3738 columns .append (
@@ -47,7 +48,7 @@ def generate_apogee_hdu(observatory="APO",
4748 columns += [
4849 fits .Column (name = "mjd" , array = [59804 ], format = "J" ),
4950 ]
50- flux_col = ' model_flux' if astra else ' flux'
51+ flux_col = " model_flux" if astra else " flux"
5152
5253 columns += [
5354 fits .Column (name = flux_col , array = flux , format = "8575E" , dim = "(8575)" ),
@@ -98,14 +99,14 @@ def generate_boss_hdu(observatory="APO",
9899 continuum = np .array ([np .zeros_like (wl )] * nvisits )
99100 nmf_rectified_model_flux = np .array ([np .zeros_like (wl )] * nvisits )
100101 columns = [
101- fits .Column (name = "spectrum_pk_id" , array = [0 ]* nvisits , format = "K" ),
102- fits .Column (name = "release" , array = ["sdss5" ]* nvisits , format = "5A" ),
102+ fits .Column (name = "spectrum_pk_id" , array = [0 ] * nvisits , format = "K" ),
103+ fits .Column (name = "release" , array = ["sdss5" ] * nvisits , format = "5A" ),
103104 fits .Column (name = "v_astra" , array = ["0.5.0" ], format = "5A" ),
104105 fits .Column (name = "healpix" , array = [34 ], format = "J" ),
105106 fits .Column (name = "sdss_id" , array = [42 ], format = "K" ),
106107 fits .Column (name = "run2d" , array = ["6_1_2" ], format = "6A" ),
107- fits .Column (name = "telescope" , array = ["apo25m" ]* nvisits , format = "6A" ),
108- fits .Column (name = "snr" , array = [50 ]* nvisits , format = "E" ),
108+ fits .Column (name = "telescope" , array = ["apo25m" ] * nvisits , format = "6A" ),
109+ fits .Column (name = "snr" , array = [50 ] * nvisits , format = "E" ),
109110 ]
110111
111112 if with_wl :
@@ -122,7 +123,7 @@ def generate_boss_hdu(observatory="APO",
122123 columns += [
123124 fits .Column (name = "mjd" , array = [59804 ], format = "J" ),
124125 ]
125- flux_col = ' model_flux' if astra else ' flux'
126+ flux_col = " model_flux" if astra else " flux"
126127 columns += [
127128 fits .Column (name = flux_col , array = flux , format = "4648E" , dim = "(4648)" ),
128129 fits .Column (name = "ivar" , array = ivar , format = "4648E" , dim = "(4648)" ),
@@ -472,9 +473,9 @@ def test_mwm_1d_nohdu(file_obj, hdu, with_wl, hduflags, nvisits):
472473 if nvisits > 1 :
473474 assert data .flux .value .shape [0 ] == nvisits
474475 if with_wl :
475- assert data .meta [' datatype' ].lower () == ' mwmstar'
476- else :
477- assert data .meta [' datatype' ].lower () == ' mwmvisit'
476+ assert data .meta [" datatype" ].lower () == " mwmstar"
477+ else :
478+ assert data .meta [" datatype" ].lower () == " mwmvisit"
478479 assert data .spectral_axis .unit == Angstrom
479480 assert data .flux .unit == Unit ("1e-17 erg / (s cm2 Angstrom)" )
480481 os .remove (tmpfile )
@@ -512,9 +513,9 @@ def test_astra_nohdu(file_obj, hdu, with_wl, hduflags, nvisits):
512513 if nvisits > 1 :
513514 assert data .flux .value .shape [0 ] == nvisits
514515 if with_wl :
515- assert data .meta [' datatype' ].lower () == ' astrastar'
516- else :
517- assert data .meta [' datatype' ].lower () == ' astravisit'
516+ assert data .meta [" datatype" ].lower () == " astrastar"
517+ else :
518+ assert data .meta [" datatype" ].lower () == " astravisit"
518519 assert data .spectral_axis .unit == Angstrom
519520 assert data .flux .unit == Unit ("1e-17 erg / (s cm2 Angstrom)" )
520521 os .remove (tmpfile )
@@ -564,9 +565,9 @@ def test_mwm_1d(file_obj, hdu, with_wl, hduflags, nvisits):
564565 if nvisits > 1 :
565566 assert data .flux .value .shape [0 ] == nvisits
566567 if with_wl :
567- assert data .meta [' datatype' ].lower () == ' mwmstar'
568- else :
569- assert data .meta [' datatype' ].lower () == ' mwmvisit'
568+ assert data .meta [" datatype" ].lower () == " mwmstar"
569+ else :
570+ assert data .meta [" datatype" ].lower () == " mwmvisit"
570571 assert data .spectral_axis .unit == Angstrom
571572 assert data .flux .unit == Unit ("1e-17 erg / (s cm2 Angstrom)" )
572573 os .remove (tmpfile )
@@ -603,9 +604,9 @@ def test_astra_1d(file_obj, hdu, with_wl, hduflags, nvisits):
603604 assert data .flux .value .shape [0 ] == nvisits
604605
605606 if with_wl :
606- assert data .meta [' datatype' ].lower () == ' astrastar'
607- else :
608- assert data .meta [' datatype' ].lower () == ' astravisit'
607+ assert data .meta [" datatype" ].lower () == " astrastar"
608+ else :
609+ assert data .meta [" datatype" ].lower () == " astravisit"
609610
610611 assert data .spectral_axis .unit == Angstrom
611612 assert data .flux .unit == Unit ("1e-17 erg / (s cm2 Angstrom)" )
@@ -645,9 +646,9 @@ def test_mwm_list(file_obj, with_wl, hduflags):
645646 raise ValueError (
646647 "INSTRMNT tag in test HDU header is not set properly." )
647648 if with_wl :
648- assert data [i ].meta [' datatype' ].lower () == ' mwmstar'
649+ assert data [i ].meta [" datatype" ].lower () == " mwmstar"
649650 else :
650- assert data [i ].meta [' datatype' ].lower () == ' mwmvisit'
651+ assert data [i ].meta [" datatype" ].lower () == " mwmvisit"
651652 assert len (data [i ].spectral_axis .value ) == length
652653 assert data [i ].flux .value .shape [- 1 ] == length
653654 if nvisits > 1 :
@@ -656,6 +657,7 @@ def test_mwm_list(file_obj, with_wl, hduflags):
656657 assert data [i ].flux .unit == Unit ("1e-17 erg / (s cm2 Angstrom)" )
657658 os .remove (tmpfile )
658659
660+
659661@pytest .mark .parametrize (
660662 "file_obj, with_wl, hduflags" ,
661663 [
@@ -673,8 +675,8 @@ def test_astra_list(file_obj, with_wl, hduflags):
673675 """Test astra SpectrumList loader"""
674676 tmpfile = str (file_obj ) + ".fits"
675677 nvisits = 1 if with_wl else 3
676- mwm_HDUList (hduflags , with_wl , nvisits = nvisits ,astra = True ). writeto ( tmpfile ,
677- overwrite = True )
678+ mwm_HDUList (hduflags , with_wl , nvisits = nvisits ,
679+ astra = True ). writeto ( tmpfile , overwrite = True )
678680
679681 data = SpectrumList .read (tmpfile )
680682 assert isinstance (data , SpectrumList )
@@ -689,9 +691,9 @@ def test_astra_list(file_obj, with_wl, hduflags):
689691 raise ValueError (
690692 "INSTRMNT tag in test HDU header is not set properly." )
691693 if with_wl :
692- assert data [i ].meta [' datatype' ].lower () == ' astrastar'
693- else :
694- assert data [i ].meta [' datatype' ].lower () == ' astravisit'
694+ assert data [i ].meta [" datatype" ].lower () == " astrastar"
695+ else :
696+ assert data [i ].meta [" datatype" ].lower () == " astravisit"
695697 assert len (data [i ].spectral_axis .value ) == length
696698 assert data [i ].flux .value .shape [- 1 ] == length
697699 if nvisits > 1 :
@@ -735,6 +737,7 @@ def test_mwm_1d_fail(file_obj, with_wl):
735737 Spectrum .read (tmpfile )
736738 os .remove (tmpfile )
737739
740+
738741@pytest .mark .parametrize (
739742 "file_obj, with_wl" ,
740743 [
@@ -745,7 +748,8 @@ def test_mwm_1d_fail(file_obj, with_wl):
745748def test_astra_1d_fail (file_obj , with_wl ):
746749 """Test astra Spectrum1D loader fail on empty"""
747750 tmpfile = str (file_obj ) + ".fits"
748- mwm_HDUList ([0 , 0 , 0 , 0 ], with_wl ,astra = True ).writeto (tmpfile , overwrite = True )
751+ mwm_HDUList ([0 , 0 , 0 , 0 ], with_wl , astra = True ).writeto (tmpfile ,
752+ overwrite = True )
749753
750754 with pytest .raises (ValueError ):
751755 Spectrum1D .read (tmpfile )
@@ -768,6 +772,7 @@ def test_mwm_list_fail(file_obj, with_wl):
768772 SpectrumList .read (tmpfile )
769773 os .remove (tmpfile )
770774
775+
771776@pytest .mark .parametrize (
772777 "file_obj, with_wl" ,
773778 [
@@ -778,7 +783,8 @@ def test_mwm_list_fail(file_obj, with_wl):
778783def test_astra_list_fail (file_obj , with_wl ):
779784 """Test astra SpectrumList loader fail on empty"""
780785 tmpfile = str (file_obj ) + ".fits"
781- mwm_HDUList ([0 , 0 , 0 , 0 ], with_wl ,astra = True ).writeto (tmpfile , overwrite = True )
786+ mwm_HDUList ([0 , 0 , 0 , 0 ], with_wl , astra = True ).writeto (tmpfile ,
787+ overwrite = True )
782788
783789 with pytest .raises (ValueError ):
784790 SpectrumList .read (tmpfile )
0 commit comments