|
1 | 1 | """Test of a complicated set of interlocking data objects.""" |
2 | 2 | import json |
3 | 3 |
|
4 | | -from gemd.entity.object.ingredient_run import IngredientRun |
5 | | -from toolz import keymap, merge, keyfilter |
6 | | - |
7 | 4 | from gemd.json import dumps |
8 | 5 | from gemd.entity.attribute.condition import Condition |
9 | 6 | from gemd.entity.attribute.parameter import Parameter |
10 | 7 | from gemd.entity.attribute.property import Property |
11 | 8 | from gemd.entity.bounds.real_bounds import RealBounds |
12 | 9 | from gemd.entity.object import MeasurementRun, MaterialRun, ProcessRun, ProcessSpec,\ |
13 | | - MeasurementSpec, MaterialSpec |
| 10 | + MeasurementSpec, MaterialSpec, IngredientRun |
14 | 11 | from gemd.entity.template.condition_template import ConditionTemplate |
15 | 12 | from gemd.entity.template.material_template import MaterialTemplate |
16 | 13 | from gemd.entity.template.measurement_template import MeasurementTemplate |
|
45 | 42 |
|
46 | 43 | def make_data_island(density, bulk_modulus, firing_temperature, binders, powders, tag=None): |
47 | 44 | """Helper function to create a relatively involved data island.""" |
48 | | - binder_specs = keymap(lambda x: MaterialSpec(name=x), binders) |
49 | | - powder_specs = keymap(lambda x: MaterialSpec(name=x), powders) |
| 45 | + binder_specs = {MaterialSpec(name=k): v for k, v in binders.items()} |
| 46 | + powder_specs = {MaterialSpec(name=k): v for k, v in powders.items()} |
50 | 47 |
|
51 | | - binder_runs = keymap(lambda x: MaterialRun(name=x.name, spec=x), binder_specs) |
52 | | - powder_runs = keymap(lambda x: MaterialRun(name=x.name, spec=x), powder_specs) |
| 48 | + binder_runs = {MaterialRun(name=k.name, spec=k): v for k, v in binder_specs.items()} |
| 49 | + powder_runs = {MaterialRun(name=k.name, spec=k): v for k, v in powder_specs.items()} |
53 | 50 |
|
54 | | - all_input_materials = keymap(lambda x: x.spec.name, merge(binder_runs, powder_runs)) |
| 51 | + all_input_materials = {k.spec.name: v for k, v in binder_runs.items() | powder_runs.items()} |
55 | 52 | mixing_composition = Condition( |
56 | 53 | name="composition", |
57 | 54 | value=NominalComposition(all_input_materials) |
@@ -161,9 +158,7 @@ def test_access_data(): |
161 | 158 |
|
162 | 159 | # read the quantity of alumina |
163 | 160 | quantities = island.process.ingredients[0].material.process.conditions[0].value.quantities |
164 | | - assert(list( |
165 | | - keyfilter(lambda x: x == "Al2O3", quantities).values() |
166 | | - )[0] == 0.96) |
| 161 | + assert quantities.get("Al2O3") == 0.96 |
167 | 162 |
|
168 | 163 | # check that the serialization results in the correct number of objects in the preface |
169 | 164 | # (note that neither measurements nor ingredients are serialized) |
|
0 commit comments