-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] add test for subsetting distributions (#43)
Adds a test to the distribution suite tests ensuring that they subset appropriately via `loc` and `iloc`, and satisfy common interface expectations on the resulting object and index. Also fixes a bug in subsetting of `Empirical` that was highlighted by these tests.
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Utility functions for working with indices.""" | ||
|
||
import numpy as np | ||
|
||
|
||
def random_ss_ix(ix, size, replace=True): | ||
"""Randomly uniformly sample indices from a list of indices. | ||
Parameters | ||
---------- | ||
ix : pd.Index or subsettable iterable via getitem | ||
list of indices to sample from | ||
size : int | ||
number of indices to sample | ||
replace : bool, default=True | ||
whether to sample with replacement | ||
""" | ||
a = range(len(ix)) | ||
ixs = ix[np.random.choice(a, size=size, replace=replace)] | ||
return ixs |