nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: yt-project/unyt
Pull request #162 (2020-07-21 21:17:58)

Add US customary units kip and ksi
Adds the force unit kip (a.k.a. kipf or kilopound, 1000 lbf) and the pressure unit ksi (kips per square inch, 1000 psi). These are most commonly used in architecture and engineering. I'm following `pint` in making the default name kip refer to a force unit.

I'm a little confused on tests -- some are in `test_units.py` and some are in `test_unyt_array.py`. Is there a preferred place for tests for units?


Patch:
diff --git a/unyt/_unit_lookup_table.py b/unyt/_unit_lookup_table.py
index ba2bfb4..48247a2 100644
--- a/unyt/_unit_lookup_table.py
+++ b/unyt/_unit_lookup_table.py
@@ -166,6 +166,16 @@ default_unit_symbol_lut = OrderedDict(
                 False,
             ),
         ),
+        (
+            "kip",
+            (
+                1000 * kg_per_pound * standard_gravity_m_per_s2,
+                dimensions.force,
+                0.0,
+                r"\rm{kip}",
+                False,
+            ),
+        ),
         ("lb", (kg_per_pound, dimensions.mass, 0.0, r"\rm{lb}", False)),
         ("atm", (pascal_per_atm, dimensions.pressure, 0.0, r"\rm{atm}", False)),
         ("hp", (watt_per_horsepower, dimensions.power, 0.0, r"\rm{hp}", False)),
@@ -193,6 +203,16 @@ default_unit_symbol_lut = OrderedDict(
                 False,
             ),
         ),
+        (
+            "ksi",
+            (
+                1000 * kg_per_pound * standard_gravity_m_per_s2 / m_per_inch ** 2,
+                dimensions.pressure,
+                0.0,
+                r"\rm{ksi}",
+                False,
+            ),
+        ),
         ("smoot", (1.7018, dimensions.length, 0.0, r"\rm{smoot}", False)),
         # dimensionless stuff
         ("dimensionless", (1.0, dimensions.dimensionless, 0.0, r"", False)),
@@ -443,6 +463,7 @@ default_unit_name_alternatives = OrderedDict(
         ("degF", ("degree_fahrenheit", "degree_Fahrenheit", "fahrenheit", "°F")),
         ("R", ("degree_rankine", "rankine")),
         ("lbf", ("pound_force",)),
+        ("kip", ("kilopound", "kipf")),
         ("lb", ("pound", "pound_mass", "lbm")),
         ("atm", ("atmosphere",)),
         ("hp", ("horsepower",)),
@@ -450,6 +471,7 @@ default_unit_name_alternatives = OrderedDict(
         ("cal", ("calorie",)),
         ("BTU", ("british_thermal_unit",)),
         ("psi", ("pounds_per_square_inch",)),
+        ("ksi", ("kips_per_square_inch",)),
         # dimensionless stuff
         ("dimensionless", ("_", "")),
         ("B", ("bel",)),


Test patch:
diff --git a/unyt/tests/test_unyt_array.py b/unyt/tests/test_unyt_array.py
index bd03e4b..4f69fb7 100644
--- a/unyt/tests/test_unyt_array.py
+++ b/unyt/tests/test_unyt_array.py
@@ -2415,3 +2415,11 @@ def test_delta_degF():
 
 def test_mil():
     assert_allclose_units(unyt_quantity(1, "mil"), unyt_quantity(0.001, "inch"))
+
+
+def test_kip():
+    assert_allclose_units(unyt_quantity(1, "lbf"), unyt_quantity(0.001, "kip"))
+
+
+def test_ksi():
+    assert_allclose_units(unyt_quantity(1, "lbf/inch**2"), unyt_quantity(0.001, "ksi"))