Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ttricco committed Jul 21, 2024
1 parent 8649dee commit 93a3e76
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
6 changes: 4 additions & 2 deletions sarracen/readers/read_phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions sarracen/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions sarracen/sarracen_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions sarracen/tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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)

Expand Down

0 comments on commit 93a3e76

Please sign in to comment.