diff --git a/src/Jupyter/ConfigurationSource.cs b/src/Jupyter/ConfigurationSource.cs index 3ded3daaa3..15d2b403df 100644 --- a/src/Jupyter/ConfigurationSource.cs +++ b/src/Jupyter/ConfigurationSource.cs @@ -69,6 +69,13 @@ private T GetOptionOrDefault(string optionName, T defaultValue) => /// public PhaseDisplayStyle PhaseDisplayStyle => GetOptionOrDefault("dump.phaseDisplayStyle", PhaseDisplayStyle.ArrowOnly); + + /// + /// Allows for setting the default depth for visualizing Q# operations using the + /// %trace command. + /// + public int TraceVisualizationDefaultDepth => + GetOptionOrDefault("trace.defaultDepth", 1); } /// diff --git a/src/Kernel/Magic/ConfigMagic.cs b/src/Kernel/Magic/ConfigMagic.cs index db8abdf039..dd715af8ab 100644 --- a/src/Kernel/Magic/ConfigMagic.cs +++ b/src/Kernel/Magic/ConfigMagic.cs @@ -6,9 +6,7 @@ using System.Linq; using Microsoft.Jupyter.Core; -using Microsoft.Quantum.IQSharp; using Microsoft.Quantum.IQSharp.Jupyter; -using Microsoft.Quantum.IQSharp.Kernel; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -66,6 +64,12 @@ of basis states of a state vector. Configures the phase visualization style in output from callables such as `DumpMachine` or `DumpRegister`. Supports displaying phase as arrows, numbers (in radians), both, or neither. + + **`trace.defaultDepth`** + + **Value:** positive integer (default `1`) + + Configures the default depth used in the `%trace` command for visualizing Q# operations. ".Dedent(), Examples = new [] { diff --git a/src/Kernel/Magic/TraceMagic.cs b/src/Kernel/Magic/TraceMagic.cs index db7497f1f6..bbef6a8020 100644 --- a/src/Kernel/Magic/TraceMagic.cs +++ b/src/Kernel/Magic/TraceMagic.cs @@ -77,7 +77,7 @@ or function name that has been defined either in the notebook or in a Q# file in - `{ParameterNameDepth}=` (default=1): The depth at which to render operations along the execution path. ".Dedent(), - Examples = new [] + Examples = new[] { @" Visualize the execution path of a Q# operation defined as `operation MyOperation() : Result`: @@ -137,7 +137,10 @@ public async Task RunAsync(string input, IChannel channel) var symbol = SymbolResolver.Resolve(name) as IQSharpSymbol; if (symbol == null) throw new InvalidOperationException($"Invalid operation name: {name}"); - var depth = inputParameters.DecodeParameter(ParameterNameDepth, defaultValue: 1); + var depth = inputParameters.DecodeParameter( + ParameterNameDepth, + defaultValue: this.ConfigurationSource.TraceVisualizationDefaultDepth + ); if (depth <= 0) throw new ArgumentOutOfRangeException($"Invalid depth: {depth}. Must be >= 1."); var tracer = new ExecutionPathTracer(depth);