Utility functions for image handling
Project description
Credit to https://www.kaggle.com/code/stassl/displaying-inline-images-in-pandas-dataframe.
Usage example:
from datasets import load_dataset
# Load Fashion MNIST dataset
rows = load_dataset("zalando-datasets/fashion_mnist", split="test")
rows.set_format(type="pandas") # rows is a datasets.Dataset object from Hugging Face
df = rows[:]
from draxutils import show_pd
show_pd(df)
# if there is a column with multiple images, you can specify the column name
# show_pd(df, imglist_key='mycol')
# Extended Timer Usage Example
from simple_timer import Timer, timer, time_this, timed
import time
# Example 1: Using start() and end() methods
print("Example 1: start() and end() methods")
timer.start()
time.sleep(1) # Simulate some work
elapsed = timer.end()
print(f"Elapsed time: {elapsed:.6f} seconds")
print(timer) # Output the total time
# Example 2: Using lap() method
print("\nExample 2: lap() method")
timer.start()
for i in range(3):
time.sleep(0.5) # Simulate some work
lap_time = timer.lap(f"Lap {i+1}")
print(f"Lap {i+1} time: {lap_time:.6f} seconds")
total_time = timer.end()
print(f"Total time: {total_time:.6f} seconds")
# Print all laps
for lap_name, _, lap_time in timer.laps:
print(f"{lap_name}: {lap_time:.6f} seconds")
# Example 3: Using as a context manager
print("\nExample 3: Context Manager")
with Timer() as t:
time.sleep(0.75) # Simulate some work
t.lap("Midpoint")
time.sleep(0.75) # More work
print(t)
print(f"Lap time: {t.laps[0][2]:.6f} seconds")
# Example 4: Using as a decorator
print("\nExample 4: Decorator")
@timed
def some_function():
time.sleep(1) # Simulate some work
some_function()
print(f"Function execution time: {some_function.elapsed:.6f} seconds")
# Example 5: Multiple timers
print("\nExample 5: Multiple Timers")
timer1 = Timer()
timer2 = Timer()
timer1.start()
time.sleep(0.5)
timer2.start()
time.sleep(0.5)
print(f"Timer 1: {timer1.elapsed:.6f} seconds")
print(f"Timer 2: {timer2.elapsed:.6f} seconds")
timer2.end()
timer1.end()
print(f"Final Timer 1: {timer1}")
print(f"Final Timer 2: {timer2}")
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
draxutils-0.1.8.tar.gz
(3.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file draxutils-0.1.8.tar.gz.
File metadata
- Download URL: draxutils-0.1.8.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f27e96341e84efc9a44942583242dd659702120c9a7c2f6d9b232e0d4ed40636
|
|
| MD5 |
5fcae29fd21d7846184e060cf46df688
|
|
| BLAKE2b-256 |
71517c0c1de679a3b381a06132a2b4de02cf46ccf16de233be4dc68edeea35ca
|
File details
Details for the file draxutils-0.1.8-py3-none-any.whl.
File metadata
- Download URL: draxutils-0.1.8-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ee810185e9549468ca90692c2c4904df275ee5f5e5f25183af96846d24e59c4
|
|
| MD5 |
713b12df0ed51af7787b763f455de54a
|
|
| BLAKE2b-256 |
9e1126c4097c129b0bd240b5e09e087a8e41349ae7bc6cd2255736d5b9ef25b2
|