本文整理汇总了Python中numpy.lib.format.read_array函数的典型用法代码示例。如果您正苦于以下问题:Python read_array函数的具体用法?Python read_array怎么用?Python read_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_array函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: roundtrip_truncated
def roundtrip_truncated(arr):
f = BytesIO()
format.write_array(f, arr)
#BytesIO is one byte short
f2 = BytesIO(f.getvalue()[0:-1])
arr2 = format.read_array(f2)
return arr2
开发者ID:dyao-vu,项目名称:meta-core,代码行数:7,代码来源:test_format.py
示例2: _unpickle_array
def _unpickle_array(bytes):
arr = read_array(BytesIO(bytes))
# All datetimes should be stored as M8[ns]. When unpickling with
# numpy1.6, it will read these as M8[us]. So this ensures all
# datetime64 types are read as MS[ns]
if is_datetime64_dtype(arr):
arr = arr.view(_NS_DTYPE)
return arr
开发者ID:bkandel,项目名称:pandas,代码行数:10,代码来源:pickle.py
示例3: test_version_2_0
def test_version_2_0():
f = BytesIO()
# requires more than 2 byte for header
dt = [(("%d" % i) * 100, float) for i in range(500)]
d = np.ones(1000, dtype=dt)
format.write_array(f, d, version=(2, 0))
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', '', UserWarning)
format.write_array(f, d)
assert_(w[0].category is UserWarning)
f.seek(0)
n = format.read_array(f)
assert_array_equal(d, n)
# 1.0 requested but data cannot be saved this way
assert_raises(ValueError, format.write_array, f, d, (1, 0))
开发者ID:dyao-vu,项目名称:meta-core,代码行数:18,代码来源:test_format.py
示例4: roundtrip_randsize
def roundtrip_randsize(arr):
f = BytesIO()
format.write_array(f, arr)
f2 = BytesIOSRandomSize(f.getvalue())
arr2 = format.read_array(f2)
return arr2
开发者ID:dyao-vu,项目名称:meta-core,代码行数:6,代码来源:test_format.py
示例5: roundtrip
def roundtrip(arr):
f = BytesIO()
format.write_array(f, arr)
f2 = BytesIO(f.getvalue())
arr2 = format.read_array(f2)
return arr2
开发者ID:dyao-vu,项目名称:meta-core,代码行数:6,代码来源:test_format.py
示例6: _unpickle_array
def _unpickle_array(bytes):
arr = read_array(BytesIO(bytes))
return arr
开发者ID:while,项目名称:pandas,代码行数:3,代码来源:common.py
示例7: _unpickle_array
def _unpickle_array(bytes):
arr = read_array(StringIO(bytes))
return arr
开发者ID:timClicks,项目名称:pandas,代码行数:3,代码来源:common.py
示例8: roundtrip
def roundtrip(arr):
f = BytesIO()
format.write_array(f, arr)
f2 = BytesIO(f.getvalue())
arr2 = format.read_array(f2, allow_pickle=True)
return arr2
开发者ID:anntzer,项目名称:numpy,代码行数:6,代码来源:test_format.py
示例9: ls
# Load the info file and get the task and metric
info_file = ls(os.path.join(input_dir, basename + '*_public.info'))[0]
info = get_info(info_file)
score_name = info['task'][0:-15] + info['metric'][0:-7].upper()
predict_name = basename
try:
# Get the last prediction from the res subdirectory (must end with
# '.predict')
predict_file = ls(os.path.join(
prediction_dir, basename + '_' + set_name + '*.predict'))[-1]
if (predict_file == []):
raise IOError('Missing prediction file {}'.format(basename))
predict_name = predict_file[-predict_file[::-1].index(filesep):-
predict_file[::-1].index('.') - 1]
# Read the solution and prediction values into numpy arrays
solution = read_array(solution_file)
prediction = read_array(predict_file)
if (solution.shape != prediction.shape):
raise ValueError(
'Bad prediction shape {}'.format(prediction.shape))
try:
# Compute the score prescribed by the info file (for regression
# scores, no normalization)
if info['metric'] == 'r2_metric' or info[
'metric'] == 'a_metric':
# Remove NaN and Inf for regression
solution = sanitize_array(solution)
prediction = sanitize_array(prediction)
score = eval(info['metric'] + '(solution, prediction, "' +
info['task'] + '")')
开发者ID:WarmongeR1,项目名称:auto-sklearn,代码行数:31,代码来源:score.py
示例10: toArray
def toArray(s):
f=StringIO(s)
arr=format.read_array(f)
return arr
开发者ID:LuisJavierMontielArenas,项目名称:Redes2016,代码行数:4,代码来源:Servidor.py
示例11: from_string
def from_string(s):
f = StringIO(s)
arr = format.read_array(f)
return arr
开发者ID:patykov,项目名称:SD_2016.1,代码行数:4,代码来源:server.py
注:本文中的numpy.lib.format.read_array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论