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/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_partial_indexing.py
import numpy as np import pytest from pandas import ( DataFrame, IndexSlice, MultiIndex, date_range, ) import pandas._testing as tm @pytest.fixture def df(): # c1 # 2016-01-01 00:00:00 a 0 # b 1 # c 2 # 2016-01-0...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_names.py
import pytest import pandas as pd from pandas import MultiIndex import pandas._testing as tm def check_level_names(index, names): assert [level.name for level in index.levels] == list(names) def test_slice_keep_name(): x = MultiIndex.from_tuples([("a", "b"), (1, 2), ("c", "d")], names=["x", "y"]) asser...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_sorting.py
import numpy as np import pytest from pandas.errors import ( PerformanceWarning, UnsortedIndexError, ) from pandas import ( CategoricalIndex, DataFrame, Index, MultiIndex, RangeIndex, Series, Timestamp, ) import pandas._testing as tm from pandas.core.indexes.frozen import FrozenLis...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_astype.py
import numpy as np import pytest from pandas.core.dtypes.dtypes import CategoricalDtype import pandas._testing as tm def test_astype(idx): expected = idx.copy() actual = idx.astype("O") tm.assert_copy(actual.levels, expected.levels) tm.assert_copy(actual.codes, expected.codes) assert actual.name...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_isin.py
import numpy as np import pytest from pandas import MultiIndex import pandas._testing as tm def test_isin_nan(): idx = MultiIndex.from_arrays([["foo", "bar"], [1.0, np.nan]]) tm.assert_numpy_array_equal(idx.isin([("bar", np.nan)]), np.array([False, True])) tm.assert_numpy_array_equal( idx.isin([(...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_get_set.py
import numpy as np import pytest from pandas.compat import PY311 from pandas.core.dtypes.dtypes import DatetimeTZDtype import pandas as pd from pandas import ( CategoricalIndex, MultiIndex, ) import pandas._testing as tm def assert_matching(actual, expected, check_dtype=False): # avoid specifying inter...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_formats.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, MultiIndex, ) import pandas._testing as tm def test_format(idx): msg = "MultiIndex.format is deprecated" with tm.assert_produces_warning(FutureWarning, match=msg): idx.format() idx[:0].format() def test...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_get_level_values.py
import numpy as np import pandas as pd from pandas import ( CategoricalIndex, Index, MultiIndex, Timestamp, date_range, ) import pandas._testing as tm class TestGetLevelValues: def test_get_level_values_box_datetime64(self): dates = date_range("1/1/2000", periods=4) levels = [...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_monotonic.py
import numpy as np import pytest from pandas import ( Index, MultiIndex, ) def test_is_monotonic_increasing_lexsorted(lexsorted_two_level_string_multiindex): # string ordering mi = lexsorted_two_level_string_multiindex assert mi.is_monotonic_increasing is False assert Index(mi.values).is_mono...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_analytics.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, MultiIndex, date_range, period_range, ) import pandas._testing as tm def test_infer_objects(idx): with pytest.raises(NotImplementedError, match="to_frame"): idx.infer_objects() def test_shift(idx): # GH...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_missing.py
import numpy as np import pytest import pandas as pd from pandas import MultiIndex import pandas._testing as tm def test_fillna(idx): # GH 11343 msg = "isna is not defined for MultiIndex" with pytest.raises(NotImplementedError, match=msg): idx.fillna(idx[0]) def test_dropna(): # GH 6194 ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_reindex.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, MultiIndex, ) import pandas._testing as tm def test_reindex(idx): result, indexer = idx.reindex(list(idx[:4])) assert isinstance(result, MultiIndex) assert result.names == ["first", "second"] assert [level.name f...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_drop.py
import numpy as np import pytest from pandas.errors import PerformanceWarning import pandas as pd from pandas import ( Index, MultiIndex, ) import pandas._testing as tm def test_drop(idx): dropped = idx.drop([("foo", "two"), ("qux", "one")]) index = MultiIndex.from_tuples([("foo", "two"), ("qux", "...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_take.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_take(idx): indexer = [4, 3, 0, 2] result = idx.take(indexer) expected = idx[indexer] assert result.equals(expected) # GH 10791 msg = "'MultiIndex' object has no attribute 'freq'" with pytest.raises...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/conftest.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, MultiIndex, ) # Note: identical the "multi" entry in the top-level "index" fixture @pytest.fixture def idx(): # a MultiIndex used to test the general functionality of the # general functionality of this object major_...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_lexsort.py
from pandas import MultiIndex class TestIsLexsorted: def test_is_lexsorted(self): levels = [[0, 1], [0, 1, 2]] index = MultiIndex( levels=levels, codes=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 1, 2]] ) assert index._is_lexsorted() index = MultiIndex( leve...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_duplicates.py
from itertools import product import numpy as np import pytest from pandas._libs import ( hashtable, index as libindex, ) from pandas import ( NA, DatetimeIndex, MultiIndex, Series, ) import pandas._testing as tm @pytest.mark.parametrize("names", [None, ["first", "second"]]) def test_unique...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_pickle.py
import pytest from pandas import MultiIndex def test_pickle_compat_construction(): # this is testing for pickle compat # need an object to create with with pytest.raises(TypeError, match="Must pass both levels and codes"): MultiIndex()
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_indexing.py
from datetime import timedelta import re import numpy as np import pytest from pandas._libs import index as libindex from pandas.errors import ( InvalidIndexError, PerformanceWarning, ) import pandas as pd from pandas import ( Categorical, Index, MultiIndex, date_range, ) import pandas._testi...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_setops.py
import numpy as np import pytest import pandas as pd from pandas import ( CategoricalIndex, DataFrame, Index, IntervalIndex, MultiIndex, Series, ) import pandas._testing as tm from pandas.api.types import ( is_float_dtype, is_unsigned_integer_dtype, ) @pytest.mark.parametrize("case", ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_conversion.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, MultiIndex, ) import pandas._testing as tm def test_to_numpy(idx): result = idx.to_numpy() exp = idx.values tm.assert_numpy_array_equal(result, exp) def test_to_frame(): tuples = [(1, "one"), (1, "two"), (2...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_constructors.py
from datetime import ( date, datetime, ) import itertools import numpy as np import pytest from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike import pandas as pd from pandas import ( Index, MultiIndex, Series, Timestamp, date_range, ) import pandas._testing as tm ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_integrity.py
import re import numpy as np import pytest from pandas._libs import index as libindex from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike import pandas as pd from pandas import ( Index, IntervalIndex, MultiIndex, RangeIndex, ) import pandas._testing as tm def test_labels_dt...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_reshape.py
from datetime import datetime import numpy as np import pytest import pytz import pandas as pd from pandas import ( Index, MultiIndex, ) import pandas._testing as tm def test_insert(idx): # key contained in all levels new_index = idx.insert(0, ("bar", "two")) assert new_index.equal_levels(idx) ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_compat.py
import numpy as np import pytest import pandas as pd from pandas import MultiIndex import pandas._testing as tm def test_numeric_compat(idx): with pytest.raises(TypeError, match="cannot perform __mul__"): idx * 1 with pytest.raises(TypeError, match="cannot perform __rmul__"): 1 * idx di...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_equivalence.py
import numpy as np import pytest from pandas.core.dtypes.common import is_any_real_numeric_dtype import pandas as pd from pandas import ( Index, MultiIndex, Series, ) import pandas._testing as tm def test_equals(idx): assert idx.equals(idx) assert idx.equals(idx.copy()) assert idx.equals(idx...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_join.py
import numpy as np import pytest from pandas import ( DataFrame, Index, Interval, MultiIndex, Series, StringDtype, ) import pandas._testing as tm @pytest.mark.parametrize( "other", [Index(["three", "one", "two"]), Index(["one"]), Index(["one", "three"])] ) def test_join_level(idx, other, ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/multi/test_copy.py
from copy import ( copy, deepcopy, ) import pytest from pandas import MultiIndex import pandas._testing as tm def assert_multiindex_copied(copy, original): # Levels should be (at least, shallow copied) tm.assert_copy(copy.levels, original.levels) tm.assert_almost_equal(copy.codes, original.codes...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/ranges/test_indexing.py
import numpy as np import pytest from pandas import ( Index, RangeIndex, ) import pandas._testing as tm class TestGetIndexer: def test_get_indexer(self): index = RangeIndex(start=0, stop=20, step=2) target = RangeIndex(10) indexer = index.get_indexer(target) expected = np....
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/ranges/test_setops.py
from datetime import ( datetime, timedelta, ) from hypothesis import ( assume, given, strategies as st, ) import numpy as np import pytest from pandas import ( Index, RangeIndex, ) import pandas._testing as tm class TestRangeIndexSetOps: @pytest.mark.parametrize("dtype", [None, "int6...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/ranges/test_range.py
import numpy as np import pytest from pandas.core.dtypes.common import ensure_platform_int import pandas as pd from pandas import ( Index, RangeIndex, ) import pandas._testing as tm class TestRangeIndex: @pytest.fixture def simple_index(self): return RangeIndex(start=0, stop=20, step=2) ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/ranges/test_constructors.py
from datetime import datetime import numpy as np import pytest from pandas import ( Index, RangeIndex, Series, ) import pandas._testing as tm class TestRangeIndexConstructors: @pytest.mark.parametrize("name", [None, "foo"]) @pytest.mark.parametrize( "args, kwargs, start, stop, step", ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/ranges/test_join.py
import numpy as np from pandas import ( Index, RangeIndex, ) import pandas._testing as tm class TestJoin: def test_join_outer(self): # join with Index[int64] index = RangeIndex(start=0, stop=20, step=2) other = Index(np.arange(25, 14, -1, dtype=np.int64)) res, lidx, ridx ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_formats.py
import numpy as np import pytest import pandas._config.config as cf from pandas import Index import pandas._testing as tm class TestIndexRendering: def test_repr_is_valid_construction_code(self): # for the case of Index, where the repr is traditional rather than # stylized idx = Index(["...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_pickle.py
from pandas import Index import pandas._testing as tm def test_pickle_preserves_object_dtype(): # GH#43188, GH#43155 don't infer numeric dtype index = Index([1, 2, 3], dtype=object) result = tm.round_trip_pickle(index) assert result.dtype == object tm.assert_index_equal(index, result)
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_indexing.py
import numpy as np import pytest from pandas._libs import index as libindex import pandas as pd from pandas import ( Index, NaT, ) import pandas._testing as tm class TestGetSliceBounds: @pytest.mark.parametrize("side, expected", [("left", 4), ("right", 5)]) def test_get_slice_bounds_within(self, sid...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_setops.py
from datetime import datetime import numpy as np import pytest import pandas as pd from pandas import ( Index, Series, ) import pandas._testing as tm from pandas.core.algorithms import safe_sort class TestIndexSetOps: @pytest.mark.parametrize( "method", ["union", "intersection", "difference", "s...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_constructors.py
import numpy as np import pytest import pandas as pd from pandas import ( Index, MultiIndex, ) import pandas._testing as tm class TestIndexConstructor: # Tests for the Index constructor, specifically for cases that do # not return a subclass @pytest.mark.parametrize("value", [1, np.int64(1)]) ...
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_reshape.py
""" Tests for ndarray-like method on the base Index class """ import numpy as np import pytest from pandas import Index import pandas._testing as tm class TestReshape: def test_repeat(self): repeats = 2 index = Index([1, 2, 3]) expected = Index([1, 1, 2, 2, 3, 3]) result = index....
0
public_repos/pandas/pandas/tests/indexes
public_repos/pandas/pandas/tests/indexes/base_class/test_where.py
import numpy as np from pandas import Index import pandas._testing as tm class TestWhere: def test_where_intlike_str_doesnt_cast_ints(self): idx = Index(range(3)) mask = np.array([True, False, True]) res = idx.where(mask, "2") expected = Index([0, "2", 2]) tm.assert_index_...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_interval_array_equal.py
import pytest from pandas import interval_range import pandas._testing as tm @pytest.mark.parametrize( "kwargs", [ {"start": 0, "periods": 4}, {"start": 1, "periods": 5}, {"start": 5, "end": 10, "closed": "left"}, ], ) def test_interval_array_equal(kwargs): arr = interval_rang...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_shares_memory.py
import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm def test_shares_memory_interval(): obj = pd.interval_range(1, 5) assert tm.shares_memory(obj, obj) assert tm.shares_memory(obj, obj._data) assert tm.shares_memory(obj, obj[::-1]) assert tm.shares_memory(ob...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_index_equal.py
import numpy as np import pytest from pandas import ( NA, Categorical, CategoricalIndex, Index, MultiIndex, NaT, RangeIndex, ) import pandas._testing as tm def test_index_equal_levels_mismatch(): msg = """Index are different Index levels are different \\[left\\]: 1, Index\\(\\[1, 2,...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_extension_array_equal.py
import numpy as np import pytest from pandas import ( Timestamp, array, ) import pandas._testing as tm from pandas.core.arrays.sparse import SparseArray @pytest.mark.parametrize( "kwargs", [ {}, # Default is check_exact=False {"check_exact": False}, {"check_exact": True}, ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_deprecate_kwarg.py
import pytest from pandas.util._decorators import deprecate_kwarg import pandas._testing as tm @deprecate_kwarg("old", "new") def _f1(new=False): return new _f2_mappings = {"yes": True, "no": False} @deprecate_kwarg("old", "new", _f2_mappings) def _f2(new=False): return new def _f3_mapping(x): ret...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_deprecate_nonkeyword_arguments.py
""" Tests for the `deprecate_nonkeyword_arguments` decorator """ import inspect from pandas.util._decorators import deprecate_nonkeyword_arguments import pandas._testing as tm @deprecate_nonkeyword_arguments( version="1.1", allowed_args=["a", "b"], name="f_add_inputs" ) def f(a, b=0, c=0, d=0): return a + ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_rewrite_warning.py
import warnings import pytest from pandas.util._exceptions import rewrite_warning import pandas._testing as tm @pytest.mark.parametrize( "target_category, target_message, hit", [ (FutureWarning, "Target message", True), (FutureWarning, "Target", True), (FutureWarning, "get mess", Tr...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_validate_args.py
import pytest from pandas.util._validators import validate_args @pytest.fixture def _fname(): return "func" def test_bad_min_fname_arg_count(_fname): msg = "'max_fname_arg_count' must be non-negative" with pytest.raises(ValueError, match=msg): validate_args(_fname, (None,), -1, "foo") def te...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/conftest.py
import pytest @pytest.fixture(params=[True, False]) def check_dtype(request): return request.param @pytest.fixture(params=[True, False]) def check_exact(request): return request.param @pytest.fixture(params=[True, False]) def check_index_type(request): return request.param @pytest.fixture(params=[0....
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_categorical_equal.py
import pytest from pandas import Categorical import pandas._testing as tm @pytest.mark.parametrize( "c", [Categorical([1, 2, 3, 4]), Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4, 5])], ) def test_categorical_equal(c): tm.assert_categorical_equal(c, c) @pytest.mark.parametrize("check_category_order"...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_doc.py
from textwrap import dedent from pandas.util._decorators import doc @doc(method="cumsum", operation="sum") def cumsum(whatever): """ This is the {method} method. It computes the cumulative {operation}. """ @doc( cumsum, dedent( """ Examples -------- >>> cum...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_deprecate.py
from textwrap import dedent import pytest from pandas.util._decorators import deprecate import pandas._testing as tm def new_func(): """ This is the summary. The deprecate directive goes next. This is the extended summary. The deprecate directive goes before this. """ return "new_func called" ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_make_objects.py
""" Tests for tm.makeFoo functions. """ import numpy as np import pandas._testing as tm def test_make_multiindex_respects_k(): # GH#38795 respect 'k' arg N = np.random.default_rng(2).integers(0, 100) mi = tm.makeMultiIndex(k=N) assert len(mi) == N
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_validate_inclusive.py
import numpy as np import pytest from pandas.util._validators import validate_inclusive import pandas as pd @pytest.mark.parametrize( "invalid_inclusive", ( "ccc", 2, object(), None, np.nan, pd.NA, pd.DataFrame(), ), ) def test_invalid_inclusive(in...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_validate_args_and_kwargs.py
import pytest from pandas.util._validators import validate_args_and_kwargs @pytest.fixture def _fname(): return "func" def test_invalid_total_length_max_length_one(_fname): compat_args = ("foo",) kwargs = {"foo": "FOO"} args = ("FoO", "BaZ") min_fname_arg_count = 0 max_length = len(compat_...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_util.py
import os import pytest from pandas import ( array, compat, ) import pandas._testing as tm def test_numpy_err_state_is_default(): expected = {"over": "warn", "divide": "warn", "invalid": "warn", "under": "ignore"} import numpy as np # The error state should be unchanged after that import. a...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_numpy_array_equal.py
import copy import numpy as np import pytest import pandas as pd from pandas import Timestamp import pandas._testing as tm def test_assert_numpy_array_equal_shape_mismatch(): msg = """numpy array are different numpy array shapes are different \\[left\\]: \\(2L*,\\) \\[right\\]: \\(3L*,\\)""" with pytest....
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_almost_equal.py
import numpy as np import pytest from pandas import ( NA, DataFrame, Index, NaT, Series, Timestamp, ) import pandas._testing as tm def _assert_almost_equal_both(a, b, **kwargs): """ Check that two objects are approximately equal. This check is performed commutatively. Parame...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_frame_equal.py
import pytest import pandas as pd from pandas import DataFrame import pandas._testing as tm @pytest.fixture(params=[True, False]) def by_blocks_fixture(request): return request.param @pytest.fixture(params=["DataFrame", "Series"]) def obj_fixture(request): return request.param def _assert_frame_equal_bot...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_show_versions.py
import json import os import re from pandas.util._print_versions import ( _get_dependency_info, _get_sys_info, ) import pandas as pd def test_show_versions(tmpdir): # GH39701 as_json = os.path.join(tmpdir, "test_output.json") pd.show_versions(as_json=as_json) with open(as_json, encoding="u...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_hashing.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Series, ) import pandas._testing as tm from pandas.core.util.hashing import hash_tuples from pandas.util import ( hash_array, hash_pandas_object, ) @pytest.fixture( params=[ Ser...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_numba.py
import pytest import pandas.util._test_decorators as td from pandas import option_context @td.skip_if_installed("numba") def test_numba_not_installed_option_context(): with pytest.raises(ImportError, match="Missing optional"): with option_context("compute.use_numba", True): pass
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_series_equal.py
import numpy as np import pytest import pandas as pd from pandas import ( Categorical, DataFrame, Series, ) import pandas._testing as tm def _assert_series_equal_both(a, b, **kwargs): """ Check that two Series equal. This check is performed commutatively. Parameters ---------- a...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_validate_kwargs.py
import pytest from pandas.util._validators import ( validate_bool_kwarg, validate_kwargs, ) @pytest.fixture def _fname(): return "func" def test_bad_kwarg(_fname): good_arg = "f" bad_arg = good_arg + "o" compat_args = {good_arg: "foo", bad_arg + "o": "bar"} kwargs = {good_arg: "foo", b...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_attr_equal.py
from types import SimpleNamespace import pytest from pandas.core.dtypes.common import is_float import pandas._testing as tm def test_assert_attr_equal(nulls_fixture): obj = SimpleNamespace() obj.na_value = nulls_fixture tm.assert_attr_equal("na_value", obj, obj) def test_assert_attr_equal_different_n...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/util/test_assert_produces_warning.py
"""" Test module for testing ``pandas._testing.assert_produces_warning``. """ import warnings import pytest from pandas.errors import ( DtypeWarning, PerformanceWarning, ) import pandas._testing as tm @pytest.fixture( params=[ RuntimeWarning, ResourceWarning, UserWarning, ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/api/test_types.py
from __future__ import annotations import pandas._testing as tm from pandas.api import types from pandas.tests.api.test_api import Base class TestTypes(Base): allowed = [ "is_any_real_numeric_dtype", "is_bool", "is_bool_dtype", "is_categorical_dtype", "is_complex", ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/api/test_api.py
from __future__ import annotations import pytest import pandas as pd from pandas import api import pandas._testing as tm from pandas.api import ( extensions as api_extensions, indexers as api_indexers, interchange as api_interchange, types as api_types, typing as api_typing, ) class Base: de...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_time_grouper.py
from datetime import datetime from operator import methodcaller import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Series, Timestamp, ) import pandas._testing as tm from pandas.core.groupby.grouper import Grouper from pandas.core.indexes.datetimes import date_range @pyt...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_datetime_index.py
from datetime import datetime from functools import partial import numpy as np import pytest import pytz from pandas._libs import lib from pandas._typing import DatetimeNaTType import pandas as pd from pandas import ( DataFrame, Series, Timedelta, Timestamp, isna, notna, ) import pandas._test...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_timedelta.py
from datetime import timedelta import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Series, ) import pandas._testing as tm from pandas.core.indexes.timedeltas import timedelta_range def test_asfreq_bug(): df = DataFrame(data=[1, 3], index=[timedelta(), timedelta(minutes=3...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_resampler_grouper.py
from textwrap import dedent import numpy as np import pytest from pandas.compat import is_platform_windows import pandas as pd from pandas import ( DataFrame, Index, Series, TimedeltaIndex, Timestamp, ) import pandas._testing as tm from pandas.core.indexes.datetimes import date_range @pytest.fi...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_resample_api.py
from datetime import datetime import re import numpy as np import pytest from pandas._libs import lib from pandas.errors import UnsupportedFunctionCall import pandas as pd from pandas import ( DataFrame, NamedAgg, Series, ) import pandas._testing as tm from pandas.core.indexes.datetimes import date_range...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/conftest.py
from datetime import datetime import warnings import numpy as np import pytest from pandas import ( DataFrame, Series, ) from pandas.core.indexes.datetimes import date_range from pandas.core.indexes.period import period_range # The various methods we support downsample_methods = [ "min", "max", "...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_base.py
from datetime import datetime import numpy as np import pytest from pandas import ( DataFrame, MultiIndex, NaT, PeriodIndex, Series, TimedeltaIndex, ) import pandas._testing as tm from pandas.core.groupby.groupby import DataError from pandas.core.groupby.grouper import Grouper from pandas.core...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/resample/test_period_index.py
from datetime import datetime import dateutil import numpy as np import pytest import pytz from pandas._libs.tslibs.ccalendar import ( DAYS, MONTHS, ) from pandas._libs.tslibs.period import IncompatibleFrequency from pandas.errors import InvalidIndexError import pandas as pd from pandas import ( DataFram...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/generate_legacy_storage_files.py
""" self-contained to write legacy storage pickle files To use this script. Create an environment where you want generate pickles, say its for 0.20.3, with your pandas clone in ~/pandas . activate pandas_0.20.3 cd ~/pandas/pandas $ python -m tests.io.generate_legacy_storage_files \ tests/io/data/legacy_pickle/0....
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_parquet.py
""" test parquet compat """ import datetime from decimal import Decimal from io import BytesIO import os import pathlib import numpy as np import pytest from pandas._config import using_copy_on_write from pandas._config.config import _get_option from pandas.compat import is_platform_windows from pandas.compat.pyarro...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_gbq.py
import pandas as pd import pandas._testing as tm def test_read_gbq_deprecated(): with tm.assert_produces_warning(FutureWarning): with tm.external_error_raised(Exception): pd.read_gbq("fake") def test_to_gbq_deprecated(): with tm.assert_produces_warning(FutureWarning): with tm.ext...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_spss.py
import datetime from pathlib import Path import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.util.version import Version pyreadstat = pytest.importorskip("pyreadstat") # TODO(CoW) - detection of chained assignment in cython # https://github.com/pandas-dev/pandas/issues/513...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/conftest.py
import shlex import subprocess import time import uuid import pytest from pandas.compat import ( is_ci_environment, is_platform_arm, is_platform_mac, is_platform_windows, ) import pandas.util._test_decorators as td import pandas.io.common as icom from pandas.io.parsers import read_csv @pytest.fixtu...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_sql.py
from __future__ import annotations import contextlib from contextlib import closing import csv from datetime import ( date, datetime, time, timedelta, ) from io import StringIO from pathlib import Path import sqlite3 from typing import TYPE_CHECKING import uuid import numpy as np import pytest from p...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_fsspec.py
import io import numpy as np import pytest from pandas import ( DataFrame, date_range, read_csv, read_excel, read_feather, read_json, read_parquet, read_pickle, read_stata, read_table, ) import pandas._testing as tm from pandas.util import _test_decorators as td pytestmark = p...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_gcs.py
from io import BytesIO import os import pathlib import tarfile import zipfile import numpy as np import pytest from pandas import ( DataFrame, date_range, read_csv, read_excel, read_json, read_parquet, ) import pandas._testing as tm from pandas.util import _test_decorators as td pytestmark = ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_feather.py
""" test feather-format compat """ import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import ( ArrowStringArray, StringArray, ) from pandas.io.feather_format import read_feather, to_feather # isort:skip pytestmark = pytest.mark.filterwarnings( "igno...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_common.py
""" Tests for the pandas.io.common functionalities """ import codecs import errno from functools import partial from io import ( BytesIO, StringIO, UnsupportedOperation, ) import mmap import os from pathlib import Path import pickle import tempfile import pytest from pandas.compat import is_platform_windo...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_pickle.py
""" manage legacy pickle tests How to add pickle tests: 1. Install pandas version intended to output the pickle. 2. Execute "generate_legacy_storage_files.py" to create the pickle. $ python generate_legacy_storage_files.py <output_dir> pickle 3. Move the created pickle to "data/legacy_pickle/<version>" directory. "...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_html.py
from collections.abc import Iterator from functools import partial from io import ( BytesIO, StringIO, ) import os from pathlib import Path import re import threading from urllib.error import URLError import numpy as np import pytest from pandas.compat import is_platform_windows import pandas.util._test_decor...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_orc.py
""" test orc compat """ import datetime from decimal import Decimal from io import BytesIO import os import pathlib import numpy as np import pytest import pandas as pd from pandas import read_orc import pandas._testing as tm from pandas.core.arrays import StringArray pytest.importorskip("pyarrow.orc") import pyarr...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_compression.py
import gzip import io import os from pathlib import Path import subprocess import sys import tarfile import textwrap import time import zipfile import pytest from pandas.compat import is_platform_windows import pandas as pd import pandas._testing as tm import pandas.io.common as icom @pytest.mark.parametrize( ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_s3.py
from io import BytesIO import pytest from pandas import read_csv def test_streaming_s3_objects(): # GH17135 # botocore gained iteration support in 1.10.47, can now be used in read_* pytest.importorskip("botocore", minversion="1.10.47") from botocore.response import StreamingBody data = [b"foo,b...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_clipboard.py
import os from textwrap import dedent import numpy as np import pytest from pandas.compat import ( is_ci_environment, is_platform_mac, ) from pandas.errors import ( PyperclipException, PyperclipWindowsException, ) import pandas as pd from pandas import ( NA, DataFrame, Series, get_opt...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_stata.py
import bz2 import datetime as dt from datetime import datetime import gzip import io import os import struct import tarfile import zipfile import numpy as np import pytest import pandas as pd from pandas import CategoricalDtype import pandas._testing as tm from pandas.core.frame import ( DataFrame, Series, ) ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/io/test_user_agent.py
""" Tests for the pandas custom headers in http(s) requests """ import gzip import http.server from io import BytesIO import multiprocessing import socket import time import urllib.error import pytest from pandas.compat import is_ci_environment import pandas.util._test_decorators as td import pandas as pd import pan...
0
public_repos/pandas/pandas/tests/io
public_repos/pandas/pandas/tests/io/data/gbq_fake_job.txt
{'status': {'state': 'DONE'}, 'kind': 'bigquery#job', 'statistics': {'query': {'cacheHit': True, 'totalBytesProcessed': '0'}, 'endTime': '1377668744674', 'totalBytesProcessed': '0', 'startTime': '1377668744466'}, 'jobReference': {'projectId': '57288129629', 'jobId': 'bqjob_r5f956972f0190bdf_00000140c374bf42_2'}, 'etag'...
0
public_repos/pandas/pandas/tests/io/data
public_repos/pandas/pandas/tests/io/data/html/wikipedia_states.html
<!DOCTYPE html> <html lang="en" dir="ltr" class="client-nojs"> <head> <meta charset="UTF-8" /> <title>List of U.S. states and territories by area - Wikipedia, the free encyclopedia</title> <meta name="generator" content="MediaWiki 1.24wmf14" /> <link rel="alternate" href="android-app://org.wikipedia/http/en.m.wikipedia...
0
public_repos/pandas/pandas/tests/io/data
public_repos/pandas/pandas/tests/io/data/html/valid_markup.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org"> <title></title> </head> <body> <table border="1" class="dataframe"> <thead> <tr style="text...
0
public_repos/pandas/pandas/tests/io/data
public_repos/pandas/pandas/tests/io/data/html/banklist.html
<!DOCTYPE html><!-- HTML5 --> <html lang="en-US"> <!-- Content language is American English. --> <head> <title>FDIC: Failed Bank List</title> <!-- Meta Tags --> <meta charset="UTF-8"> <!-- Unicode character encoding --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Turns off IE Compatibility Mode --> <meta...
0
public_repos/pandas/pandas/tests/io/data
public_repos/pandas/pandas/tests/io/data/html/spam.html
<!DOCTYPE html> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <htm...
0
public_repos/pandas/pandas/tests/io/data
public_repos/pandas/pandas/tests/io/data/stata/stata5.csv
byte_,int_,long_,float_,double_,date_td,string_,string_1 0,0,0,0,0,,"a","a" 1,1,1,1,1,,"ab","b" -1,-1,-1,-1,-1,,"abc","c" 100,32740,-2147483647,-1.70100000027769e+38,-2.0000000000000e+307,1970-01-01,"abcdefghijklmnop","d" -127,-32767,2147483620,1.70100000027769e+38,8.0000000000000e+307,1970-01-02,"abcdefghijklmnopqrstu...
0