Skip to content

Commit 3c2ad34

Browse files
committed
more changes
1 parent 784c6ec commit 3c2ad34

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

src/galax/potential/_src/scf/utils.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
from typing import TypeAlias, TypeVar, cast
55

66
import jax
7-
from jax import lax
8-
from jax.scipy.special import sph_harm
97
from jaxtyping import ArrayLike, Shaped
108

119
import quaxed.numpy as jnp
1210

1311
import galax._custom_types as gt
12+
from galax.potential._src.builtin.multipole import compute_Ylm
1413

1514
BatchableIntSz0: TypeAlias = Shaped[gt.IntSz0, "*#batch"]
1615

@@ -53,16 +52,6 @@ def psi_of_r(r: T) -> T:
5352
# =============================================================================
5453

5554

56-
@partial(jax.numpy.vectorize, signature="(n),(),()->(n)", excluded=(3,))
57-
@partial(jax.jit, static_argnames=("m_max",)) # TODO: should l,m be static?
58-
def _real_Ylm(theta: gt.SzN, l: gt.IntSz0, m: gt.IntSz0, m_max: int) -> gt.SzN:
59-
# TODO: sph_harm only supports scalars, even though it returns an array!
60-
theta = jnp.atleast_1d(theta)
61-
return sph_harm(
62-
m, jnp.atleast_1d(l), theta=jnp.zeros_like(theta), phi=theta, n_max=m_max
63-
).real
64-
65-
6655
@partial(jax.jit, static_argnames=("m_max",))
6756
def real_Ylm(
6857
theta: gt.SzAny, l: BatchableIntSz0, m: BatchableIntSz0, m_max: int = 100
@@ -90,4 +79,5 @@ def real_Ylm(
9079
``(n),(),()->(n)``.
9180
"""
9281
# TODO: raise an error if m > m_max
93-
return _real_Ylm(theta, l, m, m_max)
82+
_real_Ylm, _ = compute_Ylm(l, m, theta=theta, phi=jnp.zeros_like(theta), l_max=m_max)
83+
return _real_Ylm

tests/potential/scf/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import hypothesis.extra.numpy as hnp
55
import jax
66
import numpy as np
7-
import numpy.typing as npt
87
import scipy.special as sp
98
from hypothesis import assume, given, strategies as st
109

0 commit comments

Comments
 (0)