forked from SciSharp/Numpy.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumPy.set.gen.cs
More file actions
302 lines (293 loc) · 11.8 KB
/
NumPy.set.gen.cs
File metadata and controls
302 lines (293 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// Copyright (c) 2019 by the SciSharp Team
// Code generated by CodeMinion: https://github.com/SciSharp/CodeMinion
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Python.Runtime;
using Numpy.Models;
using Python.Included;
namespace Numpy
{
public partial class NumPy
{
/// <summary>
/// Test whether each element of a 1-D array is also present in a second array.<br></br>
///
/// Returns a boolean array the same length as ar1 that is True
/// where an element of ar1 is in ar2 and False otherwise.<br></br>
///
/// We recommend using isin instead of in1d for new code.<br></br>
///
/// Notes
///
/// in1d can be considered as an element-wise function version of the
/// python keyword in, for 1-D sequences.<br></br>
/// in1d(a, b) is roughly
/// equivalent to np.array([item in b for item in a]).<br></br>
///
/// However, this idea fails if ar2 is a set, or similar (non-sequence)
/// container: As ar2 is converted to an array, in those cases
/// asarray(ar2) is an object array rather than the expected array of
/// contained values.
/// </summary>
/// <param name="ar1">
/// Input array.
/// </param>
/// <param name="ar2">
/// The values against which to test each value of ar1.
/// </param>
/// <param name="assume_unique">
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.<br></br>
/// Default is False.
/// </param>
/// <param name="invert">
/// If True, the values in the returned array are inverted (that is,
/// False where an element of ar1 is in ar2 and True otherwise).<br></br>
///
/// Default is False.<br></br>
/// np.in1d(a, b, invert=True) is equivalent
/// to (but is faster than) np.invert(in1d(a, b)).
/// </param>
/// <returns>
/// The values ar1[in1d] are in ar2.
/// </returns>
public NDarray in1d(NDarray ar1, NDarray ar2, bool? assume_unique = false, bool? invert = false)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
ar1,
ar2,
});
var kwargs=new PyDict();
if (assume_unique!=false) kwargs["assume_unique"]=ToPython(assume_unique);
if (invert!=false) kwargs["invert"]=ToPython(invert);
dynamic py = __self__.InvokeMethod("in1d", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Find the intersection of two arrays.<br></br>
///
/// Return the sorted, unique values that are in both of the input arrays.
/// </summary>
/// <param name="ar2">
/// Input arrays.<br></br>
/// Will be flattened if not already 1D.
/// </param>
/// <param name="ar1">
/// Input arrays.<br></br>
/// Will be flattened if not already 1D.
/// </param>
/// <param name="assume_unique">
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.<br></br>
/// Default is False.
/// </param>
/// <param name="return_indices">
/// If True, the indices which correspond to the intersection of the two
/// arrays are returned.<br></br>
/// The first instance of a value is used if there are
/// multiple.<br></br>
/// Default is False.
/// </param>
/// <returns>
/// A tuple of:
/// intersect1d
/// Sorted 1D array of common and unique elements.
/// comm1
/// The indices of the first occurrences of the common values in ar1.
/// Only provided if return_indices is True.
/// comm2
/// The indices of the first occurrences of the common values in ar2.
/// Only provided if return_indices is True.
/// </returns>
public (NDarray, NDarray, NDarray) intersect1d(NDarray ar2, NDarray ar1, bool assume_unique = false, bool return_indices = false)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
ar2,
ar1,
});
var kwargs=new PyDict();
if (assume_unique!=false) kwargs["assume_unique"]=ToPython(assume_unique);
if (return_indices!=false) kwargs["return_indices"]=ToPython(return_indices);
dynamic py = __self__.InvokeMethod("intersect1d", pyargs, kwargs);
var t = py as PyTuple;
return (ToCsharp<NDarray>(t[0]), ToCsharp<NDarray>(t[1]), ToCsharp<NDarray>(t[2]));
}
/// <summary>
/// Calculates element in test_elements, broadcasting over element only.<br></br>
///
/// Returns a boolean array of the same shape as element that is True
/// where an element of element is in test_elements and False otherwise.<br></br>
///
/// Notes
///
/// isin is an element-wise function version of the python keyword in.<br></br>
///
/// isin(a, b) is roughly equivalent to
/// np.array([item in b for item in a]) if a and b are 1-D sequences.<br></br>
///
/// element and test_elements are converted to arrays if they are not
/// already.<br></br>
/// If test_elements is a set (or other non-sequence collection)
/// it will be converted to an object array with one element, rather than an
/// array of the values contained in test_elements.<br></br>
/// This is a consequence
/// of the array constructor’s way of handling non-sequence collections.<br></br>
///
/// Converting the set to a list usually gives the desired behavior.
/// </summary>
/// <param name="element">
/// Input array.
/// </param>
/// <param name="test_elements">
/// The values against which to test each value of element.<br></br>
///
/// This argument is flattened if it is an array or array_like.<br></br>
///
/// See notes for behavior with non-array-like parameters.
/// </param>
/// <param name="assume_unique">
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.<br></br>
/// Default is False.
/// </param>
/// <param name="invert">
/// If True, the values in the returned array are inverted, as if
/// calculating element not in test_elements.<br></br>
/// Default is False.<br></br>
///
/// np.isin(a, b, invert=True) is equivalent to (but faster
/// than) np.invert(np.isin(a, b)).
/// </param>
/// <returns>
/// Has the same shape as element.<br></br>
/// The values element[isin]
/// are in test_elements.
/// </returns>
public NDarray isin(NDarray element, NDarray test_elements, bool? assume_unique = false, bool? invert = false)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
element,
test_elements,
});
var kwargs=new PyDict();
if (assume_unique!=false) kwargs["assume_unique"]=ToPython(assume_unique);
if (invert!=false) kwargs["invert"]=ToPython(invert);
dynamic py = __self__.InvokeMethod("isin", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Find the set difference of two arrays.<br></br>
///
/// Return the unique values in ar1 that are not in ar2.
/// </summary>
/// <param name="ar1">
/// Input array.
/// </param>
/// <param name="ar2">
/// Input comparison array.
/// </param>
/// <param name="assume_unique">
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.<br></br>
/// Default is False.
/// </param>
/// <returns>
/// 1D array of values in ar1 that are not in ar2. The result
/// is sorted when assume_unique=False, but otherwise only sorted
/// if the input is sorted.
/// </returns>
public NDarray setdiff1d(NDarray ar1, NDarray ar2, bool assume_unique = false)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
ar1,
ar2,
});
var kwargs=new PyDict();
if (assume_unique!=false) kwargs["assume_unique"]=ToPython(assume_unique);
dynamic py = __self__.InvokeMethod("setdiff1d", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Find the set exclusive-or of two arrays.<br></br>
///
/// Return the sorted, unique values that are in only one (not both) of the
/// input arrays.
/// </summary>
/// <param name="ar2">
/// Input arrays.
/// </param>
/// <param name="ar1">
/// Input arrays.
/// </param>
/// <param name="assume_unique">
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.<br></br>
/// Default is False.
/// </param>
/// <returns>
/// Sorted 1D array of unique values that are in only one of the input
/// arrays.
/// </returns>
public NDarray setxor1d(NDarray ar2, NDarray ar1, bool assume_unique = false)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
ar2,
ar1,
});
var kwargs=new PyDict();
if (assume_unique!=false) kwargs["assume_unique"]=ToPython(assume_unique);
dynamic py = __self__.InvokeMethod("setxor1d", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Find the union of two arrays.<br></br>
///
/// Return the unique, sorted array of values that are in either of the two
/// input arrays.
/// </summary>
/// <param name="ar2">
/// Input arrays.<br></br>
/// They are flattened if they are not already 1D.
/// </param>
/// <param name="ar1">
/// Input arrays.<br></br>
/// They are flattened if they are not already 1D.
/// </param>
/// <returns>
/// Unique, sorted union of the input arrays.
/// </returns>
public NDarray union1d(NDarray ar2, NDarray ar1)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
ar2,
ar1,
});
var kwargs=new PyDict();
dynamic py = __self__.InvokeMethod("union1d", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
}
}