Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Remove unneeded logs #1207

Merged
merged 2 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[pytest]
log_cli = true
log_cli_level = DEBUG
log_cli_format = %(asctime)s [%(levelname)s, %(name)s.%(funcName)s]: %(message)s (%(filename)s:%(lineno)s)
log_cli_format = %(asctime)s [%(levelname)s]: %(message)s (%(filename)s:%(lineno)s)
log_cli_date_format = %Y-%m-%d %H:%M:%S
capture = no
filterwarnings =
ignore::DeprecationWarning:tensorboard.*
ignore::pytorch_lightning.utilities.warnings.PossibleUserWarning
Expand Down
22 changes: 2 additions & 20 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ def test_df_utils_func():
global_data_params = df_utils.init_data_params(df_global, normalize="soft1")
global_data_params = df_utils.init_data_params(df_global, normalize="standardize")

log.debug(f"Time Threshold: \n {time_threshold}")
log.debug(f"Df_train: \n {df_train}")
log.debug(f"Df_val: \n {df_val}")


def test_trend():
log.info("testing: Trend")
Expand Down Expand Up @@ -134,9 +130,6 @@ def test_custom_changepoints():
dates = df["ds"][range(1, len(df) - 1, int(len(df) / 5.0))]
dates_list = [str(d) for d in dates]
dates_array = pd.to_datetime(dates_list).values
log.debug(f"dates: {dates}")
log.debug(f"dates_list: {dates_list}")
log.debug(f"dates_array: {dates_array.dtype} {dates_array}")
for cp in [dates_list, dates_array]:
m = NeuralProphet(
changepoints=cp,
Expand Down Expand Up @@ -209,6 +202,7 @@ def test_no_trend():
def test_seasons():
log.info("testing: Seasonality: additive")
df = pd.read_csv(PEYTON_FILE, nrows=NROWS)
# Additive
m = NeuralProphet(
yearly_seasonality=8,
weekly_seasonality=4,
Expand All @@ -221,22 +215,14 @@ def test_seasons():
metrics_df = m.fit(df, freq="D")
future = m.make_future_dataframe(df, n_historic_predictions=365, periods=365)
forecast = m.predict(df=future)
log.debug(
"SUM of yearly season params: {}".format(sum(abs(m.model.seasonality.season_params["yearly"].data.numpy())))
)
log.debug(
"SUM of weekly season params: {}".format(sum(abs(m.model.seasonality.season_params["weekly"].data.numpy())))
)
log.debug(f"season params: {m.model.seasonality.season_params.items()}")
if PLOT:
m.plot(forecast)
# m.plot_components(forecast)
m.plot_parameters()
plt.show()
log.info("testing: Seasonality: multiplicative")
df = pd.read_csv(PEYTON_FILE, nrows=NROWS)
# m = NeuralProphet(n_lags=60, n_changepoints=10, n_forecasts=30, verbose=True,
# epochs=EPOCHS, batch_size=BATCH_SIZE, learning_rate=LR,)
# Multiplicative
m = NeuralProphet(
yearly_seasonality=8,
weekly_seasonality=4,
Expand Down Expand Up @@ -276,13 +262,11 @@ def test_custom_seasons():
m.add_seasonality(name="weekend", period=1, fourier_order=3, condition_name="weekend")
m.add_seasonality(name="weekday", period=1, fourier_order=3, condition_name="weekday")

log.debug(f"seasonalities: {m.config_seasonality.periods}")
metrics_df = m.fit(df, freq="D")
future = m.make_future_dataframe(df, n_historic_predictions=365, periods=365)
future = df_utils.add_quarter_condition(future)
future = df_utils.add_weekday_condition(future)
forecast = m.predict(df=future)
log.debug(f"season params: {m.model.seasonality.season_params.items()}")
if PLOT:
m.plot(forecast)
# m.plot_components(forecast)
Expand Down Expand Up @@ -565,8 +549,6 @@ def test_random_seed():
future = m.make_future_dataframe(df, periods=10, n_historic_predictions=10)
forecast = m.predict(future)
checksum3 = sum(forecast["yhat1"].values)
log.debug(f"should be same: {checksum1} and {checksum2}")
log.debug(f"should not be same: {checksum1} and {checksum3}")
assert math.isclose(checksum1, checksum2)
assert not math.isclose(checksum1, checksum3)

Expand Down
39 changes: 3 additions & 36 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def test_auto_batch_epoch():
"10000000": (512, 18),
}

observe = {}
for n_data, (batch_size, epochs) in check.items():
n_data = int(n_data)
c = configure.Train(
Expand All @@ -204,14 +203,8 @@ def test_auto_batch_epoch():
optimizer="SGD",
)
c.set_auto_batch_epoch(n_data=n_data)
observe[f"{n_data}"] = (c.batch_size, c.epochs)
log.debug(f"[config] n_data: {n_data}, batch: {c.batch_size}, epoch: {c.epochs}")
log.debug(f"[should] n_data: {n_data}, batch: {batch_size}, epoch: {epochs}")
assert c.batch_size == batch_size
assert c.epochs == epochs
# print("\n")
# print(check)
# print(observe)


def test_split_impute():
Expand Down Expand Up @@ -278,14 +271,6 @@ def check_folds(df, n_lags, n_forecasts, valid_fold_num, valid_fold_pct, fold_ov
for i in range(valid_fold_num)
]
assert all([x == y for (x, y) in zip(train_folds_samples, train_folds_should)])
log.debug(f"total_samples: {total_samples}")
log.debug(f"val_fold_each: {val_fold_each}")
log.debug(f"overlap_each: {overlap_each}")
log.debug(f"val_folds_len: {val_folds_len}")
log.debug(f"val_folds_samples: {val_folds_samples}")
log.debug(f"train_folds_len: {train_folds_len}")
log.debug(f"train_folds_samples: {train_folds_samples}")
log.debug(f"train_folds_should: {train_folds_should}")

len_df = 100
check_folds(
Expand Down Expand Up @@ -346,16 +331,6 @@ def check_folds_dict(
for i in range(valid_fold_num)
]
assert all([x == y for (x, y) in zip(train_folds_samples, train_folds_should)])
log.debug(f"global_model_cv_type: {global_model_cv_type}")
log.debug(f"df_name: {df_name}")
log.debug(f"total_samples: {total_samples}")
log.debug(f"val_fold_each: {val_fold_each}")
log.debug(f"overlap_each: {overlap_each}")
log.debug(f"val_folds_len: {val_folds_len}")
log.debug(f"val_folds_samples: {val_folds_samples}")
log.debug(f"train_folds_len: {train_folds_len}")
log.debug(f"train_folds_samples: {train_folds_samples}")
log.debug(f"train_folds_should: {train_folds_should}")
return folds

# Test cv for dict with time series with similar time range
Expand Down Expand Up @@ -474,7 +449,6 @@ def test_reg_delay():
(1, 8, 0),
]:
weight = c.get_reg_delay_weight(e, i, reg_start_pct=0.5, reg_full_pct=0.8)
log.debug(f"e {e}, i {i}, expected w {w}, got w {weight}")
assert weight == w


Expand Down Expand Up @@ -502,11 +476,7 @@ def test_double_crossvalidation():
assert train_folds_len2[0] == 85
assert val_folds_len1[0] == 10
assert val_folds_len2[0] == 5
log.debug(f"train_folds_len1: {train_folds_len1}")
log.debug(f"val_folds_len1: {val_folds_len1}")
log.debug(f"train_folds_len2: {train_folds_len2}")
log.debug(f"val_folds_len2: {val_folds_len2} ")
log.info(f"Test m.double_crossvalidation_split_df")

m = NeuralProphet(
epochs=EPOCHS,
batch_size=BATCH_SIZE,
Expand All @@ -533,11 +503,8 @@ def test_double_crossvalidation():
assert train_folds_len2[0] == 88
assert val_folds_len1[0] == 12
assert val_folds_len2[0] == 6
log.debug(f"train_folds_len1: {train_folds_len1}")
log.debug(f"val_folds_len1: {val_folds_len1}")
log.debug(f"train_folds_len2: {train_folds_len2}")
log.debug(f"val_folds_len2: {val_folds_len2}")
log.info("Raise not implemented error as double_crossvalidation is not compatible with many time series")

# Raise not implemented error as double_crossvalidation is not compatible with many time series
with pytest.raises(NotImplementedError):
df = pd.DataFrame({"ds": pd.date_range(start="2017-01-01", periods=len_df), "y": np.arange(len_df)})
df1 = df.copy(deep=True)
Expand Down