Ozon3Org / Ozon3

An open-source Python package to easily obtain real-time, historical, or forecasted air quality data for anywhere in the world. Reliable, accurate and simple.
GNU General Public License v3.0
66 stars 23 forks source link

fix: Force convert into float (np.nan if fails) #126

Closed lahdjirayhan closed 2 years ago

lahdjirayhan commented 2 years ago

This PR tries to solve the problem previously written up in https://github.com/Milind220/Ozone/pull/120#issuecomment-1105971303 (point no 2)

It introduces a helper method that tries to convert its input into float, and if that fails, gives out numpy.nan.

In light of the fact that WAQI backend sometimes sends invalid AQI value (e.g. - as noted above), I've also modified the _AQI_meaning method to return an "invalid" description rather than raising exception, to allow values such as np.nan to be given as its input without raising exceptions,