A good example of writing a less-trivial blockwise operation
| 1824 | |
| 1825 | |
| 1826 | class Apply(Elemwise): |
| 1827 | """A good example of writing a less-trivial blockwise operation""" |
| 1828 | |
| 1829 | _parameters = ["frame", "function", "args", "meta", "kwargs"] |
| 1830 | _defaults = {"args": (), "kwargs": {}} |
| 1831 | operation = M.apply |
| 1832 | |
| 1833 | @functools.cached_property |
| 1834 | def _meta(self): |
| 1835 | return make_meta(self.operand("meta"), parent_meta=self.frame._meta) |
| 1836 | |
| 1837 | def _task(self, name: Key, index: int) -> Task: |
| 1838 | return Task( |
| 1839 | name, |
| 1840 | M.apply, |
| 1841 | TaskRef((self.frame._name, index)), |
| 1842 | self.function, |
| 1843 | *self.args, |
| 1844 | **self.kwargs, |
| 1845 | ) |
| 1846 | |
| 1847 | |
| 1848 | class Map(Elemwise): |