Skip to content
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

WIP: RectVisual, Regular polygon visuals, and more. #284

Merged
merged 1 commit into from Jul 8, 2014

Conversation

mssurajkaiga
Copy link
Member

As a start, I have updated the EllipseVisual to support float input as radius to draw a circle. I have also replaced instances of paint with draw which wasn't done in PR #275

@@ -23,7 +22,8 @@ class Ellipse(Polygon):
default: (1,1)
"""
def __init__(self, pos=None, color=(0, 0, 0, 0), border_color=None,
radius=(0.1, 0.1), **kwds):
radius=(0.1, 0.1), start_angle=0., span_angle=360.,
num_segments=100, **kwds):
super(Ellipse, self).__init__()

glopts = kwds.pop('gl_options', 'translucent')
Copy link
Member

Choose a reason for hiding this comment

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

Try to avoid repeated code as much as possible. For example, set_gl_options is called once for each constructor, which means it is called 3 times for the RegularPolygon constructor.

@campagnola
Copy link
Member

Sorry, hadn't realized this had been updated.

@campagnola
Copy link
Member

I think this is ready for merge; it just needs to be merged with scenegraph first to resolve a minor conflict.

@mssurajkaiga
Copy link
Member Author

Sure. No problem. I'm currently working on tests for the EllipseVisual.
Also, could you explain more on the difference b/w document coordinate
system and pixel coordinate system?

With regards,
M S Suraj

On Sat, Jul 5, 2014 at 12:22 AM, Luke Campagnola notifications@github.com
wrote:

I think this is ready for merge; it just needs to be merged with
scenegraph first to resolve a minor conflict.


Reply to this email directly or view it on GitHub
#284 (comment).

@campagnola
Copy link
Member

On Fri, Jul 4, 2014 at 3:12 PM, M S Suraj notifications@github.com wrote:

Also, could you explain more on the difference b/w document coordinate
system and pixel coordinate system?

I recommend to read up on the difference between logical pixels and
physical pixels, and then read the recent additions to the transform
thread. Feel free to join that discussion if you have further questions.
We also discussed lpx/dpx some time ago:
#99 (comment)

@mssurajkaiga
Copy link
Member Author

Thanks.

With regards,
M S Suraj

On Sat, Jul 5, 2014 at 6:28 AM, Luke Campagnola notifications@github.com
wrote:

On Fri, Jul 4, 2014 at 3:12 PM, M S Suraj notifications@github.com
wrote:

Also, could you explain more on the difference b/w document coordinate
system and pixel coordinate system?

I recommend to read up on the difference between logical pixels and
physical pixels, and then read the recent additions to the transform
thread. Feel free to join that discussion if you have further questions.
We also discussed lpx/dpx some time ago:
#99 (comment)


Reply to this email directly or view it on GitHub
#284 (comment).

@mssurajkaiga
Copy link
Member Author

@lcampagn Here's a sample test that uses a reference image and checks if the visual data is same as that. I was thinking of adding a diff based comparison with some tolerance level for other tests. Since vispy.util.dataio does not have an image comparison function, I think it would be appropriate if I add it there. WDYT?

Also, a373cd4 adds requires_img_lib decorator which is not in scenegraph branch. If available, it would remove out a few lines of code from future visual tests.

@larsoner
Copy link
Member

larsoner commented Jul 8, 2014

If the goal is to use it for testing, my vote would be to put it in vispy.testing so we can just do something like:

from vispy.testing import assert_image_almost_equal

Assuming we can settle on a reasonable API for the function, this would work well. I had in mind checking the maximal value of a cross-correlation, since this would allow for small shifts/inaccuracies. But we might have to experiment with different ideas to get it to work.

Note that a diff-with-tolerance is exactly what from numpy.testing import assert_allclose and assert_array_almost_equal are both designed for, so if that's "good enough" for now, just use one of those (I prefer assert_allclose, it's more flexible).

Regarding the requires_img_lib, that can be settled the next time @lcampagn does a merge with upstream -- I'd leave it separate / duplicated for now.

@campagnola
Copy link
Member

Note: image data should not be added to the main repository. For this PR, you should backtrack to the last commit before the image was added, and re-commit from there without the image. I have opened a new vispy/test-data repository that you can push test data into, and the test should attempt to download the test data from there if it is not already available. (see https://github.com/vispy/vispy/blob/master/vispy/util/_data.py#L21, perhaps that can be modified to facilitate this?) @eric, perhaps we should discuss a basic system for enabling this kind of testing throughout vispy.

@larsoner
Copy link
Member

larsoner commented Jul 8, 2014

@lcampagn that should be pretty easy. We already have functions for downloading data for examples, should be straightforward to adapt that to download test data (and save to disk permanently) on demand.

@campagnola
Copy link
Member

I wonder if, for testing purposes, it might be better to just use git to synchronize the complete set of test results? Then when we run make test it could do a pull to check for new images immediately before testing.. We run into a weird issue, though, where tests that used to pass on one commit will no longer pass if the test data is updated..

@campagnola
Copy link
Member

Perhaps we should continue this discussion over at #89 .

@campagnola
Copy link
Member

Strike that, #156 is closer.

@mssurajkaiga
Copy link
Member Author

@lcampagn My bad. I will re-commit.
@Eric89GXL For now I will try tests with assert_allclose but as more visuals and features get added, it would be good to have an API for better image comparison algorithms.

@mssurajkaiga
Copy link
Member Author

@lcampagn Can this be merged? I think it would be better if I wrote all the tests in a different PR.

@campagnola
Copy link
Member

Agreed.
However, can't merge yet--the image is still in the commit history. Reverting and adding new commits does not remove the prior commits (the point is to minimize growth of the repository over time, so we try to make sure images are not added anywhere in the history). The last commit without the image was 3c00645, so I think this should work:

git checkout 3c00645
git checkout -b more-visuals-clean
git checkout more-visuals ./
git commit
git push -f origin more-visuals-clean:more-visuals

Normally push -f is dangerous, but in this case we know that nobody else has based new work on the commits that will be forced out.

@larsoner
Copy link
Member

larsoner commented Jul 8, 2014

You could also use this if you want:

$ git checkout more-visuals-clean
$ git rebase -i HEAD~2  # during this interactive rebase, delete the offending commit(s)
$ git push origin --force more-visuals-clean:more-visuals

git usually provides a few different options for these sorts of things.

@campagnola
Copy link
Member

Grazie!

campagnola added a commit that referenced this pull request Jul 8, 2014
WIP: RectVisual, Regular polygon visuals, and more.
@campagnola campagnola merged commit 0bd9adb into vispy:scenegraph Jul 8, 2014
@campagnola
Copy link
Member

Request: for a future PR, can we add properties like Ellipse.radius, Polygon.border, Polygon.fill_color, etc? Ideally, changing any of these properties should call Visual.update() to inform listeners that the visual needs to be redrawn, and should delay rebuilding the geometry until Visual.draw() is called.

@mssurajkaiga
Copy link
Member Author

Sure. I will keep it in mind.
Also, dumb question, I'm not able to fork the 'test-data' repo. Is this an issue from github end?

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.

None yet

3 participants