bw_processing.array_creation
Functions
|
|
|
Create a numpy array data |
|
Create a numpy array from an iterable of indeterminate length. |
|
Create a numpy structured array from an iterable of indeterminate length. |
|
Create a numpy structured array for data |
|
|
|
Module Contents
- bw_processing.array_creation.create_array(iterable, nrows=None, dtype=np.float32)[source]
Create a numpy array data
iterable. Returns a filepath of a created file (iffilepathis provided, or the array.iterablecan be data already in memory, or a generator.nrowscan be supplied, if known. Ifiterablehas a length, it will be determined automatically. Ifnrowsis not known, this function generates chunked arrays untiliterableis exhausted, and concatenates them.Either
nrowsorncolsmust be specified.
- bw_processing.array_creation.create_chunked_array(iterable, ncols, dtype=np.float32, bucket_size=500)[source]
Create a numpy array from an iterable of indeterminate length.
Needed when we can’t determine the length of the iterable ahead of time (e.g. for a generator or a database cursor), so can’t create the complete array in memory in on step
Creates a list of arrays with
bucket_sizerows untiliterableis exhausted, then concatenates them.- Parameters:
iterable – Iterable of data used to populate the array.
ncols – Number of columns in the created array.
dtype – Numpy dtype of the created array
bucket_size – Number of rows in each intermediate array.
- Returns:.
Returns the created array. Will return a zero-length array if
iterablehas no data.
- bw_processing.array_creation.create_chunked_structured_array(iterable, dtype, bucket_size=20000)[source]
Create a numpy structured array from an iterable of indeterminate length.
Needed when we can’t determine the length of the iterable ahead of time (e.g. for a generator or a database cursor), so can’t create the complete array in memory in on step
Creates a list of arrays with
bucket_sizerows untiliterableis exhausted, then concatenates them.- Parameters:
iterable – Iterable of data used to populate the array.
dtype – Numpy dtype of the created array
format_function – If provided, this function will be called on each row of
iterablebefore insertion in the array.bucket_size – Number of rows in each intermediate array.
- Returns:.
Returns the created array. Will return a zero-length array if
iterablehas no data.
- bw_processing.array_creation.create_structured_array(iterable, dtype, nrows=None, sort=False, sort_fields=None)[source]
Create a numpy structured array for data
iterable. Returns a filepath of a created file (iffilepathis provided, or the array.iterablecan be data already in memory, or a generator.nrowscan be supplied, if known. Ifiterablehas a length, it will be determined automatically. Ifnrowsis not known, this function generates chunked arrays untiliterableis exhausted, and concatenates them.