use moveaxis instead of deprecated rollaxis

This commit is contained in:
Jan Petykiewicz 2022-11-20 19:55:51 -08:00
parent 23d5a160c8
commit 68a9818388
2 changed files with 5 additions and 5 deletions

View File

@ -146,7 +146,7 @@ def generate_kmn(
Gi = numpy.moveaxis(Gi_grids, 0, -1)
k_G = k0[None, None, None, :] - Gi
k_xyz = numpy.rollaxis(G_matrix @ numpy.rollaxis(k_G, 3, 2), 3, 2)
k_xyz = numpy.moveaxis(G_matrix @ numpy.moveaxis(k_G, 3, 2), 3, 2)
m = numpy.broadcast_to([0, 1, 0], tuple(shape[:3]) + (3,)).astype(float)
n = numpy.broadcast_to([0, 0, 1], tuple(shape[:3]) + (3,)).astype(float)
@ -283,7 +283,7 @@ def hmn_2_exyz(
- m * hin_n) * k_mag
# divide by epsilon
return numpy.array([ei for ei in numpy.rollaxis(ifftn(d_xyz, axes=range(3)) / epsilon, 3)]) # TODO avoid copy
return numpy.array([ei for ei in numpy.moveaxis(ifftn(d_xyz, axes=range(3)) / epsilon, 3, 0)]) # TODO avoid copy
return operator
@ -319,7 +319,7 @@ def hmn_2_hxyz(
hin_m, hin_n = [hi.reshape(shape) for hi in numpy.split(h, 2)]
h_xyz = (m * hin_m
+ n * hin_n)
return numpy.array([ifftn(hi) for hi in numpy.rollaxis(h_xyz, 3)])
return numpy.array([ifftn(hi) for hi in numpy.moveaxis(h_xyz, 3, 0)])
return operator

View File

@ -15,8 +15,8 @@ def assert_fields_close(
) -> None:
numpy.testing.assert_allclose(
x, y, verbose=False,
err_msg='Fields did not match:\n{}\n{}'.format(numpy.rollaxis(x, -1),
numpy.rollaxis(y, -1)),
err_msg='Fields did not match:\n{}\n{}'.format(numpy.moveaxis(x, -1, 0),
numpy.moveaxis(y, -1, 0)),
*args,
**kwargs,
)