forked from blaze/blaze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_quickstart.py
51 lines (37 loc) · 1.19 KB
/
test_quickstart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Tests for the simple sessions we put on the documentation page.
"""
def test_simple_session():
from blaze import Array, dshape
ds = dshape('2, 2, int')
a = Array([1,2,3,4], ds)
def test_simple_persistence():
import tempfile, shutil, os.path
import numpy as np
from blaze import Array, dshape, params
ds = dshape('2, 2, float64')
data = np.zeros(4).reshape(2,2)
td = tempfile.mkdtemp()
tmppath = os.path.join(td, 'a')
a = Array([1,2,3,4], ds, params=params(storage=tmppath))
# Remove everything under the temporary dir
shutil.rmtree(td)
def test_ones():
from blaze import ones
a = ones('10, float64', params=params(clevel=5))
def test_fromiter():
from blaze import fromiter
a = fromiter(xrange(10), 'x, float64', params=params(clevel=5))
def test_custom_dshape():
from blaze import Array, RecordDecl
from blaze import int32, string
class CustomStock(RecordDecl):
name = string
max = int32
min = int32
def mid(self):
return (self.min + self.max)/2
a = Array([('GOOG', 120, 153)], CustomStock)
def test_sqlite():
from blaze import open
a = open('sqlite://')