As per the documentation provided by Microsoft Azure Quantum at this link , I followed the steps given and installed Q# with Jupyter Notebook, using Anaconda.
I then wrote the following Q# program in a Jupyter Notebook (IQ# kernel) using the code taken from here.
(I am currently using Google Chrome)
open Microsoft.Quantum.Diagnostics;
operation MultiQubitDumpMachineDemo() : Unit {
use qubit = Qubit();
H(qubit);
DumpMachine();
Reset(qubit);
}
When I used the magic commands such as %simulate and %trace, the program executed normally. The DumpMachine result clearly shows the qubit in a superposition of |0> and |1> (measurement probability is 50%), and the trace command printed out the quantum circuit.
%simulate Result
%trace Result
However, when I run the %debug command, the interactive HTML display does not work. The debug control button can display the circuit but, the controls for the chart options do not display the amplitudes, probabilities, or real/imaginary co-efficients.
When I opened the console, I observed the following error, every time I clicked the chart options controls:
Couldn't process kernel message TypeError: state.getDenseAmplitudes is not a function
at fitChart (bundle.js?v=20221015232727:292:32)
at Object.updateChart (bundle.js?v=20221015232727:277:9)
at update (bundle.js?v=20221015232727:811:32)
at bundle.js?v=20221015232727:850:17
at Kernel._handle_iopub_message (main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:63064:20)
at Kernel._finish_ws_message (main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:62843:29)
at main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:62834:44
Error Message
Unfortunately, I am not familiar with this type of error or its possible solutions, so I didn't try anything more than updating the 'iqsharp' package.
Can anyone explain why I'm getting this error, and, if possible, provide with me a solution for the same?
Thanks in advance!
Related
I'm getting started with cocotb.
I can run the example tests. They don't fail and cocotb terminates with success. My usual simulator is modelsim. If I start cocotb with:
make GUI=1 WAVES=1 I get the GUI of modelsim and can see the signals in the objects window. The only thing I did never get are the signals in the wave window. I can add them manually over the GUI, but this is too late. The test has already finished.
What is the correct way to select the waves I want to see?
Try setting the SCRIPT_FILE makefile variable to point to a modelsim wave.do file, which you should be able to produce from the GUI.
here are my console output examples
as you see, there are no output values when using r studio console.
Actually, there are many related issues about this, but no clear solutions. Only a temporal or Adhoc solution like: restart R or using r notebook script.
Anyway, this phenomenon happens just 1 day ago, with the same code, same operations.
At the first time, console works and a few minutes later it doesn't work.
It is so annoying me to restart or run r notebook script...
Is anybody have the same issues as me?
(I cannot give reproducible data, because it works well the other's computer)
Click on the gear icon beside knit and make sure that "chunk output in console" is enabled.
I have just switched from windows 7 to windows 10 on my pc.
When I was still using windows 7, using the combination CTRL+R or CTRL+ENTER would run the line of code that I was in. Moreover, if the code continued on one or more lines below or started above my current line, it would run the entire section without me having to select it.
After switching to windows 10, the same combinations will only run the line of code that I am currently in, or the piece of code that is selected by me. To give an example:
#Tryout
for(i in 1:3){
print(i)
}
This code would normally run at once without having to select it, even when I would start in the first line (#Tryout). Now, if I don't select, I will need to use CTRL+R or CTRL+ENTER three times to go through this code and I have to start in the correct line. Starting in the line #Tryout will not run any part of the code but will only result in the line #Tryout being shown in the console.
I'm not good with computers (in your answers please pretend to be adressing a five-year-old) so I had one of my colleagues look at it who's our expert on R. Here are the findings:
The problem occurs in both RStudio as the standalone version of R.
I'm using R version 3.3.2, the same as before the windows update. Switching to version 3.5 didn't solve the problem.
I have other colleagues also using R 3.3 in combination with windows 10 for whom this problem does not occur.
Going to Tools-Global Options-Code and checking the box of 'Focus console after executing from source' doesn't help
When we went to 'Modify Keyboard Shortcuts', the name attached to the shortcut (CTRL+R or CTRL+ENTER) was the same as it was for other colleagues for which the function does run all lines in a command: 'Run Current Line or Selection'
The problem is not preventing me from using R, but it is tedious and I hope someone can help me to solve it.
Thanks so much for reading!
Click on header Tools, then Global Options..., then Code, then Ctrl + Enter Executes and choose Multi-line R statement
#M Waz & #Just Burfi: I know I can select the code and then run it, that works fine. But I don't want to have to manually select the code all the time.
#Clemsang: your answer puzzled me for a moment because I didn't have the CTRL + Enter Executes that you were referring to. I went back to my colleague who had the bright idea to check the version of RStudio that I was using.
As it turns out, I was using an old version (0.99.903). Now that I've installed a newer version (1.1.463), running the code works as before! I also have the CTRL + Enter Executes now.
Is it possible to run something similar to a Linux R console (which uses GNU Readline) from within a C++ program using RInside? The best option would be, if such a console would have all the nice features like the autocomplete.
The background:
I have a big solver, which has a RInside-based plugin for running small chunks of R code during a simulation. It would be nice if the user would be able to switch it to "interactive" mode and check things out as they go.
Notice:
1. I cannot just run R as a separate program, as I need it to see my objects and pointers from the main code. 2. I know about callbacks in RInside, but they do not provide any console-like capabilities.
Code: I doubt it will help, but here is my code now: https://github.com/llaniewski/TCLB/blob/RInside/src/Handlers/cbRunR.cpp.Rt
I have a script with self-written functions (no plots). When I copy-paste that script into the R-Studio console, it takes ages to execute, but when I use source("Helperfunctions.R") it doesn't take more than a second.
Question: Where does the difference in speed come from?
I am aware of two differences between running code via the source() function vs. entering code at the R-Studio console:
From ?source:
Since expressions are not executed at the top level, auto-printing is not done.
The way I understand this: source() will not plot graphs (unless made specific with e.g. print(plot)), while the R Studio console codes will always plot graphs. I'm sure this will affect the speed of execution to a certain degree, but this seems irrelevant in my case, because there are barely any plot calls.
And:
(...) the complete file is parsed before any of it is run
I have been working with R for a while now, but I'm not sure whether this relevant for the speed-issue I'm having. Is it possible that completely parsing all code "before any of it is run" speeds up the execution of my helper functions script by a factor of a hundred?
Edit: I'm using R version 3.2.3.
The issue is not source() vs. console line code. Instead, it is an issue of how RStudio sends code from the source pane to the console.
When I copy the content of Helperfunctions.R and run it in RGui (instead of RStudio), the code is executed with nearly the same speed as when I use source("Helperfunctions.R") in RStudio.
Apparently, lines of code always (?) require more execution time in RStudio than in RGui. Even though you may usually not notice the time-difference when executing a couple of lines in the console, it seems to make a huge difference when, say, 3.000 lines of code are being executed in the R Studio console at once.
My understanding is that upon using source("Helperfunctions.R") in the RStudio source pane, the code is not actually sent to the RStudio console (which would have been slow), but is actually executed directly in the R language.