Skip to main content

.

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

```
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)

""" `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()
print arr

""" `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()
print arr
```

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.4.tar.gz (5.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page