def test_dates_to_index_monthly(): dates = [date(2000, 1, 1), date(2000, 2, 27), date(2014, 1, 22), date(1999, 12, 1), date(1998, 2, 15)] index = mu.dates_to_index_monthly(dates) print index assert (index == np.array([0, 1, 12 * 14, -1, -23])).all()
def l1_fit_monthly(dates, y, **kwargs): #wrapper that allows an numpy array of dates #that will be converted to an index #defined as months since Jan 2000. days are ignored xx = mu.dates_to_index_monthly(dates) return l1_fit(xx, y, **kwargs)