Makes sure the class is hashable.

    Needs a working __eq__ and __hash__ and will add a __ne__.
163648
def hashable(cls):
    

    # py2
    assert "__hash__" in cls.__dict__
    # py3
    assert cls.__dict__["__hash__"] is not None
    assert "__eq__" in cls.__dict__

    cls.__ne__ = lambda self, other: not self.__eq__(other)

    return cls
517743
def exact(self, *args, **kwargs):
        
        compare = Exact(*args, **kwargs)
        self.add(compare)

        return self
851731
def _add_base_class(mcs, cls):
        
        # Do all magic only if subclass had defined required attributes
        if getattr(mcs, '_base_classes_hash', None) is not None:
            meta = getattr(cls, 'Meta', None)
            _hash = getattr(meta, mcs._hashattr, None)
            if _hash is None and cls not in mcs._get_base_classes():
                mcs._base_classes.insert(0, cls)
                mcs._generated_class = {}  # Cleanup all caches
            elif _hash is not None and cls not in mcs._get_base_classes(_hash):
                mcs._base_classes_hash[_hash].insert(0, cls)
                mcs._generated_class[_hash] = None
658477
def cast(hash)
      return hash if empty?
      merge = {}
      hash.delete_if do |key, value|
        next unless casted = lazy.map { |e| e.cast(key, value) }.detect { |e| e }
        casted = { key => casted } unless casted.respond_to? :to_hash
        merge.update(casted.to_hash)
      end
      hash.update(merge)
    end
1233867
def _get_hashtable_algo(values):
    
    values, dtype, ndtype = _ensure_data(values)

    if ndtype == 'object':

        # it's cheaper to use a String Hash Table than Object; we infer
        # including nulls because that is the only difference between
        # StringHashTable and ObjectHashtable
        if lib.infer_dtype(values, skipna=False) in ['string']:
            ndtype = 'string'
        else:
            ndtype = 'object'

    htable, table = _hashtables[ndtype]
    return (htable, table, values, dtype, ndtype)
1325148
public static boolean isAssignableToOrFrom(Class<?> classToCheck, Class<?> anotherClass) {
    return classToCheck.isAssignableFrom(anotherClass)
        || anotherClass.isAssignableFrom(classToCheck);
  }
931638
def **(other)
      if other.is_a?(Numeric)
        self.class.new(to_hash.merge(:exponent => exponent * other))
      else
        fail TypeError, "Can't raise #{self} to #{other}."
      end
    end
920958
function createHashtable(checksums) {
  var hashtable = {};
  var len = checksums.length;
  var checksum;
  var weak16;

  for (var i = 0; i < len; i++) {
    checksum = checksums[i];
    weak16 = calcWeak16(checksum.weak);
    if (hashtable[weak16]) {
      hashtable[weak16].push(checksum);
    } else {
      hashtable[weak16] = [checksum];
    }
  }
  return hashtable;
}
1064439
private long mixInHash(long hash, StorableInfo<?> info, LayoutOptions options, int multiplier)
    {
        hash = mixInHash(hash, info.getStorableType().getName(), multiplier);
        hash = mixInHash(hash, options, multiplier);

        for (StorableProperty<?> property : info.getAllProperties().values()) {
            if (!property.isJoin()) {
                hash = mixInHash(hash, property, multiplier);
            }
        }

        return hash;
    }
889055
def add_type( type )
      hash = type.hash
      raise "upps #{hash} #{hash.class}" unless hash.is_a?(::Integer)
      was = types[hash]
      return was if was
      types[hash] = type
    end
524609
def add_hash(self, value):
        
        self.leaves.append(Node(codecs.decode(value, 'hex_codec'), prehashed=True))
784480
private void addEquals(TypeSpec.Builder classBuilder) {
        MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("equals")
                .addModifiers(Modifier.PUBLIC)
                .addParameter(ClassName.get(Object.class), "obj")
                .returns(boolean.class)
                .addAnnotation(Override.class)
                .addStatement("return (obj instanceof " + getRemoterInterfaceClassName() + ClassBuilder.PROXY_SUFFIX + ") && obj.hashCode() == hashCode()");
        classBuilder.addMethod(methodBuilder.build());
    }
93151
protected void registerKnownJdkImmutableClasses() {
        registerImmutable(String.class);
        registerImmutable(Integer.class);
        registerImmutable(Long.class);
        registerImmutable(Boolean.class);
        registerImmutable(Class.class);
        registerImmutable(Float.class);
        registerImmutable(Double.class);
        registerImmutable(Character.class);
        registerImmutable(Byte.class);
        registerImmutable(Short.class);
        registerImmutable(Void.class);

        registerImmutable(BigDecimal.class);
        registerImmutable(BigInteger.class);
        registerImmutable(URI.class);
        registerImmutable(URL.class);
        registerImmutable(UUID.class);
        registerImmutable(Pattern.class);
    }
595954
def require_valid_type(value, *classes):
    

    if value is not None:
        valid = False
        for auxiliar_class in classes:
            if isinstance(value, auxiliar_class):
                valid = True
                break
        if not valid:
            raise TypeError()
474563
def hash(self):
        '''
        
        '''
        hashed = super(Conditional, self).hash()
        return khash(hashed, self._condition.hash())
562549
public static void putHashTable(final String name, final Hashtable hash) {
		final Enumeration<String> keys = hash.keys();
		final StringBuffer buf = new StringBuffer("");
		while (keys.hasMoreElements()) {
			if (!buf.toString().equals("")) {
				// end the previous record
				buf.append(";");
			}
			final String key = keys.nextElement();
			final String value = hash.get(key).toString();
			buf.append(key + ":" + value);
		}
		put(fixKey(name), buf.toString());
	}
627183
def callable(cls, nans=False, reverse=False, scalar=False):
        
        _valgetter = cls._valgetter_scalar if scalar else cls._valgetter
        valgetter = nb.njit(_valgetter)
        outersetter = nb.njit(cls._outersetter)

        _cls_inner = nb.njit(cls._inner)
        if nans:
            def _inner(ri, val, ret, counter, mean):
                if not np.isnan(val):
                    _cls_inner(ri, val, ret, counter, mean)
            inner = nb.njit(_inner)
        else:
            inner = _cls_inner

        def _loop(group_idx, a, ret, counter, mean, outer, fill_value, ddof):
            # fill_value and ddof need to be present for being exchangeable with loop_2pass
            size = len(ret)
            rng = range(len(group_idx) - 1, -1 , -1) if reverse else range(len(group_idx))
            for i in rng:
                ri = group_idx[i]
                if ri < 0:
                    raise ValueError("negative indices not supported")
                if ri >= size:
                    raise ValueError("one or more indices in group_idx are too large")
                val = valgetter(a, i)
                inner(ri, val, ret, counter, mean)
                outersetter(outer, i, ret[ri])
        return nb.njit(_loop, nogil=True)