File: test_constants.py

package info (click to toggle)
python-hepunits 2.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 180 kB
  • sloc: python: 1,970; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license, see LICENSE.
"""
Tests for the hepunits.constants.constants module.
"""

from pytest import approx

from hepunits import *
from hepunits import THz, eV, nanometer, s


def test_constants():
    assert pi_sq == two_pi * half_pi
    assert Avogadro == 6.02214076e23
    assert c_light / (m / s) == 299792458
    assert hbarc_sq / c_light_sq == approx((h_Planck / two_pi) ** 2)
    assert hbar / (eV * s) == hbar / 1.0e3
    # wavelength of 555-ish nanometres (green light) has a frequency of 540 THz
    assert c_light / (555.17121851852 * nanometer) == approx(540 * THz)