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

fix gc undeclare #883

Merged
merged 2 commits into from
Apr 7, 2023
Merged

fix gc undeclare #883

merged 2 commits into from
Apr 7, 2023

Conversation

homosapien-lcy
Copy link
Contributor

@homosapien-lcy homosapien-lcy commented Apr 4, 2023

Found that the gc (GraphicsContext) is referenced before construction in the line 136. This has caused the test chaco/chaco/examples/demo/simple_polar.py to fail.
The solution is to find the gc in the context. A gc context is actually conveniently included in the *args, thus retrieving that gc as GraphicContext to solve the problem. closes #875

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

Just add gc as the first argument to the function

@@ -133,6 +133,7 @@ def _downsample(self):
def _draw_plot(self, *args, **kw):
"""Draws the 'plot' layer."""
self._gather_points()
gc = args[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want the gc to be the first argument to the function, make it the first argument to the function!

Doing this is fragile, not self-documenting and will produce confusing error messages if used incorrectly.

@dpinte
Copy link
Member

dpinte commented Apr 6, 2023

For reference, the prototype of the _draw_plot method is defined here: https://github.com/enthought/enable/blob/main/enable/component.py#L807. You could even remove the *arg and **kwargs in favour of the ones from the prototype.

@homosapien-lcy homosapien-lcy merged commit 9ffeefb into main Apr 7, 2023
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.

NameError: name 'gc' is not defined
3 participants