Issue with finding dimension of index

+1 vote

I have a very simple question concerning the dimension of an index i for Julia's version of iTensor, example given here under "Constructors":

https://itensor.github.io/ITensors.jl/stable/IndexType.html

When I make an index and run

i = Index(2; tags = "l", plev = 1)
dim(i)


I get

  UndefVarError: dim not defined


Why am I getting this error? Is the command for finding the dimension of i not "dim"?

commented by (64.6k points)
Hi, so I tried this in the interactive Julia mode, inputting “using ITensors” followed by your two commands above (on separate lines). When you try it that way does it work? Could you please provide more details about how you are running these two commands (& are they on a single line as typed above or two separate lines)?
commented by (240 points)
Hi Miles,

Sorry, I should have been clearer. In an iJulia notebook, I have all commands on separate lines, and it didn't work. It turns out there was a package clash between ITensors and and the Distributions package. If I call the latter first, for some reason "dim" is no longer defined in ITensors. Commenting out Distributions makes everything run fine. Thank you.
commented by (64.6k points)
I see, thanks for raising this issue. It’s something we should keep an eye on. There are certain more commonly used function and variable names we’ve stopped exporting for this reason, though we didn’t know about dim.

I think the best options here are either to use a fully qualified name such as ITensors.dim or to use the import command if you only need to import a small number of functions from, say, the distributions package.

Finally, you may want to try making an alias like this:

idim(i) = ITensors.dim(i)