Skip to main content

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


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.13.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

draxutils-0.1.13-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file draxutils-0.1.13.tar.gz.

File metadata

  • Download URL: draxutils-0.1.13.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for draxutils-0.1.13.tar.gz
Algorithm Hash digest
SHA256 b16e61c3e5858be28b20a6dd75614544ac2073e61934b8756f8e323ca931ef2b
MD5 c2b4fd91072a3447c9f4bbbb78de873f
BLAKE2b-256 f04b6140225011427d8a2a506ec6822973fab6b95ec055ac597f9bc533f10227

See more details on using hashes here.

File details

Details for the file draxutils-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: draxutils-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for draxutils-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e635dafd22cee2d091e50ed013fb0046bf042260b618d83e6d2037b0ac1b03
MD5 36b113122a87150848c3eb9c38f2ec64
BLAKE2b-256 37e7263fb9ac8aa7d4f93307341e616738910f7039ff29e187b741f642a3e2d2

See more details on using hashes here.

Supported by

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