Skip to content

TST: Add tests for deprecated C functions (PyArray_As1D, PyArray_As1D) #14223

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

Merged
merged 2 commits into from
Sep 19, 2019

Conversation

kritisingh1
Copy link
Member

@kritisingh1 kritisingh1 commented Aug 7, 2019

Followup to #14036 , related to #11521

PyObject* temp = PyArray_As2D((PyObject **)&arg1, (char ***)&arg2, (int *)4, (int *)6, NPY_DOUBLE);
return NULL;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the compiler is complaining that you never use temp. Either return it or call Py_DECREF(temp)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface to PyArray_AsCArray is very strange - it modifies the first argument, replacing it with the result of PyArray_FromAny but only if it returns success. In the tests this doesn't matter, since the first argument is a valid ndarray so the value returned from PyArray_FromAny is the same as the input, but in these tests (if successful) it would have changed result.

All that is irrelevant since the deprecated functions fail, but I tried to use a correct approach for the unused branch anyway.

@kritisingh1 kritisingh1 force-pushed the dep-tests branch 5 times, most recently from 9091d76 to 1740a75 Compare August 9, 2019 20:56
@seberg seberg self-requested a review August 9, 2019 21:08
@kritisingh1 kritisingh1 force-pushed the dep-tests branch 2 times, most recently from 0ee2c50 to 98f079a Compare August 18, 2019 20:58
@mattip mattip added the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Aug 19, 2019
@mattip
Copy link
Member

mattip commented Aug 19, 2019

Since #14036 did not add a release note, this PR should

@kritisingh1
Copy link
Member Author

Have updated the PR with release notes, though shippable builds are failing.

PyObject **result = Py_BuildValue("i", 42);
int dim = 4;
double arg[2] = {1, 2};
int temp = PyArray_As1D(result, (char **)&arg, &dim, NPY_DOUBLE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define result as PyObject * and use &result here. (and below) The shippable tests are just broken, but the Travis failures are real due to compiler warnings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I overwrote Matti's changes by force-pushing the commit without pulling :(

@mattip mattip merged commit 7618f19 into numpy:master Sep 19, 2019
@mattip
Copy link
Member

mattip commented Sep 19, 2019

Thanks @kritisingh1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
05 - Testing 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes component: numpy._core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants