Returns a DummySpecie object that can be safely used
        with (i.e. not present in) a given composition
968136
def safe_from_composition(cls, comp: "Composition",
                              oxidation_state: float = 0):
        
        # We don't want to add a DummySpecie with the same
        # symbol as anything in the composition, even if the
        # oxidation state is different
        els = comp.element_composition.elements
        for c in 'abcdfghijklmnopqrstuvwxyz':
            if DummySpecie('X' + c) not in els:
                return DummySpecie('X' + c, oxidation_state)
        raise ValueError("All attempted DummySpecies already "
                         "present in {}".format(comp))
1246600
def *(other)
      if other.is_a?(InternalComplex) or other.is_a?(Complex)
        InternalComplex.new @real * other.real - @imag * other.imag,
                    @real * other.imag + @imag * other.real
      elsif InternalComplex.generic? other
        InternalComplex.new @real * other, @imag * other
      else
        x, y = other.coerce self
        x * y
      end
    end
1103875
def factory(cls, str_type, version):
        
        type = Object.Types(str_type)

        if type is Object.Types.object:
            object = ObjectObject()
        elif type is Object.Types.array:
            object = ObjectArray()
        elif type is Object.Types.number:
            object = ObjectNumber()
        elif type is Object.Types.integer:
            object = ObjectInteger()
        elif type is Object.Types.string:
            object = ObjectString()
        elif type is Object.Types.boolean:
            object = ObjectBoolean()
        elif type is Object.Types.reference:
            object = ObjectReference()
        elif type is Object.Types.type:
            object = ObjectType()
        elif type is Object.Types.none:
            object = ObjectNone()
        elif type is Object.Types.dynamic:
            object = ObjectDynamic()
        elif type is Object.Types.const:
            object = ObjectConst()
        elif type is Object.Types.enum:
            object = ObjectEnum()
        else:
            object = Object()
        object.type = type
        object.version = version
        return object
910860
function mixin(obj) {
  for (var key in Emitter.prototype) {
    obj[key] = Emitter.prototype[key];
  }
  return obj;
}
543293
def _get_mixins_(bases):
        
        if not bases or Enum is None:
            return object, Enum


        # double check that we are not subclassing a class with existing
        # enumeration members; while we're at it, see if any other data
        # type has been mixed in so we can use the correct __new__
        member_type = first_enum = None
        for base in bases:
            if  (base is not Enum and
                    issubclass(base, Enum) and
                    base._member_names_):
                raise TypeError("Cannot extend enumerations")
        # base is now the last base in bases
        if not issubclass(base, Enum):
            raise TypeError("new enumerations must be created as "
                    "`ClassName([mixin_type,] enum_type)`")

        # get correct mix-in type (either mix-in type of Enum subclass, or
        # first base if last base is Enum)
        if not issubclass(bases[0], Enum):
            member_type = bases[0]     # first data type
            first_enum = bases[-1]  # enum type
        else:
            for base in bases[0].__mro__:
                # most common: (IntEnum, int, Enum, object)
                # possible:    (<Enum 'AutoIntEnum'>, <Enum 'IntEnum'>,
                #               <class 'int'>, <Enum 'Enum'>,
                #               <class 'object'>)
                if issubclass(base, Enum):
                    if first_enum is None:
                        first_enum = base
                else:
                    if member_type is None:
                        member_type = base

        return member_type, first_enum
1346429
def _get_type_or_substitute(typecode, pyobj, sw, elt):
    '''
    '''
    sub = getattr(pyobj, 'typecode', typecode)
    if sub is typecode or sub is None:
        return typecode

    # Element WildCard
    if isinstance(typecode, AnyElement):
        return sub
 
    # Global Element Declaration
    if isinstance(sub, ElementDeclaration):
        if (typecode.nspname,typecode.pname) == (sub.nspname,sub.pname):
            raise TypeError(\
                'bad usage, failed to serialize element reference (%s, %s), in: %s' %
                 (typecode.nspname, typecode.pname, sw.Backtrace(elt),))

        # check substitutionGroup 
        if _is_substitute_element(typecode, sub):
            return sub

        raise TypeError(\
            'failed to serialize (%s, %s) illegal sub GED (%s,%s): %s' %
             (typecode.nspname, typecode.pname, sub.nspname, sub.pname,
              sw.Backtrace(elt),))

    # Local Element
    if not isinstance(typecode, AnyType) and not isinstance(sub, typecode.__class__):
        raise TypeError(\
            'failed to serialize substitute %s for %s,  not derivation: %s' %
             (sub, typecode, sw.Backtrace(elt),))

    # Make our substitution type match the elements facets,
    # since typecode is created for a single existing pyobj
    # some facets are irrelevant.
    sub = _copy(sub)
    sub.nspname = typecode.nspname
    sub.pname = typecode.pname
    sub.aname = typecode.aname
    sub.minOccurs = sub.maxOccurs = 1
    return sub
603563
function createCompositeKeyString(rec) {
    const cKey = createCompositeKey(rec);
    return rec.hasDynamicPath
        ? cKey.id +
            Object.keys(cKey)
                .filter(k => k !== "id")
                .map(k => `::${k}:${cKey[k]}`)
        : rec.id;
}
1289682
def composed_deps(self):
        """"""
        if 'deps' in self.params:
            param_deps = self.params['deps'] or []
            deps = [self.makeaddress(dep) for dep in param_deps]
            return deps
        else:
            return None
1186111
def coerce(other)
      if other.is_a? InternalComplex
        return other, self
      elsif other.is_a? Complex
        return InternalComplex.new( other.real, other.imag ), self
      else
        return InternalComplex.new( other, 0 ), self
      end
    end
910274
function dummy(caller) {
    return function() {
      queue.call({caller: caller}, slice.call(arguments, 0));
      return self;
    }
  }
3416
def factory(cls, object_source):
        
        if object_source.type is ObjectRaw.Types.object:
            return ObjectObject(object_source)
        elif object_source.type not in ObjectRaw.Types or object_source.type is ObjectRaw.Types.type:
            return ObjectType(object_source)
        elif object_source.type is ObjectRaw.Types.array:
            return ObjectArray(object_source)
        elif object_source.type is ObjectRaw.Types.dynamic:
            return ObjectDynamic(object_source)
        elif object_source.type is ObjectRaw.Types.const:
            return ObjectConst(object_source)
        elif object_source.type is ObjectRaw.Types.enum:
            return ObjectEnum(object_source)
        else:
            return Object(object_source)
193034
function dummyObsWrap(fn) {
    return function() {
        return Rx.Observable.create(function(observer) {
            fn(function(err, res) {
                if(err) 
                    return observer.onError(err);
                observer.onNext(res);
                observer.onCompleted();
            });
        });
    }
}
688682
def mixin (cls):
    
    cls._events = {}
    cls.bind = Pyevent.bind.__func__
    cls.unbind = Pyevent.unbind.__func__
    cls.trigger = Pyevent.trigger.__func__
    return cls
224702
def wrapinstance(ptr, base=None):
    """"""
    if ptr is None:
        return None
    ptr = long(ptr)  # Ensure type
    from wishlib.qt import active, QtCore, QtGui
    if active == "PySide":
        import shiboken
        if base is None:
            qObj = shiboken.wrapInstance(ptr, QtCore.QObject)
            metaObj = qObj.metaObject()
            cls = metaObj.className()
            superCls = metaObj.superClass().className()
            if hasattr(QtGui, cls):
                base = getattr(QtGui, cls)
            elif hasattr(QtGui, superCls):
                base = getattr(QtGui, superCls)
            else:
                base = QtGui.QWidget
        return shiboken.wrapInstance(ptr, base)
    elif active == "PyQt4":
        import sip
        return sip.wrapinstance(ptr, QtGui.QWidget)
    return None
3055
def compose (composite_property_s, component_properties_s):
    
    from . import property

    component_properties_s = to_seq (component_properties_s)
    composite_property = property.create_from_string(composite_property_s)
    f = composite_property.feature

    if len(component_properties_s) > 0 and isinstance(component_properties_s[0], property.Property):
        component_properties = component_properties_s
    else:
        component_properties = [property.create_from_string(p) for p in component_properties_s]

    if not f.composite:
        raise BaseException ("'%s' is not a composite feature" % f)

    if property in __composite_properties:
        raise BaseException ('components of "%s" already set: %s' % (composite_property, str (__composite_properties[composite_property])))

    if composite_property in component_properties:
        raise BaseException ('composite property "%s" cannot have itself as a component' % composite_property)

    __composite_properties[composite_property] = component_properties
929394
def construct(cls, faker, path_to_factories=None):
        
        factory = faker.__class__()

        if path_to_factories is not None and os.path.isdir(path_to_factories):
            for filename in os.listdir(path_to_factories):
                if os.path.isfile(filename):
                    cls._resolve(path_to_factories, filename)

        return factory
607561
@Override
    public ImmutableSubstitution<ImmutableTerm> composeWith(ImmutableSubstitution<? extends ImmutableTerm> f) {
        if (isEmpty()) {
            return (ImmutableSubstitution<ImmutableTerm>)f;
        }
        if (f.isEmpty()) {
            return (ImmutableSubstitution<ImmutableTerm>)this;
        }

        Map<Variable, ImmutableTerm> substitutionMap = new HashMap<>();

        /**
         * For all variables in the domain of f
         */

        for (Map.Entry<Variable, ? extends ImmutableTerm> gEntry :  f.getImmutableMap().entrySet()) {
            substitutionMap.put(gEntry.getKey(), apply(gEntry.getValue()));
        }

        /**
         * For the other variables (in the local domain but not in f)
         */
        for (Map.Entry<Variable, ? extends ImmutableTerm> localEntry :  getImmutableMap().entrySet()) {
            Variable localVariable = localEntry.getKey();

            if (substitutionMap.containsKey(localVariable))
                continue;

            substitutionMap.put(localVariable, localEntry.getValue());
        }

        return substitutionFactory.getSubstitution(
                substitutionMap.entrySet().stream()
                        // Clean out entries like t/t
                        .filter(entry -> !entry.getKey().equals(entry.getValue()))
                        .collect(ImmutableCollectors.toMap()));
    }