Skip to content

Commit

Permalink
Add test for NaN value handling during indexing
Browse files Browse the repository at this point in the history
Test for issue #525
  • Loading branch information
Kirill888 authored and mergify[bot] committed Aug 1, 2018
1 parent a266853 commit c89a704
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions integration_tests/test_dataset_add.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import yaml
import toolz

Expand Down Expand Up @@ -305,6 +306,45 @@ def test_dataset_add_ambgious_products(dataset_add_configs, index_empty, clirunn
assert index.datasets.has(ds.id) is True


def test_dataset_add_with_nans(dataset_add_configs, index_empty, clirunner):
p = dataset_add_configs
index = index_empty

clirunner(['metadata_type', 'add', p.metadata])
clirunner(['product', 'add', p.products])

mk = dataset_maker(0)

c = mk('C', product_type='C',
val_is_nan=math.nan,
val_is_inf=math.inf,
val_is_neginf=-math.inf)

b = mk('B', sources={'bc': c}, product_type='B')
a = mk('A', sources={'ac': c}, product_type='A')

prefix = write_files({
'dataset.yml': yaml.safe_dump_all([a, b]),
})

r = clirunner(['dataset', 'add',
'--auto-add-lineage',
'--verify-lineage',
str(prefix/'dataset.yml')])

assert "ERROR" not in r.output

a, b, c = [SimpleDocNav(v) for v in (a, b, c)]

assert index.datasets.bulk_has([a.id, b.id, c.id]) == [True, True, True]

c_doc = index.datasets.get(c.id).metadata_doc

assert c_doc['val_is_nan'] == 'NaN'
assert c_doc['val_is_inf'] == 'Infinity'
assert c_doc['val_is_neginf'] == '-Infinity'


def test_dataset_add_inconsistent_measurements(dataset_add_configs, index_empty, clirunner):
p = dataset_add_configs
index = index_empty
Expand Down

0 comments on commit c89a704

Please sign in to comment.