Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Commit 7bf681d

Browse files
committed
Merge pull request #137 from dstansby/bg-overwrite
Prevent bg being modified in place
1 parent 53cce31 commit 7bf681d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/changes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.4.2
5+
-----
6+
7+
- Fix a bug where :class`pfsspy.tracing.FotranTracer` would overwrite the
8+
magnetic field values in an :class:`~pfsspy.Output` each time it was used.
9+
410
0.4.1
511
-----
612

pfsspy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ def bg(self):
362362
bpg[i, :, :] /= (Sbp[:-1, :-1] + Sbp[1:, :-1] +
363363
Sbp[1:, 1:] + Sbp[:-1, 1:])
364364
bsg *= -1
365-
return np.stack((bpg, bsg, brg), axis=-1)
365+
out = np.stack((bpg, bsg, brg), axis=-1)
366+
out.flags.writeable = False
367+
return out
366368

367369
def _common_b(self):
368370
"""

pfsspy/tracing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def trace(self, seeds, output):
7878
self.validate_seeds_shape(seeds)
7979

8080
# The indexing order on the last index is (phi, s, r)
81-
vectors = output.bg
81+
vectors = output.bg.copy()
8282

8383
# Correct s direction for coordinate system distortion
8484
sqrtsg = output.grid._sqrtsg_correction

0 commit comments

Comments
 (0)