Title: Console doesn't respect numpy.set_printoptions linewidth · Issue #1044 · bpython/bpython · GitHub
Open Graph Title: Console doesn't respect numpy.set_printoptions linewidth · Issue #1044 · bpython/bpython
X Title: Console doesn't respect numpy.set_printoptions linewidth · Issue #1044 · bpython/bpython
Description: Description When using bpython console, output of print(sum_numpy_array) is truncated to a line width of ~70 characters, regardless of the value set by numpy.set_printoptions(linewidth=
Open Graph Description: Description When using bpython console, output of print(sum_numpy_array) is truncated to a line width of ~70 characters, regardless of the value set by numpy.set_printoptions(linewidth=
X Description: Description When using bpython console, output of print(sum_numpy_array) is truncated to a line width of ~70 characters, regardless of the value set by numpy.set_printoptions(linewidth=<n_chars&...
Opengraph URL: https://github.com/bpython/bpython/issues/1044
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Console doesn't respect numpy.set_printoptions linewidth","articleBody":"## Description\n\nWhen using bpython console, output of `print(sum_numpy_array)` is truncated to a line width of ~70 characters, regardless of the value set by `numpy.set_printoptions(linewidth=\u003cn_chars\u003e)`. (Probably truncating to 75 characters, per the [default value](https://numpy.org/doc/stable/reference/generated/numpy.set_printoptions.html#:~:text=linewidthint%2C%20optional,breaks%20(default%2075).))\n\n## Reproduction\n\n```python\nimport numpy as np\nmy_array = np.random.rand(10,10)\nprint(my_array) # Default width\nnp.set_printoptions(linewidth=500) # Significantly increase width\nprint(my_array) # See if width has changed\n```\n\n### Output using `bpython` console\n\nLaunching the console with\n\n```bash\nbpython\n```\n\nand running the above commands, the final output stays the same width, e.g., \n\n```python\n[[0.16879042 0.3686932 0.11583333 0.71321688 0.13670377 0.25383321\n 0.92788538 0.85056165 0.95871566 0.45657286]\n [0.49414317 0.88604218 0.49922465 0.55992626 0.42089223 0.13897627\n 0.67980652 0.88978922 0.43246291 0.90526356]\n [0.33860567 0.52356898 0.75102455 0.33301567 0.7098871 0.21842158\n 0.46992689 0.76128979 0.88457363 0.78181751]\n [0.81131105 0.78620507 0.42323958 0.67422569 0.55118114 0.70407957\n 0.09016517 0.74287572 0.64249138 0.32268192]\n [0.73698842 0.69307092 0.53539859 0.28499058 0.21822006 0.04206897\n 0.49433916 0.09354207 0.43103985 0.93385655]\n [0.57097254 0.14512517 0.2543967 0.09382002 0.45794077 0.35054257\n 0.10442983 0.91845382 0.55508597 0.43811922]\n [0.11549397 0.21101277 0.33120293 0.02861319 0.68274748 0.65524105\n 0.85512808 0.24291806 0.50740652 0.55194984]\n [0.75793193 0.37992667 0.9271967 0.40700423 0.87117636 0.82544539\n 0.6475613 0.375711 0.10660802 0.80992348]\n [0.10731481 0.63415828 0.29611222 0.6099451 0.55459819 0.26587325\n 0.02677911 0.56104341 0.11235509 0.21292126]\n [0.0105919 0.77393485 0.94602175 0.93723815 0.26395324 0.60083277\n 0.9612396 0.01070631 0.28442629 0.54188245]]\n```\n\n### Output using `python3` console\n\nLaunching the console with\n\n```bash\npython3\n```\n\nand running the above commands, the final output changes truncation, as expected, e.g., \n\n```python\n[[0.46753165 0.01686997 0.70437271 0.24879456 0.02556759 0.83650928 0.43286804 0.9451887 0.46181752 0.61630296]\n [0.14566225 0.30565914 0.77176535 0.95703763 0.90894262 0.27614148 0.81659766 0.34812769 0.56174244 0.11549844]\n [0.32356831 0.25946131 0.0412169 0.75370806 0.33468114 0.20393067 0.55025587 0.44584574 0.58217767 0.0194622 ]\n [0.04457736 0.44181464 0.57638118 0.85024418 0.39383885 0.7514973 0.82326232 0.78800379 0.32851216 0.73534777]\n [0.83012166 0.02666477 0.55707597 0.57091802 0.65053171 0.38345246 0.93166186 0.35886066 0.98315683 0.29832238]\n [0.0459551 0.87111509 0.96831739 0.57373146 0.00515242 0.64619749 0.29837364 0.96973241 0.87579246 0.8223942 ]\n [0.50320441 0.80214551 0.27265131 0.43892873 0.28584371 0.17528833 0.10920415 0.18958378 0.52295676 0.24579679]\n [0.13021351 0.80121593 0.60686516 0.37569768 0.69666459 0.12626204 0.01553835 0.80746448 0.48018188 0.58879389]\n [0.02042933 0.10991487 0.50438164 0.41571544 0.37653485 0.08231128 0.36678203 0.29661942 0.8794024 0.82026911]\n [0.72970859 0.89390088 0.0175212 0.96947842 0.49559425 0.37974255 0.32831178 0.86434193 0.63606216 0.46084129]]\n```\n\n## Details\n\nStumbled across this issue using the following environment (installed by `uv` via a `hatch` environment), running on Ubuntu 22.04.3 LTS via Windows Subsystem for Linux.\n\n```term\n$ python3 -m pip freeze\nattrs==25.3.0\nblack==25.1.0\nblessed==1.21.0\nbpython==0.25\ncertifi==2025.8.3\ncfgv==3.4.0\ncharset-normalizer==3.4.3\nclick==8.2.1\ncoverage==7.10.6\ncurtsies==0.4.3\ncwcwidth==0.1.10\ndistlib==0.4.0\nfilelock==3.19.1\ngreenlet==3.2.4\nhypothesis==6.138.15\nidentify==2.6.14\nidna==3.10\niniconfig==2.1.0\nmypy_extensions==1.1.0\nnodeenv==1.9.1\nnumpy==2.3.3\npackaging==25.0\npathspec==0.12.1\nplatformdirs==4.4.0\npluggy==1.6.0\npre_commit==4.3.0\nPygments==2.19.2\npytest==8.4.2\npytest-cov==7.0.0\npyxdg==0.28\nPyYAML==6.0.2\nrequests==2.32.5\nscipy==1.16.2\nsortedcontainers==2.4.0\nurllib3==2.5.0\nvirtualenv==20.34.0\nwcwidth==0.2.13\n```\n\n## Additional context\n\nThis seems specific to the numpy set_printoptions function. \nIf I print a long string in the bpython console, it does not truncate at ~70 characters like the numpy array:\n\n```python\n\u003e\u003e\u003e print('x'*100)\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\n","author":{"url":"https://github.com/andrewwillowen","@type":"Person","name":"andrewwillowen"},"datePublished":"2025-09-17T02:37:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1044/bpython/issues/1044"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1d59e482-cd61-7ea3-6569-9be2b57977d7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D2DE:1BBF62:A0E980:E5D29C:69676BCA |
| html-safe-nonce | 5ab045d9aa37450c3e250ce568a1c10c5a4261b5924683014668e338e4284e63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMkRFOjFCQkY2MjpBMEU5ODA6RTVEMjlDOjY5Njc2QkNBIiwidmlzaXRvcl9pZCI6IjI1ODY3NjI3NjQzODU0Nzk2MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ac66139eb38e5a000d8bc4405cffc067426c3d9b7c8797478bb6fe171f3c2e58 |
| hovercard-subject-tag | issue:3424374925 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bpython/bpython/1044/issue_layout |
| twitter:image | https://opengraph.githubassets.com/035d7162ce73ade296d4639fc178bbc481417361e7f6c4bbccb6c94c788e2a92/bpython/bpython/issues/1044 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/035d7162ce73ade296d4639fc178bbc481417361e7f6c4bbccb6c94c788e2a92/bpython/bpython/issues/1044 |
| og:image:alt | Description When using bpython console, output of print(sum_numpy_array) is truncated to a line width of ~70 characters, regardless of the value set by numpy.set_printoptions(linewidth= |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andrewwillowen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6a4ac66aaa8be0077b72a69fd56fb51cd11215a1e31f0365079e012987234a |
| turbo-cache-control | no-preview |
| go-import | github.com/bpython/bpython git https://github.com/bpython/bpython.git |
| octolytics-dimension-user_id | 8071396 |
| octolytics-dimension-user_login | bpython |
| octolytics-dimension-repository_id | 21508865 |
| octolytics-dimension-repository_nwo | bpython/bpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21508865 |
| octolytics-dimension-repository_network_root_nwo | bpython/bpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 045909cd564d790cacd96dcb8722039dff679d63 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width