Replies: 3 comments 1 reply
-
I think both 1 and 2 are good options. 1 should probably be relatively easy to implement with: split var_names between include and exclude filters, subset using include filters, then subset its result using exclude filters. While also being conceptually simple and intuitive for users. I personally prefer 1, as 2 is in 99% of the cases equivalent to "ignore the include filter". Option 3 sounds a bit too complicated, and I think we should ask/expect users who want these kinds of "advanced" behaviour to use Extra note: what I think happens currently is "ignore the include filter" when both are present. It is not option 2 as described here. We could also stick to this, but then we should probably warn when both include and exclude filters are present. Exampleslst = ["foo", "bar", "foobar", "foo_x", "bar_x", "x"]
az.utils._subset_list(["foo", "~bar"], lst, filter_items="like")
['foo', 'foo_x', 'x'] # current behaviour
['foo', 'foo_x'] # option 1
['foo', 'foobar', 'foo_x', 'x'] # option 2 |
Beta Was this translation helpful? Give feedback.
-
This seems to be true and is definitely unexpected. lst = ["abc", "foo", "bar", "foobar", "foo_x", "bar_x", "x"]
az.utils._subset_list(["foo", "~bar"], lst, filter_items="like")
# ['abc', 'foo', 'foo_x', 'x'] |
Beta Was this translation helpful? Give feedback.
-
I'll add a weird option 4 that I think we should lean into using fnmatch for the "like" case, since it saves users from having to learn a new dialect. That is, you'd write something like lst = ["abc", "foo", "bar", "foobar", "foo_x", "bar_x", "x"] to get "everything starting with |
Beta Was this translation helpful? Give feedback.
-
I often would want to select subsets of variables with both positive and negative conditions. Things like: "give me a traceplot of all variables that contain in their name
sigma
but notfoo
". At first it looks likearviz
already supports this, you can just passvar_names=["sigma", "~foo"], filter_items="like"
. This doesn't do what I would have expected though, if negative selections are present it simply ignores the positive ones.This however raises the question how the combination of negative and positive filters should be interpreted. I can think of several options of how to do this:
or
ed together. So["sigma", "~foo"]
returns all variables that either containsigma
or do not containfoo
. I think this would be the most consistent, because it treats the negative selectors the same as the positive ones, but I don't think that is what users would usually want to achieve?and
andor
selectors. So we could do the same thing as in 2., but additionally allow lists as elements invar_names
, and interpret those lists asand
conditions. Sovar_names=[["foo", "~bar"], "sigma"]
would show all variables that either containsigma
, or that containfoo
but notbar
. I think I like the flexibility of the last one, but I'm not sure if this is maybe getting to complicated...(cc @ColCarroll @OriolAbril @cluhmann)
Beta Was this translation helpful? Give feedback.
All reactions