[BUG] List of numpy arrays does not print correctly
See original GitHub issueThe bug is actually rather simple. Whenever you attempt to print a list that consists of NumPy arrays, it cuts off the first element of the list when combined with a string. Below is a minimal code example that shows the bug:
import numpy as np
from rich import print
list_of_arrays = [np.array([1, 0, 0]), np.array([0, 1, 0]), np.array([0, 0, 1])]
print(list_of_arrays)
print(f'Does something weird with f strings: {list_of_arrays}')
output
[array([1, 0, 0]), array([0, 1, 0]), array([0, 0, 1])]
Does something weird with f strings: ), array([0, 1, 0]), array([0, 0, 1])]
Of course, the output should be that the second line also shows the complete list.
I provide a screenshot below to show what it looks like in my terminal.
Platform
Platform: Mac
Terminal: Oh-my-zsh
Python version: 3.7
Rich version: 11.0.0
Click to expand
The other information that was asked after executing the commands: โญโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ A high level console interface. โ โ โ โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ โ โ <console width=197 ColorSystem.EIGHT_BIT> โ โ โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ โ โ โ color_system = '256' โ โ encoding = 'utf-8' โ โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> โ โ height = 12 โ โ is_alt_screen = False โ โ is_dumb_terminal = False โ โ is_interactive = True โ โ is_jupyter = False โ โ is_terminal = True โ โ legacy_windows = False โ โ no_color = False โ โ options = ConsoleOptions( โ โ size=ConsoleDimensions(width=197, height=12), โ โ legacy_windows=False, โ โ min_width=1, โ โ max_width=197, โ โ is_terminal=True, โ โ encoding='utf-8', โ โ max_height=12, โ โ justify=None, โ โ overflow=None, โ โ no_wrap=False, โ โ highlight=None, โ โ markup=None, โ โ height=None โ โ ) โ โ quiet = False โ โ record = False โ โ safe_box = True โ โ size = ConsoleDimensions(width=197, height=12) โ โ soft_wrap = False โ โ stderr = False โ โ style = None โ โ tab_size = 8 โ โ width = 197 โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏplatform=โDarwinโ WindowsConsoleFeatures(vt=False, truecolor=False)
I would be happy to provide any additional feedback if necessary.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How do I print the full NumPy array, without truncation?
Use numpy.set_printoptions : import sys import numpy numpy.set_printoptions(threshold=sys.maxsize).
Read more >BUG: np.array fails on a list of arrays with partially matching ...
asarray have a well defined behaviour when applied to lists of arrays: if the listed arrays have the same dimensions and size, the...
Read more >numpy.set_printoptions โ NumPy v1.24 Manual
Set printing options. These options determine the way floating point numbers, arrays and other NumPy objects are displayed. Parameters: precisionintย ...
Read more >3. Strings, Lists, Arrays, and Dictionaries โ PyMan 0.9.31 ...
Core Python has an array data structure, but it's not nearly as versatile, efficient, or useful as the NumPy array. We will not...
Read more >NumPy arange(): How to Use np.arange() - Real Python
Creating NumPy arrays is important when you're working with other Python ... You got the error because arange() doesn't allow you to explicitly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
New version landing in a few days ๐
Iโm absolutely stupid, for some reason I thought it would already be in there. Iโm very sorry!