// 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
{
///
/// Test whether each element of a 1-D array is also present in a second array.
///
/// Returns a boolean array the same length as ar1 that is True
/// where an element of ar1 is in ar2 and False otherwise.
///
/// We recommend using isin instead of in1d for new code.
///
/// Notes
///
/// in1d can be considered as an element-wise function version of the
/// python keyword in, for 1-D sequences.
/// in1d(a, b) is roughly
/// equivalent to np.array([item in b for item in a]).
///
/// 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.
///
///
/// Input array.
///
///
/// The values against which to test each value of ar1.
///
///
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.
/// Default is False.
///
///
/// If True, the values in the returned array are inverted (that is,
/// False where an element of ar1 is in ar2 and True otherwise).
///
/// Default is False.
/// np.in1d(a, b, invert=True) is equivalent
/// to (but is faster than) np.invert(in1d(a, b)).
///
///
/// The values ar1[in1d] are in ar2.
///
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(py);
}
///
/// Find the intersection of two arrays.
///
/// Return the sorted, unique values that are in both of the input arrays.
///
///
/// Input arrays.
/// Will be flattened if not already 1D.
///
///
/// Input arrays.
/// Will be flattened if not already 1D.
///
///
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.
/// Default is False.
///
///
/// If True, the indices which correspond to the intersection of the two
/// arrays are returned.
/// The first instance of a value is used if there are
/// multiple.
/// Default is False.
///
///
/// 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.
///
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(t[0]), ToCsharp(t[1]), ToCsharp(t[2]));
}
///
/// Calculates element in test_elements, broadcasting over element only.
///
/// 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.
///
/// Notes
///
/// isin is an element-wise function version of the python keyword in.
///
/// isin(a, b) is roughly equivalent to
/// np.array([item in b for item in a]) if a and b are 1-D sequences.
///
/// element and test_elements are converted to arrays if they are not
/// already.
/// 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.
/// This is a consequence
/// of the array constructor’s way of handling non-sequence collections.
///
/// Converting the set to a list usually gives the desired behavior.
///
///
/// Input array.
///
///
/// The values against which to test each value of element.
///
/// This argument is flattened if it is an array or array_like.
///
/// See notes for behavior with non-array-like parameters.
///
///
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.
/// Default is False.
///
///
/// If True, the values in the returned array are inverted, as if
/// calculating element not in test_elements.
/// Default is False.
///
/// np.isin(a, b, invert=True) is equivalent to (but faster
/// than) np.invert(np.isin(a, b)).
///
///
/// Has the same shape as element.
/// The values element[isin]
/// are in test_elements.
///
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(py);
}
///
/// Find the set difference of two arrays.
///
/// Return the unique values in ar1 that are not in ar2.
///
///
/// Input array.
///
///
/// Input comparison array.
///
///
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.
/// Default is False.
///
///
/// 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.
///
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(py);
}
///
/// Find the set exclusive-or of two arrays.
///
/// Return the sorted, unique values that are in only one (not both) of the
/// input arrays.
///
///
/// Input arrays.
///
///
/// Input arrays.
///
///
/// If True, the input arrays are both assumed to be unique, which
/// can speed up the calculation.
/// Default is False.
///
///
/// Sorted 1D array of unique values that are in only one of the input
/// arrays.
///
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(py);
}
///
/// Find the union of two arrays.
///
/// Return the unique, sorted array of values that are in either of the two
/// input arrays.
///
///
/// Input arrays.
/// They are flattened if they are not already 1D.
///
///
/// Input arrays.
/// They are flattened if they are not already 1D.
///
///
/// Unique, sorted union of the input arrays.
///
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(py);
}
}
}