pint-compute

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Unit Computation with Pint

使用Pint进行单位计算

Cognitive prosthetics for unit-aware computation. Use Pint for converting between units, performing unit arithmetic, checking dimensional compatibility, and simplifying compound units.
用于带单位计算的认知辅助工具。使用Pint进行单位转换、单位运算、量纲兼容性检查,以及简化复合单位。

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 units
convert
convert "5 meters" --to feet
Unit math
calc
calc "10 m/s * 5 s"
Check dimensions
check
check newton --against "kg * m / s^2"
Parse quantity
parse
parse "100 km/h"
Simplify units
simplify
simplify "1 kg*m/s^2"
我想...命令示例
转换单位
convert
convert "5 meters" --to feet
单位运算
calc
calc "10 m/s * 5 s"
检查量纲
check
check newton --against "kg * m / s^2"
解析量值
parse
parse "100 km/h"
简化单位
simplify
simplify "1 kg*m/s^2"

Commands

命令

parse

parse

Parse a quantity string into magnitude, units, and dimensionality.
bash
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"
将带单位的量值字符串解析为数值、单位和量纲。
bash
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

Convert a quantity to different units.
bash
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
将量值转换为其他单位。
bash
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

calc

Perform unit-aware arithmetic. Operators must be space-separated.
bash
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"
执行带单位的算术运算。运算符必须用空格分隔。
bash
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

Check if two units have compatible dimensions.
bash
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"
检查两个单位是否具有兼容的量纲。
bash
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

Simplify compound units to base or compact form.
bash
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"
将复合单位简化为基本单位或紧凑形式。
bash
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
领域示例
长度meter、foot、inch、mile、km、yard
时间second、minute、hour、day、year
质量kg、gram、pound、ounce、ton
速度m/s、km/h、mph、knot
能量joule、calorie、eV、kWh、BTU
newton、pound_force、dyne
温度kelvin、celsius、fahrenheit
压力pascal、bar、atmosphere、psi
功率watt、horsepower

Output Format

输出格式

All commands return JSON with relevant fields:
json
{
  "result": "16.4042 foot",
  "magnitude": 16.4042,
  "units": "foot",
  "dimensionality": "[length]",
  "latex": "16.4042\\,\\mathrm{ft}"
}
所有命令均返回包含相关字段的JSON:
json
{
  "result": "16.4042 foot",
  "magnitude": 16.4042,
  "units": "foot",
  "dimensionality": "[length]",
  "latex": "16.4042\\,\\mathrm{ft}"
}

Error Handling

错误处理

Dimensionality errors are caught and reported:
bash
undefined
量纲错误会被捕获并报告:
bash
undefined

This will error - incompatible dimensions

此命令会报错——量纲不兼容

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

Error: Cannot convert '[length]' to '[mass]'

错误:无法将'[length]'转换为'[mass]'

undefined
undefined

Related Skills

相关技能

  • /math-mode - Full math orchestration (SymPy + Z3)
  • /sympy-compute - Symbolic computation
  • /math-mode - 完整数学编排(SymPy + Z3)
  • /sympy-compute - 符号计算