Function that identifies whether two crystals are equivalent
422644
def check_crystal_equivalence(crystal_a, crystal_b):
    """"""

    # getting symmetry datasets for both crystals
    cryst_a = spglib.get_symmetry_dataset(ase_to_spgcell(crystal_a), symprec=1e-5, angle_tolerance=-1.0, hall_number=0)
    cryst_b = spglib.get_symmetry_dataset(ase_to_spgcell(crystal_b), symprec=1e-5, angle_tolerance=-1.0, hall_number=0)

    samecell = np.allclose(cryst_a['std_lattice'], cryst_b['std_lattice'], atol=1e-5)
    samenatoms = len(cryst_a['std_positions']) == len(cryst_b['std_positions'])
    samespg = cryst_a['number'] == cryst_b['number']
    
    def test_rotations_translations(cryst_a, cryst_b, repeat):
        cell = cryst_a['std_lattice']
        pristine = crystal('Mg', [(0, 0., 0.)], 
                           spacegroup=int(cryst_a['number']),
                           cellpar=[cell[0]/repeat[0], cell[1]/repeat[1], cell[2]/repeat[2]]).repeat(repeat)

        sym_set_p = spglib.get_symmetry_dataset(ase_to_spgcell(pristine), symprec=1e-5,
                                               angle_tolerance=-1.0, hall_number=0)

        for _,trans in enumerate(zip(sym_set_p['rotations'], sym_set_p['translations'])):
            pnew=(np.matmul(trans[0],cryst_a['std_positions'].T).T + trans[1]) % 1.0
            fulln = np.concatenate([cryst_a['std_types'][:, None], pnew], axis=1)
            fullb = np.concatenate([cryst_b['std_types'][:, None], cryst_b['std_positions']], axis=1)
            sorted_n = np.array(sorted([ list(row) for row in list(fulln) ]))
            sorted_b = np.array(sorted([ list(row) for row in list(fullb) ]))
            if np.allclose(sorted_n, sorted_b, atol=1e-5):
                return True
        return False

    if samecell and samenatoms and samespg:
        cell = cryst_a['std_lattice']
        # we assume there are no crystals with a lattice parameter smaller than 2 A
        rng1 = range(1, int(norm(cell[0])/2.))
        rng2 = range(1, int(norm(cell[1])/2.))
        rng3 = range(1, int(norm(cell[2])/2.))

        for repeat in itertools.product(rng1, rng2, rng3):
            if test_rotations_translations(cryst_a, cryst_b, repeat):
                return True

    return False
1208117
function isMatch (obj, source) {
  var objKeys = objectKeys(obj)
  var sourceKeys = objectKeys(source)
  if (sourceKeys.length) {
    if (XEUtils.includeArrays(objKeys, sourceKeys)) {
      return XEUtils.some(sourceKeys, function (key2) {
        return findIndexOf(objKeys, function (key1) {
          return key1 === key2 && isEqual(obj[key1], source[key2])
        }) > -1
      })
    }
  } else {
    return true
  }
  return isEqual(obj, source)
}
202332
def _comparable(self):
        
        return self._replace(
            name='' if self.name is None else self.name,
            wavelength=tuple() if self.wavelength is None else self.wavelength,
            resolution=0 if self.resolution is None else self.resolution,
            polarization='' if self.polarization is None else self.polarization,
            calibration='' if self.calibration is None else self.calibration,
        )
755906
def is_different(old_value, new_value):
    """"""
    if opt.has_numpy:
        return not opt.np.array_equal(old_value, new_value)
    else:
        return old_value != new_value
1348224
function equal(a, b, diff) {
  diff = diff || {};
  if (a.type !== b.type) {
    return equalDiff(a, b, diff);
  }
  if (a.value !== b.value) {
    return equalDiff(a, b, diff);
  }
  if (isValueNode(a) !== isValueNode(b)) {
    return equalDiff(a, b, diff);
  }
  if (!isValueNode(a)) {
    if (a.nodes.length !== b.nodes.length) {
      return equalDiff(a, b, diff);
    }
    for (var i = 0; i < b.nodes.length; i++) {
      if (!equal(a.nodes[i], b.nodes[i], diff)) {
        return false;
      }
    }
  }
  return true;
}
122917
function areEqual(a,b) {
	var same = true;
	$.each(a, function(i, _) {
		if (b[i] === undefined || a[i] !== b[i]) {
			same = false;
			return false;
		}
	});
	return same;
}
790548
def identical_blocks(self):
        
        identical_blocks = []
        for (func_a, func_b) in self.function_matches:
            identical_blocks.extend(self.get_function_diff(func_a, func_b).identical_blocks)
        return identical_blocks
1222432
function compareAst(actualSrc, expectedSrc, options) {
	var actualAst, expectedAst;
	options = options || {};

	if (!options.comparators) {
		options.comparators = [];
	}

	/*
	 * A collection of comparator functions that recognize equivalent nodes
	 * that would otherwise be reported as unequal by simple object comparison.
	 * These may:
	 *
	 * - return `true` if the given nodes can be verified as equivalent with no
	 *   further processing
	 * - return an instance of MatchError if the nodes are verified as
	 *   uniquivalent
	 * - return any other value if equivalency cannot be determined
	 */
	Array.prototype.push.apply(options.comparators, [
		require('./comparators/fuzzy-identifiers')(options),
		require('./comparators/fuzzy-strings')(options)
	]);

	try {
		actualAst = parse(actualSrc).body;
	} catch(err) {
		throw new Errors.ParseError();
	}

	try {
		expectedAst = parse(expectedSrc).body;
	} catch (err) {
		throw new Errors.ParseError();
	}

	function _bind(actual, expected) {
		var attr;

		// Literal values
		if (Object(actual) !== actual) {
			if (actual !== expected) {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
			return;
		}

		// Arrays
		if (Array.isArray(actual)) {
			if (actual.length !== expected.length) {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
			actual.forEach(function(_, i) {
				_bind(actual[i], expected[i]);
			});
			return;
		}

		// Nodes

		normalizeMemberExpr(actual);
		normalizeMemberExpr(expected);

		if (checkEquivalency(options.comparators, actual, expected)) {
			return;
		}

		// Either remove attributes or recurse on their values
		for (attr in actual) {
			if (expected && attr in expected) {
				_bind(actual[attr], expected[attr]);
			} else {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
		}
	}

	// Start recursing on the ASTs from the top level.
	_bind(actualAst, expectedAst);

	return null;
}
438522
public boolean isEquivalent(CrystalTransform other) {
		Matrix4d mul = new Matrix4d();
		mul.mul(this.matTransform,other.matTransform);

		if (mul.epsilonEquals(IDENTITY, 0.0001)) {
			return true;
		}
		return false;
	}
464772
def similarity( color1, color2, ignore_lightness: false )
      l1, a1, b1 = *rgb2lab(color1.to_rgb)
      l2, a2, b2 = *rgb2lab(color2.to_rgb)
      Math.sqrt( (ignore_lightness ? 0 : (l1-l2)**2) + (a1-a2)**2 + (b1-b2)**2 )
    end
450627
def is_same_function(f1, f2):
    
    if f1 is f2:
        return True
    if f1.__class__ is not f2.__class__:
        return False
    if isinstance(f1, calldef_members.member_calldef_t) and \
            f1.has_const != f2.has_const:
        return False
    if f1.name != f2.name:
        return False
    if not is_same_return_type(f1, f2):
        return False
    if len(f1.arguments) != len(f2.arguments):
        return False
    for f1_arg, f2_arg in zip(f1.arguments, f2.arguments):
        if not type_traits.is_same(f1_arg.decl_type, f2_arg.decl_type):
            return False
    return True
188612
def wavelength_match(a, b):
        
        if type(a) == (type(b) or
                       isinstance(a, numbers.Number) and
                       isinstance(b, numbers.Number)):
            return a == b
        elif a is None or b is None:
            return False
        elif isinstance(a, (list, tuple)) and len(a) == 3:
            return a[0] <= b <= a[2]
        elif isinstance(b, (list, tuple)) and len(b) == 3:
            return b[0] <= a <= b[2]
        else:
            raise ValueError("Can only compare wavelengths of length 1 or 3")
899487
function(a, b)
{
    return (a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t);
}
834694
def _compare_match(dict1, dict2):
    '''
    
    '''
    for karg, warg in six.iteritems(dict1):
        if karg in dict2 and dict2[karg] != warg:
            return False
    return True
676258
def equivalent(kls, first, second):
    
    if first.empty() and second.empty():
      return True
    elif first.vertices.shape[0] != second.vertices.shape[0]:
      return False
    elif first.edges.shape[0] != second.edges.shape[0]:
      return False

    EPSILON = 1e-7

    vertex1, inv1 = np.unique(first.vertices, axis=0, return_inverse=True)
    vertex2, inv2 = np.unique(second.vertices, axis=0, return_inverse=True)

    vertex_match = np.all(np.abs(vertex1 - vertex2) < EPSILON)
    if not vertex_match:
      return False

    remapping = {}
    for i in range(len(inv1)):
      remapping[inv1[i]] = inv2[i]
    remap = np.vectorize(lambda idx: remapping[idx])

    edges1 = np.sort(np.unique(first.edges, axis=0), axis=1)
    edges1 = edges1[np.lexsort(edges1[:,::-1].T)]

    edges2 = remap(second.edges)
    edges2 = np.sort(np.unique(edges2, axis=0), axis=1)
    edges2 = edges2[np.lexsort(edges2[:,::-1].T)]
    edges_match = np.all(edges1 == edges2)

    if not edges_match:
      return False

    second_verts = {}
    for i, vert in enumerate(second.vertices):
      second_verts[tuple(vert)] = i
    
    for i in range(len(first.radii)):
      i2 = second_verts[tuple(first.vertices[i])]

      if first.radii[i] != second.radii[i2]:
        return False

      if first.vertex_types[i] != second.vertex_types[i2]:
        return False

    return True
1125873
def DiffAnys(obj1, obj2, looseMatch=False, ignoreArrayOrder=True):
   """"""
   differ = Differ(looseMatch = looseMatch, ignoreArrayOrder = ignoreArrayOrder)
   return differ.DiffAnyObjects(obj1, obj2)
729530
function isEqual (array1, array2) {
    return array1.length === array2.length && array1.every(function (element, index) {
      return element === array2[index];
    });
  }