本文整理汇总了Python中util.serialize函数的典型用法代码示例。如果您正苦于以下问题:Python serialize函数的具体用法?Python serialize怎么用?Python serialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: put
def put(self, key, value, raw_key=False, raw_value=False):
"""Store any Python object into a hash database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, c_value_len) = util.serialize(value, raw_value)
result = tc.hdb_put(self.db, c_key, c_key_len, c_value, c_value_len)
if not result:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:hdb.py
示例2: put
def put(self, key, value, raw_key=False, raw_value=False):
"""Store any Python object into an abstract database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, c_value_len) = util.serialize(value, raw_value)
result = tc.adb_put(self.db, c_key, c_key_len, c_value, c_value_len)
if not result:
self._raise('Error putting a Python object in an abstract ' \
'database object')
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:9,代码来源:adb.py
示例3: putcat
def putcat(self, key, value, raw_key=False, raw_value=False):
"""Concatenate an object value at the end of the existing
record in a hash database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, c_value_len) = util.serialize(value, raw_value)
result = tc.hdb_putcat(self.db, c_key, c_key_len, c_value, c_value_len)
if not result:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:9,代码来源:hdb.py
示例4: putcat
def putcat(self, key, value, raw_key=False, raw_value=False):
"""Concatenate an object value at the end of the existing
record in an abstract database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, c_value_len) = util.serialize(value, raw_value)
result = tc.adb_putcat(self.db, c_key, c_key_len, c_value, c_value_len)
if not result:
self._raise('Error concatenating a Python object in an abstract ' \
'database object')
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:10,代码来源:adb.py
示例5: get_col
def get_col(self, key, col, default=None, raw_key=False, value_type=None):
"""Retrieve the value of a column of a record in a table
database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_col, c_col_len) = util.serialize(col, as_raw=True)
(c_value, c_value_len) = tc.tdb_get4(self.db, c_key, c_key_len, c_col,
c_col_len)
if c_value:
value = util.deserialize(c_value, c_value_len, value_type)
else:
value = default
return value
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:12,代码来源:tdb.py
示例6: _getitem
def _getitem(self, key, raw_key=False, schema=None):
""""Retrieve a record in a table database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
cols_tcmap = tc.tdb_get(self.db, c_key, c_key_len)
if not cols_tcmap:
raise KeyError(key)
return util.deserialize_tcmap(cols_tcmap, schema)
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:7,代码来源:tdb.py
示例7: get_aic_bic
def get_aic_bic(img):
subplot_data = img
ctype = ['spherical', 'tied', 'diag', 'full']
aic_res = np.zeros(5)
bic_res = np.zeros(5)
res_idx = 0
for ncomponents in range(1, 6):
X_train = np.ceil(serialize(subplot_data))
# clf = mixture.DPGMM(n_components=3, covariance_type='full')
clf = mixture.GMM(n_components=ncomponents, covariance_type=ctype[2],
n_iter=100)
clf.fit(X_train)
aic_res[res_idx] = clf.aic(X_train)
bic_res[res_idx] = clf.bic(X_train)
# print clf.weights_
# print clf.means_
# print clf.get_params()
# x = np.linspace(0.0, subplot_data.shape[0])
# y = np.linspace(0.0, subplot_data.shape[1])
# X, Y = np.meshgrid(x, y)
# XX = np.c_[X.ravel(), Y.ravel()]
# #Z = np.log(-clf.score_samples(XX)[0])
# Z = np.log(-clf.score_samples(XX)[0])
# Z = Z.reshape(X.shape)
res_idx += 1
return aic_res, bic_res
开发者ID:ymnliu,项目名称:cyto_lib,代码行数:33,代码来源:feature.py
示例8: serialize
def serialize(self):
first = Operation(ROBOT_NOTIFY_CAPABILITIES_HASH,
'0',
{'capabilitiesHash': self._capability_hash})
operations = [first] + self.__pending
res = util.serialize(operations)
return res
开发者ID:GunioRobot,项目名称:rss-feeder-bot,代码行数:7,代码来源:ops.py
示例9: out
def out(self, key, as_raw=False):
"""Remove a Python object of a hash database object."""
(c_key, c_key_len) = util.serialize(key, as_raw)
result = tc.hdb_out(self.db, c_key, c_key_len)
if not result:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:7,代码来源:hdb.py
示例10: _getitem
def _getitem(self, key, raw_key=False, value_type=None):
"""Retrieve a Python object in a hash database object."""
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, c_value_len) = tc.hdb_get(self.db, c_key, c_key_len)
if not c_value:
raise KeyError(key)
return util.deserialize(c_value, c_value_len, value_type)
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:7,代码来源:hdb.py
示例11: data
def data(self):
return {
"players": self.players,
"match": serialize(self.match),
"results": self.results.json(),
"hands": self.read_hands()
}
开发者ID:gnmerritt,项目名称:casino,代码行数:7,代码来源:match_logs.py
示例12: putcat
def putcat(self, key, value, as_raw=False):
"""Concatenate a Python object value at the end of the
existing record in a fixed-length database object."""
(c_value, c_value_len) = util.serialize(value, as_raw)
result = tc.fdb_putcat(self.db, key, c_value, c_value_len)
if not result:
raise tc.TCException(tc.fdb_errmsg(tc.fdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:fdb.py
示例13: put
def put(self, key, value, as_raw=False):
"""Store any Python object into a fixed-length database
object."""
(c_value, c_value_len) = util.serialize(value, as_raw)
result = tc.fdb_put(self.db, key, c_value, c_value_len)
if not result:
raise tc.TCException(tc.fdb_errmsg(tc.fdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:fdb.py
示例14: serialize
def serialize(self):
first = Operation(ROBOT_NOTIFY_CAPABILITIES_HASH,
'0',
{'capabilitiesHash': self._capability_hash,
'protocolVersion': PROTOCOL_VERSION})
operations = [first] + self.__pending
res = util.serialize(operations)
return res
开发者ID:JackDanger,项目名称:google-wave-robot-python-client,代码行数:8,代码来源:ops.py
示例15: add_float
def add_float(self, key, num, as_raw=False):
"""Add a real number to a record in a hash database object."""
assert isinstance(num, float), 'Value is not a float'
(c_key, c_key_len) = util.serialize(key, as_raw)
result = tc.hdb_adddouble(self.db, c_key, c_key_len, num)
if not result:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:hdb.py
示例16: fwmkeys
def fwmkeys(self, prefix, max_=-1, as_raw=True):
"""Get forward matching string keys in a hash database object."""
(c_prefix, c_prefix_len) = util.serialize(prefix, as_raw)
tclist_objs = tc.hdb_fwmkeys(self.db, c_prefix, c_prefix_len, max_)
if not tclist_objs:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
as_type = util.get_type(prefix, as_raw)
return util.deserialize_tclist(tclist_objs, as_type)
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:hdb.py
示例17: finished
def finished(self, user):
matches = Match.query.filter(Match.finished.isnot(None)) \
.order_by(Match.finished.desc()) \
.offset(self.offset) \
.limit(25) \
.all()
pagination = {'offset': self.offset, 'limit': 25}
return pagination, [serialize(m) for m in matches]
开发者ID:gnmerritt,项目名称:casino,代码行数:8,代码来源:matches.py
示例18: has_key
def has_key(self, key, raw_key=False):
"""Return True if abstract database object has the key."""
result = False
(c_key, c_key_len) = util.serialize(key, raw_key)
(c_value, _) = tc.adb_get(self.db, c_key, c_key_len)
if c_value:
result = True
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:adb.py
示例19: vsiz
def vsiz(self, key, as_raw=False):
"""Get the size of the value of a Python object in a hash
database object."""
(c_key, c_key_len) = util.serialize(key, as_raw)
result = tc.hdb_vsiz(self.db, c_key, c_key_len)
if result == -1:
raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:hdb.py
示例20: out
def out(self, key, as_raw=False):
"""Remove a Python object of an abstract database object."""
(c_key, c_key_len) = util.serialize(key, as_raw)
result = tc.adb_out(self.db, c_key, c_key_len)
if not result:
self._raise('Error deleting a Python object in an abstract ' \
'database object.');
return result
开发者ID:pombreda,项目名称:pombredanne-py-tcdb,代码行数:8,代码来源:adb.py
注:本文中的util.serialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论