No project description provided
Project description
py42195
Tiny library in pure Python to help you keep in (running) pace. It defines classes for Distance, Pace, Duration and Speeds, together with (hopefully) complete arithmetics capabilities and string IO, both in metric and imperial unit systems.
All started with a task (worth five minutes): "I have these ten pace values and ten distances. Let's compute the total duration." Typically, these problems are best solved by hours of coding :-D
Installation
pip install py42195 # or `uv pip install py42195`
Examples
How fast do I (well, not me) need to be to finish a marathon in 2 hours?
>>> from py42195 import duration, Distance
>>> desired_pace = duration("2:00:00") / Distance.MARATHON
>>> desired_pace
Pace(seconds_per_km=170.63633131887664) # repr
>>> print(desired_pace)
2:50.6/km # str
What would be the speed in mph?
>>> desired_speed = desired_pace.to_speed()
>>> desired_speed.mph
13.109 # + a few more digits
Will I be able to finish a half-marathon in 1:30 hours if I run at a pace of 4:07 min/km?
>>> from py42195 import pace, Distance
>>> my_pace = pace("4:07")
>>> my_pace * Distance.HALF_MARATHON <= duration("1:30:00")
True # 1:26:51
How long will it take me to run 10 miles at a pace of 5:00 min/km?
>>> from py42195 import pace, distance
>>> my_pace = pace("5:00")
>>> my_distance = distance("10 mi")
>>> my_pace * my_distance
duration('1:20:28.0')
Configuration
By default, the library uses the metric system. You can change it by calling set_unit_system
:
>>> from py42195 import set_unit_system, IMPERIAL, Distance
>>> with set_unit_system(IMPERIAL):
... print(Distance.MARATHON)
26.22 mi
You can also explicitly choose the unit system ("metric" or "imperial") using the
PY42195_UNIT_SYSTEM
environment variable.
Not included
- fast computation for arrays
- extension type for pandas (perhaps?)
- compatibility with
pint
orastropy
units (perhaps?) - simple CLI tool
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
Built Distribution
File details
Details for the file py42195-0.1.4.tar.gz
.
File metadata
- Download URL: py42195-0.1.4.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 389834e2f6be21655a4ce1d968ba803b5a64c764c24b6ffa328e757f25a5253a |
|
MD5 | 52560ea2a0b34822ec4b35d66a7b763f |
|
BLAKE2b-256 | 6c2c6be711e21948a1685cfba3d30c52e13c765c37d037c97c449bfc25cbc7d3 |
File details
Details for the file py42195-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: py42195-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f5e0abd97653f5fa1c81cbafe2833829888fe9f54fbdcec11b069590351b1d2 |
|
MD5 | edfa77338352a8433e83d60e8f60690d |
|
BLAKE2b-256 | 5f5fa90e8c71490eb948a7419f1a02bcd29309208fe32068b2801912cd6aae0b |