Point-wise, hinge loss-like, difference between arrays.

  Args:
    arr1: integer array to compare.
    arr2: integer array to compare.
    min_diff: minimal difference taken into consideration.
    dtype: dtype of returned array.

  Returns:
    array
177936
def absolute_hinge_difference(arr1, arr2, min_diff=10, dtype=np.uint8):
  
  diff = np.abs(arr1.astype(np.int) - arr2, dtype=np.int)
  return np.maximum(diff - min_diff, 0).astype(dtype)
995932
private int getLeastCommonArrayLength(String[] arr1, String[] arr2) {
        return arr1.length <= arr2.length ? arr1.length : arr2.length;
    }
978806
def compare(ver1, ver2):
    ''''''
    if ver1 == ver2:
        return 0
    ver1 = _cut(ver1)
    ver2 = _cut(ver2)
    # magic multiplier
    m = 1
    # if the first one is shorter, replace them
    if len(ver1) < len(ver2):
        ver1, ver2 = ver2, ver1
        # and reverse magic multiplier
        m = -1
    # compare all items that both have
    for i, part in enumerate(ver2):
        if ver1[i] > ver2[i]:
            return m * 1
        if ver1[i] < ver2[i]:
            return m * -1
    # if the first "extra" item is not negative, it's bigger
    if ver1[len(ver2)] >= 0:
        return m * 1
    else:
        return m * -1
286443
def list_diff(list1, list2):
    
    diff_list = []
    for item in list1:
        if not item in list2:
            diff_list.append(item)
    for item in list2:
        if not item in list1:
            diff_list.append(item)
    return diff_list
1125873
def DiffAnys(obj1, obj2, looseMatch=False, ignoreArrayOrder=True):
   """"""
   differ = Differ(looseMatch = looseMatch, ignoreArrayOrder = ignoreArrayOrder)
   return differ.DiffAnyObjects(obj1, obj2)
798270
public static function arrayDiff($array1, $array2) {
        return array_udiff($array1, $array2,
            function ($a, $b) {
                if (is_object($a)) {
                    return strcmp(spl_object_hash($a), spl_object_hash($b));
                } else if (is_array($a)) {
                    return ArrayUtils::arrayDiff($a, $b);
                } else {
                    return strcmp($a, $b);
                }
            }
        );
    }
688153
function(arr) {
        return {
            min: Math.min.apply(null, arr),
            max: Math.max.apply(null, arr)
        };
    }
411538
def diff(self, first_row: List[Row], second_row: List[Row], column: NumberColumn) -> Number:
        
        if not first_row or not second_row:
            return 0.0  # type: ignore
        first_value = first_row[0].values[column.name]
        second_value = second_row[0].values[column.name]
        if isinstance(first_value, float) and isinstance(second_value, float):
            return first_value - second_value  # type: ignore
        else:
            raise ExecutionError(f"Invalid column for diff: {column.name}")
874894
private static function setDiff(array $arr1, array $arr2)
    {
        $missingSets = array();
        
        foreach ($arr1 as $searchSet)
        {
            $found = false;
            
            foreach ($arr2 as $subArray2)
            {
                if ($subArray2 === $searchSet)
                {
                    $found = true;
                    break;
                }
            }
            
            if (!$found)
            {
                $missingSets[] = $searchSet;
            }
        }
        
        return $missingSets;
    }
504182
function equalSimpleArrays(arr1, arr2) {

	if (arr1 && (arr1.length > 0))
		return (
			arr2 &&
				(arr2.length === arr1.length) &&
				arr2.every((v, i) => (v === arr1[i]))
		);

	return (!arr2 || (arr2.length === 0));
}
389982
def closest(self, dt1, dt2):
        
        dt1 = self.__class__(dt1.hour, dt1.minute, dt1.second, dt1.microsecond)
        dt2 = self.__class__(dt2.hour, dt2.minute, dt2.second, dt2.microsecond)

        if self.diff(dt1).in_seconds() < self.diff(dt2).in_seconds():
            return dt1

        return dt2
1141707
def histogram_distance(arr1, arr2, bins=None):
    
    eps = 1e-6
    assert arr1.min() > 0 - eps
    assert arr1.max() < 1 + eps
    assert arr2.min() > 0 - eps
    assert arr2.max() < 1 + eps

    if not bins:
        bins = [x / 10 for x in range(11)]
    hist1 = np.histogram(arr1, bins=bins)[0] / arr1.size
    hist2 = np.histogram(arr2, bins=bins)[0] / arr2.size

    assert abs(hist1.sum() - 1.0) < eps
    assert abs(hist2.sum() - 1.0) < eps

    sqerr = (hist1 - hist2) ** 2
    return sqerr.sum()
266543
def cmp_like_py2(dict1, dict2):  # type: (Dict[Text, Any], Dict[Text, Any]) -> int
    
    # extract lists from both dicts
    first, second = dict1["position"], dict2["position"]
    # iterate through both list till max of their size
    for i, j in zip_longest(first, second):
        if i == j:
            continue
        # in case 1st list is smaller
        # should come first in sorting
        if i is None:
            return -1
        # if 1st list is longer,
        # it should come later in sort
        elif j is None:
            return 1

        # if either of the list contains str element
        # at any index, both should be str before comparing
        if isinstance(i, str) or isinstance(j, str):
            return 1 if str(i) > str(j) else -1
        # int comparison otherwise
        return 1 if i > j else -1
    # if both lists are equal
    return 0
1205475
def equal_power(arr1, arr2):
    
    n = N.shape(arr1)[0]
    try:
        channels = N.shape(arr1)[1]
    except:
        channels = 1

    f_in = N.arange(n) / float(n - 1)
    f_out = N.arange(n - 1, -1, -1) / float(n)

    if channels > 1:
        f_in = N.tile(f_in, (channels, 1)).T
        f_out = N.tile(f_out, (channels, 1)).T

    vals = log_factor(f_out) * arr1 + log_factor(f_in) * arr2

    return limiter(vals)
1133874
public function difference($array_one=null, $array_two=null) {
    $arrays = self::_wrapArgs(func_get_args(), 1);
    
    return self::_wrap(array_values(call_user_func_array('array_diff', $arrays)));
  }
103320
private static String[] differences(String[] first, String[] second) {

        String[] sortedFirst = Arrays.copyOf(first, first.length); // O(n)
        String[] sortedSecond = Arrays.copyOf(second, second.length); // O(m)
        Arrays.sort(sortedFirst); // O(n log n)
        Arrays.sort(sortedSecond); // O(m log m)

        int firstIndex = 0;
        int secondIndex = 0;

        LinkedList<String> diffs = new LinkedList<>();

        while (firstIndex < sortedFirst.length && secondIndex < sortedSecond.length) {
            int compare = (int) Math.signum(sortedFirst[firstIndex].compareTo(sortedSecond[secondIndex]));

            switch (compare) {
                case -1:
                    diffs.add(sortedFirst[firstIndex]);
                    firstIndex++;
                    break;
                case 1:
                    diffs.add(sortedSecond[secondIndex]);
                    secondIndex++;
                    break;
                default:
                    firstIndex++;
                    secondIndex++;
            }
        }

        String[] strDups = new String[diffs.size()];

        return diffs.toArray(strDups);
    }
496902
public static String[] subtraction(String[] arr1, String[] arr2) {
        if (arr1 == null || arr1.length == 0 || arr2 == null || arr2.length == 0) {
            return arr1;
        }
        List<String> list = new ArrayList<String>(Arrays.asList(arr1));
        list.removeAll(Arrays.asList(arr2));
        return list.toArray(new String[0]);
    }