Recap: in the `pressure` property there is a test `if var1 == 0:` in order to avoid a division-by-zero exception. Current code return a pressure of 0 in that case.
It was suggested that my PR makes this a little more pythonic by usage of exception raise.
Analysis of the root cause: because last calculation is
```var1 = (1.0 + var1 / 32768.0) * self._pressure_calib[0]```
the only reason for `var1` to be 0 is `self._pressure_calib[0]` is 0. Calibration values are read at init time from registers in the chip. So the root cause probably relates to a register read problem.
Analysis of other similar codes
Bosch bme280.c (Github): if var1 == 0, return minimum valid pressure (300hPa).
Adafruit CiPy BMP280 driver:
=> initially, no tests were performed
=> In Feb, jraber implemeted return 0 in a commit named "Adopt changes from the BME280 library"
=> In Mar, jraber implemeted return minimum value in a commit named "Remove unnecessary 'if' and 'else' in the pressure property"
Adafruit CiPy BMP680 driver: not tested => ZeroDivisionError
I feel that returning silently the minimun valid pressure is not correct to draw attention on a possible hardware reliability problem. Returning 0 could make sense only if we were sure that the user was testing the return value against 0.
Alternatively, letting the ZeroDivisionError occur will not provide proper clue to the user as to the root cause of the problem and will probably lead to this issue to be raised again as a bug in GitHub.
Proposed solution:
Test against 0 and raise a ArithmeticError with message "Invalid calculation possibly related to error while reading the calibration registers"
Removed `frozenset()` on `_BME280_IIR_FILTERS`, `_BME280_MODES`, `_BME280_STANDBY_TCS`. Kept as tuples.
Removed useless `if/else` in property `pressure` (was pointed by pylint)
In FORCE mode, the sensor changes back to SLEEP after completeing a single
measurement, but we are not updating the mode internally. It's better to
always write the mode to the sensor, and trust the caller not to change it
needlessly.
Add attributes for IIR filter, standby period, operation mode,
and overscan for temperature, pressure and humidity.
Add Enum classes for the overscan, standby, and iir filter values
The calculation of dig_H5 from the calibration data did not match the
definition of the data sheet and the Bosch sample code. As a result,
the compensated relative humidity data could have been calculated wrong.