Skip to content

CLN: remove unused in pd._testing #32534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 3 additions & 90 deletions pandas/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
is_datetime64tz_dtype,
is_extension_array_dtype,
is_interval_dtype,
is_list_like,
is_number,
is_period_dtype,
is_sequence,
Expand Down Expand Up @@ -417,10 +416,7 @@ def rands_array(nchars, size, dtype="O"):
.view((np.str_, nchars))
.reshape(size)
)
if dtype is None:
return retval
else:
return retval.astype(dtype)
return retval.astype(dtype)


def randu_array(nchars, size, dtype="O"):
Expand All @@ -432,10 +428,7 @@ def randu_array(nchars, size, dtype="O"):
.view((np.unicode_, nchars))
.reshape(size)
)
if dtype is None:
return retval
else:
return retval.astype(dtype)
return retval.astype(dtype)


def rands(nchars):
Expand All @@ -448,16 +441,6 @@ def rands(nchars):
return "".join(np.random.choice(RANDS_CHARS, nchars))


def randu(nchars):
"""
Generate one random unicode string.

See `randu_array` if you want to create an array of random unicode strings.

"""
return "".join(np.random.choice(RANDU_CHARS, nchars))


def close(fignum=None):
from matplotlib.pyplot import get_fignums, close as _close

Expand Down Expand Up @@ -724,10 +707,7 @@ def repr_class(x):
# return Index as it is to include values in the error message
return x

try:
return type(x).__name__
except AttributeError:
return repr(type(x))
return type(x).__name__

if exact == "equiv":
if type(left) != type(right):
Expand Down Expand Up @@ -2103,53 +2083,6 @@ def _gen_unique_rand(rng, _extra_size):
return i.tolist(), j.tolist()


def makeMissingCustomDataframe(
nrows,
ncols,
density=0.9,
random_state=None,
c_idx_names=True,
r_idx_names=True,
c_idx_nlevels=1,
r_idx_nlevels=1,
data_gen_f=None,
c_ndupe_l=None,
r_ndupe_l=None,
dtype=None,
c_idx_type=None,
r_idx_type=None,
):
"""
Parameters
----------
Density : float, optional
Float in (0, 1) that gives the percentage of non-missing numbers in
the DataFrame.
random_state : {np.random.RandomState, int}, optional
Random number generator or random seed.

See makeCustomDataframe for descriptions of the rest of the parameters.
"""
df = makeCustomDataframe(
nrows,
ncols,
c_idx_names=c_idx_names,
r_idx_names=r_idx_names,
c_idx_nlevels=c_idx_nlevels,
r_idx_nlevels=r_idx_nlevels,
data_gen_f=data_gen_f,
c_ndupe_l=c_ndupe_l,
r_ndupe_l=r_ndupe_l,
dtype=dtype,
c_idx_type=c_idx_type,
r_idx_type=r_idx_type,
)

i, j = _create_missing_idx(nrows, ncols, density, random_state)
df.values[i, j] = np.nan
return df


def makeMissingDataframe(density=0.9, random_state=None):
df = makeDataFrame()
i, j = _create_missing_idx(*df.shape, density=density, random_state=random_state)
Expand Down Expand Up @@ -2397,7 +2330,6 @@ def wrapper(*args, **kwargs):
def assert_produces_warning(
expected_warning=Warning,
filter_level="always",
clear=None,
check_stacklevel=True,
raise_on_extra_warnings=True,
):
Expand Down Expand Up @@ -2427,12 +2359,6 @@ class for all warnings. To check that no warning is returned,
from each module
* "once" - print the warning the first time it is generated

clear : str, default None
If not ``None`` then remove any previously raised warnings from
the ``__warningsregistry__`` to ensure that no warning messages are
suppressed by this context manager. If ``None`` is specified,
the ``__warningsregistry__`` keeps track of which warnings have been
shown, and does not show them again.
check_stacklevel : bool, default True
If True, displays the line that called the function containing
the warning to show were the function is called. Otherwise, the
Expand Down Expand Up @@ -2465,19 +2391,6 @@ class for all warnings. To check that no warning is returned,

with warnings.catch_warnings(record=True) as w:

if clear is not None:
# make sure that we are clearing these warnings
# if they have happened before
# to guarantee that we will catch them
if not is_list_like(clear):
clear = [clear]
for m in clear:
try:
m.__warningregistry__.clear()
except AttributeError:
# module may not have __warningregistry__
pass

saw_warning = False
warnings.simplefilter(filter_level)
yield w
Expand Down