def test_get_doy_sequence_datetime(): time = (datetime(2000, 1, 1), datetime(2001, 1, 1)) doy = day_of_year(time) assert np.array_equal(doy, [1, 1]) doy = day_of_year(list(time)) assert np.array_equal(doy, [1, 1])
def test_day_of_year_with_time(): """Operate in days even if time (H:M:S) are given """ doy = day_of_year("2000-01-01T00:00:00") assert doy == 1 doy = day_of_year(["2000-01-01T00:00:00", "2000-01-02T00:00:00"]) assert np.array_equal(doy, [1, 2])
def test_get_doy_sequence_datetime64(): time = (np.datetime64("2000-01-01"), np.datetime64("2001-01-01")) doy = day_of_year(time) assert np.array_equal(doy, [1, 1]) doy = day_of_year(list(time)) assert np.array_equal(doy, [1, 1]) doy = day_of_year(np.array(time)) assert np.array_equal(doy, [1, 1])
def test_get_doy_single_datetime64(): doy = day_of_year(np.datetime64("2000-01-01")) assert doy == 1
def test_get_doy_single_datetime(): doy = day_of_year(datetime(2000, 1, 1)) assert doy == 1