Spaces:
Running
Running
File size: 1,536 Bytes
1eb327d 3837815 1eb327d 3837815 1eb327d 3837815 1eb327d 3837815 1eb327d 3837815 1eb327d 3837815 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import pytest
import pandas as pd
import numpy as np
def test_basic():
assert 1 + 1 == 2
def test_sample_data_shape():
dates = pd.date_range(start="2021-01-01", end="2023-12-31", freq="D")
df = pd.DataFrame({"ds": dates, "y": np.random.rand(len(dates)) * 100})
assert "ds" in df.columns
assert "y" in df.columns
assert len(df) > 0
def test_data_types():
dates = pd.date_range(start="2022-01-01", periods=100, freq="D")
df = pd.DataFrame({"ds": dates, "y": np.random.rand(100) * 100})
assert pd.api.types.is_datetime64_any_dtype(df['ds'])
assert pd.api.types.is_numeric_dtype(df['y'])
def test_no_nulls():
dates = pd.date_range(start="2022-01-01", periods=100, freq="D")
df = pd.DataFrame({"ds": dates, "y": np.random.rand(100) * 100})
assert df['ds'].isnull().sum() == 0
assert df['y'].isnull().sum() == 0
def test_positive_demand():
y = np.random.rand(365) * 100 + 50
assert all(y > 0)
def test_prophet_import():
try:
from prophet import Prophet
assert Prophet is not None
except Exception:
pytest.skip("Prophet backend not available in CI")
def test_prophet_trains():
try:
from prophet import Prophet
dates = pd.date_range(start="2022-01-01", periods=365, freq="D")
df = pd.DataFrame({"ds": dates, "y": np.random.rand(365) * 100 + 50})
model = Prophet()
model.fit(df)
assert model is not None
except Exception:
pytest.skip("Prophet Stan backend not available in CI")
|