From 93a3e764d6a3d630f9f4a23ab9fe8673e178f379 Mon Sep 17 00:00:00 2001 From: Terrence Tricco Date: Sun, 21 Jul 2024 12:01:22 -0230 Subject: [PATCH] linting --- sarracen/readers/read_phantom.py | 6 ++++-- sarracen/render.py | 18 +++++++++--------- sarracen/sarracen_dataframe.py | 3 +-- sarracen/tests/test_render.py | 10 ++++++---- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/sarracen/readers/read_phantom.py b/sarracen/readers/read_phantom.py index 482c915..03f779d 100644 --- a/sarracen/readers/read_phantom.py +++ b/sarracen/readers/read_phantom.py @@ -222,8 +222,10 @@ def _create_aprmass_column(df, header_vars): return df - -def read_phantom(filename: str, separate_types: str = 'sinks', ignore_inactive: bool = True): + +def read_phantom(filename: str, + separate_types: str = 'sinks', + ignore_inactive: bool = True): """ Read data from a Phantom dump file. diff --git a/sarracen/render.py b/sarracen/render.py index ccf48bf..a446ad4 100644 --- a/sarracen/render.py +++ b/sarracen/render.py @@ -207,10 +207,10 @@ def render(data: 'SarracenDataFrame', # noqa: F821 log_scale: bool Whether to use a logarithmic scale for color coding. symlog_scale: bool - Whether to use a symmetrical logarithmic scale for color coding (i.e., - allows positive and negative values). Optionally add "linthresh" and - "linscale" to kwargs to set the linear region and the scaling of linear - values, respectively (defaults to 1e-9 and 1, respectevely). Only works + Whether to use a symmetrical logarithmic scale for color coding (i.e., + allows positive and negative values). Optionally add "linthresh" and + "linscale" to kwargs to set the linear region and the scaling of linear + values, respectively (defaults to 1e-9 and 1, respectevely). Only works if log_scale == True. cototation: list, optional Moves particles to the co-rotating frame of two location. corotation @@ -314,14 +314,14 @@ def render(data: 'SarracenDataFrame', # noqa: F821 kwargs.setdefault("extent", [xlim[0], xlim[1], ylim[0], ylim[1]]) if log_scale: if symlog_scale: - kwargs.setdefault("norm", - SymLogNorm(kwargs.pop("linthresh", 1e-9), + kwargs.setdefault("norm", + SymLogNorm(kwargs.pop("linthresh", 1e-9), linscale=kwargs.pop("linscale", 1.), - vmin=kwargs.get('vmin'), + vmin=kwargs.get('vmin'), vmax=kwargs.get('vmax'))) else: - kwargs.setdefault("norm", LogNorm(clip=True, - vmin=kwargs.get('vmin'), + kwargs.setdefault("norm", LogNorm(clip=True, + vmin=kwargs.get('vmin'), vmax=kwargs.get('vmax'))) kwargs.pop("vmin", None) kwargs.pop("vmax", None) diff --git a/sarracen/sarracen_dataframe.py b/sarracen/sarracen_dataframe.py index 71ab7db..be0a2ca 100644 --- a/sarracen/sarracen_dataframe.py +++ b/sarracen/sarracen_dataframe.py @@ -302,10 +302,9 @@ def render(self, return render(self, target, x, y, z, xsec, kernel, x_pixels, y_pixels, xlim, ylim, cmap, cbar, cbar_kws, cbar_ax, ax, exact, backend, integral_samples, rotation, rot_origin, - log_scale, symlog_scale, dens_weight, normalize, hmin, + log_scale, symlog_scale, dens_weight, normalize, hmin, **kwargs) - @_copy_doc(lineplot) def lineplot(self, target: str, diff --git a/sarracen/tests/test_render.py b/sarracen/tests/test_render.py index c935361..dfdc053 100644 --- a/sarracen/tests/test_render.py +++ b/sarracen/tests/test_render.py @@ -153,8 +153,9 @@ def test_kwargs(backend): 'h': [1, 1], 'rho': [1, 1], 'm': [1, 1]} sdf_3 = SarracenDataFrame(data_3) sdf_3.backend = backend - df_4 = pd.DataFrame({'x': [-3, 6], 'y': [5, -1], 'z': [2, 1], 'P': [-1, 1], 'h': [1, 1], 'rho': [-1, -1], 'm': [1, 1]}) - sdf_4 = SarracenDataFrame(df_4) + data_4 = {'x': [-3, 6], 'y': [5, -1], 'z': [2, 1], 'P': [-1, 1], + 'h': [1, 1], 'rho': [-1, -1], 'm': [1, 1]} + sdf_4 = SarracenDataFrame(data_4) sdf_4.backend = backend for args in [{'data': sdf_2, 'xsec': None}, @@ -164,10 +165,11 @@ def test_kwargs(backend): render(args['data'], 'P', xsec=args['xsec'], ax=ax, origin='upper') assert ax.images[0].origin == 'upper' plt.close(fig) - + for arg in [True, False]: fig, ax = plt.subplots() - render(sdf_4, 'P', ax=ax, log_scale=arg, symlog_scale=True, origin='upper', vmin=-1., vmax=1.) + render(sdf_4, 'P', ax=ax, log_scale=arg, symlog_scale=True, + origin='upper', vmin=-1., vmax=1.) assert ax.images[0].origin == 'upper' plt.close(fig)