Quick Start¶
Parse a tensor expression¶
Output:
{
'type': 'TensorExpression',
'head': 'R',
'indices': [
{'label': 'a', 'variance': 'Contra', 'type': 'Latin'},
{'label': 'b', 'variance': 'Covar', 'type': 'Latin'},
{'label': 'c', 'variance': 'Covar', 'type': 'Latin'},
{'label': 'd', 'variance': 'Covar', 'type': 'Latin'},
]
}
Use a TOML context for type checking¶
Create a TOML file declaring your manifold and tensors:
# basic.toml
[manifold.M]
dimension = 4
index_type = "Latin"
[tensor.R]
manifold = "M"
rank = 4
index_pattern = ["Contra", "Covar", "Covar", "Covar"]
[tensor.A]
manifold = "M"
rank = 1
index_pattern = ["Contra"]
[tensor.B]
manifold = "M"
rank = 1
index_pattern = ["Contra"]
Then load it and parse with type checking:
import chacana
ctx = chacana.load_context("basic.toml")
# Valid: matching free indices in sum
chacana.parse("A{^a} + B{^a}", context=ctx)
# Invalid: mismatched variance in sum
chacana.parse("A{^a} + B{_a}", context=ctx)
# raises ChacanaTypeError: Free index mismatch in sum