From 7f2e5c777b479b5fc38f36a25d224a91123e7d70 Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 2 Oct 2023 22:47:31 +0200 Subject: [PATCH 1/2] simplified `l_coratio` code --- lmo/_lm_co.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lmo/_lm_co.py b/lmo/_lm_co.py index 971645c3..89731bae 100644 --- a/lmo/_lm_co.py +++ b/lmo/_lm_co.py @@ -16,7 +16,7 @@ from numpy import typing as npt from ._lm import l_weights -from ._utils import clean_order, ordered +from ._utils import broadstack, clean_order, ordered from .typing import AnyInt, AnyTrim, IntVector, LComomentOptions, SortKind if sys.version_info < (3, 11): @@ -199,12 +199,8 @@ def l_coratio( - [`lmo.l_comoment`][lmo.l_comoment] - [`lmo.l_ratio`][lmo.l_ratio] """ - rs = np.stack(np.broadcast_arrays(np.asarray(r), np.asarray(s))) - l_r, l_s = l_comoment(a, rs, trim, dtype=dtype, **kwargs) - - l_s = np.diagonal(l_s, axis1=-2, axis2=-1) - - return l_r / np.expand_dims(l_s, -1) + l_r, l_s = l_comoment(a, broadstack(r, s), trim, dtype=dtype, **kwargs) + return l_r / np.expand_dims(np.diagonal(l_s, axis1=-2, axis2=-1), -1) def l_costats( From 55f311603459f5723af032cc54dbbdaaebc82334 Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 2 Oct 2023 22:48:45 +0200 Subject: [PATCH 2/2] corrected L-coratio docstring definitions --- lmo/_lm_co.py | 2 +- lmo/theoretical.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lmo/_lm_co.py b/lmo/_lm_co.py index 89731bae..80ce2f4f 100644 --- a/lmo/_lm_co.py +++ b/lmo/_lm_co.py @@ -191,7 +191,7 @@ def l_coratio( \tilde \Lambda_{rs}^{(t_1, t_2)} = \left[ \left. \lambda_{r [ij]}^{(t_1, t_2)} \right/ - \lambda_{s [jj]}^{(t_1, t_2)} + \lambda_{s [ii]}^{(t_1, t_2)} \right]_{m \times m} $$ diff --git a/lmo/theoretical.py b/lmo/theoretical.py index 3969e0d7..33984495 100644 --- a/lmo/theoretical.py +++ b/lmo/theoretical.py @@ -1491,7 +1491,7 @@ def l_coratio_from_pdf( \tilde \Lambda_{r,r_0}^{(s, t)} = \left[ \left. \lambda_{r [ij]}^{(s, t)} \right/ - \lambda_{r_0 [jj]}^{(s, t)} + \lambda_{r_0 [ii]}^{(s, t)} \right]_{n \times n} $$