You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/ndarray/any-by/README.md
+6-25Lines changed: 6 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,10 +52,7 @@ var x = array( [ [ 1.0, -2.0 ], [ 3.0, -4.0 ] ] );
52
52
53
53
// Test whether at least one element is positive:
54
54
var out =anyBy( x, isPositive );
55
-
// returns <ndarray>
56
-
57
-
var v =out.get();
58
-
// returns true
55
+
// returns <ndarray>[ true ]
59
56
```
60
57
61
58
The function accepts the following arguments:
@@ -73,7 +70,6 @@ The function accepts the following options:
73
70
By default, the function performs a reduction over all elements in a provided [`ndarray`][@stdlib/ndarray/ctor]. To reduce specific dimensions, set the `dims` option.
74
71
75
72
```javascript
76
-
var ndarray2array =require( '@stdlib/ndarray/to-array' );
77
73
var array =require( '@stdlib/ndarray/array' );
78
74
79
75
functionisPositive( value ) {
@@ -82,23 +78,20 @@ function isPositive( value ) {
82
78
83
79
// Create an input ndarray:
84
80
var x =array( [ [ 1.0, 2.0 ], [ -3.0, -4.0 ] ] );
81
+
// returns <ndarray>
85
82
86
83
var opts = {
87
84
'dims': [ 1 ]
88
85
};
89
86
90
87
// Perform reduction:
91
88
var out =anyBy( x, opts, isPositive );
92
-
// returns <ndarray>
93
-
94
-
var v =ndarray2array( out );
95
-
// returns [ true, false ]
89
+
// returns <ndarray>[ true, false ]
96
90
```
97
91
98
92
By default, the function returns an [`ndarray`][@stdlib/ndarray/ctor] having a shape matching only the non-reduced dimensions of the input [`ndarray`][@stdlib/ndarray/ctor] (i.e., the reduced dimensions are dropped). To include the reduced dimensions as singleton dimensions in the output [`ndarray`][@stdlib/ndarray/ctor], set the `keepdims` option to `true`.
99
93
100
94
```javascript
101
-
var ndarray2array =require( '@stdlib/ndarray/to-array' );
102
95
var array =require( '@stdlib/ndarray/array' );
103
96
104
97
functionisPositive( value ) {
@@ -114,10 +107,7 @@ var opts = {
114
107
115
108
// Perform reduction:
116
109
var out =anyBy( x, opts, isPositive );
117
-
// returns <ndarray>
118
-
119
-
var v =ndarray2array( out );
120
-
// returns [ [ [ true ] ] ]
110
+
// returns <ndarray>[ [ [ true ] ] ]
121
111
```
122
112
123
113
To set the function execution context, provide a `thisArg`.
@@ -141,10 +131,7 @@ var ctx = {
141
131
142
132
// Perform reduction:
143
133
var out =anyBy( x, isPositive, ctx );
144
-
// returns <ndarray>
145
-
146
-
var v =out.get();
147
-
// returns true
134
+
// returns <ndarray>[ true ]
148
135
149
136
var count =ctx.count;
150
137
// returns 4
@@ -172,10 +159,7 @@ var y = empty( [], {
172
159
173
160
// Perform reduction:
174
161
var out =anyBy.assign( x, y, isPositive );
175
-
// returns <ndarray>
176
-
177
-
var v =out.get();
178
-
// returns true
162
+
// returns <ndarray>[ true ]
179
163
180
164
var bool = ( out === y );
181
165
// returns true
@@ -222,9 +206,6 @@ var out = anyBy.assign( x, y, opts, predicate );
0 commit comments