-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make _assign_metrics public #199
Comments
I think this is resonable. @rabernat, do you have thoughts? |
I think if we do this, we could also implement a |
How about |
I would be in favor of that! |
Sure, sounds good to me. |
Something we can integrate in this feature is a way to return the original |
Just started to tinker with a PR for #103 and I think it would be helpful to address this here first. A few additional questions: I would create a subclass
this would enable us to store the name in combination with the dataarray. This is helpful for naming derived metrics (e.g. for #222 and #103) and prepare the internals to be able to generate for instance a subset with all needed kwargs to create a new grid (useful for #193 #200 ). should the Should we be able to What checks should we perform in the
|
How about something like class Metrics(dict):
def __setitem__(self, key, value):
# do validation / alignment checks here
super().__setitem__(key, value)
def validate(self):
# could be useful
pass
def infer_remaining(self):
# maybe?
pass
class Grid:
metrics: Metrics = Metrics()
inst = Grid()
print(inst.metrics) # {}
inst.metrics["a"] = 10
inst.metrics["b"] = 20
print(inst.metrics) # {a: 10, b: 20}
What are these names? Are they the same as
To help with #108 (comment) (grid operations used to construct metrics), I think we should allow setting DataArrays.
Hmm.. maybe not until this is actually needed? #108 (comment) should only require setting metrics that have not been assigned |
I like your suggestion a lot. Couple of thoughts (forgive me if these are stupid, I am not that versed with classes yet):
Yes, if we require a dataarray as value, we could just check for a name on the input, and allow to pass either a str (value gets picked from
I think I wasnt exactly clear here. I think your example clarified, that you can set each metric by itself, and dont need to pass them as a list of values or anything like that. |
I thought Why should we track "native" vs "inferred" metrics? We could add a private attribute to the Metrics class |
For future features (#103 and extension of the
Let me clarify what I envision under I am also working on a draft of a new vanity feature that Ill describe in an issue soon, which would need both of these informations, hehe. |
Yes but the I think coarsen syntax could be coarsegrid = grid.coarsen(X=5)
newds = coarsegrid.mean(ds) This would preserve the names of metrics variables coarsegrid, newds = grid.coarsen(X=5).mean(ds)
Yes, but this could be opt-in and we can add a |
Yes, I think we are thinking the same thing here.
Interesting. I am not quite sure which version I favor at the moment. But could you copy+paste this suggestion to #103 , so folks who are not watching this issue could discuss? I think this is sufficiently concrete that I can take a swing at implementing this maybe tomorrow or next week, and then we can discuss details over in the PR? Thanks for all the input. |
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! |
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. |
Just for posteriority: This was closed via #336 |
#108 (comment) suggests that
_assign_metrics
should be public.That way you can use
grid.interp
andgrid.diff
to construct metrics when necessary and then just assign them to an existing object.The text was updated successfully, but these errors were encountered: