Skip to content

kingspp/rainbow-print

Repository files navigation

version badge build coverage badge test badge docs badge commits badge footprint badge Say Thanks!

Rainbow Print

Inspired by Rainbow CSV - Rainbow Print adds colors to the standard outputs to ease the process of monitoring respective data / metrics

Main features

  • Highlights data points in different colors to ease monitoring capabilities
  • By default provides 7 colors (light and dark each) for N Variables(rolling). Supports N colors
  • Support for Dark and Light backgrounds
  • Supports string print based on separator / dictionary's key-value based print
  • Supports custom colors based on sty.fg package
  • Supports use of python logging frameword for advance usecases

Demo

How rainbow print helps

Default print a dictionary of metrics for 10 steps

Dict Print

Default print a string of metrics for 10 steps

Str Print

Rainbow Print - Dark Mode

Rainbow Print Dark

Rainbow Print - Light Mode

Rainbow Print Light

Requirements

  1. python >3
  2. sty

Installation

pip install rainbow-print

Usage

# Print
from rainbow_print import printr
data = {"Episode": 10, "Episode Len":5, "Cost": 0.95, "Reward":135, "Mode":"Explore"}
printr(data)

printr dict

data = f"Episode:{10}, Episode Len:{5}, Cost:{0.95}, Reward:{135}, Mode:{'Explore'}"
printr(data, sep=',')

printr str

# Logging
from rainbow_print import rlogging
logger = rlogging.getLogger(__name__)
data = {"Episode": 10, "Episode Len":5, "Cost": 0.95, "Reward":135, "Mode":"Explore"}
logger.info(data)

logger dict

data = f"Episode:{10}, Episode Len:{5}, Cost:{0.95}, Reward:{135}, Mode:{'Explore'}"
logger.debug(data, sep=',')

logger str

# Get information regarding current configuration
printr.info()
>>Theme: dark
>>Colors: ['\x1b[38;2;5;152;154m', '\x1b[38;2;116;162;103m', '\x1b[38;2;179;128;168m', '\x1b[38;2;255;127;0m', '\x1b[38;2;112;154;180m', '\x1b[38;2;255;255;0m', '\x1b[38;2;255;0;0m']

Configuration

# By default printr works in dark mode
from rainbow_print import printr

# Switch to light palette
printr.set_light_palette()

# Switch to dark palette
printr.set_dark_palette()

# Set colors for dark palette
colors = [sty.fg(0,0,0), sty.fg(255,255,255)]
printr.update_dark_palette(colors)

# Set colors for light palette
colors = [sty.fg(0,0,0), sty.fg(255,255,255)]
printr.update_light_palette(colors)

About

Rainbow print inspired by rainbow csv

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages