32
32
is_datetime64tz_dtype ,
33
33
is_extension_array_dtype ,
34
34
is_interval_dtype ,
35
- is_list_like ,
36
35
is_number ,
37
36
is_numeric_dtype ,
38
37
is_period_dtype ,
@@ -418,10 +417,7 @@ def rands_array(nchars, size, dtype="O"):
418
417
.view ((np .str_ , nchars ))
419
418
.reshape (size )
420
419
)
421
- if dtype is None :
422
- return retval
423
- else :
424
- return retval .astype (dtype )
420
+ return retval .astype (dtype )
425
421
426
422
427
423
def randu_array (nchars , size , dtype = "O" ):
@@ -433,10 +429,7 @@ def randu_array(nchars, size, dtype="O"):
433
429
.view ((np .unicode_ , nchars ))
434
430
.reshape (size )
435
431
)
436
- if dtype is None :
437
- return retval
438
- else :
439
- return retval .astype (dtype )
432
+ return retval .astype (dtype )
440
433
441
434
442
435
def rands (nchars ):
@@ -449,16 +442,6 @@ def rands(nchars):
449
442
return "" .join (np .random .choice (RANDS_CHARS , nchars ))
450
443
451
444
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
-
462
445
def close (fignum = None ):
463
446
from matplotlib .pyplot import get_fignums , close as _close
464
447
@@ -725,10 +708,7 @@ def repr_class(x):
725
708
# return Index as it is to include values in the error message
726
709
return x
727
710
728
- try :
729
- return type (x ).__name__
730
- except AttributeError :
731
- return repr (type (x ))
711
+ return type (x ).__name__
732
712
733
713
if exact == "equiv" :
734
714
if type (left ) != type (right ):
@@ -2093,53 +2073,6 @@ def _gen_unique_rand(rng, _extra_size):
2093
2073
return i .tolist (), j .tolist ()
2094
2074
2095
2075
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
-
2143
2076
def makeMissingDataframe (density = 0.9 , random_state = None ):
2144
2077
df = makeDataFrame ()
2145
2078
i , j = _create_missing_idx (* df .shape , density = density , random_state = random_state )
@@ -2387,7 +2320,6 @@ def wrapper(*args, **kwargs):
2387
2320
def assert_produces_warning (
2388
2321
expected_warning = Warning ,
2389
2322
filter_level = "always" ,
2390
- clear = None ,
2391
2323
check_stacklevel = True ,
2392
2324
raise_on_extra_warnings = True ,
2393
2325
):
@@ -2417,12 +2349,6 @@ class for all warnings. To check that no warning is returned,
2417
2349
from each module
2418
2350
* "once" - print the warning the first time it is generated
2419
2351
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.
2426
2352
check_stacklevel : bool, default True
2427
2353
If True, displays the line that called the function containing
2428
2354
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,
2455
2381
2456
2382
with warnings .catch_warnings (record = True ) as w :
2457
2383
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
-
2471
2384
saw_warning = False
2472
2385
warnings .simplefilter (filter_level )
2473
2386
yield w
0 commit comments