PolicyEngine / policyengine-uk

The UK's only open-source static tax-benefit microsimulation model.
https://policyengine.github.io/policyengine-uk/
GNU Affero General Public License v3.0
23 stars 24 forks source link

`test_validity.py::test_not_nan` throwing `RuntimeWarning: invalid value encountered in true_divide` #422

Open MaxGhenis opened 2 years ago

MaxGhenis commented 2 years ago

e.g. see this from the latest successful test run:

openfisca_uk/tests/microsimulation/test_validity.py::test_not_nan[2019]
  /home/runner/work/openfisca-uk/openfisca-uk/openfisca_uk/variables/consumption/property.py:83: RuntimeWarning: invalid value encountered in true_divide
    / residential_sd.transactions_by_age.calc(age)

openfisca_uk/tests/microsimulation/test_validity.py::test_not_nan[2017]
openfisca_uk/tests/microsimulation/test_validity.py::test_not_nan[2018]
  /home/runner/work/openfisca-uk/openfisca-uk/openfisca_uk/variables/wealth/land.py:78: RuntimeWarning: divide by zero encountered in true_divide
    land.value.aggregate_corporate_land_value / total_corporate_wealth

openfisca_uk/tests/microsimulation/test_validity.py::test_not_nan[2017]
openfisca_uk/tests/microsimulation/test_validity.py::test_not_nan[2018]
  /home/runner/work/openfisca-uk/openfisca-uk/openfisca_uk/variables/wealth/land.py:51: RuntimeWarning: divide by zero encountered in true_divide
    land.value.aggregate_household_land_value / total_property_wealth
nikhilwoodruff commented 2 years ago

OK yep - for context, this here isn't because there is any actual divide by zero used: when deriving the intensities of land and carbon emissions, we check if there is property wealth provided, and if not, use a failsafe parameter. But numpy still evaluates the divide by zero, even when it's not chosen by the where clause. I'll take it out