Skip to content
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

More Index constructors #688

Closed
mtfishman opened this issue Jun 16, 2021 · 1 comment
Closed

More Index constructors #688

mtfishman opened this issue Jun 16, 2021 · 1 comment
Labels
api Issues related to the interface enhancement New feature or request

Comments

@mtfishman
Copy link
Member

It may be nice to have more compact constructors for specifying the prime levels of an Index. Currently the interface is:

Index(2, plev=1)
Index(2, "x", plev=1)

We could add:

Index(2, 1)
Index(2, "x", 1)
Index(2, ("x", 1))

though the first one is unfortunate since it is pretty opaque when written like that.

Follow up to #686 (comment).

This is mostly nice for having more compact syntax for making sets of indices for the purpose of testing, such as:

N = 4
ds = (n + 1 for n in 1:N)
ps = (n - 1 for n in 1:N)
is = Index.(ds, ps)

Currently you would have to do:

is = [Index(d, plev=p) for (d, p) in zip(ds, ps)]

since broadcasting doesn't work through the keyword argument, so you can't do Index.(ds, plev=ps).

@mtfishman
Copy link
Member Author

Also note that as of #686 you can do:

N = 4
ds = (n + 1 for n in 1:N)
ts = ("$n" for n in 1:N)
is = Index.(ds, ts)

which is pretty compact, but a similarly compact prime level version would be nice as well.

@kshyatt kshyatt added api Issues related to the interface enhancement New feature or request labels Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants