Skip to content

Commit e08b1ca

Browse files
committed
Fix various test warnings
1 parent c0cd280 commit e08b1ca

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

dedalus/core/basis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ def local_radius_weights(self, dist, scale=None):
24332433
@CachedAttribute
24342434
def constant_mode_value(self):
24352435
Qk = dedalus_sphere.zernike.polynomials(2, 1, self.alpha+self.k, 0, np.array([0]))
2436-
return Qk[0]
2436+
return Qk[0,0]
24372437

24382438
def _new_k(self, k):
24392439
# TODO: replace this in all operators
@@ -3257,9 +3257,9 @@ def _last_axis_component_ncc_matrix(cls, subproblem, ncc_basis, arg_basis, out_b
32573257
# ell_min of data is based off |m|, but ell_min of matrix takes into account |s| and |m|
32583258
lmin_out = max(abs(spintotal_out) - abs(m), 0)
32593259
lmin_arg = max(abs(spintotal_arg) - abs(m), 0 )
3260-
matrix_cos = sparse.csr_matrix((N, N))
3260+
matrix_cos = sparse.lil_matrix((N, N))
32613261
matrix_cos[lmin_out:,lmin_arg:] = (prefactor @ clenshaw.matrix_clenshaw(coeffs_cos_filter, A, B, f0, cutoff=cutoff))[:N-lmin_out,:N-lmin_arg]
3262-
matrix_msin = sparse.csr_matrix((N, N))
3262+
matrix_msin = sparse.lil_matrix((N, N))
32633263
matrix_msin[lmin_out:,lmin_arg:] = (prefactor @ clenshaw.matrix_clenshaw(coeffs_msin_filter, A, B, f0, cutoff=cutoff))[:N-lmin_out,:N-lmin_arg]
32643264
matrix = sparse.bmat([[matrix_cos, -matrix_msin], [matrix_msin, matrix_cos]], format='csr')
32653265
if m >= arg_basis.mmax//4:
@@ -4003,7 +4003,7 @@ def _radius_weights(self, scale):
40034003
@CachedAttribute
40044004
def constant_mode_value(self):
40054005
Qk = dedalus_sphere.zernike.polynomials(3, 1, self.alpha+self.k, 0, np.array([0]))
4006-
return Qk[0]
4006+
return Qk[0,0]
40074007

40084008
@CachedMethod
40094009
def interpolation(self, ell, regtotal, position):

dedalus/tests/test_sphere_calculus.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
from dedalus.core import coords, distributor, basis, field, operators, arithmetic, problems, solvers
66
from dedalus.tools.cache import CachedFunction
7-
from scipy.special import sph_harm
7+
from scipy.special import sph_harm_y
88

99
Nphi_range = [32]
1010
Ntheta_range = [16]
@@ -157,16 +157,17 @@ def test_gradient_scalar_explicit(Nphi, Ntheta, dealias, dtype):
157157
f = d.Field(bases=b)
158158
f.preset_scales(dealias)
159159
if np.iscomplexobj(dtype()):
160-
f['g'] = sph_harm(m, l, phi, theta)
160+
f['g'] = sph_harm_y(m, l, theta, phi)
161161
else:
162-
f['g'] = sph_harm(m, l, phi, theta).real
162+
f['g'] = sph_harm_y(m, l, theta, phi).real
163163
# Evaluate gradient
164164
u = operators.Gradient(f).evaluate()
165165
ug_phi = 1j*np.exp(2j*phi)*np.sqrt(15/(2*np.pi))*np.sin(theta)/2
166166
ug_theta = np.exp(2j*phi)*np.sqrt(15/(2*np.pi))*np.cos(theta)*np.sin(theta)/2
167167
ug = np.array([ug_phi, ug_theta]) / radius
168168
if np.isrealobj(dtype()):
169169
ug = ug.real
170+
print(u['g']-ug)
170171
assert np.allclose(u['g'], ug)
171172

172173

@@ -348,9 +349,9 @@ def test_laplacian_scalar_explicit(Nphi, Ntheta, dealias, dtype):
348349
f = d.Field(bases=b)
349350
f.preset_scales(dealias)
350351
if np.iscomplexobj(dtype()):
351-
f['g'] = sph_harm(m, l, phi, theta)
352+
f['g'] = sph_harm_y(m, l, theta, phi)
352353
else:
353-
f['g'] = sph_harm(m, l, phi, theta).real
354+
f['g'] = sph_harm_y(m, l, theta, phi).real
354355
# Evaluate Laplacian
355356
u = operators.Laplacian(f).evaluate()
356357
assert np.allclose(u['g'], -f['g']*(l*(l+1))/radius**2)
@@ -367,9 +368,9 @@ def test_laplacian_scalar_implicit(Nphi, Ntheta, dealias, dtype):
367368
f = d.Field(bases=b)
368369
f.preset_scales(dealias)
369370
if np.iscomplexobj(dtype()):
370-
f['g'] = sph_harm(m, l, phi, theta)
371+
f['g'] = sph_harm_y(m, l, theta, phi)
371372
else:
372-
f['g'] = sph_harm(m, l, phi, theta).real
373+
f['g'] = sph_harm_y(m, l, theta, phi).real
373374
# Poisson LBVP
374375
u = d.Field(bases=b)
375376
tau = d.Field()
@@ -397,8 +398,8 @@ def test_laplacian_scalar_implicit(Nphi, Ntheta, dealias, dtype):
397398
# l0 = 1
398399
# m1 = 1
399400
# l1 = 2
400-
# f['g'][0] = sph_harm(m0,l0,phi,theta)
401-
# f['g'][1] = sph_harm(m1,l1,phi,theta)
401+
# f['g'][0] = sph_harm_y(m0,l0,theta,phi)
402+
# f['g'][1] = sph_harm_y(m1,l1,theta,phi)
402403
# lap = lambda A: operators.Laplacian(A,c)
403404
# problem = problems.LBVP([u])
404405
# problem.add_equation((lap(u),f))

0 commit comments

Comments
 (0)