@@ -39,6 +39,12 @@ def golden_mst():
3939
4040@pytest .fixture ()
4141def expected_solpos ():
42+ return _expected_solpos_df ()
43+
44+
45+ # hack to make tests work without too much modification while avoiding
46+ # pytest 4.0 inability to call features directly
47+ def _expected_solpos_df ():
4248 return pd .DataFrame ({'elevation' : 39.872046 ,
4349 'apparent_zenith' : 50.111622 ,
4450 'azimuth' : 194.340241 ,
@@ -483,15 +489,14 @@ def test_get_solarposition_error(golden):
483489 method = 'error this' )
484490
485491
486- @pytest .mark .parametrize (
487- "pressure, expected" , [
488- (82000 , expected_solpos ()),
492+ @pytest .mark .parametrize ("pressure, expected" , [
493+ (82000 , _expected_solpos_df ()),
489494 (90000 , pd .DataFrame (
490495 np .array ([[ 39.88997 , 50.11003 , 194.34024 , 39.87205 , 14.64151 ,
491496 50.12795 ]]),
492- columns = ['apparent_elevation' , 'apparent_zenith' , 'azimuth' , 'elevation' ,
493- 'equation_of_time' , 'zenith' ],
494- index = expected_solpos (). index ))
497+ columns = ['apparent_elevation' , 'apparent_zenith' , 'azimuth' ,
498+ 'elevation' , ' equation_of_time' , 'zenith' ],
499+ index = [ '2003-10-17T12:30:30Z' ] ))
495500 ])
496501def test_get_solarposition_pressure (pressure , expected , golden ):
497502 times = pd .date_range (datetime .datetime (2003 ,10 ,17 ,13 ,30 ,30 ),
@@ -507,15 +512,14 @@ def test_get_solarposition_pressure(pressure, expected, golden):
507512 assert_frame_equal (this_expected , ephem_data [this_expected .columns ])
508513
509514
510- @pytest .mark .parametrize (
511- "altitude, expected" ,
512- [(golden ().altitude , expected_solpos ()),
515+ @pytest .mark .parametrize ("altitude, expected" , [
516+ (1830.14 , _expected_solpos_df ()),
513517 (2000 , pd .DataFrame (
514518 np .array ([[ 39.88788 , 50.11212 , 194.34024 , 39.87205 , 14.64151 ,
515519 50.12795 ]]),
516520 columns = ['apparent_elevation' , 'apparent_zenith' , 'azimuth' ,
517521 'elevation' , 'equation_of_time' , 'zenith' ],
518- index = expected_solpos (). index ))
522+ index = [ '2003-10-17T12:30:30Z' ] ))
519523 ])
520524def test_get_solarposition_altitude (altitude , expected , golden ):
521525 times = pd .date_range (datetime .datetime (2003 ,10 ,17 ,13 ,30 ,30 ),
@@ -531,17 +535,18 @@ def test_get_solarposition_altitude(altitude, expected, golden):
531535 assert_frame_equal (this_expected , ephem_data [this_expected .columns ])
532536
533537
534- @pytest .mark .parametrize (
535- "delta_t, method, expected" , [
536- (None , 'nrel_numpy' , expected_solpos_multi ()),
537- (67.0 , 'nrel_numpy' , expected_solpos_multi ()),
538- pytest .mark .xfail (
538+ @pytest .mark .parametrize ("delta_t, method" , [
539+ (None , 'nrel_numpy' ),
540+ (67.0 , 'nrel_numpy' ),
541+ pytest .param (
542+ None , 'nrel_numba' ,
543+ marks = [pytest .mark .xfail (
539544 raises = ValueError ,
540- reason = 'spa.calculate_deltat not implemented for numba yet' )
541- ((None , 'nrel_numba' , expected_solpos_multi ())),
542- (67.0 , 'nrel_numba' , expected_solpos_multi ())
545+ reason = 'spa.calculate_deltat not implemented for numba yet' )]),
546+ (67.0 , 'nrel_numba' )
543547 ])
544- def test_get_solarposition_deltat (delta_t , method , expected , golden ):
548+ def test_get_solarposition_deltat (delta_t , method , expected_solpos_multi ,
549+ golden ):
545550 times = pd .date_range (datetime .datetime (2003 ,10 ,17 ,13 ,30 ,30 ),
546551 periods = 2 , freq = 'D' , tz = golden .tz )
547552 ephem_data = solarposition .get_solarposition (times , golden .latitude ,
@@ -550,7 +555,7 @@ def test_get_solarposition_deltat(delta_t, method, expected, golden):
550555 delta_t = delta_t ,
551556 temperature = 11 ,
552557 method = method )
553- this_expected = expected . copy ()
558+ this_expected = expected_solpos_multi
554559 this_expected .index = times
555560 this_expected = np .round (this_expected , 5 )
556561 ephem_data = np .round (ephem_data , 5 )
@@ -673,10 +678,8 @@ def test_analytical_azimuth():
673678 decl , zenith )
674679
675680 idx = np .where (solar_zenith < np .pi / 2 )
676- assert np .allclose (azimuth_1 [idx ], solar_azimuth .as_matrix ()[idx ],
677- atol = 0.01 )
678- assert np .allclose (azimuth_2 [idx ], solar_azimuth .as_matrix ()[idx ],
679- atol = 0.017 )
681+ assert np .allclose (azimuth_1 [idx ], solar_azimuth .values [idx ], atol = 0.01 )
682+ assert np .allclose (azimuth_2 [idx ], solar_azimuth .values [idx ], atol = 0.017 )
680683
681684 # test for NaN values at boundary conditions (PR #431)
682685 test_angles = np .radians (np .array (
0 commit comments