| 842 | return (expr for expr in self.walk() if isinstance(expr, operation)) |
| 843 | |
| 844 | def __getattr__(self, key): |
| 845 | try: |
| 846 | return object.__getattribute__(self, key) |
| 847 | except AttributeError as err: |
| 848 | if key.startswith("_meta"): |
| 849 | # Avoid a recursive loop if/when `self._meta*` |
| 850 | # produces an `AttributeError` |
| 851 | raise RuntimeError( |
| 852 | f"Failed to generate metadata for {self}. " |
| 853 | "This operation may not be supported by the current backend." |
| 854 | ) |
| 855 | |
| 856 | # Allow operands to be accessed as attributes |
| 857 | # as long as the keys are not already reserved |
| 858 | # by existing methods/properties |
| 859 | _parameters = type(self)._parameters |
| 860 | if key in _parameters: |
| 861 | idx = _parameters.index(key) |
| 862 | return self.operands[idx] |
| 863 | |
| 864 | raise AttributeError( |
| 865 | f"{err}\n\n" |
| 866 | "This often means that you are attempting to use an unsupported " |
| 867 | f"API function.." |
| 868 | ) |
| 869 | |
| 870 | |
| 871 | class SingletonExpr(Expr): |