issue_comments
9 rows where author_association = "MEMBER" and issue = 173612265 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: reactions, created_at (date), updated_at (date)
issue 1
- Hooks for custom attribute handling in xarray operations · 9 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
413732471 | https://github.com/pydata/xarray/issues/988#issuecomment-413732471 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDQxMzczMjQ3MQ== | shoyer 1217238 | 2018-08-17T01:39:30Z | 2018-08-17T01:39:30Z | MEMBER |
Yep, this is pretty much what I was thinking of.
The virtue of this approach vs setting an global "attribute handler" (as suggested here) is that everything is controlled locally. For example, suppose people want to plug in two separate unit systems into xarray (e.g., pint and unyt). If the unit handling is determined by the specific arrays, then libraries relying on both approaches internally can happily co-exist and even call each other. In principle, this could be done safely with global handlers if you always know exactly when to switch back and forth, but that requires explicitly switching on handlers for even basic arithmetic. I doubt most users are going to bother, which is going to make using multiple tools that make use of this feature really hard. The other big advantage is that you only have to write the bulk of the unit system once, e.g., to define operations on NumPy arrays.
Rather than struggling to keep We could still do some work on the xarray side to make this easy to use. Specifically:
- The |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
413409482 | https://github.com/pydata/xarray/issues/988#issuecomment-413409482 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDQxMzQwOTQ4Mg== | shoyer 1217238 | 2018-08-16T03:02:53Z | 2018-08-16T03:02:53Z | MEMBER |
I think these overloads are a much more maintainable way to add features like unit handling into xarray, as outlined in our development roadmap. It's not a complete system for overloading attribute handling in |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
284314734 | https://github.com/pydata/xarray/issues/988#issuecomment-284314734 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI4NDMxNDczNA== | shoyer 1217238 | 2017-03-06T06:39:38Z | 2017-03-06T06:39:38Z | MEMBER | There's some chance that In general, this is a pretty tough design problem, which explains why it hasn't been solved yet :). But I was pretty happy with the way our Speaking of PEP 472, if someone has energy to push on that, it would be really awesome to see that happen. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
282082423 | https://github.com/pydata/xarray/issues/988#issuecomment-282082423 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI4MjA4MjQyMw== | shoyer 1217238 | 2017-02-23T18:44:43Z | 2017-02-23T18:44:43Z | MEMBER |
Definitely not, I'm afraid. It's gone back and forth several times on master but hasn't landed yet. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
282075293 | https://github.com/pydata/xarray/issues/988#issuecomment-282075293 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI4MjA3NTI5Mw== | shoyer 1217238 | 2017-02-23T18:18:36Z | 2017-02-23T18:18:36Z | MEMBER |
We currently have the binary arithmetic logic in |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
280574774 | https://github.com/pydata/xarray/issues/988#issuecomment-280574774 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI4MDU3NDc3NA== | shoyer 1217238 | 2017-02-17T07:25:52Z | 2017-02-17T07:25:52Z | MEMBER | Some related discussion that may be of interest to participants here is going on over in #1271. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
243980885 | https://github.com/pydata/xarray/issues/988#issuecomment-243980885 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI0Mzk4MDg4NQ== | shoyer 1217238 | 2016-09-01T05:37:08Z | 2016-09-01T05:37:08Z | MEMBER | So I guess I guess we can also start with the attrs only hooks for now and add the others later if/as necessary. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
243289800 | https://github.com/pydata/xarray/issues/988#issuecomment-243289800 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI0MzI4OTgwMA== | shoyer 1217238 | 2016-08-29T23:35:35Z | 2016-08-29T23:35:35Z | MEMBER | I agree that end users are likely to set this flag unilaterally, especially for interactive use. That's fine. This could even be OK in a higher level library, though I would encourage requiring an explicit opt in application code. One thing to consider is whether to allow multiple attribute handlers to be registered simultaneously or not. I kind of like a set_options interface that requires all handlers to be registered at once (as opposed to adding handlers incrementally ), because that ensures conflicts cannot arise inadvertantly. Either way, I don't think the performance penalty here would be significant in most cases, given how much of Python's dynamic nature xarray already uses. |
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 | |
242950070 | https://github.com/pydata/xarray/issues/988#issuecomment-242950070 | https://api.github.com/repos/pydata/xarray/issues/988 | MDEyOklzc3VlQ29tbWVudDI0Mjk1MDA3MA== | shoyer 1217238 | 2016-08-28T01:15:52Z | 2016-08-28T01:16:13Z | MEMBER | Let me give concrete examples of what this interface could look like. To implement units: ``` python from typing import List, Optional # optional Python 3.5 type annotations @xarray.register_ufunc_variables_attrs_handler def propagate_units(results: List[xarray.Variable], context: xarray.UFuncContext) -> Optional[List[dict]]: if context.func.name in ['add', 'sub']: units_set = set(getattr(arg, 'attrs', {}).get('units') for arg in context.args) if len(units_set) > 1: raise ValueError('not all input units the same: %r' % units_set) units, = units_set return [{'units': units}] else: return [] * len(results) # or equivalently, don't return anything at all ``` Or to (partially) handle
Or to implement
Every time xarray does an operation, we would call all of these registered
Similarly, we would have The downside of this approach is that unlike the way NumPy handles things, this doesn't handle conflicting implementations well. If you try to use two different libraries that register their own global attribute handlers instead of using the context manager (e.g., two different units implementations), things will break, even if the unrelated code paths do not touch. So alternatively to using the registration system, we could support/encourage using a context manager, e.g.,
It's kind of verbose, but certainly useful for libraries that want to be cautious about breaking other code. In general, it's poor behavior for libraries to unilaterally change unrelated code without an explicit opt-in. So perhaps the best approach is to encourage users to always use a context manager, e.g., ``` python import contextlib @contextlib.contextmanager def my_attrs_context(): with xarray.ufunc_variables_attrs_handlers( [always_keep_attrs, add_cell_methods, ...]): yield with my_attrs_context(): result = ds.mean() - 0.5 * (ds.max() - ds.min()) ``` So maybe a subclass based implementation (with a custom attribute like |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Hooks for custom attribute handling in xarray operations 173612265 |
Advanced export
JSON shape: default, array, newline-delimited, object
CREATE TABLE [issue_comments] ( [html_url] TEXT, [issue_url] TEXT, [id] INTEGER PRIMARY KEY, [node_id] TEXT, [user] INTEGER REFERENCES [users]([id]), [created_at] TEXT, [updated_at] TEXT, [author_association] TEXT, [body] TEXT, [reactions] TEXT, [performed_via_github_app] TEXT, [issue] INTEGER REFERENCES [issues]([id]) ); CREATE INDEX [idx_issue_comments_issue] ON [issue_comments] ([issue]); CREATE INDEX [idx_issue_comments_user] ON [issue_comments] ([user]);
user 1