Coverage for skema/gromet/execution_engine/types/unary.py: 88%

34 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1from typing import Union 

2 

3from skema.gromet.execution_engine.types.defined_types import Field 

4 

5 

6class UAdd(object): 

7 source_language_name = {"Python": "UAdd", "CAST": "UAdd"} 

8 inputs = [Field("operand", "Number")] 

9 outputs = [Field("result", "Number")] 

10 shorthand = "u+" 

11 documentation = "" 

12 

13 def exec( 

14 operand: Union[int, float, complex] 

15 ) -> Union[int, float, complex]: 

16 return +operand 

17 

18 

19class USub(object): 

20 source_language_name = {"Python": "USub", "CAST": "USub"} 

21 inputs = [Field("operand", "Number")] 

22 outputs = [Field("result", "Number")] 

23 shorthand = "u-" 

24 documentation = "" 

25 

26 def exec( 

27 operand: Union[int, float, complex] 

28 ) -> Union[int, float, complex]: 

29 return -operand 

30 

31 

32class Not(object): 

33 source_language_name = {"Python": "Not", "CAST": "Not"} 

34 inputs = [Field("operand", "Boolean")] 

35 outputs = [Field("result", "Boolean")] 

36 shorthand = "not" 

37 documentation = "" 

38 

39 def exec(operand: bool) -> bool: 

40 return not operand 

41 

42 

43class Invert(object): 

44 source_language_name = {"Python": "Invert", "CAST": "Invert"} 

45 inputs = [Field("operand", "Number")] 

46 outputs = [Field("result", "Number")] 

47 shorthand = "~" 

48 documentation = "" 

49 

50 def exec( 

51 operand: Union[int, float, complex] 

52 ) -> Union[int, float, complex]: 

53 return ~operand