Type check
check_functions(expression, function_test)
Example
from sympy import sympify expr = sympify('sin(x)') check_functions(expr, lambda x: x in ['sin']) True
expr = sympify('x + y') check_functions(expr, lambda x: x in ['sin']) True
expr = sympify('sin(x) + cos(y)') check_functions(expr, lambda x: x in ['sin', 'cos']) True
check_functions(expr, lambda x: x in ['sin']) False
Source code in src/equation_tree/util/type_check.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
is_constant_formatted(s)
Tests weather the input is in standard format for a constant
Examples:
>>> is_constant_formatted('c_4')
True
>>> is_constant_formatted('c_42')
True
>>> is_constant_formatted('c_a')
False
>>> is_constant_formatted('abc')
False
>>> is_constant_formatted('x_3')
False
Source code in src/equation_tree/util/type_check.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
is_numeric(s)
Tests weather the input is a number
Examples:
>>> is_numeric('0')
True
>>> is_numeric('10')
True
>>> is_numeric('hallo')
False
>>> is_numeric('.1')
True
>>> is_numeric('+.1')
False
Source code in src/equation_tree/util/type_check.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
is_variable_formatted(s)
Tests weather the input is in standard format for a variable
Examples:
>>> is_variable_formatted('x_1')
True
>>> is_variable_formatted('x_42')
True
>>> is_variable_formatted('x_a')
False
>>> is_variable_formatted('abc')
False
>>> is_variable_formatted('c_3')
False
Source code in src/equation_tree/util/type_check.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
parse_string_list_int(lst)
Example
a = '[1, 2, 3, 4]' parse_string_list_int(a) [1, 2, 3, 4] b = '[10, 2, 3]' parse_string_list_int(b) [10, 2, 3]
Source code in src/equation_tree/util/type_check.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|