|
22 | 22 | WorldEntity, |
23 | 23 | KinematicStructureEntity, |
24 | 24 | ) |
25 | | - from .spatial_types.spatial_types import Symbol, SymbolicType |
| 25 | + from .spatial_types.spatial_types import FloatVariable, SymbolicType |
26 | 26 |
|
27 | 27 |
|
28 | 28 | class LogicalError(Exception): |
@@ -73,33 +73,6 @@ def __post_init__(self): |
73 | 73 | super().__init__(msg) |
74 | 74 |
|
75 | 75 |
|
76 | | -class SymbolManagerException(Exception): |
77 | | - """ |
78 | | - Exceptions related to the symbol manager for special types. |
79 | | - """ |
80 | | - |
81 | | - |
82 | | -@dataclass |
83 | | -class SymbolResolutionError(SymbolManagerException): |
84 | | - """ |
85 | | - Represents an error that occurs when a symbol in a symbolic expression cannot be resolved. |
86 | | -
|
87 | | - This exception is raised when the resolution of a symbol fails due to |
88 | | - underlying exceptions or unresolved states. It provides details about |
89 | | - the symbol that caused the error and the original exception responsible |
90 | | - for the failure. |
91 | | - """ |
92 | | - |
93 | | - symbol: Symbol |
94 | | - original_exception: Exception |
95 | | - |
96 | | - def __post_init__(self): |
97 | | - super().__init__( |
98 | | - f'Symbol "{self.symbol.name}" could not be resolved. ' |
99 | | - f"({self.original_exception.__class__.__name__}: {str(self.original_exception)})" |
100 | | - ) |
101 | | - |
102 | | - |
103 | 76 | class SpatialTypesError(UsageError): |
104 | 77 | pass |
105 | 78 |
|
@@ -134,28 +107,41 @@ def __post_init__(self): |
134 | 107 |
|
135 | 108 |
|
136 | 109 | @dataclass |
137 | | -class HasFreeSymbolsError(SpatialTypesError): |
| 110 | +class HasFreeVariablesError(SpatialTypesError): |
138 | 111 | """ |
139 | | - Raised when an operation can't be performed on an expression with free symbols. |
| 112 | + Raised when an operation can't be performed on an expression with free variables. |
140 | 113 | """ |
141 | 114 |
|
142 | | - symbols: List[Symbol] |
| 115 | + variables: List[FloatVariable] |
| 116 | + |
| 117 | + def __post_init__(self): |
| 118 | + msg = f"Operation can't be performed on expression with free variables: {self.variables}." |
| 119 | + super().__init__(msg) |
| 120 | + |
| 121 | + |
| 122 | +class ExpressionEvaluationError(SpatialTypesError): ... |
| 123 | + |
| 124 | + |
| 125 | +@dataclass |
| 126 | +class WrongNumberOfArgsError(ExpressionEvaluationError): |
| 127 | + expected_number_of_args: int |
| 128 | + actual_number_of_args: int |
143 | 129 |
|
144 | 130 | def __post_init__(self): |
145 | | - msg = f"Operation can't be performed on expression with free symbols: {self.symbols}." |
| 131 | + msg = f"Expected {self.expected_number_of_args} arguments, but got {self.actual_number_of_args}." |
146 | 132 | super().__init__(msg) |
147 | 133 |
|
148 | 134 |
|
149 | 135 | @dataclass |
150 | | -class DuplicateSymbolsError(SpatialTypesError): |
| 136 | +class DuplicateVariablesError(SpatialTypesError): |
151 | 137 | """ |
152 | | - Raised when duplicate symbols are found in an operation that requires unique symbols. |
| 138 | + Raised when duplicate variables are found in an operation that requires unique variables. |
153 | 139 | """ |
154 | 140 |
|
155 | | - symbols: List[Symbol] |
| 141 | + variables: List[FloatVariable] |
156 | 142 |
|
157 | 143 | def __post_init__(self): |
158 | | - msg = f"Operation failed due to duplicate symbols: {self.symbols}. All symbols must be unique." |
| 144 | + msg = f"Operation failed due to duplicate variables: {self.variables}. All variables must be unique." |
159 | 145 | super().__init__(msg) |
160 | 146 |
|
161 | 147 |
|
@@ -206,7 +192,7 @@ class SpatialTypeNotJsonSerializable(NotJsonSerializable): |
206 | 192 | def __post_init__(self): |
207 | 193 | super().__init__( |
208 | 194 | f"Object of type '{self.spatial_object.__class__.__name__}' is not JSON serializable, because it has " |
209 | | - f"free variables: {self.spatial_object.free_symbols()}" |
| 195 | + f"free variables: {self.spatial_object.free_variables()}" |
210 | 196 | ) |
211 | 197 |
|
212 | 198 |
|
|
0 commit comments