Skip to content

Commit

Permalink
Revert upstream merge
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagnoux committed Jun 12, 2017
1 parent 26ba165 commit 7438073
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 77 deletions.
18 changes: 0 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@
- Change `ETERNITY` period effect
- Remove restriction that prevented formula changes over time for a variable with `definition_period = ETERNITY`.

## 13.0.1 - [#526](https://github.com/openfisca/openfisca-core/pull/526)

### Bug fix

* Require numpy < 1.13.
- Openfisca is not yet compatible with the new numpy version 1.13.

## 13.0.0

#### Breaking changes

* Disallow text out of tags in XML parameters
- This prevents to add "comments" that would be lost by automated transformation of these parameters.

#### New features

* Introduce a "reference" attribute to document a source in XML parameters

## 12.3.0

* Serve the [OpenAPI specification](https://www.openapis.org/) under the API route `/spec/`
Expand Down
19 changes: 8 additions & 11 deletions openfisca_core/legislation.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</xs:sequence>
</xs:group>

<xs:complexType name="nodeType">
<xs:complexType name="nodeType" mixed="true">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="NODE" type="nodeType"/>
Expand All @@ -24,18 +24,16 @@
<xs:attribute name="code" type="xs:string" use="required"/>
<xs:attribute name="description" type="xs:string"/>
<xs:attribute name="origin" type="xs:string"/>
<xs:attribute name="reference" type="xs:string"/>
</xs:complexType>

<xs:complexType name="codeType">
<xs:complexType name="codeType" mixed="true">
<xs:group ref="valuesHistory"/>
<xs:attribute name="code" type="xs:string" use="required"/>
<xs:attribute name="description" type="xs:string"/>
<xs:attribute name="format" type="xs:string"/>
<xs:attribute name="origin" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="conflicts" type="xs:string"/>
<xs:attribute name="reference" type="xs:string"/>
</xs:complexType>

<xs:complexType name="endType">
Expand All @@ -47,7 +45,7 @@
<xs:attribute name="valeur" type="xs:float" use="required"/>
</xs:complexType>

<xs:complexType name="baremeType">
<xs:complexType name="baremeType" mixed="true">
<xs:sequence>
<xs:element name="TRANCHE" type="trancheType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
Expand All @@ -57,7 +55,6 @@
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="conflicts" type="xs:string"/>
<xs:attribute name="option" type="xs:string"/>
<xs:attribute name="reference" type="xs:string"/>
</xs:complexType>

<xs:complexType name="trancheType">
Expand All @@ -70,24 +67,24 @@
<xs:attribute name="code" type="xs:string"/>
</xs:complexType>

<xs:complexType name="assietteType">
<xs:complexType name="assietteType" mixed="true">
<xs:group ref="valuesHistory"/>
</xs:complexType>

<xs:complexType name="tauxType">
<xs:complexType name="tauxType" mixed="true">
<xs:group ref="valuesHistory"/>
</xs:complexType>

<xs:complexType name="montantType">
<xs:complexType name="montantType" mixed="true">
<xs:group ref="valuesHistory"/>
</xs:complexType>

<xs:complexType name="seuilType">
<xs:complexType name="seuilType" mixed="true">
<xs:group ref="valuesHistory"/>
<xs:attribute name="conflicts" type="xs:string"/>
</xs:complexType>

<xs:complexType name="placeholderType">
<xs:complexType name="placeholderType" mixed="true">
<xs:attribute name="deb" type="xs:date" use="required"/>
</xs:complexType>

Expand Down
24 changes: 12 additions & 12 deletions openfisca_core/legislations.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ def validate_dated_node_json(node, state = None):
conv.test_in((u'Node', u'Parameter', u'Scale')),
conv.not_none,
),
'reference': conv.pipe(
'comment': conv.pipe(
conv.test_isinstance(basestring),
conv.cleanup_line,
conv.cleanup_text,
),
'description': conv.pipe(
conv.test_isinstance(basestring),
Expand Down Expand Up @@ -460,8 +460,8 @@ def validate_dated_node_json(node, state = None):
validated_node.pop('@context', None) # Remove optional @context everywhere. It will be added to root node later.
node_converters = {
'@type': conv.noop,
'comment': conv.noop,
'description': conv.noop,
'reference': conv.noop,
'end_line_number': conv.test_isinstance(int),
'start_line_number': conv.test_isinstance(int),
# baremes-ipp related attributes
Expand Down Expand Up @@ -570,9 +570,9 @@ def validate_dated_bracket_json(bracket, state = None):
conv.test_greater_or_equal(0),
),
),
reference = conv.pipe(
comment = conv.pipe(
conv.test_isinstance(basestring),
conv.cleanup_line,
conv.cleanup_text,
),
end_line_number = conv.test_isinstance(int),
rate = conv.item_or_sequence(
Expand Down Expand Up @@ -679,9 +679,9 @@ def validate_node_json(node, state = None):
conv.test_in((u'Node', u'Parameter', u'Scale')),
conv.not_none,
),
'reference': conv.pipe(
'comment': conv.pipe(
conv.test_isinstance(basestring),
conv.cleanup_line,
conv.cleanup_text,
),
'description': conv.pipe(
conv.test_isinstance(basestring),
Expand Down Expand Up @@ -712,7 +712,7 @@ def validate_node_json(node, state = None):
validated_node.pop('@context', None) # Remove optional @context everywhere. It will be added to root node later.
node_converters = {
'@type': conv.noop,
'reference': conv.noop,
'comment': conv.noop,
'description': conv.noop,
'end_line_number': conv.noop,
'start_line_number': conv.noop,
Expand Down Expand Up @@ -827,9 +827,9 @@ def validate_bracket_json(bracket, state = None):
dict(
amount = validate_values_holder_json,
base = validate_values_holder_json,
reference = conv.pipe(
comment = conv.pipe(
conv.test_isinstance(basestring),
conv.cleanup_line,
conv.cleanup_text,
),
end_line_number = conv.test_isinstance(int),
rate = validate_values_holder_json,
Expand Down Expand Up @@ -910,9 +910,9 @@ def validate_value_json(value, state = None):
conv.test_isinstance(dict),
conv.struct(
{
u'reference': conv.pipe(
u'comment': conv.pipe(
conv.test_isinstance(basestring),
conv.cleanup_line,
conv.cleanup_text,
),
u'end_line_number': conv.test_isinstance(int),
u'start': conv.pipe(
Expand Down
10 changes: 5 additions & 5 deletions openfisca_core/legislationsxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def transform_etree_to_json_recursive(xml_node):
json_node['unit'] = json_unit_by_xml_json_type.get(value)
elif key == 'conflicts':
json_node['conflicts'] = value.split(',')
elif key in {'description', 'origin', 'option', 'reference'}:
elif key in {'description', 'origin', 'option'}:
json_node[key] = value
else:
raise ValueError(u'Unknown attribute "{}": "{}"'.format(key, value).encode('utf-8'))
raise ValueError('Unknown attribute "{}": "{}"'.format(key, value).encode('utf-8'))

if xml_node.tag == 'NODE':
json_node['@type'] = 'Node'
Expand Down Expand Up @@ -131,7 +131,7 @@ def transform_etree_to_json_recursive(xml_node):
elif child.tag == 'MONTANT':
json_node['amount'] = new_child
else:
raise ValueError(u'Unknown TRANCHE child {}'.format(child.tag).encode('utf-8'))
raise ValueError('Unknown TRANCHE child {}'.format(child.tag).encode('utf-8'))

elif xml_node.tag == 'TAUX':
json_node = transform_values_history(xml_node, value_format)
Expand All @@ -149,7 +149,7 @@ def transform_etree_to_json_recursive(xml_node):
pass

else:
raise ValueError(u'Unknown tag {}'.format(xml_node.tag).encode('utf-8'))
raise ValueError('Unknown tag {}'.format(xml_node.tag).encode('utf-8'))

return name, json_node

Expand Down Expand Up @@ -181,7 +181,7 @@ def merge(name_list, json_list, path_list):
'children': {},
}

assert name not in pointer['children'], u'{} is defined twice'.format('.'.join(path) + '.' + 'name').encode('utf-8')
assert name not in pointer['children'], '{} is defined twice'.format('.'.join(path) + '.' + 'name').encode('utf-8')
pointer['children'][name] = json_tree

return merged_json
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
include_package_data = True, # Will read MANIFEST.in
install_requires = [
'Biryani[datetimeconv] >= 0.10.4',
'numpy >= 1.11, < 1.13',
'numpy >= 1.11',
'PyYAML >= 3.10',
'flask == 0.12',
'flask-cors == 3.0.2',
Expand Down
8 changes: 0 additions & 8 deletions tests/core/parameter_validation/free_text.xml

This file was deleted.

30 changes: 8 additions & 22 deletions tests/core/parameter_validation/test_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,15 @@ def __init__(self, path_to_xml):
@raises(XMLSyntaxError)
def test_malformed():
path_to_xml = os.path.join(BASE_DIR, 'malformed.xml')
tbs = TestTaxBenefitSystem(path_to_xml)
tbs.compute_legislation()


def test_free_text():
path_to_xml = os.path.join(BASE_DIR, 'free_text.xml')
tbs = TestTaxBenefitSystem(path_to_xml)
try:
tbs.compute_legislation()
except ValueError as e:
content = str(e)
assert len(content) < 1000
for keyword in {'free_text.xml:3', 'content', 'not allowed', 'element-only'}:
assert keyword in content
else:
assert False, "This test should raise a ValueError."
tbf = TestTaxBenefitSystem(path_to_xml)
tbf.compute_legislation()


def test_unknown_node():
path_to_xml = os.path.join(BASE_DIR, 'unknown_node.xml')
tbs = TestTaxBenefitSystem(path_to_xml)
tbf = TestTaxBenefitSystem(path_to_xml)
try:
tbs.compute_legislation()
tbf.compute_legislation()
except ValueError as e:
content = str(e)
assert len(content) < 1000
Expand All @@ -57,9 +43,9 @@ def test_unknown_node():

def test_wrong_value():
path_to_xml = os.path.join(BASE_DIR, 'wrong_value.xml')
tbs = TestTaxBenefitSystem(path_to_xml)
tbf = TestTaxBenefitSystem(path_to_xml)
try:
tbs.compute_legislation()
tbf.compute_legislation()
except ValueError as e:
content = str(e)
assert len(content) < 1000
Expand All @@ -71,9 +57,9 @@ def test_wrong_value():

def test_wrong_bareme():
path_to_xml = os.path.join(BASE_DIR, 'wrong_bareme.xml')
tbs = TestTaxBenefitSystem(path_to_xml)
tbf = TestTaxBenefitSystem(path_to_xml)
try:
tbs.compute_legislation()
tbf.compute_legislation()
except ValueError as e:
content = str(e)
assert len(content) < 1000
Expand Down

0 comments on commit 7438073

Please sign in to comment.