Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
CHANGES
=======

-----------
Unreleased
-----------

- Correct the pond force unit to 0.00980665 N (one gram-force); it was
previously 1000 times too large (`#44 <https://github.com/python-quantities/python-quantities/issues/44>`_).

------
0.16.4
------
Expand Down
44 changes: 44 additions & 0 deletions quantities/tests/test_units.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from .. import units as pq
from ..quantity import Quantity
from .common import TestCase


Expand Down Expand Up @@ -38,3 +39,46 @@ def test_code_injection(self):
with pytest.raises(LookupError) as exc_info:
pq.CompoundUnit("exec(\"print('Hello there.')\\nprint('General Wasabi!')\")")
assert "Wasabi" in str(exc_info.value)


class TestForceUnits(TestCase):

def test_pond_newtons(self):
# A pond is a gram-force, not a kilogram-force.
self.assertQuantityEqual(
pq.pond.rescale(pq.N), 0.00980665 * pq.N, delta=1e-12
)

def test_pond_names(self):
self.assertEqual(pq.pond.name, 'pond')
self.assertEqual(pq.pond.symbol, 'p')
for unit in ('pond', 'ponds', 'p'):
with self.subTest(unit=unit):
self.assertQuantityEqual(
Quantity(1, unit).rescale(pq.N),
0.00980665 * pq.N,
delta=1e-12
)

def test_pond_array(self):
self.assertQuantityEqual(
([-1, 0, 1, 1000] * pq.pond).rescale(pq.N),
[-0.00980665, 0, 0.00980665, 9.80665] * pq.N,
delta=1e-12
)

def test_pond_dimensionality(self):
self.assertEqual(
pq.pond.simplified.dimensionality,
(pq.kg * pq.m / pq.s**2).dimensionality
)

def test_gram_force_newtons(self):
self.assertQuantityEqual(
pq.gram_force.rescale(pq.N), 0.00980665 * pq.N, delta=1e-12
)

def test_kilogram_force_newtons(self):
self.assertQuantityEqual(
pq.kgf.rescale(pq.N), 9.80665 * pq.N, delta=1e-12
)
2 changes: 1 addition & 1 deletion quantities/units/force.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
pond = UnitQuantity(
'pond',
g_0*kg,
g_0*gram,
symbol='p',
aliases=['ponds']
)
Expand Down
Loading