Repository: NREL/hescore-hpxml

Issue:
NumberofBedrooms silently capped at 10
If `NumberofBedrooms` is greater than 10 then hpxml2hescore returns `number_bedrooms` set to 10 and no error.

Test file: 
[bad_input_hpxml.txt](https://github.com/NREL/hescore-hpxml/files/6225296/bad_input_hpxml.txt)
* Currently: returns json with `number_bedrooms` set to 10
* Expected: returns InputOutOfBounds error

Discussion:

Patch:
diff --git a/examples/house6.xml b/examples/house6.xml
index 0ab806c2..fdc7713d 100644
--- a/examples/house6.xml
+++ b/examples/house6.xml
@@ -32,7 +32,7 @@
                     <ResidentialFacilityType>single-family detached</ResidentialFacilityType>
                     <NumberofConditionedFloorsAboveGrade>2</NumberofConditionedFloorsAboveGrade>
                     <AverageCeilingHeight>8</AverageCeilingHeight>
-                    <NumberofBedrooms>11</NumberofBedrooms>
+                    <NumberofBedrooms>10</NumberofBedrooms>
                     <ConditionedFloorArea>2600</ConditionedFloorArea>
                 </BuildingConstruction>
             </BuildingSummary>
diff --git a/examples/house6_v3.xml b/examples/house6_v3.xml
index 83d2f02f..c8c2c7d8 100644
--- a/examples/house6_v3.xml
+++ b/examples/house6_v3.xml
@@ -32,7 +32,7 @@
                     <ResidentialFacilityType>single-family detached</ResidentialFacilityType>
                     <NumberofConditionedFloorsAboveGrade>2</NumberofConditionedFloorsAboveGrade>
                     <AverageCeilingHeight>8</AverageCeilingHeight>
-                    <NumberofBedrooms>11</NumberofBedrooms>
+                    <NumberofBedrooms>10</NumberofBedrooms>
                     <ConditionedFloorArea>2600</ConditionedFloorArea>
                 </BuildingConstruction>
             </BuildingSummary>
diff --git a/hescorehpxml/base.py b/hescorehpxml/base.py
index 3dc254f5..e8c9380b 100644
--- a/hescorehpxml/base.py
+++ b/hescorehpxml/base.py
@@ -927,8 +927,6 @@ class HPXMLtoHEScoreTranslatorBase(object):
         bldg_cons_el = xpath(b, 'h:BuildingDetails/h:BuildingSummary/h:BuildingConstruction', raise_err=True)
         bldg_about['year_built'] = int(xpath(bldg_cons_el, 'h:YearBuilt/text()', raise_err=True))
         nbedrooms = int(xpath(bldg_cons_el, 'h:NumberofBedrooms/text()', raise_err=True))
-        if nbedrooms > 10:
-            nbedrooms = 10
         bldg_about['number_bedrooms'] = nbedrooms
         bldg_about['num_floor_above_grade'] = int(
             math.ceil(float(xpath(bldg_cons_el, 'h:NumberofConditionedFloorsAboveGrade/text()', raise_err=True))))


Test patch:
diff --git a/tests/test_translation.py b/tests/test_translation.py
index 50571e69..5dd4fd65 100644
--- a/tests/test_translation.py
+++ b/tests/test_translation.py
@@ -1149,6 +1149,14 @@ class TestInputOutOfBounds(unittest.TestCase, ComparatorBase):
                                'num_floor_above_grade is out of bounds',
                                tr.hpxml_to_hescore)
 
+    def test_number_bedrooms(self):
+        tr = self._load_xmlfile('hescore_min')
+        el = self.xpath('//h:NumberofBedrooms')
+        el.text = '25'
+        self.assertRaisesRegex(InputOutOfBounds,
+                               'number_bedrooms is out of bounds',
+                               tr.hpxml_to_hescore)
+
     def test_floor_to_ceiling_height1(self):
         tr = self._load_xmlfile('hescore_min')
         el = self.xpath('//h:AverageCeilingHeight')