Skip to content

Commit 0a498a6

Browse files
committed
cp to tests
1 parent 761c166 commit 0a498a6

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/test_fetch_same.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from nose.tools import assert_equal
2+
from . import PREFIX, CONN_INFO
3+
import numpy as np
4+
import datajoint as dj
5+
6+
schema = dj.Schema(PREFIX + "_fetch_same", connection=dj.conn(**CONN_INFO))
7+
8+
9+
class TestFetchSame:
10+
@classmethod
11+
def setup_class(cls):
12+
@schema
13+
class ProjData(dj.Manual):
14+
definition = """
15+
id : int
16+
---
17+
resp : float
18+
sim : float
19+
big : longblob
20+
blah : varchar(10)
21+
"""
22+
23+
ProjData().insert(
24+
[
25+
{"id": 0, "resp": 20.33, "sim": 45.324, "big": 3, "blah": "yes"},
26+
{
27+
"id": 1,
28+
"resp": 94.3,
29+
"sim": 34.23,
30+
"big": {"key1": np.random.randn(20, 10)},
31+
"blah": "si",
32+
},
33+
{
34+
"id": 2,
35+
"resp": 1.90,
36+
"sim": 10.23,
37+
"big": np.random.randn(4, 2),
38+
"blah": "sim",
39+
},
40+
]
41+
)
42+
43+
cls.projdata = ProjData()
44+
45+
def test_object_conversion_one(self):
46+
new = self.projdata.proj(sub="resp").fetch("sub")
47+
assert_equal(new.dtype, np.float64)
48+
49+
def test_object_conversion_two(self):
50+
[sub, add] = self.projdata.proj(sub="resp", add="sim").fetch("sub", "add")
51+
assert_equal(sub.dtype, np.float64)
52+
assert_equal(add.dtype, np.float64)
53+
54+
def test_object_conversion_all(self):
55+
new = self.projdata.proj(sub="resp", add="sim").fetch()
56+
assert_equal(new["sub"].dtype, np.float64)
57+
assert_equal(new["add"].dtype, np.float64)
58+
59+
def test_object_no_convert(self):
60+
new = self.projdata.fetch()
61+
assert_equal(new["big"].dtype, "object")
62+
assert_equal(new["blah"].dtype, "object")

0 commit comments

Comments
 (0)