Coverage for skema/gromet/execution_engine/types/set.py: 88%
34 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
1from typing import Any, Set
3from skema.gromet.execution_engine.types.defined_types import Field
6class new_Set(object):
7 source_language_name = {"Python": "new_set"}
8 inputs = [Field("elements", "Any", True)]
9 outputs = [Field("set_output", "Set")]
10 shorthand = "new_Set"
11 documentation = ""
13 def exec(*elements: Any) -> Set:
14 return set(elements)
17class member(object): # TODO: Still unsure the difference between this and in
18 source_language_name = {"Python": "member"}
19 inputs = [Field("set_input", "Set", True), Field("value", "Any")]
20 outputs = [Field("result", "Boolean")]
21 shorthand = "member"
22 documentation = ""
24 def exec(set_input: Set, value: Any) -> Set:
25 return value in set_input
28class add_elm(object):
29 source_language_name = {"Python": "add_elm"}
30 inputs = [Field("input_set", "Set"), Field("element", "Any")]
31 outputs = [Field("set_output", "Set")]
32 shorthand = "add_elm"
33 documentation = ""
35 def exec(input_set: Set, element: Any) -> Set:
36 return input_set.add(element)
39class del_elm(object):
40 source_language_name = {"Python": "del_elm"}
41 inputs = [Field("input_set", "Set"), Field("element", "Any")]
42 outputs = [Field("set_output", "Set")]
43 shorthand = "del_elm"
44 documentation = ""
46 def exec(input_set: Set, element: Any) -> Set:
47 return input_set.remove(
48 element
49 ) # TODO: Do we need to check if this exists first? Will throw KeyError if it does not