ourownstory / neural_prophet

NeuralProphet: A simple forecasting package
https://neuralprophet.com
MIT License
3.89k stars 480 forks source link

[Bug] Test holidays for multiple countries is failing for Pytest 3.12 #1599

Open MaiBe-ctrl opened 4 months ago

MaiBe-ctrl commented 4 months ago

Prerequisites Python 3.12

Describe the bug We are getting the following error in our pipeline test: FAILED tests/test_event_utils.py::test_multiple_countries - AssertionError: assert 'Erster Weihnachtstag' not in {'Christi Himmelfahrt', 'Christi Himmelfahrt; Erster Mai', 'Christmas Day', 'Columbus Day', 'Erster Mai', 'Erster Weihnachtstag', ...} This is mainly due to the fact that we are getting the holidays names for the US in English and the ones for Germany in German. As a result, we would have duplicated holidays having names in different languages.

Expected behavior We would expect at the end to get a unique list of holidays(no matter what the language is). The assertion shouldn't fail.

Additional context

This only happens for the specific case of python 3.12. We tried solving this issue by creating a holiday name as a combination of both its occurrences and make sure to have at the end the holiday appearing only one time in the list.

We should find a cleaner way to do it without adding more complexity to the code.

Add any other context about the problem here.

Pytest to re-add to tests/test_event_utils.py

def test_multiple_countries():
    # test if multiple countries are added
    df = pd.read_csv(PEYTON_FILE, nrows=NROWS)
    m = NeuralProphet(
        epochs=EPOCHS,
        batch_size=BATCH_SIZE,
        learning_rate=LR,
    )
    m.add_country_holidays(country_name=["US", "Germany"])
    m.fit(df, freq="D")
    m.predict(df)
    # get the name of holidays and compare that no holiday is repeated
    holiday_names = m.model.config_holidays.holiday_names
    assert "Independence Day" in holiday_names
    assert "Christmas Day" in holiday_names
    assert "Erster Weihnachtstag" not in holiday_names
    assert "Neujahr" not in holiday_names