コード例 #1
0
ファイル: power.py プロジェクト: joshmoore/ome-units
from base import add_si
from base import print_conversions

from sympy.physics.units import centi
from sympy.physics.units import deci
from sympy.physics.units import kilo
from sympy.physics.units import mega
from sympy.physics.units import milli

from sympy import symbols as symbols
from sympy import Eq
from sympy import tan


NAME = "POWER"

w = symbols("w")

equations = [
]

units = {
    w: "WATT",
}

add_si(w, "WATT", units, equations)

if __name__ == "__main__":
    import sys
    print_conversions(sys.modules[__name__])
コード例 #2
0
ファイル: run.py プロジェクト: joshmoore/ome-units
    parser = ArgumentParser()
    parser.add_argument("--load",
                        action="store_true")
    parser.add_argument("--type")
    parser.add_argument("--python",
                        action="store_true")
    parser.add_argument("--plain",
                        action="store_true")
    ns = parser.parse_args()
    which = None
    if ns.type:
        which = (LOOKUP[ns.type],)
    else:
        which = ALL

    if ns.load:
        dir = os.path.dirname(__file__)
        efile = os.path.join(dir, "equations.py")
        execfile(efile)
        for x in which:
            print x.NAME
            sources = EQUATIONS[x.NAME]
            for source, targets in sorted(sources.items()):
                for target, eqn in sorted(targets.items()):
                    print source, target, eqn
    else:
        if ns.python:
            print_python(*which)
        elif ns.plain:
            print_conversions(*which)
コード例 #3
0
ファイル: temp.py プロジェクト: jburel/ome-units
#!/usr/bin/env python

from sympy import symbols as symbols
from sympy import Eq

NAME = "TEMPERATURE"

k, c, f, r = symbols("k c f r")

equations = (
    Eq(f, 9 * c / 5 + 32),
    Eq(f, r - 459.67),
    Eq(c, k - 273.15),
)

units = {
    k: "KELVIN",
    c: "CELSIUS",
    f: "FAHRENHEIT",
    r: "RANKINE",
}

if __name__ == "__main__":
    import sys
    from base import print_conversions
    print_conversions(sys.modules[__name__])
コード例 #4
0
    LOOKUP[e.NAME] = e

if __name__ == "__main__":
    parser = ArgumentParser()
    parser.add_argument("--load", action="store_true")
    parser.add_argument("--type")
    parser.add_argument("--python", action="store_true")
    parser.add_argument("--plain", action="store_true")
    ns = parser.parse_args()
    which = None
    if ns.type:
        which = (LOOKUP[ns.type], )
    else:
        which = ALL

    if ns.load:
        dir = os.path.dirname(__file__)
        efile = os.path.join(dir, "equations.py")
        execfile(efile)
        for x in which:
            print x.NAME
            sources = EQUATIONS[x.NAME]
            for source, targets in sorted(sources.items()):
                for target, eqn in sorted(targets.items()):
                    print source, target, eqn
    else:
        if ns.python:
            print_python(*which)
        elif ns.plain:
            print_conversions(*which)