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

MAINT: resolve UPDATEIFCOPY deprecation errors #8150

Merged
merged 11 commits into from Nov 17, 2017
Merged

MAINT: resolve UPDATEIFCOPY deprecation errors #8150

merged 11 commits into from Nov 17, 2017

Conversation

ghost
Copy link

@ghost ghost commented Nov 12, 2017

Closes #8145.

@ghost
Copy link
Author

ghost commented Nov 12, 2017

This should be ready to go. It will start working right after the API version is bumped.

@ghost
Copy link
Author

ghost commented Nov 12, 2017

See here for the passing tests: https://travis-ci.org/scipy/scipy/jobs/301100231

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

My review simply suggests cleaning up the C preprocessor code a little bit.

It may also be helpful to briefly summarize why the current Travis test matrix can't pass with this PR if there's some strange reason for that (I understand there's some tricky low level stuff going on so maybe just a quick note on that so we know it is ok or not).

@@ -190,6 +194,9 @@ static PyObject *Py_Correlate1D(PyObject *obj, PyObject *args)

NI_Correlate1D(input, weights, axis, output, (NI_ExtendMode)mode, cval,
origin);
#if NPY_API_VERSION >= 0x0000000c
PyArray_ResolveWritebackIfCopy(output);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

This C preprocessor if / endif block is used quite a lot in this PR in different places. Could it perhaps be helpful from a maintenance / code duplication standpoint to abstract the preprocessor code to a single macro declaration at the top of the C module, or perhaps even better in one of the associated header files that is included?

Copy link
Member

@pv pv Nov 13, 2017

Choose a reason for hiding this comment

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

Yes, HAVE_WRITEBACKIFCOPY or similar please

@ghost
Copy link
Author

ghost commented Nov 14, 2017

The Travis-CI is not passing because of numpy/numpy#10014. There is no action required in SciPy.

#if NPY_API_VERSION >= 0x0000000c
#define HAVE_WRITEBACKIFCOPY
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this really changes much. Rather, I think the idea is to define a macro here. Probably something like this:

#define HAVE_WRITEBACKIFCOPY(output)  if ( NPY_API_VERSION >= 0x0000000c ) \
                                         PyArray_ResolveWritebackIfCopy(output);

And then just a single HAVE_WRITEBACKIFCOPY(output) statement should suffice at the various locations where there are the ifdef blocks I think. Just have to be careful with the preprocessor literal substitutions (my syntax might be slightly off).

Copy link
Author

Choose a reason for hiding this comment

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

That's not going to work, as the symbol will not be resolved at compile-time.

@pv
Copy link
Member

pv commented Nov 14, 2017 via email

@pv
Copy link
Member

pv commented Nov 14, 2017 via email

@ghost
Copy link
Author

ghost commented Nov 14, 2017

@pv Done.

@ghost ghost closed this Nov 14, 2017
@ghost ghost reopened this Nov 14, 2017
@ghost ghost closed this Nov 17, 2017
@ghost ghost reopened this Nov 17, 2017
@ghost
Copy link
Author

ghost commented Nov 17, 2017

Hopefully that will fix the stupid typos that I made.

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

Ok, the full CI suite is passing & I see that upstream numpy fixes have been applied as well. I'm +1 to merge as long as @pv is happy with the preprocessor adjustments (looks like his comments were addressed).

@pv pv merged commit 73f723a into scipy:master Nov 17, 2017
@pv
Copy link
Member

pv commented Nov 17, 2017

Thanks, merged.

Code style nit: typically # preprocessor macros don't follow indentation rules, # is first character on a line.

@pv pv added this to the 1.1.0 milestone Nov 17, 2017
@ghost ghost deleted the patch-1 branch November 17, 2017 21:23
@ghost
Copy link
Author

ghost commented Nov 17, 2017

Code style nit: typically # preprocessor macros don't follow indentation rules, # is first character on a line.

I'm aware of that, and it's very frustrating. When I'm reading C code, I always have to spend an extra few seconds matching the preprocessor definitions. Who came up with this rule?

@rgommers rgommers added the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Mar 18, 2018
@rgommers
Copy link
Member

backporting this to 1.0.x, it fixes a lot of test errors there

rgommers pushed a commit to rgommers/scipy that referenced this pull request Mar 18, 2018
@rgommers rgommers mentioned this pull request Mar 18, 2018
rgommers pushed a commit to rgommers/scipy that referenced this pull request Mar 18, 2018
@rgommers rgommers modified the milestones: 1.1.0, 1.0.1 Mar 23, 2018
@rgommers rgommers removed the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants