set_string_function reset incomplete (Trac #1130) #1728

Closed
thouis opened this Issue Oct 19, 2012 · 3 comments

Projects

None yet

1 participant

@thouis
Collaborator
thouis commented Oct 19, 2012

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.

@thouis
Collaborator
thouis commented Oct 19, 2012

Milestone changed to 1.4.0 by @cournape on 2009-11-25

@thouis
Collaborator
thouis commented Oct 19, 2012

@pv wrote on 2010-07-18

Fixed in r8507

@thouis
Collaborator
thouis commented Oct 19, 2012

@rgommers wrote on 2010-07-19

Test to see if I get Trac notifications now. Sorry for the noise.

@thouis thouis closed this Oct 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment