def test_get_times_arrays(): df = pd.DataFrame({'date': [date] * 3, 'lat': [lat] * 3, 'lng': [lng] * 3}) times = pd.DataFrame(get_times(df['date'], df['lng'], df['lat'])) assert pd.api.types.is_datetime64_any_dtype(times['solar_noon']) assert times['solar_noon'].iloc[0].strftime( "%Y-%m-%dT%H:%M:%SZ") == testTimes['solar_noon']
def test_get_times_for_high_latitudes(): """getTimes may fail (maybe only on Windows?) for high latitudes in the summer See https://github.com/kylebarron/suncalc-py/issues/4 """ date = datetime(2020, 5, 26, 0, 0, 0) lng = -114.0719 lat = 51.0447 # Make sure this doesn't raise an exception (though it will emit a warning # due to a division error) times = get_times(date, lng, lat)
def test_get_times_datetime_single(): times = get_times(date, lng, lat) # This is true because pd.Timestamp is an instance of datetime.datetime assert isinstance(times['solar_noon'], datetime)
def test_get_times_pandas_single(): times = get_times(date, lng, lat) assert isinstance(times['solar_noon'], pd.Timestamp)
def test_get_times_height(): """getTimes adjusts sun phases when additionally given the observer height """ times = get_times(date, lng, lat, height) for key, value in heightTestTimes.items(): assert times[key].strftime("%Y-%m-%dT%H:%M:%SZ") == value
def test_get_times(): """getTimes returns sun phases for the given date and location """ times = get_times(date, lng, lat) for key, value in testTimes.items(): assert times[key].strftime("%Y-%m-%dT%H:%M:%SZ") == value