Skip to content

0-d arrays ignore printoptions (Trac #817) #1415

Closed

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/817 on 2008-06-10 by @stefanv, assigned to unknown.

import numpy as np
np.set_printoptions(precision=1)
print np.array([f])
print np.array(f)

yields

[ 0.]
0.039485656484

}}}

Activity

  1. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    Milestone changed to Unscheduled by @mwiebe on 2011-03-23

  2. charris commented on Feb 20, 2014

    @charris
    Member

    Still broken 1.9-devel.

  3. ddasilva commented on Mar 15, 2014

    @ddasilva
    Contributor

    array2string() (numpy/core/arrayprint.py) is the method that generates the string here. It has different cases based on the number of dimensions. If ndims == 0 it handles the case manually, and if ndims > 0 it calls _array2string().

    All of the logic of handling different ways of formatting/precision is in _array2string(). The ndims == 0 implementation ignores the precision setting completely.

  4. ddasilva commented on Mar 15, 2014

    @ddasilva
    Contributor

    This is a little bigger than an easy fix. It seems to me that either _array2string() should to be made capable of handling 0d arrays or the formatting logic should be moved out of _array2string().

  5. eric-wieser commented on Sep 25, 2017

    @eric-wieser
    Member

    @ahaldane: Can this be closed already, or are we still waiting on a PR for this one?

  6. ahaldane commented on Sep 25, 2017

    @ahaldane
    Member

    While this is currently fixed in master we are still changing this behavior in #9332 . How about I add it to the "fixed" commit message there?

  7. added 4 commits that reference this issue on Sep 26, 2017
    53231e6
    0254b75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions