pint-compute
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnit 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... | Command | Example |
|---|---|---|
| Convert units | | |
| Unit math | | |
| Check dimensions | | |
| Parse quantity | | |
| Simplify units | | |
| 我想... | 命令 | 示例 |
|---|---|---|
| 转换单位 | | |
| 单位运算 | | |
| 检查量纲 | | |
| 解析量值 | | |
| 简化单位 | | |
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 pascalcalc
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
常见单位领域
| Domain | Examples |
|---|---|
| Length | meter, foot, inch, mile, km, yard |
| Time | second, minute, hour, day, year |
| Mass | kg, gram, pound, ounce, ton |
| Velocity | m/s, km/h, mph, knot |
| Energy | joule, calorie, eV, kWh, BTU |
| Force | newton, pound_force, dyne |
| Temperature | kelvin, celsius, fahrenheit |
| Pressure | pascal, bar, atmosphere, psi |
| Power | watt, 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
undefinedThis will error - incompatible dimensions
此命令会报错——量纲不兼容
uv run python -m runtime.harness scripts/pint_compute.py
convert "5 meters" --to kg
convert "5 meters" --to kg
uv run python -m runtime.harness scripts/pint_compute.py
convert "5 meters" --to kg
convert "5 meters" --to kg
Error: Cannot convert '[length]' to '[mass]'
错误:无法将'[length]'转换为'[mass]'
undefinedundefinedRelated Skills
相关技能
- /math-mode - Full math orchestration (SymPy + Z3)
- /sympy-compute - Symbolic computation
- /math-mode - 完整数学编排(SymPy + Z3)
- /sympy-compute - 符号计算