Functional Weave
Code in Python

energy.degree-days@1.0.0

vectors.json

1,969 bytes · view raw

[
  { "name": "one cold, one at the base, one warm day at 15.5", "args": [[100, 155, 200], 155], "expect": { "heating": 55, "cooling": 45, "days": 3 } },
  { "name": "a cold week in January", "args": [[21, -13, 0, 35, 48, 62, 17], 155], "expect": { "heating": 915, "cooling": 0, "days": 7 } },
  { "name": "a heatwave counts only cooling", "args": [[221, 254, 198], 155], "expect": { "heating": 0, "cooling": 208, "days": 3 } },
  { "name": "warm and cold days do not cancel out", "args": [[55, 255], 155], "expect": { "heating": 100, "cooling": 100, "days": 2 } },
  { "name": "a day exactly at the base counts for neither", "args": [[155], 155], "expect": { "heating": 0, "cooling": 0, "days": 1 } },
  { "name": "tenths below the base are kept, not rounded away", "args": [[154, 154, 154], 155], "expect": { "heating": 3, "cooling": 0, "days": 3 } },
  { "name": "below freezing adds the full distance to the base", "args": [[-25], 155], "expect": { "heating": 180, "cooling": 0, "days": 1 } },
  { "name": "a lower base for a well-insulated building", "args": [[100, 120, 130], 120], "expect": { "heating": 20, "cooling": 10, "days": 3 } },
  { "name": "a cooling base of 22 °C", "args": [[230, 215, 260], 220], "expect": { "heating": 5, "cooling": 50, "days": 3 } },
  { "name": "no days is no degree days", "args": [[], 155], "expect": { "heating": 0, "cooling": 0, "days": 0 } },
  { "name": "the extremes allowed", "args": [[-1000, 1000], 0], "expect": { "heating": 1000, "cooling": 1000, "days": 2 } },
  { "name": "a temperature in hundredths is out of range", "args": [[1550], 155], "expectError": "daily mean temperature must be whole tenths of a degree" },
  { "name": "a fractional tenth is refused", "args": [[123.5], 155], "expectError": "daily mean temperature must be whole tenths of a degree" },
  { "name": "a base in Fahrenheit tenths is out of range", "args": [[100], 1500], "expectError": "base temperature must be whole tenths of a degree" }
]