如何在不包装的情况下打印完整的NumPy数组(在Jupyter Notebook中) [英] How to print the full NumPy array without wrapping (in Jupyter Notebook)

查看:119
本文介绍了如何在不包装的情况下打印完整的NumPy数组(在Jupyter Notebook中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与以下问题不同:

解决方案

只是要发布NaN的评论作为答案:

使用 np.set_printoptions(linewidth = n),其中 n 与每行的字符数(不是数组元素)有关.因此,在您的情况下, n = 100 应该可以解决问题.

This question is different from this one: How to print the full NumPy array, without truncation?

In that question, the user wanted to know how to print the full array without truncation. I can print the array without truncation just fine. My problem is that only a small portion of the screen width is used. When trying to inspect large adjacency matrices, it's impossible to inspect them when the rows unnecessarily wrap.

I'm asking this question here because it always takes me hours to find the solution, and I want to disambiguate it from that answer post above.

For example:

import networkx as nx
import numpy as np
np.set_printoptions(threshold=np.inf)
graph = nx.gnm_random_graph(20, 20, 1)
nx.to_numpy_matrix(graph)

This output displays as:

解决方案

Just gonna post NaN's comment as the answer:

Use np.set_printoptions(linewidth=n) where n has to do with the number of characters (not array elements) per line. So in your case n=100 should do the trick.

这篇关于如何在不包装的情况下打印完整的NumPy数组(在Jupyter Notebook中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆