Argmax by attribute. Returns (new_variable, "Observation: ...").
(self, variable: Variable, attribute: str)
| 174 | return None, rtn_str |
| 175 | |
| 176 | def argmax(self, variable: Variable, attribute: str): |
| 177 | """ |
| 178 | Argmax by attribute. Returns (new_variable, "Observation: ..."). |
| 179 | """ |
| 180 | cache_key = (self.task_id, hash(variable)) |
| 181 | if cache_key not in attribute_cache and variable not in variable_attributes_cache: |
| 182 | self.get_attributes(variable) |
| 183 | |
| 184 | if attribute not in variable_attributes_cache.get(variable, []): |
| 185 | raise ValueError("argmax: attribute must be an attribute of the variable") |
| 186 | |
| 187 | rtn_str = f"Observation: variable ##, which are instances of {variable.type}" |
| 188 | new_variable = Variable(variable.type, f"(ARGMAX {variable.program} {attribute})") |
| 189 | return new_variable, rtn_str |
| 190 | |
| 191 | def argmin(self, variable: Variable, attribute: str): |
| 192 | """ |
no test coverage detected