:param UnionField catch_all_field: The field designated as the
            catch-all. This field should be a member of the list of fields.

        See :meth:`Composite.set_attributes` for parameter definitions.
498075
def set_attributes(self, doc, fields,  # pylint: disable=arguments-differ
            parent_type=None, catch_all_field=None):
        
        if parent_type:
            assert isinstance(parent_type, Union)

        super(Union, self).set_attributes(doc, fields, parent_type)

        self.catch_all_field = catch_all_field
        self.parent_type = parent_type
254256
def param_union(*parameterizeds, **kwargs):
    
    warn = kwargs.pop('warn', True)
    if len(kwargs):
        raise TypeError(
            "param_union() got an unexpected keyword argument '{}'".format(
                kwargs.popitem()[0]))
    d = dict()
    for o in parameterizeds:
        for k in o.param:
            if k != 'name':
                if k in d and warn:
                    get_logger().warning("overwriting parameter {}".format(k))
                d[k] = getattr(o, k)
    return d
1265480
def _populate_union_type_attributes(self, env, data_type):
        
        parent_type = None
        extends = data_type._ast_node.extends
        if extends:
            # A parent type must be fully defined and not just a forward
            # reference.
            parent_type = self._resolve_type(env, extends, True)
            if isinstance(parent_type, Alias):
                raise InvalidSpec(
                    'A union cannot extend an alias. '
                    'Use the canonical name instead.',
                    data_type._ast_node.lineno, data_type._ast_node.path)
            if isinstance(parent_type, Nullable):
                raise InvalidSpec(
                    'A union cannot extend a nullable type.',
                    data_type._ast_node.lineno, data_type._ast_node.path)
            if not isinstance(parent_type, Union):
                raise InvalidSpec(
                    'A union can only extend another union: '
                    '%s is not a union.' % quote(parent_type.name),
                    data_type._ast_node.lineno, data_type._ast_node.path)

        api_type_fields = []
        for stone_field in data_type._ast_node.fields:
            if stone_field.name == 'other':
                raise InvalidSpec(
                    "Union cannot define an 'other' field because it is "
                    "reserved as the catch-all field for open unions.",
                    stone_field.lineno, stone_field.path)
            api_type_fields.append(self._create_union_field(env, stone_field))

        catch_all_field = None
        if data_type.closed:
            if parent_type and not parent_type.closed:
                # Due to the reversed super type / child type relationship for
                # unions, a child type cannot be closed if its parent is open
                # because the parent now has an extra field that is not
                # recognized by the child if it were substituted in for it.
                raise InvalidSpec(
                    "Union cannot be closed since parent type '%s' is open." % (
                        parent_type.name),
                    data_type._ast_node.lineno, data_type._ast_node.path)
        else:
            if not parent_type or parent_type.closed:
                # Create a catch-all field
                catch_all_field = UnionField(
                    name='other', data_type=Void(), doc=None,
                    ast_node=data_type._ast_node, catch_all=True)
                api_type_fields.append(catch_all_field)

        data_type.set_attributes(
            data_type._ast_node.doc, api_type_fields, parent_type, catch_all_field)
1068112
def _get_fields(self, attr):
        
        ret = set()
        if "OR" in self.pieces:
            return ret
        for i in range(0, len(self.pieces), 2):
            const = self.pieces[i]
            field = getattr(const, attr)
            if field is not None:
                ret.add(field)
        return ret
329448
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case SERIALIZED_PARTS:
      return is_set_serialized_parts();
    }
    throw new IllegalStateException();
  }
277485
private void parseField()
    throws IOException
  {
    int accessFlags = readShort();
    int nameIndex = readShort();
    int descriptorIndex = readShort();

    JavaField field = new JavaField();
    field.setJavaClass(_class);
    field.setName(_cp.getUtf8(nameIndex).getValue());
    field.setDescriptor(_cp.getUtf8(descriptorIndex).getValue());
    field.setAccessFlags(accessFlags);

    int attributesCount = readShort();

    for (int i = 0; i < attributesCount; i++) {
      Attribute attr = parseAttribute();

      field.addAttribute(attr);
    }

    _class.addField(field);
  }
433239
async def field(self, elem=None, elem_type=None, params=None, obj=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        fvalue = None

        src = elem if self.writing else obj
        dst = obj if self.writing else elem

        # TODO: optional elem, default value for deserialization...

        # Blob wrapper. Underlying structure should be serialized as blob.
        if x.is_type(elem_type, BlobFieldWrapper):
            blobber = Blobber(self.writing, data=x.get_elem(src) if not self.writing else None)
            fvalue = await blobber.blobize(elem=x.get_elem(src), elem_type=elem_type.ftype, params=params)
            fvalue = NoSetSentinel() if fvalue is None or len(fvalue) == 0 else fvalue

        elif issubclass(elem_type, x.UVarintType):
            fvalue = await self.uvarint(x.get_elem(src))

        elif issubclass(elem_type, x.IntType):
            fvalue = await self.uint(elem=x.get_elem(src), elem_type=elem_type, params=params)

        elif issubclass(elem_type, x.BlobType):
            fvalue = await self.blob(elem=x.get_elem(src), elem_type=elem_type, params=params)

        elif issubclass(elem_type, x.UnicodeType):
            fvalue = await self.unicode_type(x.get_elem(src))

        elif issubclass(elem_type, x.VariantType):
            fvalue = await self.variant(elem=x.get_elem(src), elem_type=elem_type, params=params, obj=dst)

        elif issubclass(elem_type, x.ContainerType):  # container ~ simple list
            fvalue = await self.container(container=x.get_elem(src), container_type=elem_type, params=params, obj=dst)

        elif issubclass(elem_type, x.TupleType):  # tuple ~ simple list
            fvalue = await self.tuple(elem=x.get_elem(src), elem_type=elem_type, params=params, obj=dst)

        elif issubclass(elem_type, x.MessageType):
            fvalue = await self.message(x.get_elem(src), msg_type=elem_type, obj=dst)

        else:
            raise TypeError

        return x.set_elem(dst, fvalue) if not isinstance(fvalue, NoSetSentinel) else fvalue
1121730
def field_(self, name):
    
    try:
        field = self.fields[name]
    except KeyError:
        raise KeyError("Key %r not found in '%s'" % (name, self.__class__.__name__))
    return BoundField(self, field, name)
547643
def _add_dynamic_field_to_instance(self, field, field_name):
        
        # create the new field
        new_field = field._create_dynamic_version()
        new_field.name = field_name
        new_field._attach_to_instance(self)

        # add the field to the list to avoid doing all of this again
        if field_name not in self._fields:  # (maybe already in it via the class)
            if id(self._fields) == id(self.__class__._fields):
                # unlink the list from the class
                self._fields = list(self._fields)
            self._fields.append(field_name)

        # if the field is an hashable field, add it to the list to allow calling
        # hmget on these fields
        if isinstance(field, limpyd_fields.InstanceHashField):
            if id(self._instancehash_fields) == id(self.__class__._instancehash_fields):
                # unlink the link from the class
                self._instancehash_fields = list(self._instancehash_fields)
            self._instancehash_fields.append(field_name)

        # set it as an attribute on the instance, to be reachable
        setattr(self, field_name, new_field)

        return new_field
1371278
def union(bitfield)
      raise "That's not a bitfield" if ! bitfield.is_a?(Bitfield)
      raise "bitfield lengths must be equal" if ! bitfield.length == length
    
      result = Bitfield.new(length)
      (@data.length).times do |i|
        result.data[i] = @data[i] | bitfield.data[i]
      end
      result
    end
420613
def get_all_fields(cls, class_obj=None, fields=None):
        

        def return_fields(obj):

            internal_fields = fields
            if internal_fields is None:
                internal_fields = {}

            for attribute in dir(obj):

                try:
                    attr_val = getattr(obj, attribute)
                    attr_cls = attr_val.__class__

                    # If it is a model field, call on init
                    if issubclass(attr_cls, ModelField):
                        internal_fields[attribute] = attr_val
                except:
                    pass

            return internal_fields

        if class_obj is None:
            class_obj = cls

            fields = return_fields(class_obj)
            for parent_class in cls.__bases__:
                parent_fields = cls.get_all_fields(parent_class, fields)
                for field_name, field_value in list(parent_fields.items()):
                    if not field_name in fields:
                        fields[field_name] = field_value

            return fields

        else:
            if not isinstance(class_obj, CollectionModel):
                return fields
314935
def _set_fields(self):
        
        self.fields = []
        self.required_input = []
        for member_name, member_object in inspect.getmembers(self.__class__):
            if inspect.isdatadescriptor(member_object) and not member_name.startswith("__"):
                self.fields.append(member_name)
                if member_object.required_input:
                    self.required_input.append(member_name)
1192819
def initialize_fields(self):
        
        # # Pull all the "normal" fields off the model instance meta.
        for name, field in self.instance._meta.fields.items():
            if getattr(field, 'primary_key', False):
                continue
            self._meta.fields[name] = self.convert_field(name, field)

        # Many-to-many fields are not stored in the meta fields dict.
        # Pull them directly off the class.
        for name in dir(type(self.instance)):
            field = getattr(type(self.instance), name, None)
            if isinstance(field, ManyToManyField):
                self._meta.fields[name] = self.convert_field(name, field)

        super().initialize_fields()
478810
def _init_composite_fields(self):
        
        # The base_composite_fields class attribute is the *class-wide*
        # definition of fields. Because a particular *instance* of the class
        # might want to alter self.composite_fields, we create
        # self.composite_fields here by copying base_composite_fields.
        # Instances should always modify self.composite_fields; they should not
        # modify base_composite_fields.
        self.composite_fields = copy.deepcopy(self.base_composite_fields)
        self.forms = OrderedDict()
        self.formsets = OrderedDict()
        for name, field in self.composite_fields.items():
            self._init_composite_field(name, field)
946033
def get_schema_field(schema, field):
    
    schema_fields_to_model = {key: get_model_field(schema, key) for (key, value) in schema._declared_fields.items()}
    for key, value in schema_fields_to_model.items():
        if value == field:
            return key

    raise Exception("Couldn't find schema field from {}".format(field))
8367
def visit_field(rec, field, op):
    # type: (Any, Iterable, Union[Callable[..., Any], partial[Any]]) -> None
    """"""

    if isinstance(rec, MutableMapping):
        if field in rec:
            rec[field] = op(rec[field])
        for d in rec:
            visit_field(rec[d], field, op)
    if isinstance(rec, MutableSequence):
        for d in rec:
            visit_field(d, field, op)
1130774
def concatenate_fields(fields, dim):
    ''
    if len(fields) == 0:
        raise ValueError('fields cannot be an empty list')
    
    if len(set((f.name, f.shape, f.dtype) for f in fields)) != 1:
        raise ValueError('fields should have homogeneous name, shape and dtype')
    tpl = fields[0]
    attr = InstanceAttribute(tpl.name, shape=tpl.shape, dtype=tpl.dtype, 
                             dim=dim, alias=None)
    
    attr.value = np.array([f.value for f in fields], dtype=tpl.dtype)
    return attr