From ce607b594a14b21fad6a55758f6b9e1082d0b83d Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 11 Aug 2021 20:29:14 -0700 Subject: [PATCH 1/4] Use isort's float-to-top --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index c44d207bf0f..2059d471e23 100644 --- a/setup.cfg +++ b/setup.cfg @@ -161,7 +161,7 @@ exclude= [isort] profile = black skip_gitignore = true -force_to_top = true +float_to_top = true default_section = THIRDPARTY known_first_party = xarray From c0854610c80a48b526f0dda2fd6d8f3c161dceb1 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 12 Aug 2021 11:15:12 -0700 Subject: [PATCH 2/4] . --- properties/test_encode_decode.py | 4 ++-- xarray/core/parallel.py | 19 ++++++++++--------- xarray/tests/test_units.py | 11 ++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/properties/test_encode_decode.py b/properties/test_encode_decode.py index 221083e16a1..8f1d232ba2f 100644 --- a/properties/test_encode_decode.py +++ b/properties/test_encode_decode.py @@ -6,14 +6,14 @@ """ import pytest # isort:skip -pytest.importorskip("hypothesis") - +pytest.importorskip("hypothesis") # isort:split import hypothesis.extra.numpy as npst import hypothesis.strategies as st from hypothesis import given import xarray as xr + an_array = npst.arrays( dtype=st.one_of( npst.unsigned_integer_dtypes(), npst.integer_dtypes(), npst.floating_dtypes() diff --git a/xarray/core/parallel.py b/xarray/core/parallel.py index 2c7f4249b5e..20ec3608ebb 100644 --- a/xarray/core/parallel.py +++ b/xarray/core/parallel.py @@ -1,12 +1,3 @@ -try: - import dask - import dask.array - from dask.array.utils import meta_from_array - from dask.highlevelgraph import HighLevelGraph - -except ImportError: - pass - import collections import itertools import operator @@ -31,6 +22,16 @@ from .dataarray import DataArray from .dataset import Dataset +try: + import dask + import dask.array + from dask.array.utils import meta_from_array + from dask.highlevelgraph import HighLevelGraph + +except ImportError: + pass + + T_DSorDA = TypeVar("T_DSorDA", DataArray, Dataset) diff --git a/xarray/tests/test_units.py b/xarray/tests/test_units.py index 2140047f38e..543100ef98c 100644 --- a/xarray/tests/test_units.py +++ b/xarray/tests/test_units.py @@ -5,11 +5,6 @@ import pandas as pd import pytest -try: - import matplotlib.pyplot as plt -except ImportError: - pass - import xarray as xr from xarray.core import dtypes, duck_array_ops @@ -23,6 +18,12 @@ from .test_plot import PlotTestCase from .test_variable import _PAD_XR_NP_ARGS +try: + import matplotlib.pyplot as plt +except ImportError: + pass + + pint = pytest.importorskip("pint") DimensionalityError = pint.errors.DimensionalityError From 22330b5af9a169a3b14d152fa91d4378b9a4202b Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 12 Aug 2021 18:26:59 -0700 Subject: [PATCH 3/4] --- properties/test_encode_decode.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/properties/test_encode_decode.py b/properties/test_encode_decode.py index 8f1d232ba2f..4b0643cb2fe 100644 --- a/properties/test_encode_decode.py +++ b/properties/test_encode_decode.py @@ -4,16 +4,17 @@ These ones pass, just as you'd hope! """ -import pytest # isort:skip +import pytest + +pytest.importorskip("hypothesis") +# isort: split -pytest.importorskip("hypothesis") # isort:split import hypothesis.extra.numpy as npst import hypothesis.strategies as st from hypothesis import given import xarray as xr - an_array = npst.arrays( dtype=st.one_of( npst.unsigned_integer_dtypes(), npst.integer_dtypes(), npst.floating_dtypes() From 7b51243a482fd0e293116d89d2543d0a3642b9a6 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 18 Aug 2021 22:15:34 -0700 Subject: [PATCH 4/4] whatsnew for float-to-top --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 3dad685aaf7..20d9bda6d54 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -49,6 +49,8 @@ Internal Changes By `Benoit Bovy `_. - Improve the performance of reprs for large datasets or dataarrays. (:pull:`5661`) By `Jimmy Westling `_. +- Use isort's `float_to_top` config. (:pull:`5695`). + By `Maximilian Roos `_. .. _whats-new.0.19.0: