Skip to content

Commit

Permalink
Remove optparse from example (#655)
Browse files Browse the repository at this point in the history
* replace optparse with click

* remove click entirely
  • Loading branch information
aaronayres35 authored Apr 19, 2021
1 parent 4e7831c commit 4b3747d
Showing 1 changed file with 5 additions and 56 deletions.
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()

0 comments on commit 4b3747d

Please sign in to comment.