def __str__(self):
s = 'Column names: ' + ', '.join(self.column_names) + "\n"
s += 'Data: ' + "\n"
s += np.array_str(self.get_all_columns())
return s
python类array_str()的实例源码
def test_array_str_64bit(self, level=rlevel):
# Ticket #501
s = np.array([1, np.nan], dtype=np.float64)
with np.errstate(all='raise'):
np.array_str(s) # Should succeed
def _gmmModel(self,model_path):
'''
load gmmModel
:return:
'''
for state in list(set(self.transcription)):
pkl_file = open(os.path.join(model_path,state+'.pkl'), 'rb')
self.gmmModel[state] = pickle.load(pkl_file)
pkl_file.close()
# with open ('/Users/gong/desktop/original.txt','wb') as f:
# for key in self.gmmModel:
# f.write(np.array_str(self.gmmModel[key].covars_))
def _print(self, tensor_values):
if not tensor_values:
return
for k, v in tensor_values.items():
tf.logging.info("%s: %s", k, np.array_str(v))
def _batch_print(self, tensor_values):
if not tensor_values:
return
batch_size = tensor_values.values()[0].shape[0]
for i in range(min(self._first_k, batch_size)):
for k, v in tensor_values.items():
tf.logging.info("%s: %s", k, np.array_str(v[i]))
def __str__(self):
return 'ANN model\nNodes: %u' % (self.nodes) + \
'\nOpenCL:\n ' + str(self.openCL.devList) + \
'\nwHL:\n' + np.array_str(self.weights.wHL) + \
'\nbHL:\n' + np.array_str(self.weights.bHL) + \
'\nwOL:\n' + np.array_str(self.weights.wOL) + \
'\nbOL:\n' + np.array_str(self.weights.bOL)
def test_array_str(self):
a = testing.shaped_arange((2, 3, 4), cupy)
b = testing.shaped_arange((2, 3, 4), numpy)
self.assertEqual(cupy.array_str(a), numpy.array_str(b))
def pretty_string_samples(self, idx_start=0, idx_end=20, precision=4, header=False):
s = ''
if header:
t = ' '
u = 'ch'
for i in range(self.ch):
t += '-------:'
u += ' %2i :' %(i+1)
t += '\n'
u += '\n'
s += t # -------:-------:-------:
s += u # ch 1 : 2 : 3 :
s += t # -------:-------:-------:
s += np.array_str(self.samples[idx_start:idx_end,:],
max_line_width=260, # we can print 32 channels before linewrap
precision=precision,
suppress_small=True)
if (idx_end-idx_start) < self.nofsamples:
s = s[:-1] # strip the right ']' character
s += '\n ...,\n'
lastlines = np.array_str(self.samples[-3:,:],
max_line_width=260,
precision=precision,
suppress_small=True)
s += ' %s\n' %lastlines[1:] # strip first '['
return s
test_regression.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def test_array_str_64bit(self, level=rlevel):
# Ticket #501
s = np.array([1, np.nan], dtype=np.float64)
with np.errstate(all='raise'):
np.array_str(s) # Should succeed
def convert_list_of_ints_to_string(array_of_ints):
return re.sub('\s+', ',', np.array_str(array_of_ints).strip('[]'))
def convert_list_of_ints_to_string(list_of_ints):
return re.sub('\s+', ',', np.array_str(list_of_ints).strip('[]'))
def convert_array_of_ints_to_string(array_of_ints):
return np.array_str(array_of_ints).strip('[]')
def convert_list_of_ints_to_string(list_of_ints):
return re.sub('\s+', ',', np.array_str(list_of_ints).strip('[]'))
def convert_array_of_ints_to_string(array_of_ints):
return np.array_str(array_of_ints).strip('[]')
def __analyzeTrackTermination(self):
deadTracks = []
for trackIndex, trackNode in enumerate(self.__trackNodes__):
# Check outside radarRange
if trackNode.isOutsideRange(self.position, self.radarRange):
trackNode.status = outofrangeTag
deadTracks.append(trackIndex)
log.info("Terminating track {0:} at {1:} since it is out of radarRange".format(
trackIndex, np.array_str(self.__trackNodes__[trackIndex].x_0[0:2])))
# Check if track is to insecure
elif trackNode.getScore() / (self.N + 1) > self.scoreUpperLimit:
trackNode.status = toolowscoreTag
deadTracks.append(trackIndex)
log.info("Terminating track {0:} at {1:} since its score is above the threshold ({2:.1f}>{3:.1f})".format(
trackIndex, np.array_str(self.__trackNodes__[trackIndex].x_0[0:2]),
trackNode.getScore() / (self.N + 1), self.scoreUpperLimit))
elif trackNode.cumulativeNLLR > self.clnnrUpperLimit:
trackNode.status = toolowscoreTag
deadTracks.append(trackIndex)
log.info(
"Terminating track {0:} at {1:} since its CNNLR is above the threshold ({2:.1f}>{3:.1f})".format(
trackIndex, np.array_str(
self.__trackNodes__[trackIndex].x_0[0:2]),
trackNode.cumulativeNLLR, self.clnnrUpperLimit))
return deadTracks
def __str__(self):
mmsiString = 'MMSI: ' + str(self.mmsi) if self.mmsi is not None else ""
stateString = np.array_str(self.state, precision=1)
covarianceString = 'Covariance diagonal: ' + np.array_str(np.diagonal(self.covariance),
precision=1, suppress_small=True)
return (stateString + " " + covarianceString + " " + mmsiString)
def test_array_str_64bit(self, level=rlevel):
# Ticket #501
s = np.array([1, np.nan], dtype=np.float64)
with np.errstate(all='raise'):
np.array_str(s) # Should succeed
external_sources.py 文件源码
项目:LSTM-and-maxlayer-for-SNV-based-phenotype-prediction
作者: widmi
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def __str__(self):
return np.array_str(self.mat)
def log_completion(self, record):
"""Record a completed evaluation to the log.
:param record: Record of the function evaluation
"""
xstr = np.array_str(record.params[0], max_line_width=np.inf,
precision=5, suppress_small=True)
logger.info("Feasible {:.3e} @ {}".format(record.value, xstr))
def log_completion(self, record, penalty):
"""Record a completed evaluation to the log.
:param record: Record of the function evaluation
:param penalty: Penalty for the given point
"""
xstr = np.array_str(record.params[0], max_line_width=np.inf,
precision=5, suppress_small=True)
feas = "Feasible"
if penalty > 0.0:
feas = "Infeasible"
#logger.info("{} {:.3e} @ {}".format(feas, record.value + penalty, xstr))
logger.info("{} {:.3e} @ {}".format(feas, record.value, xstr))