How to use the eemeter.config.yaml_parser.load function in eemeter

To help you get started, we’ve selected a few eemeter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openeemeter / eemeter / tests / test_meter_base.py View on Github external
def test_dummy_meter_output_duplication_list(data_collection):
    meter_yaml = """
        !obj:eemeter.meter.DummyMeter {
            input_mapping: { "value": { "name":"name", }, },
            output_mapping: {
                "result": [
                    { "name":"result1", },
                    { "name":"result2", },
                ]
            },
        }
    """

    meter = load(meter_yaml)
    result = meter.evaluate(data_collection)

    assert result.get_data(name="result1").value == "value"
    assert result.get_data(name="result2").value == "value"
    assert result.get_data(name="name") == None
github openeemeter / eemeter / tests / test_meter_control.py View on Github external
meter_yaml="""
        !obj:eemeter.meter.Condition {
            condition: {
                "name": "electricity_present"
            },
            success: !obj:eemeter.meter.DummyMeter {
                input_mapping: {"value": {"name": "success"}},
                output_mapping: {"result": {}},
            },
            failure: !obj:eemeter.meter.DummyMeter {
                input_mapping: {"value": {"name": "failure"}},
                output_mapping: {"result": {}},
            },
        }
        """
    meter = load(meter_yaml)

    data_collection = DataCollection(electricity_present=True,
            success="success", failure="failure")
    assert meter.evaluate(data_collection).get_data("result").value == "success"
    data_collection = DataCollection(electricity_present=False,
            success="success", failure="failure")
    assert meter.evaluate(data_collection).get_data("result").value == "failure"
github openeemeter / eemeter / tests / test_meter_control.py View on Github external
def test_tag_filter():
    meter_yaml = """
        !obj:eemeter.meter.TagFilter {
            meter: !obj:eemeter.meter.DummyMeter {
                input_mapping: { value: {} },
                output_mapping: { result: {} },
            }
        }
    """

    meter = load(meter_yaml)
    data_collection = DataCollection()

    with pytest.raises(NotImplementedError):
        meter.evaluate(data_collection)
github openeemeter / eemeter / tests / test_meter_components.py View on Github external
def test_sequential_meter():
    meter_yaml = """
        !obj:eemeter.meter.Sequence {
            sequence: [
                !obj:eemeter.meter.DummyMeter {},
            ]
        }"""

    meter = load(meter_yaml)

    result = meter.evaluate(value=10)

    assert result["result"] == 10
github openeemeter / eemeter / tests / test_meter_components.py View on Github external
def test_conditional_meter():
    meter_yaml="""
        !obj:eemeter.meter.Condition {
            condition_parameter: "electricity_present",
            success: !obj:eemeter.meter.DummyMeter {
                input_mapping: {"success":"value"},
            },
            failure: !obj:eemeter.meter.DummyMeter {
                input_mapping: {"failure":"value"},
            },
        }
        """
    meter = load(meter_yaml)
    assert meter.evaluate(electricity_present=True,success="success",failure="failure")["result"] == "success"
    assert meter.evaluate(electricity_present=False,success="success",failure="failure")["result"] == "failure"
github openeemeter / eemeter / tests / test_meter_fitness.py View on Github external
def test_cvrmse():
    meter_yaml = """
        !obj:eemeter.meter.CVRMSE {
            input_mapping: { "y": {}, "y_hat": {}, "params": {}},
            output_mapping: { "cvrmse": {}}
        }
    """
    meter = load(meter_yaml)

    data_collection = DataCollection(
            y=np.array([12,13,414,12,23,12,32,np.nan]),
            y_hat=np.array([32,12,322,21,22,41,32,np.nan]),
            params=BaseloadHeatingModelParameterType([1,3,4]))
    result = meter.evaluate(data_collection)

    assert_allclose(result.get_data("cvrmse").value, 59.79,
            rtol=RTOL, atol=ATOL)
github openeemeter / eemeter / tests / test_meter_helpers.py View on Github external
def test_estimated_reading_consolidation_meter_single_fuel_type(consumption_data):

    meter_yaml = """
        !obj:eemeter.meter.EstimatedReadingConsolidationMeter {
            input_mapping: {"consumption_data": {}},
            output_mapping: {"consumption_data_no_estimated": {}},
        }
    """
    meter = load(meter_yaml)
    data_collection = DataCollection(consumption_data=consumption_data)
    result = meter.evaluate(data_collection)
    values = result.get_data("consumption_data_no_estimated").value.data.values

    assert_allclose(values, np.array([0, 0, 0, np.nan]), rtol=RTOL, atol=ATOL)
github openeemeter / eemeter / tests / test_meter_library.py View on Github external
},
            },
            input_mapping: {
                "consumption_data": {},
                "weather_source": {},
                "energy_unit_str": {},
            },
            output_mapping: {
                "temp_sensitivity_params": {},
                "n_days": {},
                "average_daily_usages": {},
                "estimated_average_daily_usages": {},
            },
        }
        """
    meter = load(meter_yaml)

    cd, params = generated_consumption_data_1

    data_collection = DataCollection(
            consumption_data=cd,
            weather_source=gsod_722880_2012_2014_weather_source,
            energy_unit_str="kWh")

    result = meter.evaluate(data_collection)

    assert_allclose(result.get_data('temp_sensitivity_params').value.to_list(), params.to_list(),
            rtol=RTOL, atol=ATOL)
    assert result.get_data('n_days') is not None
    assert result.get_data('average_daily_usages') is not None
    assert result.get_data('estimated_average_daily_usages') is not None
github openeemeter / eemeter / tests / test_meter_structure.py View on Github external
def test_sequential_meter():
    meter_yaml = """
        !obj:eemeter.meter.SequentialMeter {
            sequence: [
                !obj:eemeter.meter.DummyMeter {},
            ]
        }"""

    meter = load(meter_yaml)

    result = meter.evaluate(value=10)

    assert result["result"] == 10
github openeemeter / eemeter / tests / test_yaml_parser.py View on Github external
def test_obj():
    loaded1 = load("a: !obj:decimal.Decimal { value : '1.23' }")
    assert isinstance(loaded1['a'], Decimal)