Skip to content

Commit 00bb09d

Browse files
authored
CLN: remove unused in pd._testing (#32534)
1 parent 5000420 commit 00bb09d

File tree

1 file changed

+3
-90
lines changed

1 file changed

+3
-90
lines changed

pandas/_testing.py

+3-90
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
is_datetime64tz_dtype,
3333
is_extension_array_dtype,
3434
is_interval_dtype,
35-
is_list_like,
3635
is_number,
3736
is_numeric_dtype,
3837
is_period_dtype,
@@ -418,10 +417,7 @@ def rands_array(nchars, size, dtype="O"):
418417
.view((np.str_, nchars))
419418
.reshape(size)
420419
)
421-
if dtype is None:
422-
return retval
423-
else:
424-
return retval.astype(dtype)
420+
return retval.astype(dtype)
425421

426422

427423
def randu_array(nchars, size, dtype="O"):
@@ -433,10 +429,7 @@ def randu_array(nchars, size, dtype="O"):
433429
.view((np.unicode_, nchars))
434430
.reshape(size)
435431
)
436-
if dtype is None:
437-
return retval
438-
else:
439-
return retval.astype(dtype)
432+
return retval.astype(dtype)
440433

441434

442435
def rands(nchars):
@@ -449,16 +442,6 @@ def rands(nchars):
449442
return "".join(np.random.choice(RANDS_CHARS, nchars))
450443

451444

452-
def randu(nchars):
453-
"""
454-
Generate one random unicode string.
455-
456-
See `randu_array` if you want to create an array of random unicode strings.
457-
458-
"""
459-
return "".join(np.random.choice(RANDU_CHARS, nchars))
460-
461-
462445
def close(fignum=None):
463446
from matplotlib.pyplot import get_fignums, close as _close
464447

@@ -725,10 +708,7 @@ def repr_class(x):
725708
# return Index as it is to include values in the error message
726709
return x
727710

728-
try:
729-
return type(x).__name__
730-
except AttributeError:
731-
return repr(type(x))
711+
return type(x).__name__
732712

733713
if exact == "equiv":
734714
if type(left) != type(right):
@@ -2093,53 +2073,6 @@ def _gen_unique_rand(rng, _extra_size):
20932073
return i.tolist(), j.tolist()
20942074

20952075

2096-
def makeMissingCustomDataframe(
2097-
nrows,
2098-
ncols,
2099-
density=0.9,
2100-
random_state=None,
2101-
c_idx_names=True,
2102-
r_idx_names=True,
2103-
c_idx_nlevels=1,
2104-
r_idx_nlevels=1,
2105-
data_gen_f=None,
2106-
c_ndupe_l=None,
2107-
r_ndupe_l=None,
2108-
dtype=None,
2109-
c_idx_type=None,
2110-
r_idx_type=None,
2111-
):
2112-
"""
2113-
Parameters
2114-
----------
2115-
Density : float, optional
2116-
Float in (0, 1) that gives the percentage of non-missing numbers in
2117-
the DataFrame.
2118-
random_state : {np.random.RandomState, int}, optional
2119-
Random number generator or random seed.
2120-
2121-
See makeCustomDataframe for descriptions of the rest of the parameters.
2122-
"""
2123-
df = makeCustomDataframe(
2124-
nrows,
2125-
ncols,
2126-
c_idx_names=c_idx_names,
2127-
r_idx_names=r_idx_names,
2128-
c_idx_nlevels=c_idx_nlevels,
2129-
r_idx_nlevels=r_idx_nlevels,
2130-
data_gen_f=data_gen_f,
2131-
c_ndupe_l=c_ndupe_l,
2132-
r_ndupe_l=r_ndupe_l,
2133-
dtype=dtype,
2134-
c_idx_type=c_idx_type,
2135-
r_idx_type=r_idx_type,
2136-
)
2137-
2138-
i, j = _create_missing_idx(nrows, ncols, density, random_state)
2139-
df.values[i, j] = np.nan
2140-
return df
2141-
2142-
21432076
def makeMissingDataframe(density=0.9, random_state=None):
21442077
df = makeDataFrame()
21452078
i, j = _create_missing_idx(*df.shape, density=density, random_state=random_state)
@@ -2387,7 +2320,6 @@ def wrapper(*args, **kwargs):
23872320
def assert_produces_warning(
23882321
expected_warning=Warning,
23892322
filter_level="always",
2390-
clear=None,
23912323
check_stacklevel=True,
23922324
raise_on_extra_warnings=True,
23932325
):
@@ -2417,12 +2349,6 @@ class for all warnings. To check that no warning is returned,
24172349
from each module
24182350
* "once" - print the warning the first time it is generated
24192351
2420-
clear : str, default None
2421-
If not ``None`` then remove any previously raised warnings from
2422-
the ``__warningsregistry__`` to ensure that no warning messages are
2423-
suppressed by this context manager. If ``None`` is specified,
2424-
the ``__warningsregistry__`` keeps track of which warnings have been
2425-
shown, and does not show them again.
24262352
check_stacklevel : bool, default True
24272353
If True, displays the line that called the function containing
24282354
the warning to show were the function is called. Otherwise, the
@@ -2455,19 +2381,6 @@ class for all warnings. To check that no warning is returned,
24552381

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

2458-
if clear is not None:
2459-
# make sure that we are clearing these warnings
2460-
# if they have happened before
2461-
# to guarantee that we will catch them
2462-
if not is_list_like(clear):
2463-
clear = [clear]
2464-
for m in clear:
2465-
try:
2466-
m.__warningregistry__.clear()
2467-
except AttributeError:
2468-
# module may not have __warningregistry__
2469-
pass
2470-
24712384
saw_warning = False
24722385
warnings.simplefilter(filter_level)
24732386
yield w

0 commit comments

Comments
 (0)