instancelib.instances.memory module
- class instancelib.instances.memory.AbstractMemoryProvider(instances)[source]
Bases:
InstanceProvider[InstanceType,KT,DT,VT,RT],ABC,Generic[InstanceType,KT,DT,VT,RT]- bulk_get_all()[source]
Returns a list of all instances in this provider.
Warning
When using this method on very large providers with lazily loaded instances, this may yield Out of Memory errors, as all the data will be loaded into RAM. Use with caution!
- bulk_get_vectors(keys)[source]
Given a list of instance keys, return the vectors
- Parameters:
keys (Sequence[KT]) – A list of vectors
- Returns:
A tuple of two sequences, one with keys and one with vectors. The indices match, so the instance with
keys[2]has as vectorvectors[2]- Return type:
Warning
Some underlying implementations do not preserve the ordering of the parameter keys. Therefore, always use the keys variable from the returned tuple for the correct matching.
- property empty: bool
Determines if the provider does not contain instances
- Returns:
True if the provider is empty
- Return type:
- classmethod shuffle(provider, mapping)[source]
Reorder the provider according to the given mapping
- Parameters:
provider (InstanceProvider[InstanceType, _T, DT, VT, RT]) – The provider that needs to be reordered
mapping (Mapping[_T, KT]) – The mapping that maps old identifiers to new identifiers
- Returns:
The shuffled
- Return type:
Self
- class instancelib.instances.memory.DataPoint(identifier, data, vector=None, representation=None)[source]
Bases:
Instance[KT,DT,VT,RT],Generic[KT,DT,VT,RT]- Parameters:
- property identifier: KT
Get the identifier of the instance
- Returns:
The identifier key of the instance
- Return type:
- class instancelib.instances.memory.DataPointProvider(instances)[source]
Bases:
AbstractMemoryProvider[DataPoint[Union[KT,UUID],DT,VT,RT],Union[KT,UUID],DT,VT,RT],Generic[KT,DT,VT,RT]
- class instancelib.instances.memory.MemoryBucketProvider(dataset, instances)[source]
Bases:
AbstractBucketProvider[InstanceType,KT,DT,VT,RT],Generic[InstanceType,KT,DT,VT,RT]- Parameters: