From 42e09420e97c29f04c7a23048f4c002029a8cd7d Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Fri, 6 Dec 2024 19:35:10 +0100 Subject: [PATCH] == None replaed with is None --- Utilities/pythontools/py_spec/output/_plot_iota.py | 4 ++-- .../pythontools/py_spec/output/_plot_kam_surface.py | 4 ++-- Utilities/pythontools/py_spec/output/_plot_modB.py | 2 +- .../pythontools/py_spec/output/_plot_poincare.py | 11 ++++++++--- .../pythontools/py_spec/output/_plot_pressure.py | 4 ++-- Utilities/pythontools/py_spec/output/spec.py | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_plot_iota.py b/Utilities/pythontools/py_spec/output/_plot_iota.py index 362075e5..bf653b6b 100644 --- a/Utilities/pythontools/py_spec/output/_plot_iota.py +++ b/Utilities/pythontools/py_spec/output/_plot_iota.py @@ -16,10 +16,10 @@ def plot_iota(self, xaxis="R", yaxis="i", ax=None, **kwargs): plt.sca(ax) # set default plotting parameters # use dots - if kwargs.get("marker") == None: + if "marker" not in kwargs: kwargs.update({"marker": "*"}) # use gray color - if kwargs.get("c") == None: + if "c" not in kwargs: pass # kwargs.update({"c": "gray"}) diff --git a/Utilities/pythontools/py_spec/output/_plot_kam_surface.py b/Utilities/pythontools/py_spec/output/_plot_kam_surface.py index b9d7d7db..969cda27 100644 --- a/Utilities/pythontools/py_spec/output/_plot_kam_surface.py +++ b/Utilities/pythontools/py_spec/output/_plot_kam_surface.py @@ -28,9 +28,9 @@ def plot_kam_surface(self, ns=[], ntheta=1000, zeta=0.0, ax=None, **kwargs): fig, ax = plt.subplots() plt.sca(ax) # set default plotting parameters - if kwargs.get("label") == None: + if "label" not in kwargs: kwargs.update({"label": "SPEC_KAM"}) # default label - if kwargs.get("c") == None: + if "c" not in kwargs: kwargs.update({"c": "red"}) # plot all the surfaces if Igeometry == 3: diff --git a/Utilities/pythontools/py_spec/output/_plot_modB.py b/Utilities/pythontools/py_spec/output/_plot_modB.py index e5051eab..1a32b839 100644 --- a/Utilities/pythontools/py_spec/output/_plot_modB.py +++ b/Utilities/pythontools/py_spec/output/_plot_modB.py @@ -23,7 +23,7 @@ def plot_modB( import matplotlib.pyplot as plt Nvol = self.input.physics.Nvol - if lvol == None: + if lvol is None: lvollist = np.arange(0, Nvol, dtype=int).tolist() elif np.isscalar(lvol): lvollist = [lvol] diff --git a/Utilities/pythontools/py_spec/output/_plot_poincare.py b/Utilities/pythontools/py_spec/output/_plot_poincare.py index 6de93211..89ab7522 100644 --- a/Utilities/pythontools/py_spec/output/_plot_poincare.py +++ b/Utilities/pythontools/py_spec/output/_plot_poincare.py @@ -31,19 +31,24 @@ def plot_poincare(self, toroidalIdx=0, prange="full", ax=None, **kwargs): zz = self.poincare.R[:, :, toroidalIdx] * np.sin( self.poincare.t[:, :, toroidalIdx] ) + + # Replace invalid values (unsuccessful tracing) with nan for plotting + zz[(self.poincare.success[:,np.newaxis]!=1) | ((rr==0) & (zz==0))] = np.nan + rr[(self.poincare.success[:,np.newaxis]!=1) | ((rr==0) & (zz==0))] = np.nan + # get axix data if ax is None: fig, ax = plt.subplots() plt.sca(ax) # set default plotting parameters # use dots - if kwargs.get("marker") == None: + if "marker" not in kwargs: kwargs.update({"marker": "."}) # use gray color - if kwargs.get("c") == None: + if "c" not in kwargs: pass # size of marker - if kwargs.get("s") == None: + if "s" not in kwargs: kwargs.update({"s": 0.3}) # kwargs.update({"c": "gray"}) # make plot depending on the 'range' diff --git a/Utilities/pythontools/py_spec/output/_plot_pressure.py b/Utilities/pythontools/py_spec/output/_plot_pressure.py index cb459a05..53a305bf 100644 --- a/Utilities/pythontools/py_spec/output/_plot_pressure.py +++ b/Utilities/pythontools/py_spec/output/_plot_pressure.py @@ -19,9 +19,9 @@ def plot_pressure(self, normalize=True, ax=None, **kwargs): fig, ax = plt.subplots() plt.sca(ax) # set default plotting parameters - if kwargs.get("linewidth") == None: + if "linewidth" not in kwargs: kwargs.update({"linewidth": 2.0}) # prefer thicker lines - if kwargs.get("label") == None: + if "label" not in kwargs: kwargs.update({"label": "self_pressure"}) # default label # process data _tflux = np.insert(tflux, 0, 0) diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index 99d06ca3..8391312f 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs): # as self.`args[0]` _content = None - if kwargs.get("content") == None: + if "content" not in kwargs: # assume arg[0] is a filename _content = h5py.File(args[0], "r")