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

Remove optparse from example #655

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 5 additions & 56 deletions examples/demo/advanced/scalar_image_function_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


# Standard library imports
from optparse import OptionParser
import sys
import random

# Major library imports
Expand Down Expand Up @@ -450,8 +448,10 @@ def _colormap_changed(self):

def _num_levels_changed(self):
if self.num_levels > 3:
self.polyplot.levels = self.num_levels
self.lineplot.levels = self.num_levels
if self.polyplot is not None:
self.polyplot.levels = self.num_levels
if self.lineplot is not None:
self.lineplot.levels = self.num_levels


# HasTraits class that supplies the callable for the timer event.
Expand Down Expand Up @@ -634,56 +634,5 @@ def show_plot(**kwargs):
modelview.configure_traits()


def main(argv=None):

if argv is None:
argv = sys.argv

usage = "usage: %prog [options]"
parser = OptionParser(usage=usage, version="%prog 1.0")

parser.add_option(
"-c",
"--colormap",
action="store",
type="string",
dest="colormap",
default="viridis",
metavar="CMAP",
help="choose a default colormapper",
)

parser.add_option(
"-n",
"--nlevels",
action="store",
type="int",
dest="num_levels",
default=15,
help="number countour levels to plot [default: %default]",
)

parser.add_option(
"-f",
"--function",
action="store",
type="string",
dest="function",
default="tanh(x**2+y)*cos(y)*jn(0,x+y*2)",
help="function of x and y [default: %default]",
)

opts, args = parser.parse_args(argv[1:])

if len(args) > 0:
parser.error("Incorrect number of arguments")

show_plot(
colormap=opts.colormap,
num_levels=opts.num_levels,
function=opts.function,
)


if __name__ == "__main__":
sys.exit(main())
show_plot()