Hi everybody !
Some IDEs for instance Pycharm propose export to html format directly from the main menu .
I decided to shift to VSCode (Visual Studio) and expected the same. In vain …
So I began to understand that it was only possible through JuPyter notebook.
I downloaded the JuPyter extension from VSCode and was able to create a new notebook from inside VSC and paste any code inside the cell.
Now i followed instructions to export the resulting i.pynb file.
Drop down menu ‘…’ on the right of tool-bar actually proposes ‘Export’ and asks for format (choice between PDF and HTML ,quite simple and logical). After selection I have a dialog box to select a file name for the output. Well, quite normal again.
After my choice is done NOTHING happens ! NO file is created, NO error message is issued.
I did several attempts with the same (absence of) result.
Did I miss something, did I forget something about parameters.
Thank you for your help.
I’ve had a similar problem wrt. exporting a Jupyter notebook as html from VSCode on Windows. I seem to recall that I had to install Python and possibly some package. I never recall what I had to install, though. It is possible that this is simpler on Linux or Mac – I think those have Python installed as part of the OS.
Another problem which is reported elsewhere.
Running of very simple Julia scripts through ‘run’ menu of VSCode is very long. Somebody suggested to use command ‘Julia: execute active file in REPL’ result is a little better but nothing to compare with ‘real’ REPL. So it seems to me that I will keep VSCode as a pure editor, debugger but that I will run files ‘from outside’ (REPL or linux notepadqq almost as fast as REPL)
Be aware of that the first time you run Julia code, there is an overhead in “compiling” the functions you use. If you run the code a second time, it runs much, much faster.
This code for instance:
Purpose is to compare this (searching for perfect numbers <1000000):
function sommeAliquotes(n)
“”“calcule la somme des diviseurs propres de n à l’exclusion de n “””
somme = 1
stop = sqrt(n)
i = 2
while i < stop #condition d’arrêt
if rem(n, i) == 0
somme += i + div(n, i)
end
i += 1
end
if n == i * i # cas des carrés parfaits n/i=i
somme += i
end
return somme
end
parfait(n) = ifelse(sommeAliquotes(n) == n, true, false)#si immédiat
function show()
for n in 2:1000000
if parfait(n)
println(n)
end
end
end
import math, time
def sommeAliquotes(n: int) ->int:
somme = 1
i=2
stop = math.sqrt(n)
while i<stop:
if not n%i:
somme=somme+i+n//i
i=i+1
if i*i==n:
somme+=i
return somme
def parfait(n):
return n==sommeAliquotes(n)
debut=time.time()
for n in range(2,1000000):
if parfait(n):
print(n)
fin=time.time()
print(fin-debut)
Actually on this example Julia is always 20 times faster than Python.
But REPL gives immediately 4.428420 seconds (7.16 k allocations: 527.172 KiB, 1.01% compilation time)
and run without debugging gives this result 15.350995 seconds (262.84 k allocations: 18.144 MiB, 0.25% gc time, 6.38% compilation time)
but actually to have this output you must wait more than 20 seconds
Now command: Julia run active file in REPL gives 6.023399 seconds (7.18 k allocations: 523.000 KiB, 0.91% compilation time)
But you must wait the same more than 20 seconds for this output.
Suggestion: Please insert code in a standard Julia computer code environment. In-line code is inserted between back-ticks, while multiline code is inserted between triple backtick followed by “julia”, and ends in triple backtick. This makes it much easier to read the code. Your first function would then be:
function sommeAliquotes(n)
"""calcule la somme des diviseurs propres de n à l’exclusion de n """
somme = 1
stop = sqrt(n)
i = 2
while i < stop #condition d’arrêt
if rem(n, i) == 0
somme += i + div(n, i)
end
i += 1
end
if n == i * i # cas des carrés parfaits n/i=i
somme += i
end
return somme
end
next,
parfait(n) = ifelse(sommeAliquotes(n) == n, true, false)#si immédiat
and
function show()
for n in 2:1000000
if parfait(n)
println(n)
end
end
end
The third and so on time, there are 21 allocations with 624 bytes. OK – in this case, compilation time is not important (it doesn’t take much time), but there is a significant reduction in the allocations.
If I run your code in Jupyter notebook within VSCode, I get the following results… the first time:
So: I essentially get the same computation time in the REPL and in VSCode/Jupyter notebook, but a bit more allocation in VSCode/Jupyter notebook.
My computer seems to be quite a bit faster than yours. That doesn’t explain the hike in the computation time on your computer when running the code in VSCode/Jupyter notebook. Perhaps your computer has less RAM than mine?
You’re completely right. For multi-line comment I did this ‘à la Python’. If it doesn’t cause any error if forces the interpreter to evaluate a string constant. I use both languages and sometimes I’m confused. i will take care in the future
This doesn’t explain my problem delay in execution under VSCode. Difference of performance with your system is quite normal, but your result although better are more consistent. Size of my RAM 8GB maybe the problem is here . IDE are greedy. I will make some additional checking using conky
Things begin to be clear. 8 GB RAM is sufficient although largely used by the process.
But it seems that the problem comes from the CPU. Conky signals CPU1-CPU2 100% used under VSCode. Only 40% with notepadqq or REPL.
This is a hardware problem.
You helped me very much. Thanks again.
In case it’s not clear, BLI’s suggestion regards the text input here on Discourse. The idea is to use Markdown to achieve more readable formatting. This input:
```julia
if rem(n, i) == 0
somme += i + div(n, i)
end
```
In case it’s not clear, BLI’s suggestion regards the text input here on Discourse. The idea is to use Markdown to achieve more readable formatting. This input:
Thank you nsajko for making things perfectly clear now. Anyway BLI draw my attention on the fact that my multi-line comment was not correct in Julia for this piece of code. Both language Python and Julia, share the same format for online comments only.
I will remember, Have a good day.