Package gmisclib :: Module blue_data_selector :: Class bluedata
[frames] | no frames]

Class bluedata

source code


Instance Methods
 
__init__(self, data, blueness=2.0, rng=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
check(self, fcn)
This exists to let you run some kind of read-only check on the stored data.
source code
 
add(self, datum)
Add another datum to be sampled.
source code
 
pickiter(self, n)
Pick n items from the data set.
source code
 
pick1(self) source code
list(whatever), with length==n
pick(self, n)
Pick n items from the data set.
source code
whatever (not a list!)
peek(self)
Inspect (but do not remove) the next item to be picked.
source code
tuple(list, list)
split(self, n)
Split the data set into two parts, of size n and len(data)-n.
source code
 
__iter__(self)
This iterator will produce samples forever.
source code
 
__len__(self) source code
 
reset(self)
Forget prior history of usage.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, data, blueness=2.0, rng=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • data (list(whatever)) - data to sample
  • blueness (float) - How much should you avoid choosing the same item in succession? If -0.5 < blueness < 0, then you are more likely to choose the same item several times in a row. If 0 < blueness < 1, you are unlikely to choose the same item twice in succession (though it is possible). If blueness => 1, you will never get the same item twice until you've run through the entire list of data.
  • rng - a random number generator, per the random module. You can generate repeated sequences of data by repeatedly passing it a random number generator in the same state.
Overrides: object.__init__

add(self, datum)

source code 

Add another datum to be sampled.

Parameters:
  • datum (whatever) - thing to be added. It has a probability of 1/len(self) of being the next sample.

pickiter(self, n)

source code 

Pick n items from the data set.

Parameters:
  • n (int) - how many items to pick.

pick(self, n)

source code 

Pick n items from the data set.

Parameters:
  • n (int) - how many items to pick.
Returns: list(whatever), with length==n

peek(self)

source code 

Inspect (but do not remove) the next item to be picked.

Returns: whatever (not a list!)
the next item to be picked.

split(self, n)

source code 

Split the data set into two parts, of size n and len(data)-n. Successive calls to split will avoid having the same items appear in the first part. For instance, given a bluedata of size 100, with ten calls to split(10), each datum will appear in the first part of the return tuple exactly once.

Returns: tuple(list, list)

reset(self)

source code 

Forget prior history of usage. Choices after this call are uncorrelated with choices before this call.