Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most recent numpy version failing tests #62

Closed
JMGilbert opened this issue Jan 10, 2023 · 9 comments
Closed

Most recent numpy version failing tests #62

JMGilbert opened this issue Jan 10, 2023 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@JMGilbert
Copy link
Contributor

In the most recent version of numpy, we need to replace ** with np.float_power

import xarray as xr
import numpy as np
dims = ["dim1", "dim2"]
array = xr.DataArray(
    data=np.array([[5.0, 10.0], [3.0, 2.0]]),
    dims=dims,
    coords=np.array([[1, 2], [3, 4]]),
)
weights = xr.DataArray(
    data=np.array([[0.4, 0.2], [0.1, 0.3]]),
    dims=dims,
    coords=np.array([[1, 2], [3, 4]]),
)  # sum of weights equals 1
eta = 10
exp = 1 / (1 - eta)
utility = np.true_divide(array ** (1 - eta), (1 - eta))
exp_utility = utility.weighted(weights).mean(dim=dims)
ce_array = (exp_utility * (1 - eta)) ** exp
print(ce_array.values == ((np.divide(array ** (1 - 10), 1 - 10) * weights).values.sum() * (1 - 10)) ** (1 / (1 - 10)))

prints False

while

import xarray as xr
import numpy as np
dims = ["dim1", "dim2"]
array = xr.DataArray(
    data=np.array([[5.0, 10.0], [3.0, 2.0]]),
    dims=dims,
    coords=np.array([[1, 2], [3, 4]]),
)
weights = xr.DataArray(
    data=np.array([[0.4, 0.2], [0.1, 0.3]]),
    dims=dims,
    coords=np.array([[1, 2], [3, 4]]),
)  # sum of weights equals 1
eta = 10
exp = 1 / (1 - eta)
utility = np.true_divide(np.float_power(array, (1 - eta)), (1 - eta))
exp_utility = utility.weighted(weights).mean(dim=dims)
ce_array = np.float_power((exp_utility * (1 - eta)), exp)
print(ce_array.values == np.float_power(((np.divide(np.float_power(array, (1 - 10)), 1 - 10) * weights).values.sum() * (1 - 10)),(1 / (1 - 10))))

returns True (the desired result)

@JMGilbert JMGilbert added the bug Something isn't working label Jan 10, 2023
@JMGilbert JMGilbert self-assigned this Jan 10, 2023
@JMGilbert
Copy link
Contributor Author

JMGilbert commented Jan 17, 2023

#63 fixes the np.float_power issue.

@JMGilbert
Copy link
Contributor Author

The risk aversion gwr damage function tests still fail for numpy 1.24.1 -- may have to do with numpy/numpy#22956

@kemccusker
Copy link
Member

dscim's dependency is pinned to numpy==1.23.3 for now

@brews
Copy link
Member

brews commented Jul 13, 2023

Yeah, I could get it to numpy==1.24.0 but beyond that it starts to fail. Afraid I can't decipher what's going on in testing. Unfortunately, the logs to the failed tests in #63 have expired.

Normally, it can be helpful to check for deprecation warnings in local tests or CI run logs in the section after CI shows test results, but before test coverage gets uploaded. This usually calls out behavior that will break in future releases. We have warnings but it's unclear to me if they are directly related.

Also, looking at numpy's changelog it's kinda weird that tests fail on v1.24.1 and not v1.24.0. Numpy v1.24.0 should have all the breaking behavior changes.

@brews
Copy link
Member

brews commented Jul 21, 2023

A reminder that #11 might be tangled into this?

@brews
Copy link
Member

brews commented Aug 7, 2023

Wat.

All the tests are now passing with numpy v1.25.2 in PR #119. Can we merge the PR and close this?

@JMGilbert
Copy link
Contributor Author

So strange... I can't think of any reasons not to merge though!

@brews
Copy link
Member

brews commented Aug 9, 2023

Cool. Thanks for the input. Merging away.

@brews
Copy link
Member

brews commented Aug 9, 2023

Closed with PR #119

@brews brews closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants