| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ee4f072 commit 0f204ec
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | 7 | import six | |
| 8 | 8 | ||
| 9 | + import io | ||
| 10 | + | ||
| 9 | 11 | from nose.tools import assert_equal | |
| 10 | 12 | import numpy as np | |
| 11 | 13 | from numpy.testing import assert_array_equal, assert_array_almost_equal | |
@@ -559,6 +561,22 @@ def get_transform(self): | |||
| 559 | 561 | ax.axis([-1, 1, -1, 1]) | |
| 560 | 562 | ||
| 561 | 563 | ||
| 564 | + def test_picking(): | ||
| 565 | + fig, ax = plt.subplots() | ||
| 566 | + col = ax.scatter([0], [0], [1000]) | ||
| 567 | + fig.savefig(io.BytesIO(), dpi=fig.dpi) | ||
| 568 | + | ||
| 569 | + class MouseEvent(object): | ||
| 570 | + pass | ||
| 571 | + event = MouseEvent() | ||
| 572 | + event.x = 325 | ||
| 573 | + event.y = 240 | ||
| 574 | + | ||
| 575 | + found, indices = col.contains(event) | ||
| 576 | + assert found | ||
| 577 | + assert_array_equal(indices['ind'], [0]) | ||
| 578 | + | ||
| 579 | + | ||
| 562 | 580 | if __name__ == '__main__': | |
| 563 | 581 | import nose | |
| 564 | 582 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,7 +209,7 @@ inline void points_in_path(PointArray &points, | |||
| 209 | 209 | typedef agg::conv_contour<curve_t> contour_t; | |
| 210 | 210 | ||
| 211 | 211 | size_t i; | |
| 212 | - for (i = 0; i < result.size(); ++i) { | ||
| 212 | + for (i = 0; i < points.size(); ++i) { | ||
| 213 | 213 | result[i] = false; | |
| 214 | 214 | } | |
| 215 | 215 | ||
@@ -236,8 +236,8 @@ inline bool point_in_path( | |||
| 236 | 236 | point.push_back(y); | |
| 237 | 237 | points.push_back(point); | |
| 238 | 238 | ||
| 239 | - std::vector<bool> result(1); | ||
| 240 | - result[0] = false; | ||
| 239 | + int result[1]; | ||
| 240 | + result[0] = 0; | ||
| 241 | 241 | ||
| 242 | 242 | points_in_path(points, r, path, trans, result); | |
| 243 | 243 | ||
@@ -257,7 +257,7 @@ void points_on_path(PointArray &points, | |||
| 257 | 257 | typedef agg::conv_stroke<curve_t> stroke_t; | |
| 258 | 258 | ||
| 259 | 259 | size_t i; | |
| 260 | - for (i = 0; i < result.size(); ++i) { | ||
| 260 | + for (i = 0; i < points.size(); ++i) { | ||
| 261 | 261 | result[i] = false; | |
| 262 | 262 | } | |
| 263 | 263 | ||
@@ -279,8 +279,8 @@ inline bool point_on_path( | |||
| 279 | 279 | point.push_back(y); | |
| 280 | 280 | points.push_back(point); | |
| 281 | 281 | ||
| 282 | - std::vector<bool> result(1); | ||
| 283 | - result[0] = false; | ||
| 282 | + int result[1]; | ||
| 283 | + result[0] = 0; | ||
| 284 | 284 | ||
| 285 | 285 | points_on_path(points, r, path, trans, result); | |
| 286 | 286 | ||
@@ -406,7 +406,7 @@ void point_in_path_collection(double x, | |||
| 406 | 406 | agg::trans_affine &offset_trans, | |
| 407 | 407 | bool filled, | |
| 408 | 408 | e_offset_position offset_position, | |
| 409 | - std::vector<size_t> &result) | ||
| 409 | + std::vector<int> &result) | ||
| 410 | 410 | { | |
| 411 | 411 | size_t Npaths = paths.size(); | |
| 412 | 412 | ||
@@ -432,6 +432,7 @@ void point_in_path_collection(double x, | |||
| 432 | 432 | subtrans(1, 1), | |
| 433 | 433 | subtrans(0, 2), | |
| 434 | 434 | subtrans(1, 2)); | |
| 435 | + trans *= master_transform; | ||
| 435 | 436 | } else { | |
| 436 | 437 | trans = master_transform; | |
| 437 | 438 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -309,7 +309,7 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO | |||
| 309 | 309 | agg::trans_affine offset_trans; | |
| 310 | 310 | int filled; | |
| 311 | 311 | e_offset_position offset_position; | |
| 312 | - std::vector<size_t> result; | ||
| 312 | + std::vector<int> result; | ||
| 313 | 313 | ||
| 314 | 314 | if (!PyArg_ParseTuple(args, | |
| 315 | 315 | "dddO&OO&O&O&iO&:point_in_path_collection", | |
@@ -354,8 +354,8 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO | |||
| 354 | 354 | } | |
| 355 | 355 | ||
| 356 | 356 | npy_intp dims[] = {(npy_intp)result.size() }; | |
| 357 | - numpy::array_view<size_t, 1> pyresult(dims); | ||
| 358 | - memcpy(pyresult.data(), &result[0], result.size() * sizeof(size_t)); | ||
| 357 | + numpy::array_view<int, 1> pyresult(dims); | ||
| 358 | + memcpy(pyresult.data(), &result[0], result.size() * sizeof(int)); | ||
| 359 | 359 | return pyresult.pyobj(); | |
| 360 | 360 | } | |
| 361 | 361 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments