Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hello, I am trying to declare properties to Cadabra objects inside a python file. Could someone help me with finding the right input syntax, for instance for the property Indices?

Consider the following cadabra notebook contents:

{ a, b, c, d }::Indices(spacetime, independent=True)

This assigns the Indices property to the a,b,c,d objects in a cadabra notebook. I would like to do this inside a python notebook. Here is my attempt:

import cadabra2 as cad
example_index = ['a', 'b', 'c', 'd']
cad.Indices(example_index_set, space=spacetime, independent=True)

This returns the error that example_index is not a Cadabra object, so I'm not understanding the syntax for cad.Indices.

Thanks in advance!

in General questions by (140 points)

1 Answer

+2 votes

Use the following:

import cadabra2 as cad
cad.Indices(cad.Ex("[a,b,c,d]"), 
   cad.Ex("name=spacetime, position=independent"))

The Indices function takes two Cadabra expression Ex objects. The first is the list of indices, the second all the arguments.

by (83.1k points)

Thanks for the quick response Kasper! Works perfectly now :)

...