Skip to main content

A practical tool for calculations with physical units

Project description

Quantitas

概要

Quantitasは、煩雑な単位計算を手軽に実行するためのパッケージです。物理量に対して四則演算などの計算を行ったり、単位変換をしたりできます。また、本パッケージには、自然科学の分野でよく使われる単位や定数の多くがあらかじめ実装されており、ユーザーは自身で定義することなくこれらを使うことができます。

インストール

pip install quantitas

クイックスタート

木星の半径と質量から、木星表面の重力加速度を計算するサンプルコードです。

import quantitas as qt
from quantitas.units import * #Quantitasが収録する全ての単位をインポート
from quantitas import G, M_Jupiter, M_Earth #定数をインポート

r = 71492*km_
g = G*M_Jupiter/r**2

print(g)
#出力: 24.79160264727122 m⋅s^-2

単位を表す変数名には末尾にアンダースコア (_) が付きます。万有引力定数Gや木星質量M_Jupiterなど、よく使われる定数の多くはあらかじめ定義されています。

上のサンプルコードのように物理量はprint関数で表示することもできますが、物理量を出力するのに特化したqrint関数がおすすめです。

from quantitas import qrint

qrint(g)
#出力: 24.79160264727122 m⋅s^-2

qrint(g, [N_, kg_]) #単位を指定すると自動で変換されます
#出力: 24.79160264727122 N⋅kg^-1

qrint([M_Jupiter, M_Earth]) #複数の物理量もまとめて出力できます
#出力: 1.8985138610303162e+27 kg  5.972168401180649e+24 kg

単位はユーザーが定義することもできます。give_symbol関数を使うことで物理量に文字列の記号を与えることができます。

kph_ = qt.give_symbol(km_/h_, "kph") #キロメートル毎時
qrint(340*m_/s_, kph_)
#出力: 1224.0 kph

もっと詳しく

本パッケージには上で紹介しきれなかった機能や仕様がたくさんあります。Quantitasについてもっと知りたいと思った方は以下をご参照ください。

License

This project is licensed under the MIT License, see the LICENSE.txt file for details.

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

quantitas-1.2.0b2.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantitas-1.2.0b2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file quantitas-1.2.0b2.tar.gz.

File metadata

  • Download URL: quantitas-1.2.0b2.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for quantitas-1.2.0b2.tar.gz
Algorithm Hash digest
SHA256 5383c8a92cb225e0d882c76e6201673ff96a5ecbb172b3ae7fed36faa384f23a
MD5 5465a3b6c82568b5d248bf3583f75e17
BLAKE2b-256 81ba10cc55031ca495316048f7da05b40810c487d782f2e52b4e64740514f297

See more details on using hashes here.

File details

Details for the file quantitas-1.2.0b2-py3-none-any.whl.

File metadata

  • Download URL: quantitas-1.2.0b2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for quantitas-1.2.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 403caa6403a6d8285530abb6848818cdba77feab9a9dc4018d8cdcab151cf1d8
MD5 8a0c2ab204ddff57523e6c50a08a9bf8
BLAKE2b-256 303c6e4bdf0f47a4ac1113de0b5e4a0c4cac7ee3294b980aada9cc130626c501

See more details on using hashes here.

Supported by

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