Python numpy.set_string_function() Examples

The following are 30 code examples for showing how to use numpy.set_string_function(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module numpy , or try the search function .

Example 1
Project: sms_wsj   Author: fgnt   File: metric_target_comparison.py    License: 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
Project: recruit   Author: Frank-qlu   File: arrayprint.py    License: 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 3
Project: recruit   Author: Frank-qlu   File: test_numeric.py    License: 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 4
Project: lambda-packs   Author: ryfeus   File: arrayprint.py    License: 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 5
Project: auto-alt-text-lambda-api   Author: abhisuri97   File: test_numeric.py    License: 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 6
Project: vnpy_crypto   Author: birforce   File: arrayprint.py    License: 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 7
Project: vnpy_crypto   Author: birforce   File: test_numeric.py    License: 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 8
Project: Computable   Author: ktraunmueller   File: test_numeric.py    License: 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 9
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: arrayprint.py    License: 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 10
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: test_numeric.py    License: 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 11
Project: GraphicDesignPatternByPython   Author: Relph1119   File: arrayprint.py    License: 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 12
Project: GraphicDesignPatternByPython   Author: Relph1119   File: test_numeric.py    License: 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 13
Project: pb_bss   Author: fgnt   File: dummy_data.py    License: 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 14
Project: pb_bss   Author: fgnt   File: dummy_data.py    License: 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 15
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 16
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 17
Project: pySINDy   Author: luckystarufo   File: arrayprint.py    License: 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 18
Project: pySINDy   Author: luckystarufo   File: test_numeric.py    License: 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
Project: mxnet-lambda   Author: awslabs   File: test_numeric.py    License: 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 20
Project: ImageFusion   Author: pfchai   File: test_numeric.py    License: 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 21
Project: sms_wsj   Author: fgnt   File: reference_systems.py    License: 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 22
Project: elasticintel   Author: securityclippy   File: test_numeric.py    License: 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 23
Project: coffeegrindsize   Author: jgagneastro   File: arrayprint.py    License: 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
Project: coffeegrindsize   Author: jgagneastro   File: test_numeric.py    License: 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 25
Project: Carnets   Author: holzschu   File: arrayprint.py    License: 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 26
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda   Author: PacktPublishing   File: arrayprint.py    License: 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 27
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda   Author: PacktPublishing   File: test_numeric.py    License: 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
Project: twitter-stock-recommendation   Author: alvarobartt   File: arrayprint.py    License: 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
Project: twitter-stock-recommendation   Author: alvarobartt   File: test_numeric.py    License: 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
Project: keras-lambda   Author: sunilmallya   File: test_numeric.py    License: 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]")