8000 doc/implementation mismatch for path.get_path_collection_extents() by mdboom · Pull Request #845 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

doc/implementation mismatch for path.get_path_collection_extents() #845

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
Apr 27, 2012

Conversation

mdboom
Copy link
Member
@mdboom mdboom commented Apr 19, 2012

Docstring for matplotlib.path.get_path_collection_extents() states "Given a sequence of :class:Path objects, returns the bounding box that encapsulates all of them." and the subsequent code passes *args to the CXX wrapper to the function in _path.cpp. However, the call signature and documentation for the CXX wrapped function is entirely different:

        add_varargs_method("get_path_collection_extents", &_path_module::get_path_collection_extents,
                           "get_path_collection_extents(trans, paths, transforms, offsets, offsetTrans)");

And the implementation does a check for 5 arguments and expects more than just a list of Path objects:

    args.verify_length(5);

    //segments, trans, clipbox, colors, linewidths, antialiaseds
    agg::trans_affine       master_transform = py_to_agg_transformation_matrix(args[0].ptr());
    Py::SeqBase<Py::Object> paths            = args[1];
    Py::SeqBase<Py::Object> transforms_obj   = args[2];
    Py::Object              offsets_obj      = args[3];
    agg::trans_affine       offset_trans     = py_to_agg_transformation_matrix(args[4].ptr(), false);

Since it is the python function that is borked and is probably not being used right anywhere, I think it is that part that should be changed.

@ghost ghost assigned mdboom Apr 19, 2012
@mdboom
Copy link
Member
mdboom commented Apr 19, 2012

The Python function is used internally from collections.py. I think we just need to change the docstring to match reality.

@WeatherGod
Copy link
Member Author

Correct, and also fix the usage of it in the python function. Currently,
it is using the CXX function incorrectly and throws an exception.

@mdboom
Copy link
Member
mdboom commented Apr 19, 2012

I'm not sure I follow. The Python function get_path_collection_extents is forwarding its arguments along to the C++ function using *args. This is called from Collection.get_datalim and appears to be working in that context. (Run the examples/pylab_examples/ellipse_collection.py example with a breakpoint there, for example).

Is there some other code path that produces an exception?

@WeatherGod
Copy link
Member Author

I'm sorry, you are right. My mind was sticking with the idea that *args
was the sequence of Path objects, rather than args[1] being the sequence.
Updating the docstring (and possibly improving the call signature to be
clearer?) should be sufficient.

@mdboom
Copy link
Member
mdboom commented Apr 19, 2012

See the attached PR. It's a little bit of an odd function -- basically meant to handle the incredibly flexible nature of path collections in fast C++ code. I've added a function that's a little closer to what most users would want which is just a convenience wrapper around it.

@WeatherGod
Copy link
Member Author

Sorry for the delay. Looking over the code, it looks good (not tested, but there shouldn't be any issues). My only concern are the class references in the docstrings. I haven't had a chance to attempt building the docs, but I doubt that those class refs will resolve.

@mdboom
Copy link
Member
mdboom commented Apr 27, 2012

I've fixed the cross-references in the docstrings. I think this is probably ready to merge -- maybe you want to try the code in the context of your own use case first?

@WeatherGod
Copy link
Member Author

actually, I never had a usecase, just came across it when I was searching for something else.

mdboom added a commit that referenced this pull request Apr 27, 2012
doc/implementation mismatch for path.get_path_collection_extents()
@mdboom mdboom merged commit 0e9a04c into matplotlib:master Apr 27, 2012
@mdboom mdboom deleted the get_path_collection_extents branch March 3, 2015 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0