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