6
6
from nose .tools import assert_equal , raises
7
7
import datajoint as dj
8
8
from . import PREFIX , CONN_INFO
9
-
9
+ import datetime
10
+ import numpy as np
10
11
schema = dj .Schema (PREFIX + '_aggr_regress' , connection = dj .conn (** CONN_INFO ))
11
12
12
13
# --------------- ISSUE 386 -------------------
@@ -94,6 +95,38 @@ class X(dj.Lookup):
94
95
contents = zip (range (10 ))
95
96
96
97
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
+
97
130
def test_issue558_part1 ():
98
131
q = (A - B ).proj (id2 = '3' )
99
132
assert_equal (len (A - B ), len (q ))
@@ -103,3 +136,11 @@ def test_issue558_part2():
103
136
d = dict (id = 3 , id2 = 5 )
104
137
assert_equal (len (X & d ), len ((X & d ).proj (id2 = '3' )))
105
138
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