Esempio n. 1
0
        /// <summary>
        ///     Given a given snippets collection, constructs a new magic command
        ///     that queries callables defined in that snippets collection.
        /// </summary>
        public WhoMagic(ISnippets snippets) : base(
                "who",
                new Microsoft.Jupyter.Core.Documentation
        {
            Summary     = "Lists the Q# operations available in the current session.",
            Description = @"
                    This magic command returns a list of Q# operations and functions that are available
                    in the current IQ# session for use with magic commands such as `%simulate`
                    and `%estimate`.

                    The list will include Q# operations and functions which have been defined interactively
                    within cells in the current notebook (after the cells have been executed),
                    as well as any Q# operations and functions defined within .qs files in the current folder.
                ".Dedent(),
            Examples    = new []
            {
                @"
                        Display the list of Q# operations and functions available in the current session:
                        ```
                        In []: %who
                        Out[]: <list of Q# operation and function names>
                        ```
                    ".Dedent(),
            }
        })
        {
            this.Snippets = snippets;
        }
Esempio n. 2
0
        /// <summary>
        /// IQ# Magic that enables executing the Katas on Jupyter.
        /// </summary>
        public KataMagic(IOperationResolver resolver, ISnippets snippets, ILogger <KataMagic> logger, IConfigurationSource configurationSource)
        {
            this.Name          = $"%kata";
            this.Documentation = new Microsoft.Jupyter.Core.Documentation
            {
                Summary     = "Executes a single test.",
                Description = "Executes a single test, and reports whether the test passed successfully.",
                Examples    = new []
                {
                    "To run a test called `Test`:\n" +
                    "```\n" +
                    "In []: %kata T101_StateFlip \n" +
                    "       operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n" +
                    "           // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n" +
                    "           // Type X(q);\n" +
                    "           // Then run the cell using Ctrl/⌘+Enter.\n" +
                    "\n" +
                    "           // ...\n" +
                    "       }\n" +
                    "Out[]: Qubit in invalid state. Expecting: Zero\n" +
                    "       \tExpected:\t0\n" +
                    "       \tActual:\t0.5000000000000002\n" +
                    "       Try again!\n" +
                    "```\n"
                }
            };
            this.Kind                = SymbolKind.Magic;
            this.Execute             = this.Run;
            this.ConfigurationSource = configurationSource;

            this.Resolver   = resolver;
            this.Snippets   = snippets;
            this.Logger     = logger;
            this.AllAnswers = new Dictionary <OperationInfo, OperationInfo>();
        }
Esempio n. 3
0
 public WhoMagic(ISnippets snippets) : base(
         "who",
         new Documentation {
     Summary = "Provides actions related to the current workspace."
 })
 {
     this.Snippets = snippets;
 }
Esempio n. 4
0
 public CircuitMagic(ISymbolResolver resolver, ISnippets snippets, ILogger <Workspace> logger, IReferences references) : base(
         "circuit",
         new Documentation
 {
     Summary = "Takes a given function or operation and generates the quantum circuit it represents."
 })
 {
     this.SymbolResolver   = resolver;
     this.Snippets         = (Snippets)snippets;
     this.Logger           = logger;
     this.GlobalReferences = references;
 }
Esempio n. 5
0
        /// <summary>
        /// IQ# Magic that enables executing the Katas on Jupyter.
        /// </summary>
        public KataMagic(IOperationResolver resolver, ISnippets snippets, ILogger <KataMagic> logger)
        {
            this.Name          = $"%kata";
            this.Documentation = new Documentation()
            {
                Summary = "Executes a single kata.", Full = "## Executes a single kata.\n##Usage: \n%kata Test \"q# operation\""
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Snippets = snippets;
            this.Logger   = logger;
        }
        public EntryPointGenerator(
            ICompilerService compiler,
            IWorkspace workspace,
            ISnippets snippets,
            IReferences references,
            ILogger <EntryPointGenerator> logger,
            IEventService eventService)
        {
            Compiler   = compiler;
            Workspace  = workspace;
            Snippets   = snippets;
            References = references;
            Logger     = logger;

            AssemblyLoadContext.Default.Resolving += Resolve;

            eventService?.TriggerServiceInitialized <IEntryPointGenerator>(this);
        }
Esempio n. 7
0
 /// <summary>
 ///     Constructs a new resolver that looks for symbols in a given
 ///     collection of snippets.
 /// </summary>
 /// <param name="snippets">
 ///     The collection of snippets to be used when resolving symbols.
 /// </param>
 public OperationResolver(ISnippets snippets, IWorkspace workspace, IReferences references)
 {
     this.snippets   = snippets;
     this.workspace  = workspace;
     this.references = references;
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a SymbolResolver from a Snippets implementation. Only used for testing.
 /// </summary>
 internal OperationResolver(Snippets snippets)
 {
     this.snippets   = snippets;
     this.workspace  = snippets.Workspace;
     this.references = snippets.GlobalReferences;
 }
Esempio n. 9
0
 public SnippetsController(ISnippets snippets) : base()
 {
     this.Snippets = snippets;
 }
Esempio n. 10
0
 public SnippetsController(ISnippets snippets, IWorkspace workspace) : base()
 {
     this.Snippets  = snippets;
     this.Workspace = workspace;
 }