Commit 4b5c95dc authored by Sean Leavey's avatar Sean Leavey

Add warnings when incompatible flags are specified

parent 6b7eb7e4
...@@ -56,20 +56,22 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i ...@@ -56,20 +56,22 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i
"""Base CLI command group""" """Base CLI command group"""
kat = katparser() kat = katparser()
kat.load(file.name) kat.load(file.name)
has_xaxis = hasattr(kat, "xaxis") has_xaxis = hasattr(kat, "xaxis") and not noxaxis
if ignored_blocks: if ignored_blocks:
for block in ignored_blocks: for block in ignored_blocks:
kat.removeBlock(block) kat.removeBlock(block)
if display_graph:
from .tools.plotting.graph import NodeGraph
nodegraph = NodeGraph(kat)
nodegraph.view_pdf()
if simulate: if simulate:
if xstart is not None or xstop is not None or xsteps is not None or xscale is not None: if xstart is not None or xstop is not None or xsteps is not None or xscale is not None:
if not has_xaxis: if not has_xaxis:
click.echo("Limits can only be overridden when an xaxis is defined in FILE.", click.echo("Limits can only be overridden when an xaxis is defined in FILE and "
err=True) "when --noxaxis is unset.", err=True)
sys.exit(1)
if noxaxis:
click.echo("Limits can only be set when --noxaxis is unset.", err=True)
sys.exit(1) sys.exit(1)
# Override xaxis. # Override xaxis.
limits = kat.xaxis.limits limits = kat.xaxis.limits
...@@ -88,8 +90,12 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i ...@@ -88,8 +90,12 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i
if set_limits: if set_limits:
kat.xaxis.limits = np.array(limits).astype(float) kat.xaxis.limits = np.array(limits).astype(float)
if noxaxis: if not has_xaxis:
kat.noxaxis = True kat.noxaxis = True
if save_figure is not None:
click.echo("Cannot plot or save figure without an xaxis defined in FILE.",
err=True)
sys.exit(1)
if maxtem: if maxtem:
kat.maxtem = maxtem kat.maxtem = maxtem
...@@ -110,16 +116,7 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i ...@@ -110,16 +116,7 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i
if kat.trace: if kat.trace:
click.echo(results.stdout) click.echo(results.stdout)
if has_xaxis: if has_xaxis and (plot or save_figure is not None):
if plot or save_figure is not None: results.plot(show=plot, filename=save_figure)
results.plot(show=plot, filename=save_figure) elif not kat.trace and not display_graph:
else: click.echo("No output requested.")
if save_figure is not None:
click.echo("Cannot plot or save figure without an xaxis defined in FILE.",
err=True)
sys.exit(1)
if display_graph:
from .tools.plotting.graph import NodeGraph
nodegraph = NodeGraph(kat)
nodegraph.view_pdf()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment