Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/flowrep/retrospective/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def from_recipe(cls, recipe: constant_recipe.ConstantRecipe) -> ConstantData:
},
)

@property
def value(self):
return self.output_ports[constant_recipe.ConstantRecipe.std_label].value


@dataclasses.dataclass(frozen=False)
class CompositeData(NodeData, Generic[RecipeType], abc.ABC):
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_retrospective_wfms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,14 @@ def test_run_recipe_on_constant(self):
node = wfms.run_recipe(constant_recipe.ConstantRecipe(constant=7))
self.assertEqual(node.output_ports["constant"].value, 7)

def test_shortcut(self):
recipe = constant_recipe.ConstantRecipe(constant=7)
data = datastructures.ConstantData.from_recipe(recipe)
self.assertEqual(
data.output_ports[constant_recipe.ConstantRecipe.std_label].value,
data.value,
)

def test_end_to_end_kinetic_energy(self):
recipe = workflow_parser.parse_workflow(_kinetic_energy)
result = wfms.run_recipe(recipe, mass=2.0, velocity=3.0)
Expand Down
Loading