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

Commit

Permalink
Merge pull request #137 from dstansby/bg-overwrite
Browse files Browse the repository at this point in the history
Prevent bg being modified in place
  • Loading branch information
dstansby committed Jan 3, 2020
1 parent 53cce31 commit 7bf681d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.4.2
-----

- Fix a bug where :class`pfsspy.tracing.FotranTracer` would overwrite the
magnetic field values in an :class:`~pfsspy.Output` each time it was used.

0.4.1
-----

Expand Down
4 changes: 3 additions & 1 deletion pfsspy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ def bg(self):
bpg[i, :, :] /= (Sbp[:-1, :-1] + Sbp[1:, :-1] +
Sbp[1:, 1:] + Sbp[:-1, 1:])
bsg *= -1
return np.stack((bpg, bsg, brg), axis=-1)
out = np.stack((bpg, bsg, brg), axis=-1)
out.flags.writeable = False
return out

def _common_b(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion pfsspy/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def trace(self, seeds, output):
self.validate_seeds_shape(seeds)

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

# Correct s direction for coordinate system distortion
sqrtsg = output.grid._sqrtsg_correction
Expand Down

0 comments on commit 7bf681d

Please sign in to comment.