예제 #1
0
def test_inhomogenous_3():
    parameters = ParameterNode(directory_path=LOCAL_DIR)
    parameters.rate.couple.tenant.add_child(
        'z4',
        ParameterNode('toto',
                      data={
                          'amount': {
                              'values': {
                                  "2015-01-01": {
                                      'value': 550
                                  },
                                  "2016-01-01": {
                                      'value': 600
                                  }
                              }
                          }
                      }))

    P = parameters.rate('2015-01-01')
    zone = np.asarray(['z1', 'z2', 'z2', 'z1'])
    try:
        P.couple.tenant[zone]
    except ValueError as e:
        assert_in("'rate.couple.tenant.z4' is a node", e.message)
        assert_in("'rate.couple.tenant.z2' is not", e.message)
        raise
예제 #2
0
def test_inhomogenous_3():
    parameters = ParameterNode(directory_path=LOCAL_DIR)
    parameters.rate.couple.tenant.add_child(
        'z4',
        ParameterNode('toto',
                      data={
                          'amount': {
                              'values': {
                                  "2015-01-01": {
                                      'value': 550
                                  },
                                  "2016-01-01": {
                                      'value': 600
                                  }
                              }
                          }
                      }))

    P = parameters.rate('2015-01-01')
    zone = np.asarray(['z1', 'z2', 'z2', 'z1'])
    with pytest.raises(ValueError) as e:
        P.couple.tenant[zone]
    assert "'rate.couple.tenant.z4' is a node" in get_message(e.value)
    assert re.findall(r"'rate.couple.tenant.z(1|2|3)' is not",
                      get_message(e.value))
def test_inhomogenous_2():
    parameters = ParameterNode(directory_path = LOCAL_DIR)
    parameters.rate.couple.tenant.add_child('toto', Parameter('toto', {
        "values": {
            "2015-01-01": {
                "value": 1000
                },
            }
        }))

    P = parameters.rate('2015-01-01')
    housing_occupancy_status = np.asarray(['owner', 'owner', 'tenant', 'tenant'])
    with pytest.raises(ValueError) as e:
        P.couple[housing_occupancy_status]
    assert "'rate.couple.tenant.toto' exists" in get_message(e.value)
    assert "'rate.couple.owner.toto' doesn't" in get_message(e.value)
예제 #4
0
def test_inhomogenous_2():
    parameters = ParameterNode(directory_path=LOCAL_DIR)
    parameters.rate.couple.tenant.add_child(
        'toto', Parameter('toto',
                          {"values": {
                              "2015-01-01": {
                                  "value": 1000
                              },
                          }}))

    P = parameters.rate('2015-01-01')
    housing_occupancy_status = np.asarray(
        ['owner', 'owner', 'tenant', 'tenant'])
    with pytest.raises(ValueError) as e:
        P.couple[housing_occupancy_status]
    assert "'rate.couple.tenant.toto' exists" in get_message(e.value)
    assert "'rate.couple.owner.toto' doesn't" in get_message(e.value)
def test_inhomogenous_3():
    parameters = ParameterNode(directory_path = LOCAL_DIR)
    parameters.rate.couple.tenant.add_child('z4', ParameterNode('toto', data = {
        'amount': {
            'values': {
                "2015-01-01": {'value': 550},
                "2016-01-01": {'value': 600}
                }
            }
        }))

    P = parameters.rate('2015-01-01')
    zone = np.asarray(['z1', 'z2', 'z2', 'z1'])
    with pytest.raises(ValueError) as e:
        P.couple.tenant[zone]
    assert "'rate.couple.tenant.z4' is a node" in get_message(e.value)
    assert re.findall(r"'rate.couple.tenant.z(1|2|3)' is not", get_message(e.value))
예제 #6
0
def test_inhomogenous_2():
    parameters = ParameterNode(directory_path=LOCAL_DIR)
    parameters.rate.couple.tenant.add_child(
        'toto', Parameter('toto',
                          {"values": {
                              "2015-01-01": {
                                  "value": 1000
                              },
                          }}))

    P = parameters.rate('2015-01-01')
    housing_occupancy_status = np.asarray(
        ['owner', 'owner', 'tenant', 'tenant'])
    try:
        P.couple[housing_occupancy_status]
    except ValueError as e:
        assert_in("'rate.couple.tenant.toto' exists", e.message)
        assert_in("'rate.couple.owner.toto' doesn't", e.message)
        raise
예제 #7
0
import os
import re

import numpy as np
import pytest

from openfisca_core.tools import assert_near
from openfisca_core.parameters import ParameterNode, Parameter, ParameterNotFound
from openfisca_core.model_api import *  # noqa

LOCAL_DIR = os.path.dirname(os.path.abspath(__file__))

parameters = ParameterNode(directory_path=LOCAL_DIR)

P = parameters.rate('2015-01-01')


def get_message(error):
    return error.args[0]


def test_on_leaf():
    zone = np.asarray(['z1', 'z2', 'z2', 'z1'])
    assert_near(P.single.owner[zone], [100, 200, 200, 100])


def test_on_node():
    housing_occupancy_status = np.asarray(
        ['owner', 'owner', 'tenant', 'tenant'])
    node = P.single[housing_occupancy_status]
import os
import re

import numpy as np
import pytest


from openfisca_core.tools import assert_near
from openfisca_core.parameters import ParameterNode, Parameter, ParameterNotFound
from openfisca_core.model_api import *  # noqa

LOCAL_DIR = os.path.dirname(os.path.abspath(__file__))

parameters = ParameterNode(directory_path = LOCAL_DIR)

P = parameters.rate('2015-01-01')


def get_message(error):
    return error.args[0]


def test_on_leaf():
    zone = np.asarray(['z1', 'z2', 'z2', 'z1'])
    assert_near(P.single.owner[zone], [100, 200, 200, 100])


def test_on_node():
    housing_occupancy_status = np.asarray(['owner', 'owner', 'tenant', 'tenant'])
    node = P.single[housing_occupancy_status]
    assert_near(node.z1, [100, 100, 300, 300])