sortednp.kway
Functions
intersect
Return a sorted array containing the intersection of all input arrays.
If the optional flag assume_sorted is set to False, the function sorts the arrays prior to intersecting. The arrays are order by increasing size before starting to intersection the arrays one-by-one.
The method raises a TypeError, if the array count is zero.
The arguments can load the arrays on the fly. If an argument is callable, its return value is used as an array instead of the argument itself. This makes it possible to load one array after another to avoid having all arrays in memory at the same time. Arrays deferred in this way, are loaded only after all in-memory arrays are intersected. The computed intersection is empty at any point, the function stops and returns an empty array.
Note
Note on the performance: The function intersects the arrays one-by-one. This is not the most performant implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*arrays |
ndarray or callable
|
The arrays to intersect as numpy arrays or deferred arrays. |
()
|
assume_sorted |
bool
|
If True, the function assumes that the arrays are sorted. If False, the function sorts the arrays before intersecting. The default is True. |
True
|
**kwds |
dict
|
Any other keyword argument is passed to the native intersect function. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The union array. |
Source code in sortednp/kway.py
merge
Return a sorted array containing the union of all input arrays.
If the optional flag assume_sorted is set to False, the function sorts the arrays before merging.
The method raises a TypeError, if the array count is zero.
The arguments can load the arrays on the fly. If an argument is callable, its return value is used as an array instead of the argument itself. This makes it possible to load one array after another to avoid having all arrays in memory at the same time.
Note
Note on the performance: The function merges the arrays one-by-one. This is not the most performant implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*arrays |
ndarray or callable
|
The arrays to merge as numpy arrays or deferred arrays. |
()
|
assume_sorted |
bool
|
If True, the function assumes that the arrays are sorted. If False, the function sorts the arrays before merging. The default is True. |
True
|
**kwds |
dict
|
Any other keyword argument is passed to the native merge function. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The merged array. |
Source code in sortednp/kway.py
resolve
Helper function to check whether the given object is callable. If yes, return its return value, otherwise return the object itself.
This function is used by the package to load large datasets on demand to avoid out-of-memory scenarios.