Skip to main content

efficiency

Pypi Downloads Downloads MIT_License

This is a package of useful one-line logging functions made by Zhijing.

Installation

Requirement: Python 3

pip install --upgrade  git+https://github.com/zhijing-jin/efficiency.git

Logging Shortcuts

Obtain time:

>>> from efficiency.log import show_time, fwrite
>>> time_stamp = show_time()
	time: 11241933-41
>>> time_stamp
'11241933' # means: Nov 24th, 19:33

Writing out to files by one line:

>>> text = "This is handy!"
>>> fwrite(text, "temp.txt")

Printing out variables (name + value) easily:

>>> num1 = 7
>>> num2 = 2
>>> num3 = 9
>>> show_var(["num1", "num2", "num3"])
num1 : 7
num2 : 2
num3 : 9

ML-Related

>>> from efficiency.log import gpu_mem
>>> gpu_mem(gpu_id=0)
4101 # Currently, GPU Memory of GPU #0 is 4101 MiB
>>> from efficiency.function import set_seed
>>> set_seed(0)
[Info] seed set to: 0 # set the seed for random, numpy and pytorch

Useful Functions

>>> from efficiency.function import shell
>>> stdout, stderr = shell("cat temp.txt")
>>> stdout
b'This is handy!'

Miscellaneous Functions

Formatting README.md Better

This is the way to automatically generate table of contents for an .md file using markdown_toc:

# Step 1. download the file to your local execution path `/usr/local/bin/`
curl \
  https://raw.githubusercontent.com/alexharv074/markdown_toc/master/mdtoc.rb -o \
  /usr/local/bin/mdtoc.rb

# Step 2. generate the ToC in the "copy" mode
mdtoc.rb README.md

# Alternatively, you can automatically add the content to your copyboard and paste it to your .md
mdtoc.rb README.md | pbcopy

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

efficiency-2.0.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

efficiency-2.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file efficiency-2.0.tar.gz.

File metadata

  • Download URL: efficiency-2.0.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for efficiency-2.0.tar.gz
Algorithm Hash digest
SHA256 b786908ef529cb8c6d28fc4e0f3c10e15b35f8063a8d26b6b14c860031e3784a
MD5 2fa29589a23c51847c28828033384702
BLAKE2b-256 c9516966acac64587376d8de4654f69144788268f10a5e4f21da9d7d78d8904a

See more details on using hashes here.

File details

Details for the file efficiency-2.0-py3-none-any.whl.

File metadata

  • Download URL: efficiency-2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for efficiency-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 111ac18e29cb656476bcac420306d68cd5595dae350959a6d7c8773834e35c0e
MD5 da94f285f28bbe65103cb42c787a38ae
BLAKE2b-256 4c36274e2337fea7f4290cf5e20171f530ff205f5e0f369702ace3fcba5fc67d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0 This release

2 files

1.31

2 files

1.4

2 files

1.3

2 files

1.2.1

2 files

1.2

2 files

1.1

1 file

1.0

2 files

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1.1

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page