.
Project description
Array stored in database
========================
`DBArray` is an 2D array stored in database.
The purpose of this class is to provide a way to store and access large
array which can not be loaded into memory.
## Example
```python
import numpy as np
from dbarray import DBArray
# Create random array
nrows = 5
ncols = 8
dtype = np.float32
arr = np.random.random((nrows, ncols))
arr = np.require(arr, dtype)
print arr
""" `DBArray` from scratch
"""
# Create `DBArray`
dba1 = DBArray('test1.db')
# Initialize
dba1.set_shape((nrows, ncols))
dba1.set_dtype(dtype)
# Set rows
for i in range(nrows):
dba1[i] = arr[i]
# Convert to ndarray
print dba1.tondarray()
""" `DBArray` from `ndarray`
"""
# Create `DBArray`
dba2 = DBArray.fromndarray(arr, 'test2.db')
# Check attributes
print dba2.nrows, dba2.ncols, dba2.dtype
# Convert to ndarray
print dba2.tondarray()
```
========================
`DBArray` is an 2D array stored in database.
The purpose of this class is to provide a way to store and access large
array which can not be loaded into memory.
## Example
```python
import numpy as np
from dbarray import DBArray
# Create random array
nrows = 5
ncols = 8
dtype = np.float32
arr = np.random.random((nrows, ncols))
arr = np.require(arr, dtype)
print arr
""" `DBArray` from scratch
"""
# Create `DBArray`
dba1 = DBArray('test1.db')
# Initialize
dba1.set_shape((nrows, ncols))
dba1.set_dtype(dtype)
# Set rows
for i in range(nrows):
dba1[i] = arr[i]
# Convert to ndarray
print dba1.tondarray()
""" `DBArray` from `ndarray`
"""
# Create `DBArray`
dba2 = DBArray.fromndarray(arr, 'test2.db')
# Check attributes
print dba2.nrows, dba2.ncols, dba2.dtype
# Convert to ndarray
print dba2.tondarray()
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dbarray-0.1.7.tar.gz
(5.3 kB
view details)
File details
Details for the file dbarray-0.1.7.tar.gz
.
File metadata
- Download URL: dbarray-0.1.7.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfa4461f8e6b914738efc08d93db0f085d3cbfa9f72ca4ad29c944ab71748222 |
|
MD5 | 10631f17d841ce13f488061b6d3d9c8a |
|
BLAKE2b-256 | d5a0a584a32d7819a28e626706758824272c06995ba6a997e820ea8035bcd26c |