From af9c530ec1f7d0866afe0a06c0d293f162077955 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Tue, 28 Oct 2025 22:08:19 +0000 Subject: [PATCH 1/2] Rename example --- examples/{rccsd.py => codegen_rccsd.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{rccsd.py => codegen_rccsd.py} (100%) diff --git a/examples/rccsd.py b/examples/codegen_rccsd.py similarity index 100% rename from examples/rccsd.py rename to examples/codegen_rccsd.py From 12ec832fcf4bc062e65a382c669ffa86ca0f7d6c Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Wed, 29 Oct 2025 09:31:22 +0000 Subject: [PATCH 2/2] Fix evaluate on Mul nodes --- albert/algebra.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/albert/algebra.py b/albert/algebra.py index e1ba4a0..a3b9745 100644 --- a/albert/algebra.py +++ b/albert/algebra.py @@ -16,7 +16,6 @@ from albert.base import TypeOrFilter from albert.index import Index - from albert.tensor import Tensor from albert.types import EvaluatorArrayDict, _AlgebraicJSON T = TypeVar("T", bound=Base) @@ -491,25 +490,19 @@ def evaluate( Returns: Evaluated node, as an array. """ - # Find the scalar factor - factor = 1.0 - if self.find(Scalar): - for scalar in self.search(Scalar): - factor *= scalar.evaluate(arrays, einsum) - # Get the arrays and indices - child: Tensor | Algebraic - index: Index child_index_map: dict[Index, int] = {} + factor = 1.0 args: list[Any] = [] - for child in self.search(lambda node: node is not self and not isinstance(node, Scalar)): - for index in child.external_indices: - if index not in child_index_map: - child_index_map[index] = len(child_index_map) - args.append(child.evaluate(arrays, einsum)) - args.append( - tuple(child_index_map[index] for index in child.external_indices) # type: ignore - ) + for child in self.children: + if isinstance(child, Scalar): + factor *= child.evaluate(arrays, einsum) + else: + for index in child.external_indices: + if index not in child_index_map: + child_index_map[index] = len(child_index_map) + args.append(child.evaluate(arrays, einsum)) + args.append(tuple(child_index_map[index] for index in child.external_indices)) # Call the einsum function output_indices = tuple(child_index_map[index] for index in self.external_indices)