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

climate._target_region incorrectly extracts misaligned column #278

Open
shimon-sato opened this issue Sep 1, 2022 · 2 comments
Open

climate._target_region incorrectly extracts misaligned column #278

shimon-sato opened this issue Sep 1, 2022 · 2 comments
Assignees

Comments

@shimon-sato
Copy link

There seems to be a problem with the climate.target_region function which incorrectly extracts one column to the right of the intended one.
https://github.com/mathurinm/celer/blob/main/celer/datasets/climate.py#L60-L72

The pos_Lx value range is supposed to be 0~143, but it is 0~144.
For example, if Lx is 359, pos_Lx will be 144.

Shouldn't we use np.floor insted of np.ceil?

@Badr-MOUFAD
Copy link
Collaborator

Hi @shimon-sato, thanks for reporting that.
Could you provide a code snippet that reproduces this behavior?

@shimon-sato
Copy link
Author

shimon-sato commented Sep 2, 2022

Thanks for the reply. Reproduce codes are listed below.

Testing Environment

  • Python 3.10.4
  • Celer 0.7.2.dev0
  • numpy 1.23.0

minimum example

import numpy as np

Lx = 359
pos_Lx = (np.ceil(Lx / 2.5)).astype(int)
assert 0 <= pos_Lx <= 143

result

AssertionError

via climate._target_region

from numpy import testing
from celer import datasets

_, y1 = datasets.climate._target_region(90, 359)
_, y2 = datasets.climate._target_region(87.5, 0)
# This code means `assert not assert_array_equal`
testing.assert_raises(AssertionError, testing.assert_array_equal, y1, y2)  

result

AssertionError: AssertionError not raised by assert_array_equal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants