From 086dcee7acb5547d49903caaf96b5d666602e1fd Mon Sep 17 00:00:00 2001 From: mwoss Date: Thu, 3 Jan 2019 03:15:28 +0100 Subject: [PATCH 1/2] Fix import format at pandas/tests/io/plotting directory --- pandas/tests/plotting/common.py | 21 ++++++++------ pandas/tests/plotting/test_boxplot_method.py | 15 +++++----- pandas/tests/plotting/test_converter.py | 17 +++++++----- pandas/tests/plotting/test_datetimelike.py | 27 +++++++++--------- pandas/tests/plotting/test_frame.py | 29 ++++++++++---------- pandas/tests/plotting/test_groupby.py | 8 +++--- pandas/tests/plotting/test_hist_method.py | 12 ++++---- pandas/tests/plotting/test_misc.py | 12 ++++---- pandas/tests/plotting/test_series.py | 20 +++++++------- setup.cfg | 10 ------- 10 files changed, 83 insertions(+), 88 deletions(-) diff --git a/pandas/tests/plotting/common.py b/pandas/tests/plotting/common.py index f41a3a10604af..4ca916a0aa4e4 100644 --- a/pandas/tests/plotting/common.py +++ b/pandas/tests/plotting/common.py @@ -1,25 +1,28 @@ #!/usr/bin/env python # coding: utf-8 -import pytest import os import warnings -from pandas import DataFrame, Series -from pandas.compat import zip, iteritems +import numpy as np +from numpy import random +import pytest + +from pandas.compat import iteritems, zip from pandas.util._decorators import cache_readonly -from pandas.core.dtypes.api import is_list_like -import pandas.util.testing as tm -from pandas.util.testing import (ensure_clean, - assert_is_valid_plot_return_object) import pandas.util._test_decorators as td -import numpy as np -from numpy import random +from pandas.core.dtypes.api import is_list_like + +from pandas import DataFrame, Series +import pandas.util.testing as tm +from pandas.util.testing import ( + assert_is_valid_plot_return_object, ensure_clean) import pandas.plotting as plotting from pandas.plotting._tools import _flatten + """ This is a common base class used for various plotting tests """ diff --git a/pandas/tests/plotting/test_boxplot_method.py b/pandas/tests/plotting/test_boxplot_method.py index e89584ca35d94..7d721c7de3398 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -1,21 +1,20 @@ # coding: utf-8 -import pytest import itertools import string -from pandas import Series, DataFrame, MultiIndex -from pandas.compat import range, lzip -import pandas.util.testing as tm -import pandas.util._test_decorators as td - import numpy as np from numpy import random +import pytest -import pandas.plotting as plotting +from pandas.compat import lzip, range +import pandas.util._test_decorators as td -from pandas.tests.plotting.common import (TestPlotBase, _check_plot_works) +from pandas import DataFrame, MultiIndex, Series +from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +import pandas.util.testing as tm +import pandas.plotting as plotting """ Test cases for .boxplot method """ diff --git a/pandas/tests/plotting/test_converter.py b/pandas/tests/plotting/test_converter.py index eed3679c5bc8c..ef3a8dd82d301 100644 --- a/pandas/tests/plotting/test_converter.py +++ b/pandas/tests/plotting/test_converter.py @@ -1,19 +1,22 @@ +from datetime import date, datetime import subprocess import sys -import pytest -from datetime import datetime, date import numpy as np -from pandas import Timestamp, Period, Index, date_range, Series +import pytest + from pandas.compat import u +from pandas.compat.numpy import np_datetime64_compat + +from pandas import Index, Period, Series, Timestamp, date_range import pandas.core.config as cf import pandas.util.testing as tm -from pandas.tseries.offsets import Second, Milli, Micro, Day -from pandas.compat.numpy import np_datetime64_compat + +from pandas.plotting import ( + deregister_matplotlib_converters, register_matplotlib_converters) +from pandas.tseries.offsets import Day, Micro, Milli, Second converter = pytest.importorskip('pandas.plotting._converter') -from pandas.plotting import (register_matplotlib_converters, - deregister_matplotlib_converters) def test_timtetonum_accepts_unicode(): diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 7a28f05514dd5..c78ab41d2fae4 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -1,26 +1,25 @@ """ Test cases for time series specific (freq conversion, etc) """ -import sys -from datetime import datetime, timedelta, date, time +from datetime import date, datetime, time, timedelta import pickle +import sys +import numpy as np import pytest -from pandas.compat import lrange, zip -import numpy as np -from pandas import Index, Series, DataFrame, NaT, isna -from pandas.compat import PY3 -from pandas.core.indexes.datetimes import date_range, bdate_range +from pandas.compat import PY3, lrange, zip +import pandas.util._test_decorators as td + +from pandas import DataFrame, Index, NaT, Series, isna +from pandas.core.indexes.datetimes import bdate_range, date_range +from pandas.core.indexes.period import Period, PeriodIndex, period_range from pandas.core.indexes.timedeltas import timedelta_range -from pandas.tseries.offsets import DateOffset -from pandas.core.indexes.period import period_range, Period, PeriodIndex from pandas.core.resample import DatetimeIndex - -from pandas.util.testing import assert_series_equal, ensure_clean +from pandas.tests.plotting.common import ( + TestPlotBase, _skip_if_no_scipy_gaussian_kde) import pandas.util.testing as tm -import pandas.util._test_decorators as td +from pandas.util.testing import assert_series_equal, ensure_clean -from pandas.tests.plotting.common import (TestPlotBase, - _skip_if_no_scipy_gaussian_kde) +from pandas.tseries.offsets import DateOffset @td.skip_if_no_mpl diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index cc52130a10b2e..436ccef48ae12 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2,28 +2,29 @@ """ Test cases for DataFrame.plot """ -import pytest +from datetime import date, datetime import string import warnings -from datetime import datetime, date +import numpy as np +from numpy.random import rand, randn +import pytest -import pandas as pd -from pandas import (Series, DataFrame, MultiIndex, PeriodIndex, date_range, - bdate_range) -from pandas.core.dtypes.api import is_list_like -from pandas.compat import range, lrange, lmap, lzip, u, zip, PY3 -from pandas.io.formats.printing import pprint_thing -import pandas.util.testing as tm +from pandas.compat import PY3, lmap, lrange, lzip, range, u, zip import pandas.util._test_decorators as td -import numpy as np -from numpy.random import rand, randn +from pandas.core.dtypes.api import is_list_like +import pandas as pd +from pandas import ( + DataFrame, MultiIndex, PeriodIndex, Series, bdate_range, date_range) +from pandas.tests.plotting.common import ( + TestPlotBase, _check_plot_works, _ok_for_gaussian_kde, + _skip_if_no_scipy_gaussian_kde) +import pandas.util.testing as tm + +from pandas.io.formats.printing import pprint_thing import pandas.plotting as plotting -from pandas.tests.plotting.common import (TestPlotBase, _check_plot_works, - _skip_if_no_scipy_gaussian_kde, - _ok_for_gaussian_kde) @td.skip_if_no_mpl diff --git a/pandas/tests/plotting/test_groupby.py b/pandas/tests/plotting/test_groupby.py index a7c99a06c34e9..5a5ee75928c97 100644 --- a/pandas/tests/plotting/test_groupby.py +++ b/pandas/tests/plotting/test_groupby.py @@ -3,13 +3,13 @@ """ Test cases for GroupBy.plot """ -from pandas import Series, DataFrame -import pandas.util.testing as tm -import pandas.util._test_decorators as td - import numpy as np +import pandas.util._test_decorators as td + +from pandas import DataFrame, Series from pandas.tests.plotting.common import TestPlotBase +import pandas.util.testing as tm @td.skip_if_no_mpl diff --git a/pandas/tests/plotting/test_hist_method.py b/pandas/tests/plotting/test_hist_method.py index 1d9942603a269..7bdbdac54f7a6 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -2,18 +2,18 @@ """ Test cases for .hist method """ +import numpy as np +from numpy.random import randn import pytest -from pandas import Series, DataFrame -import pandas.util.testing as tm import pandas.util._test_decorators as td -import numpy as np -from numpy.random import randn +from pandas import DataFrame, Series +from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +import pandas.util.testing as tm -from pandas.plotting._core import grouped_hist from pandas.plotting._compat import _mpl_ge_2_2_0 -from pandas.tests.plotting.common import (TestPlotBase, _check_plot_works) +from pandas.plotting._core import grouped_hist @td.skip_if_no_mpl diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index de9e2a16cd15e..44b95f7d1b00b 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -2,19 +2,19 @@ """ Test cases for misc plot functions """ +import numpy as np +from numpy import random +from numpy.random import randn import pytest -from pandas import DataFrame from pandas.compat import lmap -import pandas.util.testing as tm import pandas.util._test_decorators as td -import numpy as np -from numpy import random -from numpy.random import randn +from pandas import DataFrame +from pandas.tests.plotting.common import TestPlotBase, _check_plot_works +import pandas.util.testing as tm import pandas.plotting as plotting -from pandas.tests.plotting.common import TestPlotBase, _check_plot_works @td.skip_if_mpl diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index b857979005f5e..39f8f2f44fda0 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -3,24 +3,24 @@ """ Test cases for Series.plot """ +from datetime import datetime from itertools import chain + +import numpy as np +from numpy.random import randn import pytest -from datetime import datetime +from pandas.compat import lrange, range +import pandas.util._test_decorators as td import pandas as pd -from pandas import Series, DataFrame, date_range -from pandas.compat import range, lrange +from pandas import DataFrame, Series, date_range +from pandas.tests.plotting.common import ( + TestPlotBase, _check_plot_works, _ok_for_gaussian_kde, + _skip_if_no_scipy_gaussian_kde) import pandas.util.testing as tm -import pandas.util._test_decorators as td - -import numpy as np -from numpy.random import randn import pandas.plotting as plotting -from pandas.tests.plotting.common import (TestPlotBase, _check_plot_works, - _skip_if_no_scipy_gaussian_kde, - _ok_for_gaussian_kde) @td.skip_if_no_mpl diff --git a/setup.cfg b/setup.cfg index 032a41df90f83..938e086828c69 100644 --- a/setup.cfg +++ b/setup.cfg @@ -135,16 +135,6 @@ skip= pandas/tests/arithmetic/conftest.py, pandas/tests/arithmetic/test_timedelta64.py, pandas/tests/internals/test_internals.py, - pandas/tests/plotting/test_datetimelike.py, - pandas/tests/plotting/test_series.py, - pandas/tests/plotting/test_groupby.py, - pandas/tests/plotting/test_converter.py, - pandas/tests/plotting/test_misc.py, - pandas/tests/plotting/test_frame.py, - pandas/tests/plotting/test_hist_method.py, - pandas/tests/plotting/common.py, - pandas/tests/plotting/test_boxplot_method.py, - pandas/tests/plotting/test_deprecated.py, pandas/tests/extension/test_sparse.py, pandas/tests/extension/base/reduce.py, pandas/tests/computation/test_compat.py, From 6a740c818b043bd53ba17981e7fc81f917cfa06d Mon Sep 17 00:00:00 2001 From: mwoss Date: Fri, 4 Jan 2019 02:48:45 +0100 Subject: [PATCH 2/2] Skip converters import --- pandas/tests/plotting/test_converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/plotting/test_converter.py b/pandas/tests/plotting/test_converter.py index ef3a8dd82d301..01aa8e8ccc1ee 100644 --- a/pandas/tests/plotting/test_converter.py +++ b/pandas/tests/plotting/test_converter.py @@ -12,11 +12,11 @@ import pandas.core.config as cf import pandas.util.testing as tm -from pandas.plotting import ( - deregister_matplotlib_converters, register_matplotlib_converters) from pandas.tseries.offsets import Day, Micro, Milli, Second converter = pytest.importorskip('pandas.plotting._converter') +from pandas.plotting import (deregister_matplotlib_converters, # isort:skip + register_matplotlib_converters) def test_timtetonum_accepts_unicode():