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

Fix cunumeric.arange issues #940

Merged
merged 3 commits into from
May 29, 2023
Merged

Conversation

yimoj
Copy link
Contributor

@yimoj yimoj commented May 24, 2023

Fix #531 case 1-3

Case 1 & 2:
Cause:
cuNumeric tries to create an ndarray with the shape of (ceil((stop - start)/step),) and when the value is negative we hit error from NumPy stating negative dimensions are not being allowed.

Fix:
Create empty array when the ceil is negative.

Case 3:
Cause:
cuNumeric current uses stop solely to determine out dtype and when stop is integer while the other two consist floating points there would be a precision loss.

Fix:
Infer dtype from all three arguments.

@yimoj yimoj requested a review from bryevdv May 24, 2023 07:22
@yimoj yimoj added the category:bug-fix PR is a bug fix and will be classified as such in release notes label May 24, 2023
@bryevdv
Copy link
Contributor

bryevdv commented May 24, 2023

@yimoj FYI these are the two cases failing in CI (at least in the one job I checked)

   FAILED tests/integration/test_diag_indices.py::TestDiagIndicesErrors::test_negative_n[-10.5]
   FAILED tests/integration/test_diag_indices.py::TestDiagIndicesErrors::test_negative_n[-1]

@yimoj
Copy link
Contributor Author

yimoj commented May 25, 2023

Doesn't seem to be a valid test, the behavior should have been xfailing if it were comparing the behavior with NumPy.

    @pytest.mark.parametrize("n", [-10.5, -1])
    def test_negative_n(self, n):
        with pytest.raises(ValueError):
            num.diag_indices(n)
>>> np.diag_indices(-10.5)
(array([], dtype=float64), array([], dtype=float64))
>>> num.diag_indices(-10.5)
(array([], dtype=int64), array([], dtype=int64))

I'll fix the test and see if there are more issues.

@yimoj
Copy link
Contributor Author

yimoj commented May 25, 2023

Force push is rebase from 23.07.

@yimoj yimoj merged commit 3e03357 into nv-legate:branch-23.07 May 29, 2023
@yimoj yimoj deleted the arange_dtype branch May 29, 2023 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug-fix PR is a bug fix and will be classified as such in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumPy and cuNumeric behave differently in some cases found in test_append.py and test_array_creation.py
2 participants