Skip to content

BLD: fix build warnings #26757

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 8 commits into from
Jun 12, 2019
Merged

BLD: fix build warnings #26757

merged 8 commits into from
Jun 12, 2019

Conversation

jbrockmendel
Copy link
Member

xref #25995, #17936

AFAICT these warnings are caused by cython casting len(some_ndarray) to int or Py_ssize_t but casting len(some_memoryview) to size_t. Easiest fix is to declare the affected len variables as size_t since we know they'll never be negative.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26757 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26757      +/-   ##
==========================================
- Coverage   91.71%    91.7%   -0.01%     
==========================================
  Files         178      178              
  Lines       50740    50740              
==========================================
- Hits        46538    46533       -5     
- Misses       4202     4207       +5
Flag Coverage Δ
#multiple 90.3% <ø> (ø) ⬆️
#single 41.21% <ø> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.84% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f3e8e8...8ac7bb9. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26757 into master will increase coverage by 1.4%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #26757     +/-   ##
=========================================
+ Coverage   90.35%   91.76%   +1.4%     
=========================================
  Files         178      178             
  Lines       50753    50753             
=========================================
+ Hits        45859    46571    +712     
+ Misses       4894     4182    -712
Flag Coverage Δ
#multiple 90.35% <ø> (ø) ⬆️
#single 41.04% <ø> (?)
Impacted Files Coverage Δ
pandas/core/arrays/categorical.py 95.92% <0%> (+0.12%) ⬆️
pandas/core/indexes/datetimes.py 96.37% <0%> (+0.16%) ⬆️
pandas/io/formats/printing.py 85.56% <0%> (+1.06%) ⬆️
pandas/io/clipboard/clipboards.py 34.78% <0%> (+2.89%) ⬆️
pandas/core/computation/expr.py 97.8% <0%> (+3.02%) ⬆️
pandas/core/computation/common.py 89.47% <0%> (+5.26%) ⬆️
pandas/io/pytables.py 90.29% <0%> (+26.47%) ⬆️
pandas/core/computation/pytables.py 90.24% <0%> (+27.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 646ff0b...5228964. Read the comment docs.

@WillAyd
Copy link
Member

WillAyd commented Jun 10, 2019

Hmm understood that these would never be negative but since Py_ssize_t is what Python would use for indexing that still seems like the more natural data type to use. Is there not a way to silence these warnings while still using that type for indexers?

@WillAyd WillAyd added the Clean label Jun 10, 2019
@jbrockmendel
Copy link
Member Author

@scoder any thoughts on whether this is worthwhile and if not, how to silence the warnings?

@scoder
Copy link

scoder commented Jun 10, 2019

size_t, or, more generally, unsigned integer types in C, have their advantages and disadvantages. Special use cases like bit manipulation aside, it's nice that they explicitly state that their value cannot be lower than zero. On the downside, they mix badly with C's default (signed) integer behaviour and signed arithmetic in general, and fail to support Python's negative indexing.

I think Py_ssize_t is the most obvious return type for len(), and memory views shouldn't diverge from this. This is something we can change in Cython 3.0. If you have an opinion, please discuss it at
cython/cython#2992

As for a work-around for now, it's probably best to explicitly cast the return values to Py_ssize_t, at least where it's not used in an unsigned context anyway.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

we are consistently using Py_ssize_t, adding in size_t is confusing.

@jbrockmendel
Copy link
Member Author

Updated to use Py_ssize_t consistently

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

import comment, otherwise lgtm. ping on green.

@jreback jreback added this to the 0.25.0 milestone Jun 12, 2019
@jreback
Copy link
Contributor

jreback commented Jun 12, 2019

lgtm. merge on green (and close the issues above if this & others cover)

@jbrockmendel
Copy link
Member Author

and close the issues above if this & others cover

There's still a bunch in interval.pyx that I'm not sure are purely cosmetic (cc @jschendel)

@jreback jreback merged commit 429078b into pandas-dev:master Jun 12, 2019
@jreback
Copy link
Contributor

jreback commented Jun 12, 2019

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bldwarns2 branch June 12, 2019 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants