Handle out of scale value
Handle negative and out of scale values.
Add an option to force out of scale calculation
while doing some experiments with a air sensor in a room for smokers I played with the data and got the following error trying to convert the high PM numbers the PM10 number was 566.8 as you can see below in the trace and error I believe this is exactly what this bug mentions
Traceback (most recent call last):
File "./aqi-test.py", line 24, in
Now with fire in Australia Ozone and PM value go too high
File "/home/rva/.local/lib/python3.6/site-packages/aqi/init.py", line 45, in to_aqi return _aqi.aqi(ccs) File "/home/rva/.local/lib/python3.6/site-packages/aqi/algos/base.py", line 36, in aqi _iaqi = self.iaqi(elem, cc) File "/home/rva/.local/lib/python3.6/site-packages/aqi/algos/base.py", line 91, in iaqi (aqilo, aqihi) = self.piecewise['aqi'][idx] IndexError: list index out of range
Fundamentally, the correct behavior would be to raise an exception that qualifies the value as out of AQI calculation range.
Hey @hrbonz
How about returning float('inf') if the pollutant value is above the maximum threshold?
That should be backward-compatible in most cases and will have predictable behavior in numerical comparisons.