Skip to content

Use a plot default method instead of overriding the init method in examples part 2#709

Merged
aaronayres35 merged 14 commits into
masterfrom
dont-use-__init__-examples2
Apr 23, 2021
Merged

Use a plot default method instead of overriding the init method in examples part 2#709
aaronayres35 merged 14 commits into
masterfrom
dont-use-__init__-examples2

Conversation

@aaronayres35
Copy link
Copy Markdown
Contributor

closes #658

There are still some examples which define an __init__ method. However they either are ding something where they likely need to keep it or they belong to examples/tutorials/scipy2008/ in which I didn't touch them.

This PR also fixes many of these examples which previously had been broken (trivial changes eg defining _create_component not _create_window, or using ints instead of floats).

self.corr_plot.request_redraw()

@observe("sym1,sym2")
@observe("symbols,sym1,sym2")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was needed to get the plot to show up immediately when the application launches. Otherwise a plot would only appear after changing sym1 or sym2.

Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

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

Mostly LGTM

Comment thread examples/demo/updating_plot/updating_plot2.py Outdated
Comment thread examples/demo/updating_plot/updating_plot2.py Outdated
self.y_values = y[:]
x_values = Array()
y_values = Array()
color = Str()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not also add a trait for bgcolor like color?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is because I noticed it was never being set any time the class was instantiated. ie we would do something like AnimatedPlot(x, jn(i, x), color) and bgcolor would always just be he default.
If it is not used in this example code, and is not configurable in the UI I figured it could just be fixed

add_axis=True,
)
else:
self.x_values = x[:]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i dont know why we are passing a copy of the data x_values in one case and not in another.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was confused as well, these are also np arrays so shouldn't x[:] just be a ref to x?

Ie if x is a np array, and set y= x[:] and change y x changes as well.

Comment thread examples/demo/advanced/spec_waterfall.py
Comment thread examples/demo/basic/image_from_file.py
Comment thread examples/demo/canvas/cliptest.py
Comment thread examples/demo/updating_plot/updating_plot5.py Outdated
Comment thread examples/demo/updating_plot/updating_plot2.py
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.

Use a plot default method instead of overriding the init method in examples

2 participants