From 236ee46ff50735e0fbb018f74f6d5e685f3c12cb Mon Sep 17 00:00:00 2001 From: "Joseph W. Abbott" Date: Sat, 25 Jan 2025 14:44:27 +0100 Subject: [PATCH 1/4] Update docstring of `DensityCorrelations` Closes #372 --- .../clebsch_gordan/_density_correlations.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/python/featomic/featomic/clebsch_gordan/_density_correlations.py b/python/featomic/featomic/clebsch_gordan/_density_correlations.py index 0fa7f0a9e..01699ce92 100644 --- a/python/featomic/featomic/clebsch_gordan/_density_correlations.py +++ b/python/featomic/featomic/clebsch_gordan/_density_correlations.py @@ -85,7 +85,19 @@ def compute( where \\rho^{\\nu=1} is the input ``density`` of correlation order 1 (body order 2), and \\rho^{\\nu=n_{corr} + 1} is the output density of correlation order - ``n_correlations + 1`` + ``n_correlations + 1``. + + The input ``density`` must have at least ``"o3_lambda"`` and ``"o3_sigma"`` + key dimensions, as well as a single components axis with the ``"o3_mu"`` + dimension. Any other key dimensions present will be matched, while all properties + dimensions will have their full tensor product computed. + + For instance, if the key dimensions of ``density`` are ``"o3_lambda"``, + ``"o3_sigma"``, ``"center_type"``, and ``"neighbor_type"``, pairs of blocks will + only be combined if they have both the same center and neighbor atom type. To + fully correlate all combinations of ``"neighbor_type"``, for example, this key + dimension should be moved to properties first, using the :py:class:`TensorMap` + ``keys_to_properties`` method. Before performing any correlations, the properties dimensions of ``density`` are modified to carry a "_1" suffix. At each iteration, the dimension names of the From c4097507e41d3567f80c51ebfa5a4a31813523ae Mon Sep 17 00:00:00 2001 From: "Joseph W. Abbott" Date: Wed, 29 Jan 2025 14:20:36 +0100 Subject: [PATCH 2/4] Update python/featomic/featomic/clebsch_gordan/_density_correlations.py Co-authored-by: Guillaume Fraux --- .../featomic/featomic/clebsch_gordan/_density_correlations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/featomic/featomic/clebsch_gordan/_density_correlations.py b/python/featomic/featomic/clebsch_gordan/_density_correlations.py index 01699ce92..ff1ba596e 100644 --- a/python/featomic/featomic/clebsch_gordan/_density_correlations.py +++ b/python/featomic/featomic/clebsch_gordan/_density_correlations.py @@ -94,7 +94,7 @@ def compute( For instance, if the key dimensions of ``density`` are ``"o3_lambda"``, ``"o3_sigma"``, ``"center_type"``, and ``"neighbor_type"``, pairs of blocks will - only be combined if they have both the same center and neighbor atom type. To + only be combined if they have both the same ``"center_type"`` and ``"neighbor_type"``. To fully correlate all combinations of ``"neighbor_type"``, for example, this key dimension should be moved to properties first, using the :py:class:`TensorMap` ``keys_to_properties`` method. From 6768872f7d82e98095cef57c52f8f4e0179358b6 Mon Sep 17 00:00:00 2001 From: "Joseph W. Abbott" Date: Wed, 29 Jan 2025 14:20:42 +0100 Subject: [PATCH 3/4] Update python/featomic/featomic/clebsch_gordan/_density_correlations.py Co-authored-by: Guillaume Fraux --- .../featomic/featomic/clebsch_gordan/_density_correlations.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/featomic/featomic/clebsch_gordan/_density_correlations.py b/python/featomic/featomic/clebsch_gordan/_density_correlations.py index ff1ba596e..1f14e440f 100644 --- a/python/featomic/featomic/clebsch_gordan/_density_correlations.py +++ b/python/featomic/featomic/clebsch_gordan/_density_correlations.py @@ -96,8 +96,7 @@ def compute( ``"o3_sigma"``, ``"center_type"``, and ``"neighbor_type"``, pairs of blocks will only be combined if they have both the same ``"center_type"`` and ``"neighbor_type"``. To fully correlate all combinations of ``"neighbor_type"``, for example, this key - dimension should be moved to properties first, using the :py:class:`TensorMap` - ``keys_to_properties`` method. + dimension should be moved to properties first, using :py:meth:`TensorMap.keys_to_properties`. Before performing any correlations, the properties dimensions of ``density`` are modified to carry a "_1" suffix. At each iteration, the dimension names of the From 12eced85492ddbbb8aef528dde2202234c22874b Mon Sep 17 00:00:00 2001 From: Joseph Abbott Date: Fri, 31 Jan 2025 14:17:42 +0100 Subject: [PATCH 4/4] Format --- .../featomic/clebsch_gordan/_cg_product.py | 3 +-- .../clebsch_gordan/_density_correlations.py | 17 +++++++++-------- .../featomic/featomic/clebsch_gordan/_utils.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/featomic/featomic/clebsch_gordan/_cg_product.py b/python/featomic/featomic/clebsch_gordan/_cg_product.py index 9d1ac4e0b..9ad32a86a 100644 --- a/python/featomic/featomic/clebsch_gordan/_cg_product.py +++ b/python/featomic/featomic/clebsch_gordan/_cg_product.py @@ -117,8 +117,7 @@ def __init__( if max_angular < 0: raise ValueError( - f"Given `max_angular={max_angular}` negative. " - "Must be greater equal 0." + f"Given `max_angular={max_angular}` negative. Must be greater equal 0." ) self._max_angular = max_angular diff --git a/python/featomic/featomic/clebsch_gordan/_density_correlations.py b/python/featomic/featomic/clebsch_gordan/_density_correlations.py index 1f14e440f..e00eb47ed 100644 --- a/python/featomic/featomic/clebsch_gordan/_density_correlations.py +++ b/python/featomic/featomic/clebsch_gordan/_density_correlations.py @@ -85,18 +85,19 @@ def compute( where \\rho^{\\nu=1} is the input ``density`` of correlation order 1 (body order 2), and \\rho^{\\nu=n_{corr} + 1} is the output density of correlation order - ``n_correlations + 1``. - - The input ``density`` must have at least ``"o3_lambda"`` and ``"o3_sigma"`` - key dimensions, as well as a single components axis with the ``"o3_mu"`` - dimension. Any other key dimensions present will be matched, while all properties + ``n_correlations + 1``. + + The input ``density`` must have at least ``"o3_lambda"`` and ``"o3_sigma"`` key + dimensions, as well as a single components axis with the ``"o3_mu"`` dimension. + Any other key dimensions present will be matched, while all properties dimensions will have their full tensor product computed. For instance, if the key dimensions of ``density`` are ``"o3_lambda"``, ``"o3_sigma"``, ``"center_type"``, and ``"neighbor_type"``, pairs of blocks will - only be combined if they have both the same ``"center_type"`` and ``"neighbor_type"``. To - fully correlate all combinations of ``"neighbor_type"``, for example, this key - dimension should be moved to properties first, using :py:meth:`TensorMap.keys_to_properties`. + only be combined if they have both the same ``"center_type"`` and + ``"neighbor_type"``. To fully correlate all combinations of ``"neighbor_type"``, + for example, this key dimension should be moved to properties first, using + :py:meth:`TensorMap.keys_to_properties`. Before performing any correlations, the properties dimensions of ``density`` are modified to carry a "_1" suffix. At each iteration, the dimension names of the diff --git a/python/featomic/featomic/clebsch_gordan/_utils.py b/python/featomic/featomic/clebsch_gordan/_utils.py index 10c23f29f..b8d6ea8e0 100644 --- a/python/featomic/featomic/clebsch_gordan/_utils.py +++ b/python/featomic/featomic/clebsch_gordan/_utils.py @@ -365,7 +365,7 @@ def _compute_labels_full_cartesian_product( # Check for no shared labels dimensions for name in labels_1.names: assert name not in labels_2.names, ( - "`labels_1` and `labels_2` must not have a" " dimension ({name}) in common" + "`labels_1` and `labels_2` must not have a dimension ({name}) in common" ) # Create the new labels names by concatenating the names of the two input labels labels_names: List[str] = labels_1.names + labels_2.names