Python numpy.set_string_function() Examples

The following are 30 code examples of numpy.set_string_function(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: metric_target_comparison.py    From sms_wsj with MIT License 6 votes vote down vote up
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 
Example #2
Source File: dummy_data.py    From pb_bss with MIT License 5 votes vote down vote up
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'] 
Example #3
Source File: test_numeric.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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]") 
Example #4
Source File: arrayprint.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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() 
Example #5
Source File: arrayprint.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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() 
Example #6
Source File: test_numeric.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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]") 
Example #7
Source File: reference_systems.py    From sms_wsj with MIT License 5 votes vote down vote up
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) 
Example #8
Source File: arrayprint.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
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() 
Example #9
Source File: test_numeric.py    From ImageFusion with MIT License 5 votes vote down vote up
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]") 
Example #10
Source File: test_numeric.py    From mxnet-lambda with Apache License 2.0 5 votes vote down vote up
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]") 
Example #11
Source File: test_numeric.py    From pySINDy with MIT License 5 votes vote down vote up
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]") 
Example #12
Source File: arrayprint.py    From recruit with Apache License 2.0 5 votes vote down vote up
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() 
Example #13
Source File: arrayprint.py    From pySINDy with MIT License 5 votes vote down vote up
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() 
Example #14
Source File: test_numeric.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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]") 
Example #15
Source File: test_numeric.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
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]") 
Example #16
Source File: arrayprint.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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() 
Example #17
Source File: dummy_data.py    From pb_bss with MIT License 5 votes vote down vote up
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'] 
Example #18
Source File: test_numeric.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
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]") 
Example #19
Source File: arrayprint.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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() 
Example #20
Source File: arrayprint.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
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() 
Example #21
Source File: test_numeric.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
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]") 
Example #22
Source File: test_numeric.py    From recruit with Apache License 2.0 5 votes vote down vote up
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]") 
Example #23
Source File: arrayprint.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
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() 
Example #24
Source File: arrayprint.py    From lambda-packs with MIT License 5 votes vote down vote up
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() 
Example #25
Source File: test_numeric.py    From Computable with MIT License 5 votes vote down vote up
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]") 
Example #26
Source File: test_numeric.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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]") 
Example #27
Source File: test_numeric.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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]") 
Example #28
Source File: arrayprint.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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() 
Example #29
Source File: test_numeric.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
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]") 
Example #30
Source File: test_numeric.py    From keras-lambda with MIT License 5 votes vote down vote up
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]")