Skip to content

Commit f6df3d7

Browse files
committed
Change input and output shapes of _cg_couple_dense to the previous version
1 parent 80e95f9 commit f6df3d7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

python/featomic/featomic/clebsch_gordan/_coefficients.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ def cg_couple(
435435
for o3_lambda in o3_lambdas
436436
]
437437
elif cg_backend == "python-dense":
438+
439+
n_samples = array.shape[0]
440+
n_properties = array.shape[3]
441+
442+
array = array.swapaxes(1, 3)
443+
array = array.reshape(n_samples * n_properties, 2 * l2 + 1, 2 * l1 + 1)
444+
438445
return [
439446
_cg_couple_dense(array, o3_lambda, cg_coefficients)
440447
for o3_lambda in o3_lambdas
@@ -505,18 +512,14 @@ def _cg_couple_dense(
505512
:param cg_coefficients: CG coefficients as returned by
506513
:py:func:`calculate_cg_coefficients` with ``cg_backed="python-dense"``
507514
"""
508-
# TODO: fix this!
509-
# assert len(array.shape) == 3
515+
assert len(array.shape) == 3
510516

511-
l1 = (array.shape[1] - 1) // 2
512-
l2 = (array.shape[2] - 1) // 2
517+
l1 = (array.shape[2] - 1) // 2
518+
l2 = (array.shape[1] - 1) // 2
513519

514520
cg_l1l2lam = cg_coefficients.block({"l1": l1, "l2": l2, "lambda": o3_lambda}).values
515521

516-
return _dispatch.permute(
517-
_dispatch.tensordot(array, cg_l1l2lam[0, ..., 0], axes=([1, 2], [0, 1])),
518-
[0, 2, 1]
519-
)
522+
return _dispatch.tensordot(array, cg_l1l2lam[0, ..., 0], axes=([2, 1], [0, 1]))
520523

521524

522525
# ======================================================================= #

0 commit comments

Comments
 (0)