I am getting the weirdest error in using the write()function:
julia> write(0.1)
�8
julia>
������?
These are just the commands I'm writing in the console, as you can see. What could be going wrong?
Note: I'm using Julia Studio 0.4.4
From the documentation:
write(stream, x): Write the canonical binary representation of a value to the given stream.
I suspect that you want to use print rather than write.
Related
In Python, you can do:
print(gurobipy.gurobi.version())
What is the equivalent for Julia and JuMP?
I tried
using Gurobi
Gurobi.version()
Without success. I am not trying to get Gurobi.jl package version which can be obtained with ] status Gurobi.
There are three integer variables for this you need to combine them to get the full version number:
julia> println("Grurobi version: $(Gurobi.GRB_VERSION_MAJOR).$(Gurobi.GRB_VERSION_MINOR).$(Gurobi.GRB_VERSION_TECHNICAL)")
Grurobi version: 9.5.0
#przemyslaw-szufel's answer is mostly correct, but it can be wrong with the minor version. The constants he refers to are actually the ones we copy from the gurobi.h file, not from the Gurobi library itself, so you might get v9.5.0 returned when the actual library is v9.5.1.
You can get the exact version using:
julia> using Gurobi
julia> const MOI = Gurobi.MOI
MathOptInterface
julia> v = MOI.get(Gurobi.Optimizer(), MOI.SolverVersion())
"9.1.0"
julia> VersionNumber(v)
v"9.1.0"
this is mostly solver-independent, although not all packages support MOI.SolverVersion.
I'm having this weird issue where my target, which interfaces a slightly customized python module (installed with pip install --editable) through reticulate, gives different results when it's being called from an interactive session in R from when targets is being started from the command line directly, even when I make sure the other argument(s) to tar_make are identical (callr_function = NULL, which I use for interactive debugging). The function is deterministic and should be returning the exact same result but isn't.
It's tricky to provide a reproducible example but if truly necessary I'll invest the required time in it. I'd like to get tips on how to debug this and identify the exact issue. I already safeguarded against potential pointer issues; the python object is not getting passed around between different targets/environments (anymore), rather it's immediately used to compute the result of interest. I also checked that the same python version is being used by printing the result of reticulate::pyconfig() to screen. I also verified both approaches are using the same version of the customized module.
Thanks in advance..!
I have a big R program and somewhere in middle of a function, I put a browser() to debug the same. However, there is a pain with this debugging as even standard R functions like substr, regexpr, nchar are all getting debugged which I am not interested in. Please suggest how to stop this and debug only what I wrote in the function, but not the standard R functions.
Suppose you have a string
S = "ABCD,12345"
I want the result 12345 which is a substring of S after the character ','. I use the below command:
substr(S, regexpr(",", S) + 1, nchar(S))
Command is correct and does well. But which debugging, the main function, this substr, regexpr, nchar are also getting debugged which is waste of time for me.
It seems like you are stepping into each function, usually by having used the s command. Using the n command within debug mode should run each nested function without stepping into the function. Note that if you use s once, every run command (usually just clicking enter) will use s until another command is used.
R also has some more intricate tools for debugging. In Hadley's free online book Advanced R there is a great chapter about debugging in R (Chapter 22). For more in-depth knowledge about debugging in R, i can highly recommend this chapter.
I have a pickle file that is written by using python (By using cPickle). I need to use it inside julia. I guess I can use PyCall for that purpose.Here is what I've done so far:
julia> using PyCall
julia> #pyimport cPickle as pickle
julia> f=open("mypicklefile.picle","r")
julia> PyTextIO(f)[:seek](0) #if I don't do this, I got error.
julia> trn,tst= pickle.load(PyTextIO(f))
Here,I have two questions. As far as I know, unlike Julia, python(numpy) is rowmajor. So, what should I do to read the content of file in a correct way? I guess somehow I have to tell the PyCall it is written in rowmajor order.
My second question is about performance. The pickle file is about 4.5GB. When I read it inside python, it is completed in a minute whereas in julia it takes at least 15 minutes. Am I doing something wrong ? Since the file is not created by me, I cannot use another format such as hdf5 or jld.
Trying to use julia language as general purpose language.
I made a file called "main.jl" where I have this code:
http://pastie.org/9802792
For some reason I get printed "Create metronome" and "Start..." but no more prints.
If I copy paste that code into the Julia REPL it will work and I'll get the prints I've made.
What am I doing wrong here?
I'm in Mac by the way.
Could it be simply that the program ends too quickly for you to see anything? After adding
sleep(2)
to the end of your program, I find
dsm#notebook:~/coding$ julia tim.jl
Create metronome...
Start...
Timed! the count is: 1
as expected.