Skip to main content

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 or astropy 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

py42195-0.1.4.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

py42195-0.1.4-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

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