See base class for details.
972981
def get_tensor_info(self):
    """"""
    # Add the additional length dimension to every shape

    def add_length_dim(tensor_info):
      return feature_lib.TensorInfo(
          shape=(self._length,) + tensor_info.shape,
          dtype=tensor_info.dtype,
      )

    tensor_info = super(SequenceDict, self).get_tensor_info()
    return utils.map_nested(add_length_dim, tensor_info)
304630
def with_metaclass(meta, *bases):
    """"""
    # This requires a bit of explanation: the basic idea is to make a dummy
    # metaclass for one level of class instantiation that replaces itself with
    # the actual metaclass.
    class metaclass(type):

        def __new__(cls, name, this_bases, d):
            return meta(name, bases, d)

        @classmethod
        def __prepare__(cls, name, this_bases):
            return meta.__prepare__(name, bases)
    return type.__new__(metaclass, 'temporary_class', (), {})
230264
def base(context, config, database, root, log_level):
    """"""
    coloredlogs.install(level=log_level)
    context.obj = ruamel.yaml.safe_load(config) if config else {}
    context.obj['database'] = database if database else context.obj['database']
    context.obj['root'] = root if root else context.obj['root']
591342
def __basepl(self, content, rec_type='flat', format='json'):
        """"""
        d = {'token': self.token, 'content': content, 'format': format}
        if content not in ['metadata', 'file']:
            d['type'] = rec_type
        return d
1118645
def peek(self):
        """"""
        info = self._registry.get(self)
        obj = info and info.weakref()
        if obj is not None:
            return (obj, info.func, info.args, info.kwargs or {})
32245
function _gpfAttributesCheckAppliedOnBaseClass (classDefinition, ExpectedBaseClass) {
    var Extend = classDefinition._extend;
    if (Extend !== ExpectedBaseClass) {
        _gpfAttributesCheckAppliedOnBaseClassIsInstanceOf(Extend.prototype, ExpectedBaseClass);
    }
}
56557
def _get_members(obj, traverse_bases=True, filter=default_filter,
                 recursive=True):
    """"""
    if filter is None:
        filter = _true

    out = []
    stack = collections.deque((obj,))
    while stack:
        obj = stack.popleft()
        if traverse_bases and isinstance(obj, _CLASS_TYPES):
            roots = [base for base in inspect.getmro(obj)
                     if base not in (type, object)]
        else:
            roots = [obj]

        members = []
        seen = set()
        for root in roots:
            for name, value in _iteritems(getattr(root, '__dict__', {})):
                if name not in seen and filter(name, value):
                    members.append((name, value))

                seen.add(name)

        members = sorted(members)
        for _, value in members:
            if recursive and isinstance(value, _CLASS_TYPES):
                stack.append(value)

        out.extend(members)

    return out
843900
def build_from_bases(bases, classdict, attr, attr_dict):
    """"""
    output = OrderedDict()
    output_keys = set()
    all_bases = []
    # Go through the bases from furthest to nearest ancestor
    for base in reversed(bases):
        # Only keep the items that are still defined on the bases
        if base is not object and isinstance(base, PropertyMetaclass):
            output_keys = output_keys.union(getattr(base, attr))
        # Collect all bases so we ensure overridden items are assigned
        # in the correct order
        for item in reversed(base.__mro__):
            if item is object or not isinstance(item, PropertyMetaclass):
                continue
            if item not in all_bases:
                all_bases.append(item)
    # Update the items in reverse MRO order; only keep those that are
    # defined on the bases
    for base in all_bases:
        for key, val in iteritems(getattr(base, attr)):
            if key in base.__dict__ and key in output_keys:
                output.update({key: val})
    # Remove all items that were overridden by this class; this is
    # potentially a superset of the items added back in the next step.
    for key in classdict:
        if key in output:
            output.pop(key)
    # Update the items with those defined on this class
    output.update(attr_dict)
    return output
167637
def superclasses(access_type = nil)
      QueryResult.new(
        [
          NodeCache.find_children_of_type(self, "Base").select do |base|
            access_type.nil? ? true : base.send("#{access_type}?")
          end
        ].flatten.map {|base| base.cpp_type }
      )
    end
49613
def as_base_types(self):
    """"""
    if not self._cached:
      # Create the single cache file the first time this is called.
      self._cached = {
          'name': self.name,
          'outcome': self.outcome.name,
      }
      if self.validators:
        self._cached['validators'] = data.convert_to_base_types(
            tuple(str(v) for v in self.validators))
      if self.dimensions:
        self._cached['dimensions'] = data.convert_to_base_types(self.dimensions)
      if self.units:
        self._cached['units'] = data.convert_to_base_types(self.units)
      if self.docstring:
        self._cached['docstring'] = self.docstring
    if self.measured_value.is_value_set:
      self._cached['measured_value'] = self.measured_value.basetype_value()
    return self._cached
804284
def registry(attr, base=type):
    """"""
    class Registry(base):
        def __init__(cls, name, bases, attrs):
            super(Registry, cls).__init__(name, bases, attrs)
            if not hasattr(cls, '__registry__'):
                cls.__registry__ = {}
            key = getattr(cls, attr)
            if key is not NotImplemented:
                assert key not in cls.__registry__
                cls.__registry__[key] = cls
        def __dispatch__(cls, key):
            try:
                return cls.__registry__[key]
            except KeyError:
                raise ValueError('Unknown %s: %s' % (attr, key))
    return Registry
331187
def superclass(self, klass):
        """"""
        return bool(lib.EnvSuperclassP(self._env, self._cls, klass._cls))
27902
def get_inheritors(cls):
    """"""
    subclasses = set()
    work = [cls]
    while work:
        parent = work.pop()
        for child in parent.__subclasses__():
            if child not in subclasses:
                subclasses.add(child)
                work.append(child)
    return subclasses
308727
def construct_exc_class(cls):
    """"""

    class ProxyException(cls, BaseException):
        __pep3134__ = True

        @property
        def __traceback__(self):
            if self.__fixed_traceback__:
                return self.__fixed_traceback__

            current_exc, current_tb = sys.exc_info()[1:]
            if current_exc is self:
                return current_tb

        def __init__(self, instance=None):  # pylint: disable=W0231
            self.__original_exception__ = instance
            self.__fixed_traceback__ = None

        def __getattr__(self, item):
            return getattr(self.__original_exception__, item)

        def __repr__(self):
            return repr(self.__original_exception__)

        def __str__(self):
            return str(self.__original_exception__)

        def with_traceback(self, traceback):
            instance = copy.copy(self)
            instance.__fixed_traceback__ = traceback
            return instance

    ProxyException.__name__ = cls.__name__

    return ProxyException
974979
def walk_subclasses(root):
    """"""
    classes = [root]
    visited = set()
    while classes:
        cls = classes.pop()
        if cls is type or cls in visited:
            continue
        classes.extend(cls.__subclasses__())
        visited.add(cls)
        if cls is not root:
            yield cls
140363
def _initialize_counters(model_class, name, bases, attrs):
    """"""
    model_class._counters = []
    for k, v in attrs.iteritems():
        if isinstance(v, Counter):
            model_class._counters.append(k)
1105967
def get_topclasses(cls):
    """"""
    bases = [c for c in inspect.getmro(cls)
             if c.__module__.startswith('pycbc') and c != cls]
    return ', '.join(['{}.{}'.format(c.__module__, c.__name__) for c in bases])