-
Notifications
You must be signed in to change notification settings - Fork 5
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
Internal refactor of figures and views #231
Conversation
@@ -98,7 +98,7 @@ def is_sphinx_build() -> bool: | |||
|
|||
def copy_figure(fig: FigureLike, **kwargs) -> FigureLike: | |||
out = fig.__class__( | |||
fig._fig_constructor, | |||
fig._view.__class__, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case we are not keeping the callable anymore,
should we make sure if the _view.__class__
is the View
in def __init_figure__(self, View, *args, **kwargs):
...?
For example,
class FigBase:
def __init_figure__(self, View, *args, **kwargs):
self._view = View(*args, **kwargs)
if not self._view.__class__ is View:
raise TypeError
Cause, you might have something like
@dataclasses
class Figure:
width: int
height: int
def create_figure(size) -> Figure:
return Figure(size[0], size[1])
fig = InteractiveFigure(create_figure, size=(10, 10))
In this case above, it will create the fig
as intended, but copy_figure
will not work.
Or is it too much of worry...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any user should every be constructing InteractiveFig
manually, so I would say in this case it is not worth worrying about?
Internally, it has gotten quite confusing what is a
Figure
and what is aView
.Figure currently refers to multiple things:
plot
function (and similar) which contains another "figure" inside, and maybe a toolbar alsoFigLine
or aFigImage
, which contains a canvasFigLine
's canvas.This is getting difficult to navigate.
This PR proposes to move things around and rename for (hopefully) improved clarity:
FigLine
andFigImage
and now called views:LineView
&ImageView
plot
function is still a figure. It inherits methods from the commonFigure
mixin, which in turn inherits from theBaseFig
(now just a mixin class)fig