Repository: ESSS/barril

Issue:
Fix default category of `degF` and `degR` for `Scalar`
* Barril version: 1.9.0
* Python version: 3.6.7
* Operating System: Windows

### Description

When creating `Scalars` with only value and units `degF` or `degR` (omitting category) the generated `Scalar` has category `thermodynamic temperature` where it should have category `temperature` . This also happens for `Array`.

### What I Did

```
>>> a = Scalar(1.0, 'degR')
>>> a
Scalar(1.0, 'degR', 'thermodynamic temperature')
```

but in fact we should have the following:

```
>>> a = Scalar('temperature', 1.0, 'degR')
>>> a
Scalar(1.0, 'degR', 'temperature')
```


Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 58b4af4..a0d3e56 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,15 +1,19 @@
+UNRELEASED
+------------------
+
+* Removing ``thermodynamic temperature`` as default category for ``degF`` and ``degR`` units.
+
 1.9.0 (2020-02-20)
 ------------------
 
 * New ``classmethod`` ``Array.FromScalars`` that creates an ``Array`` from a ``List[Scalar]``.
 * Add new unit: "barrel per second" (``bbl/s``).
 
-
 1.8.0 (2020-01-10)
 ------------------
 
-* Add new category: "standard volume per standard volume"
-* Move unit ``sm3/sm3`` from "volume per volume" to "standard volume per standard volume"
+* Add new category: "standard volume per standard volume".
+* Move unit ``sm3/sm3`` from "volume per volume" to "standard volume per standard volume".
 
 1.7.2 (2019-10-16)
 ------------------
diff --git a/src/barril/units/posc.py b/src/barril/units/posc.py
index a261967..e48c763 100644
--- a/src/barril/units/posc.py
+++ b/src/barril/units/posc.py
@@ -2375,7 +2375,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         "degF",
         f_base_to_unit,
         f_unit_to_base,
-        default_category="thermodynamic temperature",
+        default_category=None,
     )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.1761102, 1.0, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.1761102, 1.0, 0.0)
@@ -2465,7 +2465,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         "degR",
         f_base_to_unit,
         f_unit_to_base,
-        default_category="thermodynamic temperature",
+        default_category=None,
     )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.1, 1.0, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.1, 1.0, 0.0)
@@ -13377,7 +13377,10 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             valid_units=["K", "ddegC", "ddegF", "ddegK", "ddegR"],
         )
         db.AddCategory(
-            "temperature", "temperature", override=override_categories, valid_units=["degC"]
+            "temperature",
+            "temperature",
+            override=override_categories,
+            valid_units=["degC", "K", "degF", "degR"],
         )
         db.AddCategory(
             "thermodynamic temperature",


Test patch:
diff --git a/src/barril/units/_tests/test_posc.py b/src/barril/units/_tests/test_posc.py
index 6f63923..e341e04 100644
--- a/src/barril/units/_tests/test_posc.py
+++ b/src/barril/units/_tests/test_posc.py
@@ -273,7 +273,6 @@ def testDefaultCategories(unit_database_posc):
         "self inductance per length",
         "shear rate",
         "status",
-        "thermodynamic temperature",
         "volume per area",
         "volume per length",
         "volume per time per area",
diff --git a/src/barril/units/_tests/test_posc2.py b/src/barril/units/_tests/test_posc2.py
index ed5486d..ee7cf75 100644
--- a/src/barril/units/_tests/test_posc2.py
+++ b/src/barril/units/_tests/test_posc2.py
@@ -49,3 +49,15 @@ def testScfPerBblToM3ToM3():
     expected = 0.17776487178535644
     obtained = unit_database.Convert("standard volume per volume", "scf/bbl", "scm(15C)/m3", 1.0)
     assert approx(abs(obtained - expected), 7) == 0
+
+
+def testAllValidTemperatureUnitsHaveSameDefaultCategory():
+    """'temperature' units should have 'temperature' as defined category (#45)"""
+    unit_database = UnitDatabase.CreateDefaultSingleton()
+
+    expected_category = "temperature"
+    valid_temperature_units = unit_database.GetValidUnits(expected_category)
+
+    for unit in valid_temperature_units:
+        T = units.Scalar(1.0, unit)
+        assert T.category == expected_category