Skip to content
Snippets Groups Projects

Resolve "Running example configs with multiple invocations leads to non-deterministic results"

9 files
+ 110
13
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -10,11 +10,13 @@
import query_executor
from io import StringIO
from pandas import DataFrame as pd
import pytest
csv_test_data = """
Timestep, 00:some, 00:other, 01:some, 01:other
0, 1, 2, 3, 4
1, 5, 6, 7, 8
Timestep, 00:some, 00:other, 01:some, 01:other, 01:other2
0, 1, 2, 3, 4, 8
1, 5, 6, 7, 8, 9
"""
csv_test_data_despawned_agent = """
@@ -35,3 +37,21 @@ def test_query_executor_parses_csv_with_despawned_agents():
csv = StringIO(csv_test_data_despawned_agent)
df = query_executor.prepare_output(csv)
assert(len(df) == 6)
def test_query_executor_obeys_datatypes():
explicit_types = { "other": "string", "other2": "float" }
expected_types = pd.from_dict({"some": [1], "other": ['2'], "other2": [3.0]}).astype({"other": "string"})
csv = StringIO(csv_test_data)
df = query_executor.prepare_output(csv, explicit_types)
assert((df.dtypes[["some", "other", "other2"]] == expected_types.dtypes[["some", "other", "other2"]]).all())
def test_query_executor_ignores_unknown_columns():
explicit_types = { "unknown": "string"}
csv = StringIO(csv_test_data)
try:
df = query_executor.prepare_output(csv, explicit_types)
except KeyError:
pytest.fail("Unknown column not ignored during datatype conversion")
\ No newline at end of file
Loading