Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix some C++ warnings#10383

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
anntzer merged 8 commits intomatplotlib:masterfromQuLogic:c-warnings
Feb 17, 2018
Merged

Fix some C++ warnings#10383

anntzer merged 8 commits intomatplotlib:masterfromQuLogic:c-warnings
Feb 17, 2018

Conversation

QuLogic
Copy link
Member

PR Summary

This fixes various minor type conversion and other casting warnings. It is not completely clean now, but saves about 100 lines of warnings in every AppVeyor build.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@@ -109,8 +109,13 @@ int convert_double(PyObject *obj, void *p)
int convert_bool(PyObject *obj, void *p)
{
bool *val = (bool *)p;
int ret;
Copy link
Contributor

Choose a reason for hiding this comment

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

just change the signature of convert_bool toint convert_bool(PyObject *obj, bool *p)?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

All of the convert functions usevoid*.

Copy link
Contributor

Choose a reason for hiding this comment

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

not convinced that they should but I guess that's another project...

@@ -387,7 +392,7 @@ int convert_path(PyObject *obj, void *pathp)
if (should_simplify_obj == NULL) {
goto exit;
}
should_simplify = PyObject_IsTrue(should_simplify_obj);
should_simplify = PyObject_IsTrue(should_simplify_obj) != 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps use convert_bool? dunno

@@ -430,7 +430,7 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg
offsets,
offset_trans,
facecolors,
antialiased,
antialiased != 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be simpler (throughout) to make antialiased a bool?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Done, mostly.

@@ -1008,7 +1008,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
gc.isaa = antialiaseds(i % Naa);

transformed_path_t tpath(path, trans);
nan_removed_t nan_removed(tpath, true, has_curves);
nan_removed_t nan_removed(tpath, true, has_curves != 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

make has_curves a bool?

case Edge_N: return BOUNDARY_N(quad_edge.quad);
case Edge_W: return BOUNDARY_W(quad_edge.quad);
case Edge_S: return BOUNDARY_S(quad_edge.quad);
case Edge_E: return BOUNDARY_E(quad_edge.quad) != 0;
Copy link
Contributor

@anntzeranntzerFeb 6, 2018
edited
Loading

Choose a reason for hiding this comment

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

modify the macro accordingly?
(same comment applies more or less throughout)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Fixed.

"norm :float, optional\n"
"The norm for the interpolation function. Default is 0.\n\n"
"norm :bool, optional\n"
"Whether to norm the interpolation function. Default is 0.\n\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

default is false

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@anntzeranntzer left a comment

Choose a reason for hiding this comment

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

few more comments left to be addressed (make macros return bools, etc) but already an improvement.

@QuLogicQuLogicforce-pushed thec-warnings branch 3 times, most recently fromcd50cd3 tofa5e2a3CompareFebruary 6, 2018 09:30
@dopplershift
Copy link
Contributor

Test failure doesn't look spurious.

@QuLogic
Copy link
MemberAuthor

It is; that one fails sporadically due to some filename re-use. I've been meaning to look into it...

@tacaswell
Copy link
Member

Do we want to hold off on this until we get a 2.2 rc tagged?

@tacaswelltacaswell added this to thev3.0 milestoneFeb 7, 2018
@dopplershift
Copy link
Contributor

I don't think it needs to wait--but your asking gives me pause on clicking the button now...

@QuLogic
Copy link
MemberAuthor

BTW, in Python 3.3,PyArg_ParseTupleAndKeywords now supports ap type which returns a boolean value as anint. However, then we'd have to do a!= 0 thing to avoid the warnings again. Not sure if that's better or worse than the converter function we have now.

@anntzer
Copy link
Contributor

btw do you really have a warning on implicitly casting a number to a bool? (dunno, just asking)

@QuLogic
Copy link
MemberAuthor

@QuLogic
Copy link
MemberAuthor

Can merge now?

setupext.py Outdated
]
ext = make_extension('matplotlib.ft2font', sources)
FreeType().add_flags(ext)
Numpy().add_flags(ext)
LibAgg().add_flags(ext)
Copy link
Contributor

Choose a reason for hiding this comment

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

so libagg became a "dep" of ft2font via py_converters? probably not a big deal but yuck... now that we're py3 only we may as well use thep converter flag instead of convert_bool, if that avoids the additional internal dep.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

py_converters has Agg stuff in it so includes its headers, and then we need to add its flags... I think I can split them up so that this isn't necessary.

Usingp will still produce anint which caused the warnings on AppVeyor.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Though maybe I'd wait for#10426 so I don't have to worry about the old backends.

Copy link
Contributor

Choose a reason for hiding this comment

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

but we can just do the cast of the result ofp ourselves?
I don't want to force you to overengineer this, the addition of agg as a dependency only somewhat annoys me.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

But then we'd need all the!= 0 that you didn't like, no? BecauseMSVC didn't like(bool)var either...

Copy link
Contributor

Choose a reason for hiding this comment

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

if an explicit typecast triggers a warning that seems a bit too much but can't do anything about it :/ I guess that sort of forces towards using!= 0 (or!!x) then...

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

If it helps you feel a little better, I also stopped it adding Agg sources to these extensions, which was unnecessary.

This prevents a bunch of repeated warnings since these headers areincluded multiple times.
This prevents a warning casting from double to float if the variable isnot double.
It only accepts a boolean on the Python side, but this is not enforcedon the C++ side. This causes many casting warnings since it's usedmultiple times calling various filters that only take a `bool`.
No need to cast the int before dividing, because the divisor is adouble. It is necessary to cast the entire expression though, since thestorage variable is only a float.
@QuLogic
Copy link
MemberAuthor

Rebased and tweaked setup a little so Agg sources don't get built into the new ones.

@anntzer
Copy link
Contributor

good to go once appveyor passes

@anntzeranntzer merged commit96c2876 intomatplotlib:masterFeb 17, 2018
@QuLogicQuLogic deleted the c-warnings branchFebruary 17, 2018 20:45
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

@dopplershiftdopplershiftdopplershift approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

4 participants
@QuLogic@dopplershift@tacaswell@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp