Set union. Returns (new_variable, "Observation: ...").
(self, variable1: Variable, variable2: Variable)
| 125 | return new_variable, rtn_str |
| 126 | |
| 127 | def union(self, variable1: Variable, variable2: Variable): |
| 128 | """ |
| 129 | Set union. Returns (new_variable, "Observation: ..."). |
| 130 | """ |
| 131 | if variable1.type != variable2.type: |
| 132 | raise ValueError("union: two variables must have the same type") |
| 133 | if not isinstance(variable1, Variable) or not isinstance(variable2, Variable): |
| 134 | raise ValueError("union: variable must be a variable") |
| 135 | |
| 136 | rtn_str = f"Observation: variable ##, which are instances of {variable1.type}" |
| 137 | new_variable = Variable(variable1.type, f"(OR {variable1.program} {variable2.program})") |
| 138 | return new_variable, rtn_str |
| 139 | |
| 140 | def count(self, variable: Variable): |
| 141 | """ |