项目作者: pjessesco

项目描述 :
Replacement of `print()` for printing 2d array with readability including Torch and Numpy.
高级语言: Python
项目地址: git://github.com/pjessesco/print2d.git
创建时间: 2021-03-12T07:02:20Z
项目社区:https://github.com/pjessesco/print2d

开源协议:MIT License

下载


print2d : Print 2d array with readability

PyPI version

Replacement of print() for printing 2d array with readability.

  1. print2d(mat1, "*" ,mat2, "=", mult)
  2. [[4. 3. 1. 1. ] * [[1 2 3] = [[26. 24. 39. ]
  3. [6. 2. 4. 8. ] [5 2 6] [64. 84. 98. ]
  4. [1.1 6.6 1.5 0.1]] [2 3 1] [37.6 20.6 45.2]]
  5. [5 7 8]]

Available types

  • Python list
  • NumPy ndarray
  • PyTorch Tensor

Install

  1. pip install print2d

Usage

Import this module

  1. from print2d import *

print2d() function gets parameter separated with comma(,).

Python list

  1. arr1 = [[1,2],[3,4], [5,6]]
  2. arr2 = [[1, 2, 3], [4, 5, 6]]
  3. print2d("arr1", arr1, "arr2", arr2)

  1. arr1 [[1, 2] arr2 [[1, 2, 3]
  2. [3, 4] [4, 5, 6]]
  3. [5, 6]]

NumPy ndarray

  1. np1 = np.array([[1,2],[3,4], [5,6]])
  2. np2 = np.array([[1, 2, 3], [4, 5, 6]])
  3. print2d("np1", np1, "np2", np2)

  1. np1 [[1 2] np2 [[1 2 3]
  2. [3 4] [4 5 6]]
  3. [5 6]]

PyTorch Tensor

  1. tc1 = torch.tensor([[1,2],[3,4], [5,6]])
  2. tc2 = torch.tensor([[1, 2, 3], [4, 5, 6]])
  3. print2d("tc1", tc1, "tc2", tc2)

  1. tc1 tensor([[1, 2], tc2 tensor([[1, 2, 3],
  2. [3, 4], [4, 5, 6]])
  3. [5, 6]])

Combination

  1. arr1 = [[1,2],[3,4], [5,6]]
  2. np2 = np.array([[1, 2, 3], [4, 5, 6]])
  3. print2d("arr1", arr1, "np2", np2)

  1. arr1 [[1, 2] np2 [[1 2 3]
  2. [3, 4] [4 5 6]]
  3. [5, 6]]