{"action":"created","issue":{"url":"https://api.github.com/repos/CellProfiler/centrosome/issues/74","repository_url":"https://api.github.com/repos/CellProfiler/centrosome","labels_url":"https://api.github.com/repos/CellProfiler/centrosome/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/CellProfiler/centrosome/issues/74/comments","events_url":"https://api.github.com/repos/CellProfiler/centrosome/issues/74/events","html_url":"https://github.com/CellProfiler/centrosome/pull/74","id":232592667,"number":74,"title":"Feature/faster zernike","user":{"login":"oleksandr-pavlyk","id":21087696,"avatar_url":"https://avatars3.githubusercontent.com/u/21087696?v=3","gravatar_id":"","url":"https://api.github.com/users/oleksandr-pavlyk","html_url":"https://github.com/oleksandr-pavlyk","followers_url":"https://api.github.com/users/oleksandr-pavlyk/followers","following_url":"https://api.github.com/users/oleksandr-pavlyk/following{/other_user}","gists_url":"https://api.github.com/users/oleksandr-pavlyk/gists{/gist_id}","starred_url":"https://api.github.com/users/oleksandr-pavlyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleksandr-pavlyk/subscriptions","organizations_url":"https://api.github.com/users/oleksandr-pavlyk/orgs","repos_url":"https://api.github.com/users/oleksandr-pavlyk/repos","events_url":"https://api.github.com/users/oleksandr-pavlyk/events{/privacy}","received_events_url":"https://api.github.com/users/oleksandr-pavlyk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-05-31T14:53:11Z","updated_at":"2017-06-08T18:56:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CellProfiler/centrosome/pulls/74","html_url":"https://github.com/CellProfiler/centrosome/pull/74","diff_url":"https://github.com/CellProfiler/centrosome/pull/74.diff","patch_url":"https://github.com/CellProfiler/centrosome/pull/74.patch"},"body":"1. Small improvements to `construct_zernike_lookuptable`\r\n   fixing potential problem manifesting itself when input\r\n   order exceeded 100.\r\n\r\n   Avoided using power to compute (-1)**k, using a variable\r\n   that was being negated at each iteration instead.\r\n\r\n2. Reworked `construct_zernike_polynomials` to avoid computation\r\n   of `arctan2(x,y)`, radial powers and complex exponentials by using\r\n   the following identity\r\n\r\n```\r\n      r**m * np.exp(1j * m * np.arctan2(x, y)) == \\\r\n         (y + 1j*x) ** m\r\n```\r\n   and taking advantage of the property of radial Zernike polynomials\r\n   that the lowest order of the radial polynomial of order (n,m) is abs(m).\r\n\r\n   This also eliminated the need to compute `np.sqrt(r_square)`.\r\n\r\n   Instead of caching `np.exp(1j*m*phi)`, code now caches `z ** m`, where\r\n   `z = y + 1j*x`\r\n\r\n   Reworked evaluation of the reduced radial Zernike polynomial\r\n   (with lowest order being 0) using more numerically accurate [Horner scheme](https://en.wikipedia.org/wiki/Horner%27s_method).\r\n\r\n3. This resulted in 8X improvement in computation of the Zernike polynomials\r\n   of order 0 through 20 inclusive for a million of random points uniformly\r\n   distributed over a unit disk. Sample output of my local benchmark script:\r\n\r\n```\r\nComputing all Zernike polynomials up to order 21\r\nComputer Zernike polynomials values at 1000000 points within unit circle\r\nnp.allclose(z_orig, z_improved) = True\r\nTimes (t_orig, t_improved) = (35.477564096450806, 4.306720972061157)\r\n```\r\n\r\n   which constitutes a factor of 8.2 improvement over the previous code."},"comment":{"url":"https://api.github.com/repos/CellProfiler/centrosome/issues/comments/307195669","html_url":"https://github.com/CellProfiler/centrosome/pull/74#issuecomment-307195669","issue_url":"https://api.github.com/repos/CellProfiler/centrosome/issues/74","id":307195669,"user":{"login":"oleksandr-pavlyk","id":21087696,"avatar_url":"https://avatars3.githubusercontent.com/u/21087696?v=3","gravatar_id":"","url":"https://api.github.com/users/oleksandr-pavlyk","html_url":"https://github.com/oleksandr-pavlyk","followers_url":"https://api.github.com/users/oleksandr-pavlyk/followers","following_url":"https://api.github.com/users/oleksandr-pavlyk/following{/other_user}","gists_url":"https://api.github.com/users/oleksandr-pavlyk/gists{/gist_id}","starred_url":"https://api.github.com/users/oleksandr-pavlyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleksandr-pavlyk/subscriptions","organizations_url":"https://api.github.com/users/oleksandr-pavlyk/orgs","repos_url":"https://api.github.com/users/oleksandr-pavlyk/repos","events_url":"https://api.github.com/users/oleksandr-pavlyk/events{/privacy}","received_events_url":"https://api.github.com/users/oleksandr-pavlyk/received_events","type":"User","site_admin":false},"created_at":"2017-06-08T18:56:57Z","updated_at":"2017-06-08T18:56:57Z","body":"The unrelated failures observed in Travis CI I was speaking of were one in `tests/test_comorphology.py`, and one in `tests/test_filter.py`. These failures cannot be reproduced locally, probably because local builds used NumPy 1.12.1, but Travis CI uses the latest NumPy 1.13.0\r\n\r\nHere is what I did for local testing:\r\n\r\n```\r\nconda create --name centrosome_test numpy Cython scipy pillow matplotlib --yes\r\nsource activate centrosome_test\r\ncd centrosome\r\ngit checkout 150b0fb71b1e5c16947f36cbf58ffba98e0721fd # latest head of feature/faster-zernike\r\npython setup.py test\r\nsource activate root\r\nconda remove --name centrosome_test --all --yes\r\n```\r\n\r\nAll tests passed, but I saw 22 warnings, some of which are reminiscent of the errors reported by Travis CI:\r\n\r\n```\r\ntests/test_filter.py::TestPoissonEquation::test_01_03_subsampling\r\n  /localdisk/work/opavlyk/projects/cellprofiler/sources/centrosome/centrosome/filter.py:1872: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 77 but corresponding boolean dimension is 75\r\n    pe[~image] = 0\r\n  /localdisk/work/opavlyk/projects/cellprofiler/sources/centrosome/centrosome/filter.py:1872: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 152 but corresponding boolean dimension is 150\r\n    pe[~image] = 0\r\n  /localdisk/work/opavlyk/projects/cellprofiler/sources/centrosome/centrosome/filter.py:1872: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 302 but corresponding boolean dimension is 300\r\n    pe[~image] = 0\r\n```\r\n"}}
{"actor":{"display_login":"oleksandr-pavlyk"}}