question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

[BUG] List of numpy arrays does not print correctly

See original GitHub issue

The 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. image

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:closed
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
willmcgugancommented, Mar 10, 2022

New version landing in a few days ๐Ÿ˜ƒ

0reactions
wilropcommented, Mar 10, 2022

Iโ€™m absolutely stupid, for some reason I thought it would already be in there. Iโ€™m very sorry!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found