Skip to content

Commit

Permalink
Fix some code quality and bug-risk issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pnijhara committed Apr 24, 2020
1 parent c788ee4 commit f835f1f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
18 changes: 18 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version = 1

test_patterns = [
"*/tests/**",
"*/test_*.py"
]

exclude_patterns = [
"doc/**",
"ci/**"
]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
6 changes: 3 additions & 3 deletions xarray/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ def _iris_cell_methods_to_str(cell_methods_obj):
"""
cell_methods = []
for cell_method in cell_methods_obj:
names = "".join([f"{n}: " for n in cell_method.coord_names])
names = "".join(f"{n}: " for n in cell_method.coord_names)
intervals = " ".join(
[f"interval: {interval}" for interval in cell_method.intervals]
f"interval: {interval}" for interval in cell_method.intervals
)
comments = " ".join([f"comment: {comment}" for comment in cell_method.comments])
comments = " ".join(f"comment: {comment}" for comment in cell_method.comments)
extra = " ".join([intervals, comments]).strip()
if extra:
extra = f" ({extra})"
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,10 @@ def dot(*arrays, dims=None, **kwargs):
# construct einsum subscripts, such as '...abc,...ab->...c'
# Note: input_core_dims are always moved to the last position
subscripts_list = [
"..." + "".join([dim_map[d] for d in ds]) for ds in input_core_dims
"..." + "".join(dim_map[d] for d in ds) for ds in input_core_dims
]
subscripts = ",".join(subscripts_list)
subscripts += "->..." + "".join([dim_map[d] for d in output_core_dims[0]])
subscripts += "->..." + "".join(dim_map[d] for d in output_core_dims[0])

join = OPTIONS["arithmetic_join"]
# using "inner" emulates `(a * b).sum()` for all joins (except "exact")
Expand Down
12 changes: 5 additions & 7 deletions xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,10 @@ def _summarize_coord_multiindex(coord, col_width, marker):

def _summarize_coord_levels(coord, col_width, marker="-"):
return "\n".join(
[
summarize_variable(
lname, coord.get_level_variable(lname), col_width, marker=marker
)
for lname in coord.level_names
]
summarize_variable(
lname, coord.get_level_variable(lname), col_width, marker=marker
)
for lname in coord.level_names
)


Expand Down Expand Up @@ -562,7 +560,7 @@ def extra_items_repr(extra_keys, mapping, ab_side):

for m in (a_mapping, b_mapping):
attr_s = "\n".join(
[summarize_attr(ak, av) for ak, av in m[k].attrs.items()]
summarize_attr(ak, av) for ak, av in m[k].attrs.items()
)
attrs_summary.append(attr_s)

Expand Down
4 changes: 3 additions & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def __init__(
grouper=None,
bins=None,
restore_coord_dims=None,
cut_kwargs={},
cut_kwargs=None,
):
"""Create a GroupBy object
Expand All @@ -299,6 +299,8 @@ def __init__(
Extra keyword arguments to pass to `pandas.cut`
"""
if cut_kwargs is None:
cut_kwargs = {}
from .dataarray import DataArray

if grouper is not None and bins is not None:
Expand Down
2 changes: 1 addition & 1 deletion xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

def _infer_line_data(darray, x, y, hue):
error_msg = "must be either None or one of ({:s})".format(
", ".join([repr(dd) for dd in darray.dims])
", ".join(repr(dd) for dd in darray.dims)
)
ndims = len(darray.dims)

Expand Down

0 comments on commit f835f1f

Please sign in to comment.