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