Tools I need in every python project
Project description
What is this?
The tools I find myself copying and pasting between every python project.
How do I use this?
pip install blissful_basics
from blissful_basics import print, flatten, to_pure, stringify, stats, product, countdown, large_pickle_save, large_pickle_load, FS, Object
#
# print helpers
#
if 1:
# settings
print.indent.string = " "
# recursively indents function calls
@print.indent.function
def my_func(counter=5):
if counter <= 0: return
print(f"function call {counter} start")
my_func(counter-1)
print(f"function call {counter} done")
my_func()
# function call 5 start
# function call 4 start
# function call 3 start
# function call 2 start
# function call 1 start
# function call 1 done
# function call 2 done
# function call 3 done
# function call 4 done
# function call 5 done
# simple indent
with print.indent:
print("howdy1")
with print.indent:
print("howdy2")
print("howdy3")
# howdy1
# howdy2
# howdy3
# also indents stuff from the function
with print.indent.block("stuff"):
print("hi")
my_func()
# stuff
# hi
# function call 5 start
# function call 4 start
# function call 3 start
# function call 2 start
# function call 1 start
# function call 1 done
# function call 2 done
# function call 3 done
# function call 4 done
# function call 5 done
#
# to_pure()
#
if 1:
import numpy
import torch
to_pure(numpy.array([1,2,3,4,5])) # [1,2,3,4,5]
to_pure(torch.tensor([1,2,3,4,5])) # [1,2,3,4,5] # even if its on a GPU device
#
# stats
#
if 1:
stats([1,2,3,4,5])
# Object(
# max = 5,
# min = 1,
# range = 4,
# count = 5,
# sum = 15,
# average = 3.0,
# stdev = 1.5811388300841898,
# median = 3,
# q1 = 1.5,
# q3 = 4.5,
# normalized = (0.0, 0.25, 0.5, 0.75, 1.0),
# )
#
# plain object
#
if 1:
a = Object(thing=10)
a.thing # 10
a.thing = 99
a.thing # 99
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blissful_basics-0.2.2.tar.gz
(11.8 kB
view details)
Built Distribution
File details
Details for the file blissful_basics-0.2.2.tar.gz
.
File metadata
- Download URL: blissful_basics-0.2.2.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e49308ce12ad3d5932afa92cdad635f3d5252b5ebe64e1244a51671befe4c129 |
|
MD5 | cbf01ef3fe5e56cd415f077355b579e1 |
|
BLAKE2b-256 | e65d96648e7991d3037f5ecafdfb43dfa4571bf49a8f80d8d0503049832e106c |
File details
Details for the file blissful_basics-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: blissful_basics-0.2.2-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f782d2d7c4cf54d6d4c2d142fea5bdf94aba40844730a348781cf1ae9f5f5201 |
|
MD5 | 4b96da9f36d1caed5d509e0e158949c5 |
|
BLAKE2b-256 | 0e9fcd042edf44470fd9b30060136f4c07bc742f54ab194b264c3187751b51e0 |