+1 vote
asked by (240 points)

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 (62.7k 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 (62.7k 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)

1 Answer

+1 vote
answered by (62.7k points)
selected by
 
Best answer

(Please see discussion above.)

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...