2323var tape = require ( 'tape' ) ;
2424var zeros5d = require ( '@stdlib/array/base/zeros5d' ) ;
2525var bquinary5d = require ( './../lib' ) ;
26- const filled5dBy = require ( '@stdlib/array/base/filled5d-by' ) ;
2726
2827
2928// FUNCTIONS //
@@ -63,45 +62,83 @@ tape( 'the function applies a provided callback to broadcasted input arrays and
6362 var u ;
6463
6564 shapes = [
66- [ 1 , 2 , 2 , 2 , 2 ] ,
67- [ 2 , 1 , 2 , 2 , 2 ] ,
68- [ 2 , 2 , 1 , 2 , 2 ] ,
69- [ 2 , 2 , 2 , 1 , 2 ] ,
70- [ 2 , 2 , 2 , 2 , 1 ] ,
71- [ 2 , 2 , 2 , 2 , 2 ]
72- ] ;
73- x = filled5dBy ( shapes [ 0 ] , discreteUniform ( - 100 , 100 ) ) ;
74- y = filled5dBy ( shapes [ 1 ] , discreteUniform ( - 100 , 100 ) ) ;
75- z = filled5dBy ( shapes [ 2 ] , discreteUniform ( - 100 , 100 ) ) ;
76- w = filled5dBy ( shapes [ 3 ] , discreteUniform ( - 100 , 100 ) ) ;
77- u = filled5dBy ( shapes [ 4 ] , discreteUniform ( - 100 , 100 ) ) ;
65+ [ 1 , 1 , 1 , 2 , 1 ] ,
66+ [ 1 , 1 , 1 , 2 , 1 ] ,
67+ [ 1 , 1 , 1 , 1 , 1 ] ,
68+ [ 1 , 1 , 1 , 1 , 1 ] ,
69+ [ 1 , 1 , 1 , 1 , 2 ] ,
70+ [ 1 , 1 , 1 , 2 , 2 ]
71+ ] ;
72+ x = [ [ [ [ [ 1.0 , 2.0 ] ] ] ] ] ;
73+ y = [ [ [ [ [ 3.0 ] ] ] , [ [ [ 4.0 ] ] ] ] ] ;
74+ z = [ [ [ [ [ 5.0 ] ] ] ] ] ;
75+ w = [ [ [ [ [ 1.0 ] ] ] ] ] ;
76+ u = [ [ [ [ [ 1.0 , 2.0 ] ] ] ] ] ;
7877 out = zeros5d ( shapes [ 5 ] ) ;
7978
80- expected = filled5dBy ( shapes [ 5 ] , ( ) => 5.0 ) ;
81- bquinary5d ( [ x , y , z , w , u , out ] , shapes , add ) ;
79+ expected = [ [ [ [ [ 11.0 , 13.0 ] ] ] , [ [ [ 12.0 , 14.0 ] ] ] ] ] ;
80+ bquinary5d ( [ x , y , z , w , u , out ] , shapes , add ) ;
8281 t . deepEqual ( out , expected , 'returns expected value' ) ;
8382
8483 shapes = [
85- [ 2 , 2 , 2 , 2 , 2 ] ,
86- [ 2 , 2 , 2 , 2 , 2 ] ,
87- [ 2 , 2 , 2 , 2 , 2 ] ,
88- [ 2 , 2 , 2 , 2 , 2 ] ,
89- [ 2 , 2 , 2 , 2 , 2 ] ,
90- [ 2 , 2 , 2 , 2 , 2 ]
84+ [ 1 , 1 , 1 , 1 , 2 ] ,
85+ [ 1 , 1 , 1 , 2 , 1 ] ,
86+ [ 1 , 1 , 1 , 1 , 1 ] ,
87+ [ 1 , 1 , 1 , 2 , 2 ] ,
88+ [ 1 , 1 , 1 , 2 , 1 ] ,
89+ [ 1 , 1 , 1 , 2 , 2 ]
9190 ] ;
92- x = filled5dBy ( shapes [ 0 ] , discreteUniform ( - 100 , 100 ) ) ;
93- y = filled5dBy ( shapes [ 1 ] , discreteUniform ( - 100 , 100 ) ) ;
94- z = filled5dBy ( shapes [ 2 ] , discreteUniform ( - 100 , 100 ) ) ;
95- w = filled5dBy ( shapes [ 3 ] , discreteUniform ( - 100 , 100 ) ) ;
96- u = filled5dBy ( shapes [ 4 ] , discreteUniform ( - 100 , 100 ) ) ;
91+ x = [ [ [ [ [ 1.0 , 2.0 ] ] ] ] ] ;
92+ y = [ [ [ [ [ 3.0 , 4.0 ] ] ] ] ] ;
93+ z = [ [ [ [ [ 5.0 ] ] ] ] ] ;
94+ w = [ [ [ [ [ 2.0 , 3.0 ] ] , [ [ 4.0 , 5.0 ] ] ] ] ] ;
95+ u = [ [ [ [ [ 1.0 ] ] , [ [ 2.0 ] ] ] ] ] ;
9796 out = zeros5d ( shapes [ 5 ] ) ;
9897
99- expected = filled5dBy ( shapes [ 5 ] , ( ) => 5 .0 ) ;
100- bquinary5d ( [ x , y , z , w , u , out ] , shapes , add ) ;
98+ expected = [ [ [ [ [ 12.0 , 15.0 ] , [ 15.0 , 18 .0 ] ] ] ] ] ;
99+ bquinary5d ( [ x , y , z , w , u , out ] , shapes , add ) ;
101100 t . deepEqual ( out , expected , 'returns expected value' ) ;
102101
103- t . end ( ) ;
104- } ) ;
102+ //Same shapes:
103+ shapes = [
104+ [ 2 , 2 , 2 , 2 , 2 ] ,
105+ [ 2 , 2 , 2 , 2 , 2 ] ,
106+ [ 2 , 2 , 2 , 2 , 2 ] ,
107+ [ 2 , 2 , 2 , 2 , 2 ] ,
108+ [ 2 , 2 , 2 , 2 , 2 ] ,
109+ [ 2 , 2 , 2 , 2 , 2 ]
110+ ] ;
111+ x = [ [
112+ [ [ [ 1.0 , 2.0 ] ] ] ,
113+ [ [ [ 3.0 , 4.0 ] ] ]
114+ ] ] ;
115+ y = [ [
116+ [ [ [ 1.0 , 2.0 ] ] ] ,
117+ [ [ [ 3.0 , 4.0 ] ] ]
118+ ] ] ;
119+ z = [ [
120+ [ [ [ 1.0 , 2.0 ] ] ] ,
121+ [ [ [ 3.0 , 4.0 ] ] ]
122+ ] ] ;
123+ w = [ [
124+ [ [ [ 1.0 , 2.0 ] ] ] ,
125+ [ [ [ 3.0 , 4.0 ] ] ]
126+ ] ] ;
127+ u = [ [
128+ [ [ [ 1.0 , 2.0 ] ] ] ,
129+ [ [ [ 3.0 , 4.0 ] ] ]
130+ ] ] ;
131+ out = zeros5d ( shapes [ 5 ] ) ;
132+
133+ expected = [ [
134+ [ [ [ 5.0 , 10.0 ] ] ] ,
135+ [ [ [ 15.0 , 20.0 ] ] ]
136+ ] ] ;
137+ bquinary5d ( [ x , y , z , w , u , out ] , shapes , add ) ;
138+ t . deepEqual ( out , expected , 'returns expected value' ) ;
139+
140+ t . end ( ) ;
141+ } ) ;
105142
106143
107144tape ( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero' , function test ( t ) {
@@ -122,11 +159,11 @@ tape( 'the function does not invoke a provided callback if provided an output sh
122159 [ 2 , 2 , 2 , 2 , 2 ] ,
123160 [ 0 , 2 , 2 , 2 , 2 ]
124161 ] ;
125- x = filled5dBy ( shapes [ 0 ] , discreteUniform ( - 100 , 100 ) ) ;
126- y = filled5dBy ( shapes [ 1 ] , discreteUniform ( - 100 , 100 ) ) ;
127- z = filled5dBy ( shapes [ 2 ] , discreteUniform ( - 100 , 100 ) ) ;
128- w = filled5dBy ( shapes [ 3 ] , discreteUniform ( - 100 , 100 ) ) ;
129- u = filled5dBy ( shapes [ 4 ] , discreteUniform ( - 100 , 100 ) ) ;
162+ x = [ [ [ [ [ 1.0 , 2.0 ] ] , [ [ 3.0 , 4.0 ] ] ] ] ] ;
163+ y = x ;
164+ z = x ;
165+ w = x ;
166+ u = x ;
130167 out = zeros5d ( [ 2 , 2 , 2 , 2 , 2 ] ) ;
131168
132169 expected = zeros5d ( [ 2 , 2 , 2 , 2 , 2 ] ) ;
@@ -158,11 +195,11 @@ tape( 'the function does not invoke a provided callback if provided an output sh
158195 [ 2 , 2 , 2 , 2 , 2 ] ,
159196 [ 2 , 2 , 2 , 2 , 0 ]
160197 ] ;
161- x = filled5dBy ( shapes [ 0 ] , discreteUniform ( - 100 , 100 ) ) ;
162- y = filled5dBy ( shapes [ 1 ] , discreteUniform ( - 100 , 100 ) ) ;
163- z = filled5dBy ( shapes [ 2 ] , discreteUniform ( - 100 , 100 ) ) ;
164- w = filled5dBy ( shapes [ 3 ] , discreteUniform ( - 100 , 100 ) ) ;
165- u = filled5dBy ( shapes [ 4 ] , discreteUniform ( - 100 , 100 ) ) ;
198+ x = [ [ [ [ [ 1.0 , 2.0 ] ] , [ [ 3.0 , 4.0 ] ] ] ] ] ;
199+ y = x ;
200+ z = x ;
201+ w = x ;
202+ u = x ;
166203 out = zeros5d ( [ 2 , 2 , 2 , 2 , 2 ] ) ;
167204
168205 expected = zeros5d ( [ 2 , 2 , 2 , 2 , 2 ] ) ;
0 commit comments