@@ -331,7 +331,7 @@ class Expression:
331
331
"""
332
332
333
333
@classmethod
334
- def load (_cls , filename : str , conflict_fn : Callable [[str ], str ]) -> Expression :
334
+ def load (_cls , filename : str , conflict_fn : Optional [ Callable [[str ], str ]] = None ) -> Expression :
335
335
"""Load an expression and its state from a file. The state will be merged
336
336
with the current one. If a symbol has conflicting attributes, the conflict
337
337
can be resolved using the renaming function `conflict_fn`.
@@ -587,7 +587,7 @@ class Expression:
587
587
588
588
def req (
589
589
self ,
590
- filter_fn : Callable [[Expression ], bool ],
590
+ filter_fn : Callable [[Expression ], bool | Condition ],
591
591
) -> PatternRestriction :
592
592
"""
593
593
Create a new pattern restriction that calls the function `filter_fn` with the matched
@@ -605,7 +605,7 @@ class Expression:
605
605
def req_cmp (
606
606
self ,
607
607
other : Expression | int | float | Decimal ,
608
- cmp_fn : Callable [[Expression , Expression ], bool ],
608
+ cmp_fn : Callable [[Expression , Expression ], bool | Condition ],
609
609
) -> PatternRestriction :
610
610
"""
611
611
Create a new pattern restriction that calls the function `cmp_fn` with another the matched
@@ -1445,24 +1445,25 @@ class Expression:
1445
1445
"""
1446
1446
1447
1447
def canonize_tensors (self ,
1448
- contracted_indices : Sequence [Tuple [Expression | int ,Expression | int ]]) -> Expression :
1448
+ contracted_indices : Sequence [Tuple [Expression | int , Expression | int ]]) -> Expression :
1449
1449
"""Canonize (products of) tensors in the expression by relabeling repeated indices.
1450
1450
The tensors must be written as functions, with its indices as the arguments.
1451
1451
Subexpressions, constants and open indices are supported.
1452
-
1452
+
1453
1453
If the contracted indices are distinguishable (for example in their dimension),
1454
1454
you can provide a group marker as the second element in the tuple of the index
1455
1455
specification.
1456
1456
This makes sure that an index will not be renamed to an index from a different group.
1457
-
1457
+
1458
1458
Examples
1459
1459
--------
1460
1460
>>> g = Expression.symbol('g', is_symmetric=True)
1461
1461
>>> fc = Expression.symbol('fc', is_cyclesymmetric=True)
1462
1462
>>> mu1, mu2, mu3, mu4, k1 = Expression.symbol('mu1', 'mu2', 'mu3', 'mu4', 'k1')
1463
1463
>>> e = g(mu2, mu3)*fc(mu4, mu2, k1, mu4, k1, mu3)
1464
1464
>>> print(e.canonize_tensors([(mu1, 0), (mu2, 0), (mu3, 0), (mu4, 0)]))
1465
- yields `g(mu1,mu2)*fc(mu1,mu3,mu2,k1,mu3,k1)`.
1465
+
1466
+ yields `g(mu1, mu2)*fc(mu1, mu3, mu2, k1, mu3, k1)`.
1466
1467
"""
1467
1468
1468
1469
@@ -2157,6 +2158,7 @@ class Transformer:
2157
2158
square_brackets_for_function : bool = False ,
2158
2159
num_exp_as_superscript : bool = True ,
2159
2160
latex : bool = False ,
2161
+ show_namespaces : bool = False ,
2160
2162
) -> Transformer :
2161
2163
"""
2162
2164
Create a transformer that prints the expression.
0 commit comments