Skip to content

Commit 0d81d7a

Browse files
More Pylint issues (#10463)
1 parent f799548 commit 0d81d7a

18 files changed

+9
-40
lines changed

properties/test_index_manipulation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,13 @@ def assert_invariants(self):
261261

262262
@pytest.mark.skip(reason="failure detected by hypothesis")
263263
def test_unstack_object():
264-
import xarray as xr
265-
266264
ds = xr.Dataset()
267265
ds["0"] = np.array(["", "\x000"], dtype=object)
268266
ds.stack({"1": ["0"]}).unstack()
269267

270268

271269
@pytest.mark.skip(reason="failure detected by hypothesis")
272270
def test_unstack_timedelta_index():
273-
import xarray as xr
274-
275271
ds = xr.Dataset()
276272
ds["0"] = np.array([0, 1, 2, 3], dtype="timedelta64[ns]")
277273
ds.stack({"1": ["0"]}).unstack()

xarray/coding/cftime_offsets.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,6 @@ def date_range(
14191419
cftime_range
14201420
date_range_like
14211421
"""
1422-
from xarray.coding.times import _is_standard_calendar
1423-
14241422
if tz is not None:
14251423
use_cftime = False
14261424

xarray/coding/cftimeindex.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,6 @@ def asi8(self):
689689
@property
690690
def calendar(self):
691691
"""The calendar used by the datetimes in the index."""
692-
from xarray.coding.times import infer_calendar_name
693-
694692
if not self._data.size:
695693
return None
696694

xarray/computation/apply_ufunc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ def apply_groupby_func(func, *args):
569569
DataArray, Variable and/or ndarray objects.
570570
"""
571571
from xarray.core.groupby import GroupBy, peek_at
572-
from xarray.core.variable import Variable
573572

574573
groupbys = [arg for arg in args if isinstance(arg, GroupBy)]
575574
assert groupbys, "must have at least one groupby to iterate over"

xarray/computation/computation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ def dot(
574574
array(235)
575575
"""
576576
from xarray.core.dataarray import DataArray
577-
from xarray.core.variable import Variable
578577

579578
if any(not isinstance(arr, Variable | DataArray) for arr in arrays):
580579
raise TypeError(

xarray/computation/fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def _wrapper(Y, *args, **kwargs):
474474
mask = np.all([np.any(~np.isnan(x), axis=0), ~np.isnan(y)], axis=0)
475475
x = x[:, mask]
476476
y = y[mask]
477-
if not len(y):
477+
if y.size == 0:
478478
popt = np.full([n_params], np.nan)
479479
pcov = np.full([n_params, n_params], np.nan)
480480
return popt, pcov

xarray/computation/nanops.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def nansum(a, axis=None, dtype=None, out=None, min_count=None):
105105

106106
def _nanmean_ddof_object(ddof, value, axis=None, dtype=None, **kwargs):
107107
"""In house nanmean. ddof argument will be used in _nanvar method"""
108-
from xarray.core.duck_array_ops import count, fillna, where_method
109-
110108
valid_count = count(value, axis=axis)
111109
value = fillna(value, 0)
112110
# As dtype inference is impossible for object dtype, we assume float

xarray/core/dataset.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,6 @@ def _setitem_check(self, key, value):
13591359
to avoid leaving the dataset in a partially updated state when an error occurs.
13601360
"""
13611361
from xarray.core.dataarray import DataArray
1362-
from xarray.structure.alignment import align
13631362

13641363
if isinstance(value, Dataset):
13651364
missing_vars = [
@@ -2551,7 +2550,6 @@ def _validate_indexers(
25512550
+ string indexers are cast to the appropriate date type if the
25522551
associated index is a DatetimeIndex or CFTimeIndex
25532552
"""
2554-
from xarray.coding.cftimeindex import CFTimeIndex
25552553
from xarray.core.dataarray import DataArray
25562554

25572555
indexers = drop_dims_from_indexers(indexers, self.dims, missing_dims)
@@ -8268,8 +8266,6 @@ def differentiate(
82688266
--------
82698267
numpy.gradient: corresponding numpy function
82708268
"""
8271-
from xarray.core.variable import Variable
8272-
82738269
if coord not in self.variables and coord not in self.dims:
82748270
variables_and_dims = tuple(set(self.variables.keys()).union(self.dims))
82758271
raise ValueError(

xarray/core/datatree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,6 @@ def _unary_op(self, f, *args, **kwargs) -> DataTree:
16291629
return self.map_over_datasets(functools.partial(f, **kwargs), *args) # type: ignore[return-value]
16301630

16311631
def _binary_op(self, other, f, reflexive=False, join=None) -> DataTree:
1632-
from xarray.core.dataset import Dataset
16331632
from xarray.core.groupby import GroupBy
16341633

16351634
if isinstance(other, GroupBy):

xarray/core/duck_array_ops.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949

5050

5151
def einsum(*args, **kwargs):
52-
from xarray.core.options import OPTIONS
53-
5452
if OPTIONS["use_opt_einsum"] and module_available("opt_einsum"):
5553
import opt_einsum
5654

@@ -681,9 +679,7 @@ def timedelta_to_numeric(value, datetime_unit="ns", dtype=float):
681679
The output data type.
682680
683681
"""
684-
import datetime as dt
685-
686-
if isinstance(value, dt.timedelta):
682+
if isinstance(value, datetime.timedelta):
687683
out = py_timedelta_to_float(value, datetime_unit)
688684
elif isinstance(value, np.timedelta64):
689685
out = np_timedelta64_to_float(value, datetime_unit)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy