hrbonz / python-aqi

A library to convert between AQI value and pollutant concentration (µg/m³ or ppm)
BSD 3-Clause "New" or "Revised" License
60 stars 28 forks source link

Fix IndexError when concentration is outside of EPA range #22

Open andriykorchak opened 3 years ago

andriykorchak commented 3 years ago

Hi @hrbonz

Thanks for this great library.

I've found a minor edge case issue. I currently handle it in the calling code, but it would be nice to take care of it in the library.

Currently If pollutant concentration is outside of the lookup table range iaqi() function will crash with IndexError.

This PR fixes it. If the concentration is lower or higher than the range defined in the look up table, the function will return lowest or highest AQI value from the table accordingly.

Please let me know what you think about these changes.

Thanks.

Andrii