Skip to content

Commit 42eb2c2

Browse files
committed
Add test for correct left join __len__
1 parent f6917ec commit 42eb2c2

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

tests/test_aggr_regressions.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from nose.tools import assert_equal, raises
77
import datajoint as dj
88
from . import PREFIX, CONN_INFO
9-
9+
import datetime
10+
import numpy as np
1011
schema = dj.Schema(PREFIX + '_aggr_regress', connection=dj.conn(**CONN_INFO))
1112

1213
# --------------- ISSUE 386 -------------------
@@ -94,6 +95,38 @@ class X(dj.Lookup):
9495
contents = zip(range(10))
9596

9697

98+
@schema
99+
class Parent(dj.Manual):
100+
definition = """
101+
# Parent table
102+
id: int
103+
---
104+
txt = "NA" : varchar(32)
105+
"""
106+
107+
108+
@schema
109+
class Child(dj.Computed):
110+
definition = """
111+
# Child table
112+
-> Parent
113+
start_time: datetime(6)
114+
---
115+
timestamps: longblob
116+
"""
117+
118+
def make(self, key):
119+
t = np.random.poisson(1000, 10)
120+
t.sort()
121+
self.insert1(
122+
{
123+
"start_time": datetime.datetime.now(),
124+
"timestamps": t,
125+
**key,
126+
}
127+
)
128+
print(f"ingested w/ {key}")
129+
97130
def test_issue558_part1():
98131
q = (A-B).proj(id2='3')
99132
assert_equal(len(A - B), len(q))
@@ -103,3 +136,11 @@ def test_issue558_part2():
103136
d = dict(id=3, id2=5)
104137
assert_equal(len(X & d), len((X & d).proj(id2='3')))
105138

139+
140+
def test_left_join_len():
141+
Parent.insert1({"id": 1})
142+
Child.populate()
143+
Parent.insert([{"id": 2}, {"id": 3}, {"id": 4}])
144+
q = Parent.join(Child & "id != 1", left=True)
145+
qf = q.fetch()
146+
assert len(q) == len(qf)

0 commit comments

Comments
 (0)