@@ -718,9 +718,20 @@ def test_sun_rise_set_transit_geometric(expected_rise_set_spa, golden_mst):
718
718
atol = np .abs (expected_transit_error ).max ())
719
719
720
720
721
+ @pytest .mark .parametrize ('tz' , [None , 'utc' , 'US/Eastern' ])
722
+ def test__datetime_to_unixtime (tz ):
723
+ # for pandas < 2.0 where "unit" doesn't exist in pd.date_range. note that
724
+ # unit of ns is the only option in pandas<2, and the default in pandas 2.x
725
+ times = pd .date_range (start = '2019-01-01' , freq = 'h' , periods = 3 , tz = tz )
726
+ expected = times .view (np .int64 )/ 10 ** 9
727
+ actual = solarposition ._datetime_to_unixtime (times )
728
+ np .testing .assert_equal (expected , actual )
729
+
730
+
731
+ @requires_pandas_2_0
721
732
@pytest .mark .parametrize ('unit' , ['ns' , 'us' , 's' ])
722
733
@pytest .mark .parametrize ('tz' , [None , 'utc' , 'US/Eastern' ])
723
- def test__datetime_to_unixtime (unit , tz ):
734
+ def test__datetime_to_unixtime_units (unit , tz ):
724
735
kwargs = dict (start = '2019-01-01' , freq = 'h' , periods = 3 )
725
736
times = pd .date_range (** kwargs , unit = 'ns' , tz = 'UTC' )
726
737
expected = times .view (np .int64 )/ 10 ** 9
0 commit comments