Skip to content

Commit

Permalink
FIX: Add isinstance checks to improve linting (#1444)
Browse files Browse the repository at this point in the history
* FIX: Add isinstance checks to improve linting

* fix other linting errors with f-strings
  • Loading branch information
mgrover1 authored Aug 11, 2023
1 parent 5f04168 commit 35d6013
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions pyart/aux_io/sinarame_h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ def write_sinarame_cfradial(path):
radar._DeflateLevel = 5

# cfrad.TIME1_to_TIME2_NAME_VCP_RANGE.nc
cffile = "cfrad.{time1}.0000_to_{time2}.0000" "_{b1}_{est}_{ran}".format(
time1=time1, time2=time2, b1=bs[0], est=bs[1], ran=bs[2]
)
cffile = f"cfrad.{time1}.0000_to_{time2}.0000" f"_{bs[0]}_{bs[1]}_{bs[2]}"

print(f"Writing to {path_user}{cffile}.nc")
write_cfradial(
Expand Down
2 changes: 1 addition & 1 deletion pyart/graph/radardisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ def plot_labels(self, labels, locations, symbols="r+", text_color="k", ax=None):
"""
ax = common.parse_ax(ax)

if type(symbols) is str:
if isinstance(symbols, str):
symbols = [symbols] * len(labels)
if len(labels) != len(locations):
raise ValueError("length of labels and locations must match")
Expand Down
6 changes: 3 additions & 3 deletions pyart/io/cfradial.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def read_cfradial(
exclude_fields=None,
include_fields=None,
delay_field_loading=False,
**kwargs
**kwargs,
):
"""
Read a Cfradial 1.4 netCDF file.
Expand Down Expand Up @@ -921,12 +921,12 @@ def _calculate_scale_and_offset(dic, dtype, minimum=None, maximum=None):
if maximum < minimum:
raise ValueError(
"Error calculating variable scaling: "
"maximum: {:f} is smaller than minimum: {:f}".format(maximum, minimum)
f"maximum: {maximum:f} is smaller than minimum: {minimum:f}"
)
elif maximum == minimum:
warnings.warn(
"While calculating variable scaling: "
"maximum: {:f} is equal to minimum: {:f}".format(maximum, minimum)
f"maximum: {maximum:f} is equal to minimum: {minimum:f}"
)
maximum = minimum + 1

Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_cfradial.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def attribute_equal(class1, class2, key, allow_str_case_diff=True):

assert type(a1) == type(a2)

if type(a1) is str and allow_str_case_diff:
if isinstance(a1, str) and allow_str_case_diff:
assert a1.upper() == a2.upper()
else:
assert a1 == a2
Expand Down

0 comments on commit 35d6013

Please sign in to comment.