#37538 TST: split up tests/plotting/test_frame.py into subdir & modules #34769

Closed Mikhaylov-yv
Coverage Reach
core/arrays/sparse/array.py core/arrays/sparse/dtype.py core/arrays/sparse/accessor.py core/arrays/sparse/scipy_sparse.py core/arrays/sparse/__init__.py core/arrays/categorical.py core/arrays/datetimelike.py core/arrays/datetimes.py core/arrays/interval.py core/arrays/timedeltas.py core/arrays/period.py core/arrays/integer.py core/arrays/boolean.py core/arrays/floating.py core/arrays/base.py core/arrays/numpy_.py core/arrays/string_.py core/arrays/masked.py core/arrays/_mixins.py core/arrays/_arrow_utils.py core/arrays/_ranges.py core/arrays/__init__.py core/indexes/base.py core/indexes/multi.py core/indexes/interval.py core/indexes/datetimelike.py core/indexes/range.py core/indexes/datetimes.py core/indexes/period.py core/indexes/category.py core/indexes/numeric.py core/indexes/extension.py core/indexes/accessors.py core/indexes/api.py core/indexes/timedeltas.py core/indexes/frozen.py core/internals/blocks.py core/internals/managers.py core/internals/construction.py core/internals/concat.py core/internals/ops.py core/internals/__init__.py core/groupby/groupby.py core/groupby/generic.py core/groupby/ops.py core/groupby/grouper.py core/groupby/numba_.py core/groupby/base.py core/groupby/categorical.py core/groupby/__init__.py core/reshape/merge.py core/reshape/reshape.py core/reshape/pivot.py core/reshape/concat.py core/reshape/tile.py core/reshape/melt.py core/reshape/util.py core/reshape/api.py core/generic.py core/dtypes/cast.py core/dtypes/dtypes.py core/dtypes/common.py core/dtypes/missing.py core/dtypes/concat.py core/dtypes/base.py core/dtypes/inference.py core/dtypes/generic.py core/dtypes/api.py core/frame.py core/computation/expr.py core/computation/pytables.py core/computation/ops.py core/computation/expressions.py core/computation/eval.py core/computation/scope.py core/computation/align.py core/computation/engines.py core/computation/parsing.py core/computation/common.py core/computation/check.py core/computation/api.py core/window/rolling.py core/window/ewm.py core/window/indexers.py core/window/expanding.py core/window/common.py core/window/numba_.py core/window/__init__.py core/strings/accessor.py core/strings/object_array.py core/strings/base.py core/strings/__init__.py core/series.py core/indexing.py core/algorithms.py core/ops/array_ops.py core/ops/__init__.py core/ops/docstrings.py core/ops/missing.py core/ops/mask_ops.py core/ops/common.py core/ops/methods.py core/ops/roperator.py core/ops/invalid.py core/ops/dispatch.py core/nanops.py core/resample.py core/tools/datetimes.py core/tools/times.py core/tools/numeric.py core/tools/timedeltas.py core/base.py core/missing.py core/aggregation.py core/apply.py core/sorting.py core/construction.py core/common.py core/config_init.py core/util/hashing.py core/util/numba_.py core/indexers.py core/array_algos/masked_reductions.py core/array_algos/replace.py core/array_algos/transforms.py core/accessor.py core/arraylike.py core/flags.py core/api.py core/shared_docs.py core/index.py core/sparse/api.py io/formats/format.py io/formats/style.py io/formats/excel.py io/formats/html.py io/formats/latex.py io/formats/info.py io/formats/printing.py io/formats/csvs.py io/formats/string.py io/formats/css.py io/formats/console.py io/pytables.py io/excel/_base.py io/excel/_openpyxl.py io/excel/_odfreader.py io/excel/_odswriter.py io/excel/_xlsxwriter.py io/excel/_xlwt.py io/excel/_util.py io/excel/_xlrd.py io/excel/_pyxlsb.py io/sas/sas7bdat.py io/sas/sas_xport.py io/sas/sas_constants.py io/sas/sasreader.py io/json/_json.py io/json/_table_schema.py io/json/_normalize.py io/html.py io/clipboard/__init__.py io/common.py io/parquet.py io/date_converters.py io/feather_format.py io/gbq.py io/api.py io/orc.py io/spss.py io/clipboards.py plotting/_matplotlib/core.py plotting/_matplotlib/converter.py plotting/_matplotlib/misc.py plotting/_matplotlib/boxplot.py plotting/_matplotlib/tools.py plotting/_matplotlib/hist.py plotting/_matplotlib/timeseries.py plotting/_matplotlib/style.py plotting/_matplotlib/__init__.py plotting/_matplotlib/compat.py plotting/_core.py plotting/_misc.py _testing.py util/_decorators.py util/_validators.py util/_doctools.py util/_test_decorators.py util/_print_versions.py util/_depr_module.py util/_tester.py util/_exceptions.py util/testing.py tseries/frequencies.py tseries/holiday.py tseries/api.py tseries/offsets.py compat/numpy/function.py compat/numpy/__init__.py compat/pickle_compat.py compat/_optional.py compat/__init__.py compat/chainmap.py _config/config.py _config/localization.py _config/display.py _config/dates.py _config/__init__.py errors/__init__.py _libs/tslibs/__init__.py _libs/__init__.py api/extensions/__init__.py api/types/__init__.py api/indexers/__init__.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 62 of 187 files from the diff.
Other files ignored by Codecov
ci/code_checks.sh has changed.
pandas/_typing.py has changed.

@@ -38,8 +38,7 @@
Loading
38 38
def _zip_axes_from_type(
39 39
    typ: Type[FrameOrSeries], new_axes: Sequence[int]
40 40
) -> Dict[str, int]:
41 -
    axes = {name: new_axes[i] for i, name in enumerate(typ._AXIS_ORDERS)}
42 -
    return axes
41 +
    return {name: new_axes[i] for i, name in enumerate(typ._AXIS_ORDERS)}
43 42
44 43
45 44
def _any_pandas_objects(terms) -> bool:
@@ -186,8 +185,11 @@
Loading
186 185
        # The condition is to distinguish 0-dim array (returned in case of
187 186
        # scalar) and 1 element array
188 187
        # e.g. np.array(0) and np.array([0])
189 -
        if len(obj.shape) == 1 and len(obj) == 1:
190 -
            if not isinstance(ret_value, np.ndarray):
191 -
                ret_value = np.array([ret_value]).astype(res_t)
188 +
        if (
189 +
            len(obj.shape) == 1
190 +
            and len(obj) == 1
191 +
            and not isinstance(ret_value, np.ndarray)
192 +
        ):
193 +
            ret_value = np.array([ret_value]).astype(res_t)
192 194
193 195
    return ret_value

@@ -1046,8 +1046,12 @@
Loading
1046 1046
        """
1047 1047
        from pandas.io.formats.csvs import CSVFormatter
1048 1048
1049 +
        created_buffer = path_or_buf is None
1050 +
        if created_buffer:
1051 +
            path_or_buf = StringIO()
1052 +
1049 1053
        csv_formatter = CSVFormatter(
1050 -
            path_or_buf=path_or_buf,
1054 +
            path_or_buf=path_or_buf,  # type: ignore[arg-type]
1051 1055
            line_terminator=line_terminator,
1052 1056
            sep=sep,
1053 1057
            encoding=encoding,
@@ -1067,9 +1071,11 @@
Loading
1067 1071
        )
1068 1072
        csv_formatter.save()
1069 1073
1070 -
        if path_or_buf is None:
1071 -
            assert isinstance(csv_formatter.path_or_buf, StringIO)
1072 -
            return csv_formatter.path_or_buf.getvalue()
1074 +
        if created_buffer:
1075 +
            assert isinstance(path_or_buf, StringIO)
1076 +
            content = path_or_buf.getvalue()
1077 +
            path_or_buf.close()
1078 +
            return content
1073 1079
1074 1080
        return None
1075 1081

@@ -2061,27 +2061,25 @@
Loading
2061 2061
        dtype, _ = infer_dtype_from_array(values)
2062 2062
        values = np.asarray(values, dtype=dtype)
2063 2063
2064 -
    def sort_mixed(values):
2065 -
        # order ints before strings, safe in py3
2066 -
        str_pos = np.array([isinstance(x, str) for x in values], dtype=bool)
2067 -
        nums = np.sort(values[~str_pos])
2068 -
        strs = np.sort(values[str_pos])
2069 -
        return np.concatenate([nums, np.asarray(strs, dtype=object)])
2070 -
2071 2064
    sorter = None
2065 +
2072 2066
    if (
2073 2067
        not is_extension_array_dtype(values)
2074 2068
        and lib.infer_dtype(values, skipna=False) == "mixed-integer"
2075 2069
    ):
2076 -
        # unorderable in py3 if mixed str/int
2077 -
        ordered = sort_mixed(values)
2070 +
        ordered = _sort_mixed(values)
2078 2071
    else:
2079 2072
        try:
2080 2073
            sorter = values.argsort()
2081 2074
            ordered = values.take(sorter)
2082 2075
        except TypeError:
2083 -
            # try this anyway
2084 -
            ordered = sort_mixed(values)
2076 +
            # Previous sorters failed or were not applicable, try `_sort_mixed`
2077 +
            # which would work, but which fails for special case of 1d arrays
2078 +
            # with tuples.
2079 +
            if values.size and isinstance(values[0], tuple):
2080 +
                ordered = _sort_tuples(values)
2081 +
            else:
2082 +
                ordered = _sort_mixed(values)
2085 2083
2086 2084
    # codes:
2087 2085
@@ -2128,3 +2126,26 @@
Loading
2128 2126
        np.putmask(new_codes, mask, na_sentinel)
2129 2127
2130 2128
    return ordered, ensure_platform_int(new_codes)
2129 +
2130 +
2131 +
def _sort_mixed(values):
2132 +
    """ order ints before strings in 1d arrays, safe in py3 """
2133 +
    str_pos = np.array([isinstance(x, str) for x in values], dtype=bool)
2134 +
    nums = np.sort(values[~str_pos])
2135 +
    strs = np.sort(values[str_pos])
2136 +
    return np.concatenate([nums, np.asarray(strs, dtype=object)])
2137 +
2138 +
2139 +
def _sort_tuples(values: np.ndarray[tuple]):
2140 +
    """
2141 +
    Convert array of tuples (1d) to array or array (2d).
2142 +
    We need to keep the columns separately as they contain different types and
2143 +
    nans (can't use `np.sort` as it may fail when str and nan are mixed in a
2144 +
    column as types cannot be compared).
2145 +
    """
2146 +
    from pandas.core.internals.construction import to_arrays
2147 +
    from pandas.core.sorting import lexsort_indexer
2148 +
2149 +
    arrays, _ = to_arrays(values, None)
2150 +
    indexer = lexsort_indexer(arrays, orders=True)
2151 +
    return values[indexer]

@@ -19,6 +19,7 @@
Loading
19 19
from pandas.core.dtypes.cast import (
20 20
    find_common_type,
21 21
    infer_dtype_from_scalar,
22 +
    maybe_box_datetimelike,
22 23
    maybe_downcast_to_dtype,
23 24
)
24 25
from pandas.core.dtypes.common import (
@@ -1074,19 +1075,6 @@
Loading
1074 1075
1075 1076
    # TODO: arithmetic operations
1076 1077
1077 -
    # GH#30817 until IntervalArray implements inequalities, get them from Index
1078 -
    def __lt__(self, other):
1079 -
        return Index.__lt__(self, other)
1080 -
1081 -
    def __le__(self, other):
1082 -
        return Index.__le__(self, other)
1083 -
1084 -
    def __gt__(self, other):
1085 -
        return Index.__gt__(self, other)
1086 -
1087 -
    def __ge__(self, other):
1088 -
        return Index.__ge__(self, other)
1089 -
1090 1078
1091 1079
def _is_valid_endpoint(endpoint) -> bool:
1092 1080
    """
@@ -1206,8 +1194,8 @@
Loading
1206 1194
    IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]],
1207 1195
                  closed='both', dtype='interval[int64]')
1208 1196
    """
1209 -
    start = com.maybe_box_datetimelike(start)
1210 -
    end = com.maybe_box_datetimelike(end)
1197 +
    start = maybe_box_datetimelike(start)
1198 +
    end = maybe_box_datetimelike(end)
1211 1199
    endpoint = start if start is not None else end
1212 1200
1213 1201
    if freq is None and com.any_none(periods, start, end):

@@ -281,17 +281,15 @@
Loading
281 281
282 282
    def min(self, *, skipna: bool = True, **kwargs) -> Scalar:
283 283
        nv.validate_min((), kwargs)
284 -
        result = masked_reductions.min(
284 +
        return masked_reductions.min(
285 285
            values=self.to_numpy(), mask=self.isna(), skipna=skipna
286 286
        )
287 -
        return result
288 287
289 288
    def max(self, *, skipna: bool = True, **kwargs) -> Scalar:
290 289
        nv.validate_max((), kwargs)
291 -
        result = masked_reductions.max(
290 +
        return masked_reductions.max(
292 291
            values=self.to_numpy(), mask=self.isna(), skipna=skipna
293 292
        )
294 -
        return result
295 293
296 294
    def sum(self, *, axis=None, skipna=True, min_count=0, **kwargs) -> Scalar:
297 295
        nv.validate_sum((), kwargs)

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 7 files with coverage changes found.

Changes in pandas/io/gbq.py
-2
+2
Loading file...
Changes in pandas/core/arrays/base.py
-1
+1
Loading file...
Changes in pandas/core/arrays/datetimes.py
-1
+1
Loading file...
Changes in pandas/core/dtypes/cast.py
-1
+1
Loading file...
Changes in pandas/core/indexes/base.py
-2
+2
Loading file...
Changes in pandas/core/frame.py
-2
+2
Loading file...
Changes in pandas/_testing.py
-1
+1
Loading file...

58 Commits

Hiding 57 contexual commits
+29
+21
+8
Pull Request Base Commit
Files Coverage
pandas -0.01% 94.20%
Project Totals (214 files) 94.20%
Loading