8000 set_string_function reset incomplete (Trac #1130) · Issue #1728 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script crossorigin="anonymous" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-99b04cc350b5.js" defer="defer">
set_string_function reset incomplete (Trac #1130) #1728
Closed
@thouis

Description

@thouis

Original ticket http://projects.scipy.org/numpy/ticket/1130 on 2009-06-06 by @rgommers, assigned to unknown.

#!rst
There seems to be a bug in set_string_function when resetting the formatting function to the default. After doing that the dtype of the array that is printed is the character string, not the numpy type. Example:

.. code-block:: python

  In [1]: a=arange(10, dtype=uint16)

  In [2]: a
  Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint16)

  In [3]: set_string_function(lambda x: str(x*2))

  In [4]: a
  Out[4]: [ 0  2  4  6  8 10 12 14 16 18]

  In [5]: set_string_function(None)   # reset to default

  In [6]: a
  Out[6]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 'H')

The ability to reset the function by using None as argument was introduced in #949.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0