Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Console doesn't respect numpy.set_printoptions linewidth #1044

Open
@andrewwillowen

Description

@andrewwillowen

Description

When using bpython console, output ofprint(sum_numpy_array) is truncated to a line width of ~70 characters, regardless of the value set bynumpy.set_printoptions(linewidth=<n_chars>). (Probably truncating to 75 characters, per thedefault value)

Reproduction

importnumpyasnpmy_array=np.random.rand(10,10)print(my_array)# Default widthnp.set_printoptions(linewidth=500)# Significantly increase widthprint(my_array)# See if width has changed

Output usingbpython console

Launching the console with

bpython

and running the above commands, the final output stays the same width, e.g.,

[[0.168790420.36869320.115833330.713216880.136703770.253833210.927885380.850561650.958715660.45657286] [0.494143170.886042180.499224650.559926260.420892230.138976270.679806520.889789220.432462910.90526356] [0.338605670.523568980.751024550.333015670.70988710.218421580.469926890.761289790.884573630.78181751] [0.811311050.786205070.423239580.674225690.551181140.704079570.090165170.742875720.642491380.32268192] [0.736988420.693070920.535398590.284990580.218220060.042068970.494339160.093542070.431039850.93385655] [0.570972540.145125170.25439670.093820020.457940770.350542570.104429830.918453820.555085970.43811922] [0.115493970.211012770.331202930.028613190.682747480.655241050.855128080.242918060.507406520.55194984] [0.757931930.379926670.92719670.407004230.871176360.825445390.64756130.3757110.106608020.80992348] [0.107314810.634158280.296112220.60994510.554598190.265873250.026779110.561043410.112355090.21292126] [0.01059190.773934850.946021750.937238150.263953240.600832770.96123960.010706310.284426290.54188245]]

Output usingpython3 console

Launching the console with

python3

and running the above commands, the final output changes truncation, as expected, e.g.,

[[0.467531650.016869970.704372710.248794560.025567590.836509280.432868040.94518870.461817520.61630296] [0.145662250.305659140.771765350.957037630.908942620.276141480.816597660.348127690.561742440.11549844] [0.323568310.259461310.04121690.753708060.334681140.203930670.550255870.445845740.582177670.0194622 ] [0.044577360.441814640.576381180.850244180.393838850.75149730.823262320.788003790.328512160.73534777] [0.830121660.026664770.557075970.570918020.650531710.383452460.931661860.358860660.983156830.29832238] [0.04595510.871115090.968317390.573731460.005152420.646197490.298373640.969732410.875792460.8223942 ] [0.503204410.802145510.272651310.438928730.285843710.175288330.109204150.189583780.522956760.24579679] [0.130213510.801215930.606865160.375697680.696664590.126262040.015538350.807464480.480181880.58879389] [0.020429330.109914870.504381640.415715440.376534850.082311280.366782030.296619420.87940240.82026911] [0.729708590.893900880.01752120.969478420.495594250.379742550.328311780.864341930.636062160.46084129]]

Details

Stumbled across this issue using the following environment (installed byuv via ahatch environment), running on Ubuntu 22.04.3 LTS via Windows Subsystem for Linux.

$ python3 -m pip freezeattrs==25.3.0black==25.1.0blessed==1.21.0bpython==0.25certifi==2025.8.3cfgv==3.4.0charset-normalizer==3.4.3click==8.2.1coverage==7.10.6curtsies==0.4.3cwcwidth==0.1.10distlib==0.4.0filelock==3.19.1greenlet==3.2.4hypothesis==6.138.15identify==2.6.14idna==3.10iniconfig==2.1.0mypy_extensions==1.1.0nodeenv==1.9.1numpy==2.3.3packaging==25.0pathspec==0.12.1platformdirs==4.4.0pluggy==1.6.0pre_commit==4.3.0Pygments==2.19.2pytest==8.4.2pytest-cov==7.0.0pyxdg==0.28PyYAML==6.0.2requests==2.32.5scipy==1.16.2sortedcontainers==2.4.0urllib3==2.5.0virtualenv==20.34.0wcwidth==0.2.13

Additional context

This seems specific to the numpy set_printoptions function.
If I print a long string in the bpython console, it does not truncate at ~70 characters like the numpy array:

>>>print('x'*100)xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp