예제 #1
0
 def aligned_with(date_str, freq):
     return str(ProcessStartField.process(date_str, freq=freq))
    AddInterDemandPeriodFeature, )

FREQ = "1D"

INTER_DEMAND_TEST_VALUES = {
    "is_train": [True, False],
    "target": [
        (np.zeros(0), np.array([])),
        (np.zeros(13), np.array([1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])),
        (
            np.array([1, 1, 0, 0, 0, 4, 0, 0, 0, 8]),
            np.array([1, 1, 1, 2, 3, 4, 1, 2, 3, 4]),
        ),
    ],
    "start": [
        ProcessStartField.process("2012-01-02", freq="1D"),
    ],
}

ZERO_DEMAND_TEST_VALUES = {
    "is_train": [True, False],
    "target": [
        (np.zeros(0), np.array([])),
        (np.zeros(13), np.array([])),
        (
            np.array([1, 1, 0, 0, 0, 4, 0, 0, 0, 8]),
            np.array([1, 1, 4, 8]),
        ),
    ],
    "start": [
        ProcessStartField.process("2012-01-02", freq="1D"),
예제 #3
0
# First-party imports
import gluonts
from gluonts import time_feature, transform
from gluonts.core import fqname_for
from gluonts.core.serde import dump_code, dump_json, load_code, load_json
from gluonts.dataset.common import ProcessStartField
from gluonts.dataset.stat import ScaleHistogram, calculate_dataset_statistics

FREQ = "1D"

TEST_VALUES = {
    "is_train": [True, False],
    "target": [np.zeros(0), np.random.rand(13), np.random.rand(100)],
    "start": [
        ProcessStartField.process("2012-01-02", freq="1D"),
        ProcessStartField.process("1994-02-19 20:01:02", freq="3D"),
    ],
    "use_prediction_features": [True, False],
    "allow_target_padding": [True, False],
}


def test_align_timestamp():
    def aligned_with(date_str, freq):
        return str(ProcessStartField.process(date_str, freq=freq))

    for _ in range(2):
        assert (
            aligned_with("2012-03-05 09:13:12", "min") == "2012-03-05 09:13:00"
        )
예제 #4
0
# First-party imports
import gluonts
from gluonts import time_feature, transform
from gluonts.core import fqname_for
from gluonts.core.serde import dump_code, dump_json, load_code, load_json
from gluonts.dataset.common import ProcessStartField
from gluonts.dataset.stat import ScaleHistogram, calculate_dataset_statistics

FREQ = '1D'

TEST_VALUES = {
    'is_train': [True, False],
    'target': [np.zeros(0), np.random.rand(13), np.random.rand(100)],
    'start': [
        ProcessStartField.process('2012-01-02', freq='1D'),
        ProcessStartField.process('1994-02-19 20:01:02', freq='3D'),
    ],
    'use_prediction_features': [True, False],
    'allow_target_padding': [True, False],
}


def test_align_timestamp():
    def aligned_with(date_str, freq):
        return str(ProcessStartField.process(date_str, freq=freq))

    for _ in range(2):
        assert (
            aligned_with('2012-03-05 09:13:12', 'min') == '2012-03-05 09:13:00'
        )