Skip to content

Commit 3a61881

Browse files
Update gdic.ijs
1 parent 9f196e6 commit 3a61881

1 file changed

Lines changed: 63 additions & 63 deletions

File tree

test/gdic.ijs

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
prolog './gdic.ijs'
2-
NB. addon/dictionary
2+
NB. addon/dict
33

4-
load 'dictionary'
4+
load 'dict'
55

6-
d =: ('hash' ,&< 'valueshape' ; 0) conew 'jdictionary'
6+
d =: ('hash' ,&< 'valueshape' ; 0) conew 'jdict'
77
'' put__d i. 1000
88
techo 'hash ',": 100 (6!:2) 'has__d f."0 k' [ k =. 10 # i. 1000
99
destroy__d ''
1010

11-
d =: ('tree' ,&< 'valueshape' ; 0) conew 'jdictionary'
11+
d =: ('tree' ,&< 'valueshape' ; 0) conew 'jdict'
1212
'' put__d i. 1000
1313
techo 'tree ',": 100 (6!:2) 'has__d f."0 k' [ k =. 10 # i. 1000
1414
destroy__d ''
@@ -28,16 +28,16 @@ u :: (<:@(13!:11)@'' >@{ 9!:8@'')
2828
}}
2929

3030
{{
31-
assert. 'length error' -: 'jdictionary' conew~ GetError y , < 'keyshape' ; 2 0 2
32-
assert. 'length error' -: 'jdictionary' conew~ GetError y , < 'keyshape' ; 0
33-
assert. 'length error' -: 'jdictionary' conew~ GetError y , < 'valueshape' ; 7 0
34-
assert. 'length error' -: 'jdictionary' conew~ GetError y , < 'valueshape' ; 0 0
31+
assert. 'length error' -: 'jdict' conew~ GetError y , < 'keyshape' ; 2 0 2
32+
assert. 'length error' -: 'jdict' conew~ GetError y , < 'keyshape' ; 0
33+
assert. 'length error' -: 'jdict' conew~ GetError y , < 'valueshape' ; 7 0
34+
assert. 'length error' -: 'jdict' conew~ GetError y , < 'valueshape' ; 0 0
3535
coreset ''
36-
jdict =. 'jdictionary' conew~ 'hash' ,&< 'keyhash' ,&< _1"0`''
36+
jdict =. 'jdict' conew~ 'hash' ,&< 'keyhash' ,&< _1"0`''
3737
'domain error' -: put__jdict GetError~ 7
3838
destroy__jdict ''
3939
params =. y , < 'valueshape' ; 5
40-
jdict =. params conew 'jdictionary'
40+
jdict =. params conew 'jdict'
4141
assert. 'domain error' -: (i. 5) put__jdict GetError 2.3 3.4
4242
assert. 'domain error' -: (2 5 $ 'abcde') put__jdict GetError 0 1
4343
assert. 'domain error' -: (3 5 $ 3.14) put__jdict GetError 2 3 4
@@ -53,8 +53,8 @@ NB. BASIC.
5353

5454
test_basic1 =: {{
5555
'index_type keyhash keycompare' =. <"0 y
56-
params =. index_type , < ('keyhash' ,&< keyhash) , ('keycompare' ,&< keycompare) , ('initcapacity' ; 4) , ('keytype' ; 'integer') , ('valueshape' ; 3) , ('keyshape' ; 2) ,: ('valuetype' ; 4)
57-
mydict =. params conew 'jdictionary'
56+
params =. index_type , < ('keyhash' ,&< keyhash) , ('keycompare' ,&< keycompare) , ('initcapacity' ; 4) , ('kt' ; 'integer') , ('vs' ; 3) , ('ks' ; 2) ,: ('vt' ; 4)
57+
mydict =. params conew 'jdict'
5858
assert. 0 -: count__mydict ''
5959
1 2 3 put__mydict 2 3
6060
assert. 1 2 3 -: get__mydict 2 3
@@ -108,7 +108,7 @@ EMPTY
108108
test_basic2 =: {{
109109
'index_type keyhash keycompare' =. <"0 y
110110
params =. index_type , < ('keyhash' ,&< keyhash) , ('keycompare' ,&< keycompare) , ('initcapacity' ; 4) , ('keytype' ; 'boxed') , ('valueshape' ; 3) , ('keyshape' ; 2) ,: ('valuetype' ; 4)
111-
mydict =. params conew 'jdictionary'
111+
mydict =. params conew 'jdict'
112112
1 2 3 put__mydict <"(0) 2 3
113113
assert. 1 2 3 -: get__mydict <"(0) 2 3
114114
4 5 6 put__mydict <"(0) 1 3
@@ -145,11 +145,11 @@ test_basic2 COMBINATIONS
145145
NB. INTERNAL RANK.
146146

147147
{{
148-
d =. y conew 'jdictionary'
148+
d =. y conew 'jdict'
149149
7 put__d i. 3
150150
assert. 7 7 7 -: get__d i. 3
151151
destroy__d ''
152-
d =. 'jdictionary' conew~ y ,&< ('keyshape' ; 2) ,: 'valueshape' ; 3 3
152+
d =. 'jdict' conew~ y ,&< ('keyshape' ; 2) ,: 'valueshape' ; 3 3
153153
(i. 3 3) put__d i. 3 2
154154
assert. (2 3 3 $ i. 9) -: get__d i. 2 2
155155
destroy__d ''
@@ -158,7 +158,7 @@ destroy__d ''
158158
NB. DESTROY.
159159

160160
{{
161-
jdict =. y conew 'jdictionary'
161+
jdict =. y conew 'jdict'
162162
put__jdict~ i. 7
163163
assert. 'rank error' -: destroy__jdict GetError 0
164164
assert. 'untimely request' -: get__jdict GetError 0
@@ -174,7 +174,7 @@ NB. CUSTOM KEYHASH & KEYCOMPARE
174174

175175
{{
176176
params =. y , < ('keycompare' ,&< 13!:8@16`'') ,: ('keyhash' ,&< 13!:8@16`'') NB. Return spelling error.
177-
jdict =. params conew 'jdictionary'
177+
jdict =. params conew 'jdict'
178178
42 put__jdict GetError 7 NB. No comparison for empty tree dictionary.
179179
assert. 'spelling error' -: 43 put__jdict GetError 8
180180
assert. 'spelling error' -: get__jdict GetError 7
@@ -186,7 +186,7 @@ EMPTY
186186

187187
{{
188188
params =. y , < ('keycompare' ,&< 0:`'') ,: ('keyhash' ,&< 0"0`'')
189-
mydict =. params conew 'jdictionary'
189+
mydict =. params conew 'jdict'
190190
put__mydict~ i. 5 [ put__mydict~ 2 3 [ put__mydict~ 1
191191
assert. 1 -: count__mydict ''
192192
destroy__mydict ''
@@ -198,7 +198,7 @@ NB. EMPTY.
198198
{{
199199
'index_type keyshape valshape' =. y
200200
params =. index_type ,&< ('keyshape' ; keyshape) ,: ('valueshape' ; valshape)
201-
mydict =. params conew 'jdictionary'
201+
mydict =. params conew 'jdict'
202202
frames =. 0 0 ; 0 2 ; 2 0 3 4 ; , 0
203203
'keys vals' =. <"1 frames (0 $~ ,)&.>"_ 0 keyshape ; valshape
204204
assert. frames (-: $@:has__mydict)&> keys
@@ -216,8 +216,8 @@ NB. SPARSE ARRAYS.
216216

217217
{{
218218
'index_type sparsetype' =. y
219-
assert. 'domain error' -: 'jdictionary' conew~ GetError index_type ,&< 'keytype' ; sparsetype
220-
assert. 'domain error' -: 'jdictionary' conew~ GetError index_type ,&< 'valuetype' ; sparsetype
219+
assert. 'domain error' -: 'jdict' conew~ GetError index_type ,&< 'keytype' ; sparsetype
220+
assert. 'domain error' -: 'jdict' conew~ GetError index_type ,&< 'valuetype' ; sparsetype
221221
EMPTY
222222
}}"1 INDEX_TYPES (, <)"0"_ 0 ] 2 ^ 10 + i. 6
223223

@@ -325,50 +325,50 @@ n_iter =. QKTEST{10 1
325325

326326
keyshape =. 3 2
327327
valueshape =. 0:^:x 5 8
328-
params =. y , < ('keytype' ; 'boolean') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
329-
jdict =. params conew 'jdictionary'
328+
params =. y , < ('kt' ; 'boolean') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
329+
jdict =. params conew 'jdict'
330330
jdict test_type rand_boolean`'' ; rand_integer`'' ; keyshape ; valueshape ; 5 25 ; n_iter
331331

332332
keyshape =. 2 3
333333
valueshape =. 0:^:x 4 5 4
334-
params =. y , < ('valuetype' ; 'floating') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
335-
jdict =. params conew 'jdictionary'
334+
params =. y , < ('vt' ; 'floating') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
335+
jdict =. params conew 'jdict'
336336
jdict test_type rand_integer`'' ; rand_floating`'' ; keyshape ; valueshape ; 100 ; n_iter
337337

338338
keyshape =. 7 1
339339
valueshape =. 0:^:x 1 7
340-
params =. y , < ('keytype' ; 'floating') , ('valuetype' ; 'complex') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
341-
jdict =. params conew 'jdictionary'
340+
params =. y , < ('kt' ; 'floating') , ('vt' ; 'complex') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
341+
jdict =. params conew 'jdict'
342342
jdict test_type rand_floating`'' ; rand_complex`'' ; keyshape ; valueshape ; 10 10 ; n_iter
343343

344344
keyshape =. 3 3
345345
valueshape =. 0:^:x 2 2 2
346-
params =. y , < ('keytype' ; 'complex') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
347-
jdict =. params conew 'jdictionary'
346+
params =. y , < ('kt' ; 'complex') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
347+
jdict =. params conew 'jdict'
348348
jdict test_type rand_complex`'' ; rand_integer`'' ; keyshape ; valueshape ; 2 3 4 5 ; n_iter
349349

350350
keyshape =. 9
351351
valueshape =. 0:^:x 10
352-
params =. y , < ('keytype' ; 'extended') , ('valuetype' ; 'rational') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
353-
jdict =. params conew 'jdictionary'
352+
params =. y , < ('kt' ; 'extended') , ('vt' ; 'rational') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
353+
jdict =. params conew 'jdict'
354354
jdict test_type rand_extended`'' ; rand_rational`'' ; keyshape ; valueshape ; 7 7 ; n_iter
355355

356356
keyshape =. 5
357357
valueshape =. 0:^:x 6
358-
params =. y , < ('keytype' ; 'rational') , ('valuetype' ; 'literal') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
359-
jdict =. params conew 'jdictionary'
358+
params =. y , < ('kt' ; 'rational') , ('vt' ; 'literal') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
359+
jdict =. params conew 'jdict'
360360
jdict test_type rand_rational`'' ; rand_byte`'' ; keyshape ; valueshape ; 3 2 ; n_iter
361361

362362
keyshape =. 8
363363
valueshape =. 0:^:x 5 5
364-
params =. y , < ('keytype' ; 'literal') , ('valuetype' ; 'extended') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
365-
jdict =. params conew 'jdictionary'
364+
params =. y , < ('kt' ; 'literal') , ('vt' ; 'extended') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
365+
jdict =. params conew 'jdict'
366366
jdict test_type rand_byte`'' ; rand_extended`'' ; keyshape ; valueshape ; 100 ; n_iter
367367

368368
keyshape =. 2 2
369369
valueshape =. 0:^:x 2 4
370-
params =. y , < ('keytype' ; 'boxed') , ('valuetype' ; 'boxed') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
371-
jdict =. params conew 'jdictionary'
370+
params =. y , < ('kt' ; 'boxed') , ('vt' ; 'boxed') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
371+
jdict =. params conew 'jdict'
372372
jdict test_type rand_boxed`'' ; rand_boxed`'' ; keyshape ; valueshape ; 25 2 ; n_iter
373373
}}"0"_ 0 INDEX_TYPES
374374

@@ -377,50 +377,50 @@ n_iter =. QKTEST{300 1
377377

378378
keyshape =. 3 2
379379
valueshape =. 0:^:x 5 8
380-
params =. y , < ('keytype' ; 'boolean') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
381-
jdict =. params conew 'jdictionary'
380+
params =. y , < ('kt' ; 'boolean') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
381+
jdict =. params conew 'jdict'
382382
jdict test_type rand_boolean`'' ; rand_integer`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
383383

384384
keyshape =. 2 3
385385
valueshape =. 0:^:x 4 5 4
386-
params =. y , < ('valuetype' ; 'floating') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
387-
jdict =. params conew 'jdictionary'
386+
params =. y , < ('vt' ; 'floating') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
387+
jdict =. params conew 'jdict'
388388
jdict test_type rand_integer`'' ; rand_floating`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
389389

390390
keyshape =. 7 1
391391
valueshape =. 0:^:x 1 7
392-
params =. y , < ('keytype' ; 'floating') , ('valuetype' ; 'complex') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
393-
jdict =. params conew 'jdictionary'
392+
params =. y , < ('kt' ; 'floating') , ('vt' ; 'complex') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
393+
jdict =. params conew 'jdict'
394394
jdict test_type rand_floating`'' ; rand_complex`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
395395

396396
keyshape =. 3 3
397397
valueshape =. 0:^:x 2 2 2
398-
params =. y , < ('keytype' ; 'complex') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
399-
jdict =. params conew 'jdictionary'
398+
params =. y , < ('kt' ; 'complex') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
399+
jdict =. params conew 'jdict'
400400
jdict test_type rand_complex`'' ; rand_integer`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
401401

402402
keyshape =. 9
403403
valueshape =. 0:^:x 10
404-
params =. y , < ('keytype' ; 'extended') , ('valuetype' ; 'rational') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
405-
jdict =. params conew 'jdictionary'
404+
params =. y , < ('kt' ; 'extended') , ('vt' ; 'rational') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
405+
jdict =. params conew 'jdict'
406406
jdict test_type rand_extended`'' ; rand_rational`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
407407

408408
keyshape =. 5
409409
valueshape =. 0:^:x 6
410-
params =. y , < ('keytype' ; 'rational') , ('valuetype' ; 'literal') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
411-
jdict =. params conew 'jdictionary'
410+
params =. y , < ('kt' ; 'rational') , ('vt' ; 'literal') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
411+
jdict =. params conew 'jdict'
412412
jdict test_type rand_rational`'' ; rand_byte`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
413413

414414
keyshape =. 8
415415
valueshape =. 0:^:x 5 5
416-
params =. y , < ('keytype' ; 'literal') , ('valuetype' ; 'extended') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
417-
jdict =. params conew 'jdictionary'
416+
params =. y , < ('kt' ; 'literal') , ('vt' ; 'extended') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
417+
jdict =. params conew 'jdict'
418418
jdict test_type rand_byte`'' ; rand_extended`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
419419

420420
keyshape =. 2 2
421421
valueshape =. 0:^:x 2 4
422-
params =. y , < ('keytype' ; 'boxed') , ('valuetype' ; 'boxed') , ('keyshape' ; keyshape) ,: ('valueshape' ; valueshape)
423-
jdict =. params conew 'jdictionary'
422+
params =. y , < ('kt' ; 'boxed') , ('vt' ; 'boxed') , ('ks' ; keyshape) ,: ('vs' ; valueshape)
423+
jdict =. params conew 'jdict'
424424
jdict test_type rand_boxed`'' ; rand_boxed`'' ; keyshape ; valueshape ; (i. 0) ; n_iter
425425
}}"0"_ 0 INDEX_TYPES
426426

@@ -447,7 +447,7 @@ test_batches =: {{)d
447447
'initsz n_iter sz mx' =. y
448448
refdict =. conew 'refdictionary'
449449
params =. x , < ('initcapacity' ; initsz) ,: ('keytype' ; 'boxed')
450-
jdict =. params conew 'jdictionary'
450+
jdict =. params conew 'jdict'
451451
for. i. n_iter do.
452452
keys =. <@":"0 vals =. sz ?@$ mx NB. Keys, vals for put.
453453
keys (>@[ set__refdict ])"0 vals
@@ -508,7 +508,7 @@ NB. x is boxed name of index type.
508508
NB. y is number of iterations , number of worker threads , number of keys and values.
509509
test_multithreading1 =: {{)d
510510
'n_iter n_threads sz' =. y
511-
jdict =. (x , < '') conew 'jdictionary'
511+
jdict =. (x , < '') conew 'jdict'
512512
'keys vals' =. ?~ ,~ sz
513513
NB. smoutput'put init',' ',":{.3 T.''
514514
vals put__jdict keys
@@ -545,7 +545,7 @@ NB. y is number of rows , number of columns , number of threads
545545
test_multithreading2 =: {{)d
546546
'rows cols n_threads' =. y
547547
params =. x , < ('valueshape' ; 2) ,: 'valuetype' ; 'boxed'
548-
jdict =. params conew 'jdictionary'
548+
jdict =. params conew 'jdict'
549549
(16&T."0 (rows , 2) $ 0) put__jdict i. rows
550550
row_sums =: rows $ 0
551551
magic =: {{ (2 * x + 3) + 3 * y + 7 }}
@@ -579,7 +579,7 @@ NB. x is boxed name of index type.
579579
NB. y is number of iterations , number of worker threads.
580580
test_multithreading3 =: {{)d
581581
'n_iter n_threads' =. y
582-
jdict =. (x , < '') conew 'jdictionary'
582+
jdict =. (x , < '') conew 'jdict'
583583
NB. x is jdict
584584
NB. y is number of iterations
585585
prog =: {{)d
@@ -616,7 +616,7 @@ NB. Result is array of two boxes:
616616
NB. * array of shortest-path distances from the source to every vertex
617617
NB. * predecessor array for shortest-path tree.
618618
dijkstra =: {{
619-
q =. conew&'jdictionary' 'tree' ,&< ('keyshape' ; 2) ,: 'valueshape' ; 0
619+
q =. conew&'jdict' 'tree' ,&< ('keyshape' ; 2) ,: 'valueshape' ; 0
620620
'ds ps' =. ($&_ ; $&_1)@# x NB. Initialize distances and predecessors.
621621
'' put__q 0 , y [ ds =. 0 y} ds NB. Distance to source is 0.
622622
while. 0 < count__q '' do.
@@ -705,7 +705,7 @@ partition =: {{
705705
NB. * l is x-coord of platform left end
706706
NB. * h is y-coord of platform
707707
NB. * id is unique platform ID.
708-
s =. 'jdictionary' conew~ 'tree concurrent' ,&< ('keytype' ; datatype y) , ('valuetype' ; 'boxed') ,: 'valueshape' ; 2
708+
s =. 'jdict' conew~ 'tree concurrent' ,&< ('keytype' ; datatype y) , ('valuetype' ; 'boxed') ,: 'valueshape' ; 2
709709
NB. Is key r in y greater then l from value ((l , h) ; id) in x.
710710
NB. This tells whether entry represents non-empty platform.
711711
ok =. (> (0 ; 0)&{::)~
@@ -768,8 +768,8 @@ f =: {.@[ 1r2&*@:+ (* {:)~ NB. (12).
768768
NB. x is D.
769769
NB. y is x(1 - D, T).
770770
enc =: {{
771-
'a b' =. 'jdictionary' (conew ,&< conew)~ 'hash' ,&< 'keytype' ; 'extended'
772-
'pe pw' =. 'jdictionary' (conew ,&< conew)~ 'hash' ,&< ('keytype' ; 'extended') ,: 'valuetype' ; 'rational'
771+
'a b' =. 'jdict' (conew ,&< conew)~ 'hash' ,&< 'keytype' ; 'extended'
772+
'pe pw' =. 'jdict' (conew ,&< conew)~ 'hash' ,&< ('keytype' ; 'extended') ,: 'valuetype' ; 'rational'
773773
B =. 0x
774774
for_bit. x }. y do.
775775
idxs =. (bit_index ,: x) (1x , 1x&(]F::(+ +:)));.0 y
@@ -800,8 +800,8 @@ dec =: {{
800800
'T c' =. y
801801
F =. +/@:(* 1r2 ^ #\) c NB. (35).
802802
D =. # x
803-
'a b' =. 'jdictionary' (conew ,&< conew)~ 'hash' ,&< 'keytype' ; 'extended'
804-
'pe pw' =. 'jdictionary' (conew ,&< conew)~ 'hash' ,&< ('keytype' ; 'extended') ,: 'valuetype' ; 'rational'
803+
'a b' =. 'jdict' (conew ,&< conew)~ 'hash' ,&< 'keytype' ; 'extended'
804+
'pe pw' =. 'jdict' (conew ,&< conew)~ 'hash' ,&< ('keytype' ; 'extended') ,: 'valuetype' ; 'rational'
805805
B =. 0x
806806
for. i. T do.
807807
idxs =. 1x , 1x ]F::(+ +:) (-D) {. x

0 commit comments

Comments
 (0)