Search is not available for this dataset
repo_id
stringlengths
12
110
file_path
stringlengths
24
164
content
stringlengths
3
89.3M
__index_level_0__
int64
0
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_operators.py
import numpy as np import pytest import pandas as pd from pandas import ( Categorical, DataFrame, Series, Timestamp, date_range, ) import pandas._testing as tm class TestCategoricalOpsWithFactor: def test_categories_none_comparisons(self): factor = Categorical(["a", "b", "b", "a", "a"...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_astype.py
import numpy as np import pytest from pandas import ( Categorical, CategoricalDtype, CategoricalIndex, DatetimeIndex, Interval, NaT, Period, Timestamp, array, to_datetime, ) import pandas._testing as tm class TestAstype: @pytest.mark.parametrize("cls", [Categorical, Catego...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_dtypes.py
import numpy as np import pytest from pandas.core.dtypes.dtypes import CategoricalDtype from pandas import ( Categorical, CategoricalIndex, Index, IntervalIndex, Series, Timestamp, ) import pandas._testing as tm class TestCategoricalDtypes: def test_categories_match_up_to_permutation(sel...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_analytics.py
import re import sys import numpy as np import pytest from pandas.compat import PYPY from pandas import ( Categorical, CategoricalDtype, DataFrame, Index, NaT, Series, date_range, ) import pandas._testing as tm from pandas.api.types import is_scalar class TestCategoricalAnalytics: @...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_missing.py
import collections import numpy as np import pytest from pandas.core.dtypes.dtypes import CategoricalDtype import pandas as pd from pandas import ( Categorical, DataFrame, Index, Series, isna, ) import pandas._testing as tm class TestCategoricalMissing: def test_isna(self): exp = np...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_take.py
import numpy as np import pytest from pandas import Categorical import pandas._testing as tm class TestTake: # https://github.com/pandas-dev/pandas/issues/20664 def test_take_default_allow_fill(self): cat = Categorical(["a", "b"]) with tm.assert_produces_warning(None): result = c...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/conftest.py
import pytest from pandas import Categorical @pytest.fixture(params=[True, False]) def allow_fill(request): """Boolean 'allow_fill' parameter for Categorical.take""" return request.param @pytest.fixture def factor(): """Fixture returning a Categorical object""" return Categorical(["a", "b", "b", "...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_indexing.py
import math import numpy as np import pytest from pandas import ( NA, Categorical, CategoricalIndex, Index, Interval, IntervalIndex, NaT, PeriodIndex, Series, Timedelta, Timestamp, ) import pandas._testing as tm import pandas.core.common as com class TestCategoricalIndexi...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_map.py
import numpy as np import pytest import pandas as pd from pandas import ( Categorical, Index, Series, ) import pandas._testing as tm @pytest.fixture(params=[None, "ignore"]) def na_action(request): return request.param @pytest.mark.parametrize( "data, categories", [ (list("abcbca"),...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_api.py
import re import numpy as np import pytest from pandas.compat import PY311 from pandas import ( Categorical, CategoricalIndex, DataFrame, Index, Series, StringDtype, ) import pandas._testing as tm from pandas.core.arrays.categorical import recode_for_categories class TestCategoricalAPI: ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_replace.py
import pytest import pandas as pd from pandas import Categorical import pandas._testing as tm @pytest.mark.parametrize( "to_replace,value,expected,flip_categories", [ # one-to-one (1, 2, [2, 2, 3], False), (1, 4, [4, 2, 3], False), (4, 1, [1, 2, 3], False), (5, 6, [1, ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_constructors.py
from datetime import ( date, datetime, ) import numpy as np import pytest from pandas.core.dtypes.common import ( is_float_dtype, is_integer_dtype, ) from pandas.core.dtypes.dtypes import CategoricalDtype import pandas as pd from pandas import ( Categorical, CategoricalIndex, DatetimeInde...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_algos.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize("ordered", [True, False]) @pytest.mark.parametrize("categories", [["b", "a", "c"], ["a", "b", "c", "d"]]) def test_factorize(categories, ordered): cat = pd.Categorical( ["b", "b", "a", "c", None], c...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/categorical/test_warnings.py
import pytest import pandas._testing as tm class TestCategoricalWarnings: def test_tab_complete_warning(self, ip): # https://github.com/pandas-dev/pandas/issues/16409 pytest.importorskip("IPython", minversion="6.0.0") from IPython.core.completer import provisionalcompleter code =...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/datetimes/test_reductions.py
import numpy as np import pytest from pandas.core.dtypes.dtypes import DatetimeTZDtype import pandas as pd from pandas import NaT import pandas._testing as tm from pandas.core.arrays import DatetimeArray class TestReductions: @pytest.fixture(params=["s", "ms", "us", "ns"]) def unit(self, request): r...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/datetimes/test_constructors.py
import numpy as np import pytest from pandas._libs import iNaT from pandas.core.dtypes.dtypes import DatetimeTZDtype import pandas as pd import pandas._testing as tm from pandas.core.arrays import DatetimeArray class TestDatetimeArrayConstructor: def test_from_sequence_invalid_type(self): mi = pd.Multi...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/datetimes/test_cumulative.py
import pytest import pandas._testing as tm from pandas.core.arrays import DatetimeArray class TestAccumulator: def test_accumulators_freq(self): # GH#50297 arr = DatetimeArray._from_sequence( [ "2000-01-01", "2000-01-02", "2000-01-03", ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/timedeltas/test_reductions.py
import numpy as np import pytest import pandas as pd from pandas import Timedelta import pandas._testing as tm from pandas.core import nanops from pandas.core.arrays import TimedeltaArray class TestReductions: @pytest.mark.parametrize("name", ["std", "min", "max", "median", "mean"]) @pytest.mark.parametrize(...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/timedeltas/test_constructors.py
import numpy as np import pytest from pandas.core.arrays import TimedeltaArray class TestTimedeltaArrayConstructor: def test_only_1dim_accepted(self): # GH#25282 arr = np.array([0, 1, 2, 3], dtype="m8[h]").astype("m8[ns]") with pytest.raises(ValueError, match="Only 1-dimensional"): ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/timedeltas/test_cumulative.py
import pytest import pandas._testing as tm from pandas.core.arrays import TimedeltaArray class TestAccumulator: def test_accumulators_disallowed(self): # GH#50297 arr = TimedeltaArray._from_sequence(["1D", "2D"]) with pytest.raises(TypeError, match="cumprod not supported"): ar...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/interval/test_overlaps.py
"""Tests for Interval-Interval operations, such as overlaps, contains, etc.""" import numpy as np import pytest from pandas import ( Interval, IntervalIndex, Timedelta, Timestamp, ) import pandas._testing as tm from pandas.core.arrays import IntervalArray @pytest.fixture(params=[IntervalArray, Interv...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/interval/test_astype.py
import pytest from pandas import ( Categorical, CategoricalDtype, Index, IntervalIndex, ) import pandas._testing as tm class TestAstype: @pytest.mark.parametrize("ordered", [True, False]) def test_astype_categorical_retains_ordered(self, ordered): index = IntervalIndex.from_breaks(ran...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/interval/test_formats.py
from pandas.core.arrays import IntervalArray def test_repr(): # GH#25022 arr = IntervalArray.from_tuples([(0, 1), (1, 2)]) result = repr(arr) expected = ( "<IntervalArray>\n" "[(0, 1], (1, 2]]\n" "Length: 2, dtype: interval[int64, right]" ) assert result == expected
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/interval/test_interval.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, Interval, IntervalIndex, Timedelta, Timestamp, date_range, timedelta_range, ) import pandas._testing as tm from pandas.core.arrays import IntervalArray @pytest.fixture( params=[ (Index([0, 2, 4]),...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/numpy_/test_numpy.py
""" Additional tests for NumpyExtensionArray that aren't covered by the interface tests. """ import numpy as np import pytest from pandas.core.dtypes.dtypes import NumpyEADtype import pandas as pd import pandas._testing as tm from pandas.arrays import NumpyExtensionArray @pytest.fixture( params=[ np.arr...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/numpy_/test_indexing.py
import numpy as np from pandas.core.dtypes.common import is_scalar import pandas as pd import pandas._testing as tm class TestSearchsorted: def test_searchsorted_string(self, string_dtype): arr = pd.array(["a", "b", "c"], dtype=string_dtype) result = arr.searchsorted("a", side="left") a...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_function.py
import numpy as np import pytest from pandas.compat import IS64 import pandas as pd import pandas._testing as tm @pytest.mark.parametrize("ufunc", [np.abs, np.sign]) # np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127> @pytest.mark.filterwarnings("ignore:invalid value encountered in si...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_to_numpy.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray @pytest.mark.parametrize("box", [True, False], ids=["series", "array"]) def test_to_numpy(box): con = pd.Series if box else pd.array # default (with or without missing values) -> ob...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_repr.py
import numpy as np import pytest import pandas as pd from pandas.core.arrays.floating import ( Float32Dtype, Float64Dtype, ) def test_dtypes(dtype): # smoke tests on auto dtype construction np.dtype(dtype.type).kind == "f" assert dtype.name is not None @pytest.mark.parametrize( "dtype, exp...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_comparison.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray from pandas.tests.arrays.masked_shared import ( ComparisonOps, NumericOps, ) class TestComparisonOps(NumericOps, ComparisonOps): @pytest.mark.parametrize("other", [True, False, p...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_astype.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_astype(): # with missing values arr = pd.array([0.1, 0.2, None], dtype="Float64") with pytest.raises(ValueError, match="cannot convert NA to integer"): arr.astype("int64") with pytest.raises(ValueErro...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_contains.py
import numpy as np import pandas as pd def test_contains_nan(): # GH#52840 arr = pd.array(range(5)) / 0 assert np.isnan(arr._data[0]) assert not arr.isna()[0] assert np.nan in arr
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_concat.py
import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize( "to_concat_dtypes, result_dtype", [ (["Float64", "Float64"], "Float64"), (["Float32", "Float64"], "Float64"), (["Float32", "Float32"], "Float32"), ], ) def test_concat_series(to_concat_dtypes,...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/conftest.py
import numpy as np import pytest import pandas as pd from pandas.core.arrays.floating import ( Float32Dtype, Float64Dtype, ) @pytest.fixture(params=[Float32Dtype, Float64Dtype]) def dtype(request): """Parametrized fixture returning a float 'dtype'""" return request.param() @pytest.fixture def data(...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_construction.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray from pandas.core.arrays.floating import ( Float32Dtype, Float64Dtype, ) def test_uses_pandas_na(): a = pd.array([1, None], dtype=Float64Dtype()) assert a[1] is pd.NA def te...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/floating/test_arithmetic.py
import operator import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray # Basic test for the arithmetic array ops # ----------------------------------------------------------------------------- @pytest.mark.parametrize( "opname, exp", [...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/string_/test_string.py
""" This module tests the functionality of StringArray and ArrowStringArray. Tests for the str accessors are in pandas/tests/strings/test_string_array.py """ import numpy as np import pytest from pandas.compat.pyarrow import pa_version_under12p0 from pandas.core.dtypes.common import is_dtype_equal import pandas as p...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/string_/test_string_arrow.py
import pickle import re import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm from pandas.core.arrays.string_ import ( StringArray, StringDtype, ) from pandas.core.arrays.string_arrow import ( ArrowStringArray, ArrowStringArrayNump...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_reductions.py
import numpy as np import pytest from pandas import ( NaT, SparseDtype, Timestamp, isna, ) from pandas.core.arrays.sparse import SparseArray class TestReductions: @pytest.mark.parametrize( "data,pos,neg", [ ([True, True, True], True, False), ([1, 2, 1], 1, ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_arithmetics.py
import operator import numpy as np import pytest import pandas as pd from pandas import SparseDtype import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray @pytest.fixture(params=["integer", "block"]) def kind(request): """kind kwarg to pass to SparseArray""" return request.param @p...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_libsparse.py
import operator import numpy as np import pytest import pandas._libs.sparse as splib import pandas.util._test_decorators as td from pandas import Series import pandas._testing as tm from pandas.core.arrays.sparse import ( BlockIndex, IntIndex, make_sparse_index, ) @pytest.fixture def test_length(): ...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_astype.py
import numpy as np import pytest from pandas._libs.sparse import IntIndex from pandas import ( SparseDtype, Timestamp, ) import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray class TestAstype: def test_astype(self): # float -> float arr = SparseArray([None, None,...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_combine_concat.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray class TestSparseArrayConcat: @pytest.mark.parametrize("kind", ["integer", "block"]) def test_basic(self, kind): a = SparseArray([1, 0, 0, 2], kind=kind) b = Spar...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_accessor.py
import string import numpy as np import pytest import pandas as pd from pandas import SparseDtype import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray class TestSeriesAccessor: def test_to_dense(self): ser = pd.Series([0, 1, 0, 10], dtype="Sparse[int64]") result = ser.s...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_array.py
import re import numpy as np import pytest from pandas._libs.sparse import IntIndex import pandas as pd from pandas import ( SparseDtype, isna, ) import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray @pytest.fixture def arr_data(): """Fixture returning numpy array with valid an...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_indexing.py
import numpy as np import pytest import pandas as pd from pandas import SparseDtype import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray @pytest.fixture def arr_data(): return np.array([np.nan, np.nan, 1, 2, 3, np.nan, 4, 5, np.nan, 6]) @pytest.fixture def arr(arr_data): return Sp...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_dtype.py
import re import warnings import numpy as np import pytest import pandas as pd from pandas import SparseDtype @pytest.mark.parametrize( "dtype, fill_value", [ ("int", 0), ("float", np.nan), ("bool", False), ("object", np.nan), ("datetime64[ns]", np.datetime64("NaT", "...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_constructors.py
import numpy as np import pytest from pandas._libs.sparse import IntIndex import pandas as pd from pandas import ( SparseDtype, isna, ) import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray class TestConstructors: def test_constructor_dtype(self): arr = SparseArray([np.n...
0
public_repos/pandas/pandas/tests/arrays
public_repos/pandas/pandas/tests/arrays/sparse/test_unary.py
import operator import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import SparseArray @pytest.mark.filterwarnings("ignore:invalid value encountered in cast:RuntimeWarning") @pytest.mark.parametrize("fill_value", [0, np.nan]) @pytest.mark.parametrize("op", [oper...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_numpy.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_sparse.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/conftest.py
import operator import pytest from pandas._config.config import _get_option from pandas import ( Series, options, ) @pytest.fixture def dtype(): """A fixture providing the ExtensionDtype to validate.""" raise NotImplementedError @pytest.fixture def data(): """ Length-100 array for this ty...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_period.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_common.py
import numpy as np import pytest from pandas.core.dtypes import dtypes from pandas.core.dtypes.common import is_extension_array_dtype import pandas as pd import pandas._testing as tm from pandas.core.arrays import ExtensionArray class DummyDtype(dtypes.ExtensionDtype): pass class DummyArray(ExtensionArray): ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_extension.py
""" Tests for behavior if an author does *not* implement EA methods. """ import numpy as np import pytest from pandas.core.arrays import ExtensionArray class MyEA(ExtensionArray): def __init__(self, values) -> None: self._values = values @pytest.fixture def data(): arr = np.arange(10) return My...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_string.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_arrow.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal t...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_masked.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_datetime.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_categorical.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/extension/test_interval.py
""" This file contains a minimal set of tests for compliance with the extension array interface test suite, and should contain no other tests. The test suite for the full functionality of the array is located in `pandas/tests/arrays/`. The tests in this file are inherited from the BaseExtensionTests, and only minimal ...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/dtype.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.api.types import ( infer_dtype, is_object_dtype, is_string_dtype, ) class BaseDtypeTests: """Base class for ExtensionDtype classes""" def test_name(self, dtype): assert isinstance(dtype.name, st...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/constructors.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.api.extensions import ExtensionArray from pandas.core.internals.blocks import EABackedBlock class BaseConstructorsTests: def test_from_sequence_from_cls(self, data): result = type(data)._from_sequence(data, dtyp...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/ops.py
from __future__ import annotations from typing import final import numpy as np import pytest from pandas.core.dtypes.common import is_string_dtype import pandas as pd import pandas._testing as tm from pandas.core import ops class BaseOpsUtil: series_scalar_exc: type[Exception] | None = TypeError frame_sca...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/base.py
class BaseExtensionTests: pass
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/getitem.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm class BaseGetitemTests: """Tests for ExtensionArray.__getitem__.""" def test_iloc_series(self, data): ser = pd.Series(data) result = ser.iloc[:4] expected = pd.Series(data[:4]) tm.assert_series_...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/casting.py
import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm from pandas.core.internals.blocks import NumpyBlock class BaseCastingTests: """Casting to and from ExtensionDtypes""" def test_astype_object_series(self, all_data): ser = pd.S...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/interface.py
import numpy as np import pytest from pandas.core.dtypes.common import is_extension_array_dtype from pandas.core.dtypes.dtypes import ExtensionDtype import pandas as pd import pandas._testing as tm class BaseInterfaceTests: """Tests that the basic interface is satisfied.""" # ------------------------------...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/groupby.py
import re import pytest from pandas.core.dtypes.common import ( is_bool_dtype, is_numeric_dtype, is_object_dtype, is_string_dtype, ) import pandas as pd import pandas._testing as tm @pytest.mark.filterwarnings( "ignore:The default of observed=False is deprecated:FutureWarning" ) class BaseGroup...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/index.py
""" Tests for Indexes backed by arbitrary ExtensionArrays. """ import pandas as pd class BaseIndexTests: """Tests for Index object backed by an ExtensionArray""" def test_index_from_array(self, data): idx = pd.Index(data) assert data.dtype == idx.dtype def test_index_from_listlike_with_d...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/methods.py
import inspect import operator import numpy as np import pytest from pandas._typing import Dtype from pandas.core.dtypes.common import is_bool_dtype from pandas.core.dtypes.missing import na_value_for_dtype import pandas as pd import pandas._testing as tm from pandas.core.sorting import nargsort class BaseMethods...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/setitem.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm class BaseSetitemTests: @pytest.fixture( params=[ lambda x: x.index, lambda x: list(x.index), lambda x: slice(None), lambda x: slice(0, len(x)), lambda x: range(le...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/printing.py
import io import pytest import pandas as pd class BasePrintingTests: """Tests checking the formatting of your EA when printed.""" @pytest.mark.parametrize("size", ["big", "small"]) def test_array_repr(self, data, size): if size == "small": data = data[:5] else: d...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/reshaping.py
import itertools import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.api.extensions import ExtensionArray from pandas.core.internals.blocks import EABackedBlock class BaseReshapingTests: """Tests for reshaping and concatenation.""" @pytest.mark.parametrize("in_fram...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/reduce.py
from typing import final import pytest import pandas as pd import pandas._testing as tm from pandas.api.types import is_numeric_dtype class BaseReduceTests: """ Reduction specific tests. Generally these only make sense for numeric/boolean operations. """ def _supports_reduction(self, ser: pd.Se...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/dim2.py
""" Tests for 2D compatibility. """ import numpy as np import pytest from pandas._libs.missing import is_matching_na from pandas.core.dtypes.common import ( is_bool_dtype, is_integer_dtype, ) import pandas as pd import pandas._testing as tm from pandas.core.arrays.integer import NUMPY_INT_TO_DTYPE class Di...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/io.py
from io import StringIO import numpy as np import pytest import pandas as pd import pandas._testing as tm class BaseParsingTests: @pytest.mark.parametrize("engine", ["c", "python"]) def test_EA_types(self, engine, data): df = pd.DataFrame({"with_dtype": pd.Series(data, dtype=str(data.dtype))}) ...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/missing.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm class BaseMissingTests: def test_isna(self, data_missing): expected = np.array([True, False]) result = pd.isna(data_missing) tm.assert_numpy_array_equal(result, expected) result = pd.Series(data_mi...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/__init__.py
""" Base test suite for extension arrays. These tests are intended for third-party libraries to subclass to validate that their extension arrays and dtypes satisfy the interface. Moving or renaming the tests should not be done lightly. Libraries are expected to implement a few pytest fixtures to provide data for the ...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/base/accumulate.py
import pytest import pandas as pd import pandas._testing as tm class BaseAccumulateTests: """ Accumulation specific tests. Generally these only make sense for numeric/boolean operations. """ def _supports_accumulation(self, ser: pd.Series, op_name: str) -> bool: # Do we expect this accum...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/list/test_list.py
import pytest import pandas as pd from pandas.tests.extension.list.array import ( ListArray, ListDtype, make_data, ) @pytest.fixture def dtype(): return ListDtype() @pytest.fixture def data(): """Length-100 ListArray for semantics test.""" data = make_data() while len(data[0]) == len(d...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/list/array.py
""" Test extension array for storing nested data in a pandas container. The ListArray stores an ndarray of lists. """ from __future__ import annotations import numbers import string from typing import TYPE_CHECKING import numpy as np from pandas.core.dtypes.base import ExtensionDtype import pandas as pd from panda...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/list/__init__.py
from pandas.tests.extension.list.array import ( ListArray, ListDtype, make_data, ) __all__ = ["ListArray", "ListDtype", "make_data"]
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/date/array.py
from __future__ import annotations import datetime as dt from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas.core.dtypes.dtypes import register_extension_dtype from pandas.api.extensions import ( ExtensionArray, ExtensionDtype, ) from pandas.api.types import pandas_dt...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/date/__init__.py
from pandas.tests.extension.date.array import ( DateArray, DateDtype, ) __all__ = ["DateArray", "DateDtype"]
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/json/array.py
""" Test extension array for storing nested data in a pandas container. The JSONArray stores lists of dictionaries. The storage mechanism is a list, not an ndarray. Note ---- We currently store lists of UserDicts. Pandas has a few places internally that specifically check for dicts, and does non-scalar things in that...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/json/test_json.py
import collections import operator import sys import pytest import pandas as pd import pandas._testing as tm from pandas.tests.extension import base from pandas.tests.extension.json.array import ( JSONArray, JSONDtype, make_data, ) @pytest.fixture def dtype(): return JSONDtype() @pytest.fixture de...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/json/__init__.py
from pandas.tests.extension.json.array import ( JSONArray, JSONDtype, make_data, ) __all__ = ["JSONArray", "JSONDtype", "make_data"]
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/decimal/array.py
from __future__ import annotations import decimal import numbers import sys from typing import TYPE_CHECKING import numpy as np from pandas.core.dtypes.base import ExtensionDtype from pandas.core.dtypes.common import ( is_dtype_equal, is_float, is_integer, pandas_dtype, ) import pandas as pd from pa...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/decimal/test_decimal.py
from __future__ import annotations import decimal import operator import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.tests.extension import base from pandas.tests.extension.decimal.array import ( DecimalArray, DecimalDtype, make_data, to_decimal, ) @pytest...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/decimal/__init__.py
from pandas.tests.extension.decimal.array import ( DecimalArray, DecimalDtype, make_data, to_decimal, ) __all__ = ["DecimalArray", "DecimalDtype", "to_decimal", "make_data"]
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/array_with_attr/array.py
""" Test extension array that has custom attribute information (not stored on the dtype). """ from __future__ import annotations import numbers from typing import TYPE_CHECKING import numpy as np from pandas.core.dtypes.base import ExtensionDtype import pandas as pd from pandas.core.arrays import ExtensionArray i...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/array_with_attr/test_array_with_attr.py
import numpy as np import pandas as pd import pandas._testing as tm from pandas.tests.extension.array_with_attr import FloatAttrArray def test_concat_with_all_na(): # https://github.com/pandas-dev/pandas/pull/47762 # ensure that attribute of the column array is preserved (when it gets # preserved in rein...
0
public_repos/pandas/pandas/tests/extension
public_repos/pandas/pandas/tests/extension/array_with_attr/__init__.py
from pandas.tests.extension.array_with_attr.array import ( FloatAttrArray, FloatAttrDtype, ) __all__ = ["FloatAttrArray", "FloatAttrDtype"]
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/config/test_config.py
import pytest from pandas._config import config as cf from pandas._config.config import OptionError import pandas as pd import pandas._testing as tm class TestConfig: @pytest.fixture(autouse=True) def clean_config(self, monkeypatch): with monkeypatch.context() as m: m.setattr(cf, "_globa...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/config/test_localization.py
import codecs import locale import os import pytest from pandas._config.localization import ( can_set_locale, get_locales, set_locale, ) from pandas.compat import ISMUSL import pandas as pd _all_locales = get_locales() _current_locale = locale.setlocale(locale.LC_ALL) # getlocale() is wrong, see GH#46...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/dtypes/test_dtypes.py
import re import weakref import numpy as np import pytest import pytz from pandas._libs.tslibs.dtypes import NpyDatetimeUnit from pandas.core.dtypes.base import _registry as registry from pandas.core.dtypes.common import ( is_bool_dtype, is_categorical_dtype, is_datetime64_any_dtype, is_datetime64_dt...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/dtypes/test_missing.py
from contextlib import nullcontext from datetime import datetime from decimal import Decimal import numpy as np import pytest from pandas._config import config as cf from pandas._libs import missing as libmissing from pandas._libs.tslibs import iNaT from pandas.compat.numpy import np_version_gte1p25 from pandas.cor...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/dtypes/test_generic.py
import re import numpy as np import pytest from pandas.core.dtypes import generic as gt import pandas as pd import pandas._testing as tm class TestABCClasses: tuples = [[1, 2, 2], ["red", "blue", "red"]] multi_index = pd.MultiIndex.from_arrays(tuples, names=("number", "color")) datetime_index = pd.to_d...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/dtypes/test_concat.py
import pytest import pandas.core.dtypes.concat as _concat import pandas as pd from pandas import Series import pandas._testing as tm def test_concat_mismatched_categoricals_with_empty(): # concat_compat behavior on series._values should match pd.concat on series ser1 = Series(["a", "b", "c"], dtype="categor...
0