本文整理匯總了Python中numpy.set_string_function方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.set_string_function方法的具體用法?Python numpy.set_string_function怎麽用?Python numpy.set_string_function使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.set_string_function方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_dataset
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def get_dataset(dataset):
"""
>>> np.set_string_function(lambda a: f'array(shape={a.shape}, dtype={a.dtype})')
>>> pprint(get_dataset('cv_dev93')[0]) # doctest: +ELLIPSIS
{'audio_path': ...,
...,
'example_id': '4k0c0301_4k6c030t_0',
...,
'kaldi_transcription': ...,
...,
'audio_data': {'speech_source': array(shape=(2, 103650), dtype=float64),
'rir': array(shape=(2, 6, 8192), dtype=float64),
'speech_image': array(shape=(2, 6, 103650), dtype=float64),
'speech_reverberation_early': array(shape=(2, 6, 103650), dtype=float64),
'speech_reverberation_tail': array(shape=(2, 6, 103650), dtype=float64),
'noise_image': array(shape=(1, 1), dtype=float64),
'observation': array(shape=(6, 103650), dtype=float64)},
'snr': 29.749852569493584}
"""
db = SmsWsj()
ds = db.get_dataset(dataset)
ds = ds.map(AudioReader())
return ds
示例2: get_printoptions
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def get_printoptions():
"""
Return the current print options.
Returns
-------
print_opts : dict
Dictionary of current print options with keys
- precision : int
- threshold : int
- edgeitems : int
- linewidth : int
- suppress : bool
- nanstr : str
- infstr : str
- formatter : dict of callables
- sign : str
For a full description of these options, see `set_printoptions`.
See Also
--------
set_printoptions, set_string_function
"""
return _format_options.copy()
示例3: test_set_string_function
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def test_set_string_function(self):
a = np.array([1])
np.set_string_function(lambda x: "FOO", repr=True)
assert_equal(repr(a), "FOO")
np.set_string_function(None, repr=True)
assert_equal(repr(a), "array([1])")
np.set_string_function(lambda x: "FOO", repr=False)
assert_equal(str(a), "FOO")
np.set_string_function(None, repr=False)
assert_equal(str(a), "[1]")
示例4: low_reverberation_data
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def low_reverberation_data():
"""
>>> import numpy as np
>>> np.set_string_function(lambda a: f'array(shape={a.shape}, dtype={a.dtype})')
>>> from IPython.lib.pretty import pprint
>>> pprint(low_reverberation_data()) # doctest: +ELLIPSIS
{'audio_path': ...,
'gender': ['m', 'm'],
'kaldi_transcription': ["NOR IS MISTER QUILTER'S MANNER LESS INTERESTING THAN HIS MATTER",
'MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL'],
'log_weights': [1.2027951449295022, -1.2027951449295022],
'num_samples': {'observation': 38520, 'speech_source': [38520, 46840]},
'num_speakers': 2,
'offset': [0, 0],
'room_dimensions': [[8.196200148369396],
[6.05928772400428],
[3.1540068920818385]],
'sensor_position': ...,
'snr': 29.749852569493584,
'sound_decay_time': 0,
'source_id': ['4k0c0301', '4k6c030t'],
'source_position': ...,
[1.6594772807620646, 1.6594772807620646]],
'speaker_id': ['1272-128104', '1272-128104'],
'example_id': 'low_reverberation',
'dataset': 'test',
'audio_data': {'noise_image': array(shape=(6, 38520), dtype=float64),
'observation': array(shape=(6, 38520), dtype=float64),
'speech_image': array(shape=(2, 6, 38520), dtype=float64),
'speech_reverberation_early': array(shape=(2, 6, 38520), dtype=float64),
'speech_reverberation_tail': array(shape=(2, 6, 38520), dtype=float64),
'speech_source': array(shape=(2, 38520), dtype=float64)}}
>>> np.set_string_function(None) # needed for pytest. np.set_string_function is not properly reseted.
"""
return _get_data()['low_reverberation']
示例5: reverberation_data
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def reverberation_data():
"""
>>> import numpy as np
>>> np.set_string_function(lambda a: f'array(shape={a.shape}, dtype={a.dtype})')
>>> from IPython.lib.pretty import pprint
>>> pprint(reverberation_data()) # doctest: +ELLIPSIS
{'audio_path': ...,
'gender': ['m', 'm'],
'kaldi_transcription': ["NOR IS MISTER QUILTER'S MANNER LESS INTERESTING THAN HIS MATTER",
'MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL'],
'log_weights': [1.2027951449295022, -1.2027951449295022],
'num_samples': {'observation': 38520, 'speech_source': [38520, 46840]},
'num_speakers': 2,
'offset': [0, 0],
'room_dimensions': ...,
'sensor_position': ...,
'snr': 29.749852569493584,
'sound_decay_time': 0.354,
'source_id': ['4k0c0301', '4k6c030t'],
'source_position': ...,
'speaker_id': ['1272-128104', '1272-128104'],
'example_id': 'reverberation',
'dataset': 'test',
'audio_data': ...
>>> np.set_string_function(None) # needed for pytest. np.set_string_function is not properly reseted.
"""
return _get_data()['reverberation']
示例6: get_dataset
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import set_string_function [as 別名]
def get_dataset(dataset, json_path):
"""
>>> from IPython.lib.pretty import pprint
>>> np.set_string_function(lambda a: f'array(shape={a.shape}, dtype={a.dtype})')
>>> pprint(get_dataset('cv_dev93')[0]) # doctest: +ELLIPSIS
{...
'example_id': '0_4k6c0303_4k4c0319',
...
'snr': 23.287502642941252,
'dataset': 'cv_dev93',
'audio_data': {'observation': array(shape=(6, 93389), dtype=float64),
'speech_source': array(shape=(2, 93389), dtype=float64),
'speech_reverberation_early': array(shape=(2, 6, 93389), dtype=float64),
'speech_reverberation_tail': array(shape=(2, 6, 93389), dtype=float64),
'noise_image': array(shape=(6, 93389), dtype=float64),
'speech_image': array(shape=(2, 6, 93389), dtype=float64),
'Speech_source': array(shape=(2, 733, 257), dtype=complex128),
'Speech_reverberation_early': array(shape=(2, 6, 733, 257), dtype=complex128),
'Speech_reverberation_tail': array(shape=(2, 6, 733, 257), dtype=complex128),
'Speech_image': array(shape=(2, 6, 733, 257), dtype=complex128),
'Noise_image': array(shape=(6, 733, 257), dtype=complex128),
'Observation': array(shape=(6, 733, 257), dtype=complex128)}}
"""
db = SmsWsj(json_path=json_path)
ds = db.get_dataset(dataset)
ds = ds.map(AudioReader())
def calculate_stfts(ex):
ex['audio_data']['Speech_source'] = stft(ex['audio_data']['speech_source'])
ex['audio_data']['Speech_reverberation_early'] = stft(ex['audio_data']['speech_reverberation_early'])
ex['audio_data']['Speech_reverberation_tail'] = stft(ex['audio_data']['speech_reverberation_tail'])
ex['audio_data']['Speech_image'] = stft(ex['audio_data']['speech_image'])
ex['audio_data']['Noise_image'] = stft(ex['audio_data']['noise_image'])
ex['audio_data']['Observation'] = stft(ex['audio_data']['observation'])
return ex
return ds.map(calculate_stfts)