Get the FREE Ultimate OpenClaw Setup Guide →

pint-compute

npx machina-cli add skill parcadei/Continuous-Claude-v3/pint-compute --openclaw
Files (1)
SKILL.md
3.5 KB

Unit Computation with Pint

Cognitive prosthetics for unit-aware computation. Use Pint for converting between units, performing unit arithmetic, checking dimensional compatibility, and simplifying compound units.

When to Use

  • Converting between units (meters to feet, kg to pounds)
  • Unit-aware arithmetic (velocity x time = distance)
  • Dimensional analysis (is force = mass x acceleration?)
  • Simplifying compound units to base or named units
  • Parsing and analyzing quantities with units

Quick Reference

I want to...CommandExample
Convert unitsconvertconvert "5 meters" --to feet
Unit mathcalccalc "10 m/s * 5 s"
Check dimensionscheckcheck newton --against "kg * m / s^2"
Parse quantityparseparse "100 km/h"
Simplify unitssimplifysimplify "1 kg*m/s^2"

Commands

parse

Parse a quantity string into magnitude, units, and dimensionality.

uv run python -m runtime.harness scripts/pint_compute.py \
    parse "100 km/h"

uv run python -m runtime.harness scripts/pint_compute.py \
    parse "9.8 m/s^2"

convert

Convert a quantity to different units.

uv run python -m runtime.harness scripts/pint_compute.py \
    convert "5 meters" --to feet

uv run python -m runtime.harness scripts/pint_compute.py \
    convert "100 km/h" --to mph

uv run python -m runtime.harness scripts/pint_compute.py \
    convert "1 atmosphere" --to pascal

calc

Perform unit-aware arithmetic. Operators must be space-separated.

uv run python -m runtime.harness scripts/pint_compute.py \
    calc "5 m * 3 s"

uv run python -m runtime.harness scripts/pint_compute.py \
    calc "10 m / 2 s"

uv run python -m runtime.harness scripts/pint_compute.py \
    calc "5 meters + 300 cm"

check

Check if two units have compatible dimensions.

uv run python -m runtime.harness scripts/pint_compute.py \
    check newton --against "kg * m / s^2"

uv run python -m runtime.harness scripts/pint_compute.py \
    check joule --against "kg * m^2 / s^2"

simplify

Simplify compound units to base or compact form.

uv run python -m runtime.harness scripts/pint_compute.py \
    simplify "1 kg*m/s^2"

uv run python -m runtime.harness scripts/pint_compute.py \
    simplify "1000 m"

Common Unit Domains

DomainExamples
Lengthmeter, foot, inch, mile, km, yard
Timesecond, minute, hour, day, year
Masskg, gram, pound, ounce, ton
Velocitym/s, km/h, mph, knot
Energyjoule, calorie, eV, kWh, BTU
Forcenewton, pound_force, dyne
Temperaturekelvin, celsius, fahrenheit
Pressurepascal, bar, atmosphere, psi
Powerwatt, horsepower

Output Format

All commands return JSON with relevant fields:

{
  "result": "16.4042 foot",
  "magnitude": 16.4042,
  "units": "foot",
  "dimensionality": "[length]",
  "latex": "16.4042\\,\\mathrm{ft}"
}

Error Handling

Dimensionality errors are caught and reported:

# This will error - incompatible dimensions
uv run python -m runtime.harness scripts/pint_compute.py \
    convert "5 meters" --to kg
# Error: Cannot convert '[length]' to '[mass]'

Related Skills

  • /math-mode - Full math orchestration (SymPy + Z3)
  • /sympy-compute - Symbolic computation

Source

git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/pint-compute/SKILL.mdView on GitHub

Overview

Pint-powered unit-aware computation tool that converts between units, performs unit arithmetic, and checks dimensional compatibility. It enables dimensional analysis and simplification of compound units, and can parse quantities for inspection.

How This Skill Works

It relies on Pint to parse quantities into magnitude, units, and dimensionality, then perform conversions, arithmetic, and compatibility checks. The workflow is exposed through commands such as parse, convert, calc, check, and simplify, returning structured results you can reuse in pipelines.

When to Use It

  • Converting between units (meters to feet or kg to pounds).
  • Performing unit-aware arithmetic (e.g., velocity × time = distance).
  • Running dimensional analysis to verify equations (e.g., is force = mass × acceleration?).
  • Simplifying compound units to base or compact forms for readability.
  • Parsing and analyzing quantities that include units (e.g., '100 km/h').

Quick Start

  1. Step 1: Parse a quantity, e.g., parse \"100 km/h\".
  2. Step 2: Convert to another unit, e.g., convert \"5 meters\" --to feet.
  3. Step 3: Perform arithmetic, e.g., calc \"10 m / 2 s\".

Best Practices

  • Always specify target units clearly when using convert.
  • Use check to ensure dimensional compatibility before arithmetic.
  • Parse quantities before performing operations to extract magnitude and units.
  • Use calc for unit-aware expressions with explicit operators.
  • Simplify results to base or compact forms for consistency.

Example Use Cases

  • Convert 5 meters to feet: convert "5 meters" --to feet.
  • Calculate distance from velocity: calc "10 m / 2 s".
  • Check dimension compatibility: check newton --against "kg * m / s^2".
  • Parse a quantity: parse "100 km/h".
  • Simplify a compound unit: simplify "1 kg*m/s^2" to a base or compact form like N.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers