Create a new Shake instance from a JSON dict.

        Args:
            data (dict): JSON dictionary representing a Shake.

        Returns:
            A Shake instance.
323972
def NewFromJSON(data):
        
        s = Shake(
            id=data.get('id', None),
            name=data.get('name', None),
            url=data.get('url', None),
            thumbnail_url=data.get('thumbnail_url', None),
            description=data.get('description', None),
            type=data.get('type', None),
            created_at=data.get('created_at', None),
            updated_at=data.get('updated_at', None)
        )
        if data.get('owner', None):
            s.owner = User.NewFromJSON(data.get('owner', None))
        return s
1306138
def create_from_dict(data: dict, format_name: str, check_version: bool = True) -> Union[HistogramBase, HistogramCollection]:
    
    # Version
    if check_version:
        compatible_version = data["physt_compatible"]
        require_compatible_version(compatible_version, format_name)

    # Construction
    histogram_type = data["histogram_type"]
    if histogram_type == "histogram_collection":
        klass = HistogramCollection
    else:
        klass = find_subclass(HistogramBase, histogram_type)
    return klass.from_dict(data)
193101
def from_dict(cls, data):
        
        auth_info = _AuthenticationInformation.from_dict(data.get("auth_info"))
        instance = cls(auth_info=auth_info)
        instance.user_id_hash_type = data.get("hash_type")
        instance.attributes = data.get("attributes", {})
        instance.user_id = data.get("user_id")
        instance.requester = data.get("requester")
        return instance
616710
def from_dict(cls, data, model):
        
        model_provided = model is not None
        result = {}
        for name, new_value in data.items():
            kwargs = {
                'name': name,
                'new_value': new_value,
            }
            if model_provided:
                kwargs['params'] = model.get_field_params(name)
            result[name] = cls(**kwargs)
        return result
1101601
def create_from_json(cls, json_data):
        
        block = Block()
        block_info = json_data["block_info"]
        block.block_id = block_info["block_id"]
        block.num_bins = block_info["num_bins"] if "num_bins" in block_info else None
        block.property_type = block_info["property_type"] if "property_type" in block_info else None
        block.meta = json_data["meta"] if "meta" in json_data else None

        block.component_results = _create_component_results(json_data, "block_info")

        return block
1306286
def FromData(cls, stream, json_data, http=None, auto_transfer=None,
                 **kwds):
        """"""
        info = json.loads(json_data)
        missing_keys = cls._REQUIRED_SERIALIZATION_KEYS - set(info.keys())
        if missing_keys:
            raise exceptions.InvalidDataError(
                'Invalid serialization data, missing keys: %s' % (
                    ', '.join(missing_keys)))
        download = cls.FromStream(stream, **kwds)
        if auto_transfer is not None:
            download.auto_transfer = auto_transfer
        else:
            download.auto_transfer = info['auto_transfer']
        setattr(download, '_Download__progress', info['progress'])
        setattr(download, '_Download__total_size', info['total_size'])
        download._Initialize(  # pylint: disable=protected-access
            http, info['url'])
        return download
883945
def new(cls, data=None):
		
		obj = cls()
		if data is not None:
			obj.update(data)
		return obj
591247
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'id' in _dict:
            args['id'] = _dict.get('id')
        else:
            raise ValueError(
                'Required property \'id\' not present in RecognitionJob JSON')
        if 'status' in _dict:
            args['status'] = _dict.get('status')
        else:
            raise ValueError(
                'Required property \'status\' not present in RecognitionJob JSON'
            )
        if 'created' in _dict:
            args['created'] = _dict.get('created')
        else:
            raise ValueError(
                'Required property \'created\' not present in RecognitionJob JSON'
            )
        if 'updated' in _dict:
            args['updated'] = _dict.get('updated')
        if 'url' in _dict:
            args['url'] = _dict.get('url')
        if 'user_token' in _dict:
            args['user_token'] = _dict.get('user_token')
        if 'results' in _dict:
            args['results'] = [
                SpeechRecognitionResults._from_dict(x)
                for x in (_dict.get('results'))
            ]
        if 'warnings' in _dict:
            args['warnings'] = _dict.get('warnings')
        return cls(**args)
468489
def from_json(json_data):
        
        # If we have a string, then decode it, otherwise assume it's already decoded
        if isinstance(json_data, str):
            data = json.loads(json_data)
        else:
            data = json_data
        oauth_dict = {
                      'client_id':data.get('oauth',{}).get('client_id',None),
                      'client_secret':data.get('oauth',{}).get('client_secret',None),
                      'redirect_url':data.get('oauth',{}).get('redirect_url',None),
                      }
        client = Client(api_key=data.get('api_key',None),
                        api_url=data.get('api_url',None),
                        oauth=oauth_dict,
                        use_cache=data.get('use_cache',None),
                        cache_dir=data.get('cache_dir',None),
                        update_cache=data.get('update_cache',None),
                        verifySSL=data.get('oauth',{}).get('verifySSL',None)
                        )
        client.cache = Cache.from_json(data.get('cache',None))
        client.oauth = OAuth2.from_json(data.get('oauth',None))
        return client
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)
345286
def _setup_from_data(self, data):
        

        fitted_state = {}

        _raise_error_if_not_of_type(data, [_SFrame])

        feature_columns = _internal_utils.get_column_names(data, self._exclude, self._features)

        if not feature_columns:
            raise RuntimeError("No valid feature columns specified in transformation.")

        fitted_state["features"] = feature_columns

        ################################################################################
        # Helper functions

        def get_valid_interpretations():
            return list(n.split("__")[0] for n in dir(_interpretations) if not n.startswith("_"))

        ################################################################################
        # Check input data.

        if not isinstance(data, _SFrame):
            raise TypeError("`data` parameter must be an SFrame.")

        all_col_names = set(feature_columns)

        column_interpretations = self._get("column_interpretations").copy()

        # Make sure all the interpretations are valid.
        for k, v in column_interpretations.items():
            if k not in all_col_names:
                raise ValueError("Column '%s' in column_interpretations, but not found in `data`." % k)

        # Get the automatic column interpretations.
        for col_name in feature_columns:
            if col_name not in column_interpretations:
                n = column_interpretations[col_name] = infer_column_interpretation(data[col_name])

                if n.startswith("unknown"):
                    raise ValueError("Interpretation inference failed on column '%s'; %s"
                                     % (col_name, n[len("unknown"):].strip()))

        # Now, build up the feature transforms.
        transforms = {}
        input_types = {}

        output_column_prefix = self._get("output_column_prefix")

        assert output_column_prefix is None or type(output_column_prefix) is str

        tr_chain = []
        for col_name in feature_columns:
            in_type = input_types[col_name] = data[col_name].dtype

            intr_func = _get_interpretation_function(column_interpretations[col_name], in_type)
            tr_list = intr_func(col_name, output_column_prefix)
            transforms[col_name] = tr_list
            tr_chain += tr_list

        fitted_state["transform_chain"] = _TransformerChain(tr_chain)
        fitted_state["transforms"] = transforms
        fitted_state["input_types"] = input_types

        fitted_state["column_interpretations"] = column_interpretations

        self.__proxy__.update(fitted_state)
240890
def update(self, data):
        
        result = None
        if data:
            _dumps = self._dumps
            data = {
                key: _dumps(value)
                for key, value in data.items()}
            result = self._client.hmset(self.key_prefix, data)
        return result
281091
def _create_feed_dict(self, data):
        
        return {
            self.input_data: data,
            self.hrand: np.random.rand(data.shape[0], self.num_hidden),
            self.vrand: np.random.rand(data.shape[0], data.shape[1])
        }
897866
def perform_create(self, data):
        

        instance = self.model(**data)
        self.request.dbsession.add(instance)
        self.request.dbsession.flush()
        return instance
1064888
def get_user_shakes(self):
        
        endpoint = '/api/shakes'
        data = self._make_request(verb="GET", endpoint=endpoint)

        shakes = [Shake.NewFromJSON(shk) for shk in data['shakes']]
        return shakes
9139
def validate_json(data: str):
    
    result = None
    try:
        result = json.loads(data)
    except ValueError as error:
        log(ERROR, "invalid json: %s", error)

    return result
764797
def _data_to_json(data):
        
        if type(data) not in [str, unicode]:
            data = json.dumps(data)
        return data