invenia / AxisSets.jl

Consistent operations over a collection of KeyedArrays
MIT License
5 stars 0 forks source link

Consider a different glob (`:_`/`:__`) syntax #22

Open rofinn opened 3 years ago

rofinn commented 3 years ago

While aligning with glob (*/**) and NamedDims.jl (:_ wildcard dim) is nice, :_ and :__ are a bit hard to distinguish depending on the font setting in an editor or terminal. We might want to consider using a different symbol or maybe our keys should just be path strings reusing the glob syntax?

bencottier commented 3 years ago

Path strings sound cool, although I'm wary of confusing users more by being too clever.

Either way, I think it would help to clarify the analogy to paths in the docs. A dimspath is not necessarily intuitive. So I mean, point out that a nested collection of namedtuples is analogous to a directory structure, and a dimspath is indexing that.

rofinn commented 3 years ago

I wonder if one solution to :_ vs :__ is to just not use the more powerful :__ in most of our examples. I think most of our datasets could just use the :_, and we might want to make that the best practice as it minimize weird behaviours (ie: matching paths of different depths).

Path strings sound cool, although I'm wary of confusing users more by being too clever.

Yeah, that's why I liked the explicit Tuple syntax for this. I wonder if we should plan to make the Pattern code a separate package. Looks like python 3.10 might be including something similar, so it probably isn't specific to our problem.

https://www.python.org/dev/peps/pep-0622/

Either way, I think it would help to clarify the analogy to paths in the docs.

We do explicitly mention the similarity to glob pattern matching in the Pattern docstring.

Special symbols :_ and :__ are used as wildcards, similar to * and ** in glob pattern matching.

Maybe there's a better place for it, though? Or maybe we should lean harder into this idea of a TreeDict with globbing and a diagram?

bencottier commented 3 years ago

We do explicitly mention the similarity to glob pattern matching in the Pattern docstring.

To me that doesn't provide the full understanding. I'm suggesting we also explain why there are these path-like objects in the first place - it's because there is this nested associative structure.