lovely-numpy
  1. โœจ Misc
  2. ๐Ÿ‘๏ธ Lo and behold!
  • ๐Ÿ’Ÿ Lovely NumPy
  • ๐Ÿ”Ž Array Representations
    • ๐Ÿงพ View as a summary
    • ๐Ÿ–Œ๏ธ View as RGB images
    • ๐Ÿ“Š View as a histogram
    • ๐Ÿ“บ View channels
  • ๐Ÿ–ผ๏ธ Image utils
    • ๐ŸŽจ color mapping
    • ๐Ÿ”ฒ Pad and frame
    • ๐Ÿ Image grid
  • โœจ Misc
    • ๐Ÿ‘๏ธ Lo and behold!
    • ๐ŸŽญ Matplotlib integration
    • ๐Ÿค” Config

On this page

  • Lo
  • lo
  • Examples
  1. โœจ Misc
  2. ๐Ÿ‘๏ธ Lo and behold!

๐Ÿ‘๏ธ Lo and behold!


source

Lo

 Lo (x:Union[numpy.ndarray,numpy.generic], plain=False, verbose=None,
     depth=0, color:Optional[bool]=None)

Lo and behold! What a lovely numpy.ndarray!

Type Default Details
x Union Your data
plain bool False Show as plain text - values only
verbose NoneType None Verbose - show values too
depth int 0 Expand up to depth
color Optional None Use ANSI colors

source

lo

 lo (x:Union[numpy.ndarray,numpy.generic], plain:bool=False,
     verbose:bool=None, depth:int=0, color:Optional[bool]=None)
Type Default Details
x Union Your data
plain bool False Show as plain text - values only
verbose bool None Verbose - show values too
depth int 0 Expand up to depth
color Optional None Use ANSI colors

Examples

t = np.array([[1,2,3], [4,5,6]])
t
array([[1, 2, 3],
       [4, 5, 6]])
lo(t).v # Verbose
array[2, 3] i64 n=6 xโˆˆ[1, 6] ฮผ=3.500 ฯƒ=1.708 [[1, 2, 3], [4, 5, 6]]
array([[1, 2, 3],
       [4, 5, 6]])
lo(t).p # Plain
array([[1, 2, 3],
       [4, 5, 6]])
lo(t).deeper
array[2, 3] i64 n=6 xโˆˆ[1, 6] ฮผ=3.500 ฯƒ=1.708 [[1, 2, 3], [4, 5, 6]]
  array[3] i64 xโˆˆ[1, 3] ฮผ=2.000 ฯƒ=0.816 [1, 2, 3]
  array[3] i64 xโˆˆ[4, 6] ฮผ=5.000 ฯƒ=0.816 [4, 5, 6]
lo(t[None]).deeper(2) # We need to go deeper
array[1, 2, 3] i64 n=6 xโˆˆ[1, 6] ฮผ=3.500 ฯƒ=1.708 [[[1, 2, 3], [4, 5, 6]]]
  array[2, 3] i64 n=6 xโˆˆ[1, 6] ฮผ=3.500 ฯƒ=1.708 [[1, 2, 3], [4, 5, 6]]
    array[3] i64 xโˆˆ[1, 3] ฮผ=2.000 ฯƒ=0.816 [1, 2, 3]
    array[3] i64 xโˆˆ[4, 6] ฮผ=5.000 ฯƒ=0.816 [4, 5, 6]
in_stats = ( (0.485, 0.456, 0.406),     # mean
             (0.229, 0.224, 0.225) )    # std
image = np.load("mysteryman.npy").transpose(1,2,0)
lo(image)
array[196, 196, 3] f32 n=115248 (0.4Mb) xโˆˆ[-2.118, 2.640] ฮผ=-0.388 ฯƒ=1.073
spicy = image.flatten()[:12].copy()

spicy[0] *= 10000
spicy[1] /= 10000
spicy[2] = float('inf')
spicy[3] = float('-inf')
spicy[4] = float('nan')

spicy = spicy.reshape((2,6))
lo(spicy)
array[2, 6] f32 n=12 xโˆˆ[-3.541e+03, -1.975e-05] ฮผ=-393.848 ฯƒ=1.113e+03 +Inf! -Inf! NaN!
# image = np.zeros((196,196,3))
# image[:75,::2,:] = 1
# image[75::2,:,:] = 1
lo(image).rgb #.fig.savefig("output.png", metadata={"Software": None})

lo(image).rgb(scale=2, denorm=in_stats)

lo(image*0.3+0.5)
array[196, 196, 3] f32 n=115248 (0.4Mb) xโˆˆ[-0.135, 1.292] ฮผ=0.384 ฯƒ=0.322
x = np.random.randn(100000)+3
lo(x).plt(center="mean")