Instantiate model class
489232
def run_command(self, command_name, varargs):
        
        command_descriptor = self.get_command(command_name)
        return command_descriptor.run(*varargs)
103561
def create(self, *args, **kwargs):
        """"""
        href = self.url
        if len(args) == 1:
            kwargs[self.model_class.primary_key] = args[0]
            href = '/'.join([href, args[0]])
        model = self.model_class(self,
                                 href=href.replace('classifications/', 'classification/'),
                                 data=kwargs)
        model.create(**kwargs)
        self._models.append(model)
        return model
287881
def instantiate(self, **extra_args):
        
        input_block = self.input_block.instantiate()
        backbone = self.backbone.instantiate(**extra_args)

        return QRainbowModel(
            input_block=input_block,
            backbone=backbone,
            action_space=extra_args['action_space'],
            vmin=self.vmin,
            vmax=self.vmax,
            atoms=self.atoms,
            initial_std_dev=self.initial_std_dev,
            factorized_noise=self.factorized_noise
        )
563746
def create(blocks, mode='basic', inplanes=64, cardinality=4, image_features=64, divisor=4, num_classes=1000):
    
    block_dict = {
        # 'basic': BasicBlock,
        'bottleneck': ResNeXtBottleneck
    }

    def instantiate(**_):
        return ResNeXt(block_dict[mode], blocks, inplanes=inplanes, image_features=image_features, cardinality=cardinality, divisor=divisor, num_classes=num_classes)

    return ModelFactory.generic(instantiate)
1280391
def create(self, model):
        

        signals.pre_create.send(model.__class__, model=model)
        signals.pre_save.send(model.__class__, model=model)

        param = self.to_pg(model)
        query = """
                INSERT INTO {table} ({dirty_cols})
                VALUES ({dirty_vals})
                RETURNING {cols};
                """

        query = query.format(
            cols=self.field_cols(model),
            dirty_cols=self.dirty_cols(model),
            dirty_vals=self.dirty_vals(model),
            table=model.rtype,
        )

        result = self.query(query, param=param)

        signals.post_create.send(model.__class__, model=model)
        signals.post_save.send(model.__class__, model=model)

        return model.merge(result[0], clean=True)
536925
def make_instance(self, data):
        """"""
        if not self.opts.model:
            return data

        if self.instance is not None:
            for key, value in data.items():
                setattr(self.instance, key, value)
            return self.instance

        return self.opts.model(**data)
1017486
def _create(cls, model_class, *args, **kwargs):
        """"""
        if cls._meta.django_get_or_create:
            return cls._get_or_create(model_class, *args, **kwargs)

        manager = cls._get_manager(model_class)
        return manager.create(*args, **kwargs)
54592
def create(input_width, input_height, input_channels=1):
    
    def instantiate(**_):
        return DoubleNatureCnn(input_width=input_width, input_height=input_height, input_channels=input_channels)

    return ModelFactory.generic(instantiate)
286152
async def create(self, model_, **data):
        
        inst = model_(**data)
        query = model_.insert(**dict(inst.__data__))

        pk = await self.execute(query)
        if inst._pk is None:
            inst._pk = pk
        return inst
661368
def _initialize_lists(model_class, name, bases, attrs):
    """"""
    model_class._lists = {}
    for k, v in attrs.iteritems():
        if isinstance(v, ListField):
            model_class._lists[k] = v
            v.name = v.name or k
1284217
def create_model(cls, data: dict, fields=None):
        '''
        
        '''
        if fields is None:
            fields = set(cls._fields.keys())
        else:
            if not isinstance(fields, set):
                fields = set(fields)
        new_keys = set(data.keys()) - fields
        if new_keys:
            for new_key in new_keys:
                del data[new_key]
        return cls(data)
938659
def instantiate_from_data(self, object_data):
        
        if isinstance(object_data, dict) and 'name' in object_data:
            name = object_data['name']
            module = importlib.import_module(name)
            return self.resolve_and_call(module.create, extra_env=object_data)
        if isinstance(object_data, dict) and 'factory' in object_data:
            factory = object_data['factory']
            module = importlib.import_module(factory)
            params = self.resolve_parameters(module.create, extra_env=object_data)
            return GenericFactory(module.create, params)
        elif isinstance(object_data, dict):
            return {k: self.instantiate_from_data(v) for k, v in object_data.items()}
        elif isinstance(object_data, list):
            return [self.instantiate_from_data(x) for x in object_data]
        elif isinstance(object_data, Variable):
            return object_data.resolve(self.parameters)
        else:
            return object_data
692847
def instantiate_model_from_attributes_hash(model_class, attributes)
      model_class.new.tap do |model|
        model.instance_variable_set :@dealing_platform, self

        attributes.each do |attribute, value|
          next unless model.class.valid_attribute? attribute

          type = model.class.attribute_type attribute
          value = instantiate_models type, value if type < Model

          set_model_attribute_value model, attribute, value
        end
      end
    end
209415
def add_to_class(self, cls, name):
        '''
        
        '''
        self.model_class = cls
        setattr(cls, name, PhoneNumberDescriptor(self))
        self._bound = True
372381
def _instantiate_model(self, response, attrs, additional_properties=None):
        
        if callable(response):
            subtype = getattr(response, '_subtype_map', {})
            try:
                readonly = [k for k, v in response._validation.items()
                            if v.get('readonly')]
                const = [k for k, v in response._validation.items()
                         if v.get('constant')]
                kwargs = {k: v for k, v in attrs.items()
                          if k not in subtype and k not in readonly + const}
                response_obj = response(**kwargs)
                for attr in readonly:
                    setattr(response_obj, attr, attrs.get(attr))
                if additional_properties:
                    response_obj.additional_properties = additional_properties
                return response_obj
            except TypeError as err:
                msg = "Unable to deserialize {} into model {}. ".format(
                    kwargs, response)
                raise DeserializationError(msg + str(err))
        else:
            try:
                for attr, value in attrs.items():
                    setattr(response, attr, value)
                return response
            except Exception as exp:
                msg = "Unable to populate response model. "
                msg += "Type: {}, Error: {}".format(type(response), exp)
                raise DeserializationError(msg)
985394
def __model_class(self, model_name):
        
        build_schema = deepcopy(self.definitions[model_name])
        return self.schema_class(build_schema, model_name)
497793
def instantiate(self, scope, args, interp):
        
        param_instances = []

        BYREF = "byref"

        # TODO are default values for function parameters allowed in 010?
        for param_name, param_cls in self._params:
            # we don't instantiate a copy of byref params
            if getattr(param_cls, "byref", False):
                param_instances.append(BYREF)
            else:
                field = param_cls()
                field._pfp__name = param_name
                param_instances.append(field)

        if len(args) != len(param_instances):
            raise errors.InvalidArguments(
                self._coords,
                [x.__class__.__name__ for x in args],
                [x.__class__.__name__ for x in param_instances]
            )

        # TODO type checking on provided types

        for x in six.moves.range(len(args)):
            param = param_instances[x]
             
            # arrays are simply passed through into the function. We shouldn't
            # have to worry about frozenness/unfrozenness at this point
            if param is BYREF or isinstance(param, pfp.fields.Array):
                param = args[x]
                param_instances[x] = param
                scope.add_local(self._params[x][0], param)
            else:
                param._pfp__set_value(args[x])
                scope.add_local(param._pfp__name, param)
            param._pfp__interp = interp

        return ParamList(param_instances)