issue_comments: 258582609
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/1080#issuecomment-258582609 | https://api.github.com/repos/pydata/xarray/issues/1080 | 258582609 | MDEyOklzc3VlQ29tbWVudDI1ODU4MjYwOQ== | 1217238 | 2016-11-05T01:32:02Z | 2016-11-05T01:32:02Z | MEMBER | I don't see a conflict between encouraging accessors and making duplicate methods/functions. If you want duplicate method/functions, you can totally do that on an accessor class: ``` python import functools import xarray @xarray.register_dataarray_accessor('custom') class CustomAccessor(object): def init(self, data_array): self._data_array = data_array def patch_custom(func): @functools.wraps(func) def method(accessor, args, kwargs): return func(accessor._data_array, args, **kwargs) setattr(CustomAccessor, func.name, method) return func @patch_custom def square(data_array): return data_array ** 2 xarray.DataArray([1, 2, 3], dims='x').custom.square() <xarray.DataArray (x: 3)>array([1, 4, 9])Coordinates:* x (x) int64 0 1 2``` If you really desire, you can even make method-like accessors by adding a
or even simpler
I would definitely discourage writing too many of such methods, though. Finally, it seems like the simplest solution to your concern about needing methods for |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
187373423 |