When using the VegaLite.jl library for Julia, it is common to get several warnings when the visualization is not fully specified. For example, if I run the following code:
using VegaLite
α = rand(10,2)
β = rand(10,2)
v1 = #vlplot(:circle,x=α[:,1],y=α[:,2])
v2 = #vlplot(mark={"type"=:circle,color="red"},x=β[:,1],y=β[:,2])
#vlplot()+v1+v2
This will plot things correctly, but I get several warnings saying "QARN Missing type for channel "x", using "quantitative" instead".
Is there a way to disable this warnings? I mean, is there a way to suppress them? Note that I'm using Jupyter Notebook.
You can use Suppressor.jl to suppress all warnings.
Your code would like like this:
using Suppressor
#suppress begin
v1 = #vlplot(:circle,x=α[:,1],y=α[:,2])
v2 = #vlplot(mark={"type"=:circle,color="red"},x=β[:,1],y=β[:,2])
#vlplot()+v1+v2
end
See other usage examples here: https://github.com/JuliaIO/Suppressor.jl#usage
Related
I am currently learning Julia and have been practicing in the Jupyter notebook environment. However, the ProgressBar package (similar to TQDM in python) is updated every new line instead of updating on the same line (picture attached). Is there any way to fix this? Thanks.
UPDATE : Here is the full function that I wrote.
function spike_rate(raw_dat, width)
N = size(raw_dat)[1]
domain = collect(1:N);
spike_rat = zeros(N);
for i in ProgressBar(1:N)
dx = i .- domain;
window = gaussian.(dx, width);
spike_rat[i] = sum(window .* raw_dat) ./ width;
end
return spike_rat;
end
This seems to be a known issue with ProgressBars.jl, unfortunately. It's not clear what changed to make these progress bars not work properly anymore, but the maintainer's comment says that tqdm uses "a custom ipywidget" to make this work for the Python library, and that hasn't been implemented for the Julia package yet.
To expand on #Zitzero's mention of ] up, that calls Pkg.update() which also prints a progress bar - so the suggestion is to use the mechanism Pkg uses for it. Pkg has an internal module called MiniProgressBars which handles this output.
Edit: Tim Holy's ProgressMeter package seems well-maintained, and is a much better option than relying on an internal non-exported Pkg submodule with no docs. So I'd recommend ProgressMeter over the below.
The Readme mentions a caveat regarding printing additional information with the progress bar when in Jupyter, which likely applies to MiniProgressBar as well. So, using ProgressMeter, and separating the progress output vs other relevant output to different cells, seems like the best option.
(not recommended)
using Pkg.MiniProgressBars
bar = MiniProgressBar(; indent=2, header = "Progress", color = Base.info_color(),
percentage=false, always_reprint=true)
bar.max = 100
# start_progress(stdout, bar)
for i in 1:100
sleep(0.05) # replace this with your code
# print_progress_bottom(stdout)
bar.current = i
show_progress(stdout, bar)
end
# end_progress(stdout, bar)
This is based on how Pkg uses it, from this file. The commented out lines (with start_progress, print_progress_bottom, and end_progress) are in the original usage in Pkg, but it's not clear what they do and here they just seem to mess up the output - maybe I'm using them wrongly, or maybe Jupyter notebooks only support a subset of the ANSI codes that MiniProgressBars uses.
There is a way, the package module does that as far as I know when you do:
] up
Could you share a little of your code?
For example, where you define what is written to the console.
One guess is that
print("text and progressbar")
instead of
println("text and progressbar")
could help, because println() always creates a new line, while print() should just overwrite you current line.
I'm trying to reproduce an example from a tutorial and I get stuck with meshes not being defined:
using DiffEqBase
using DiffEqPDEBase
f(t,x,u) = ones(size(x,1)) - .5u
u0_func(x) = zeros(size(x,1))
tspan = (0.0,1.0)
dx = 1//2^(3)
dt = 1//2^(7)
# THE FOLLOWING LINE IS FAILING
mesh = parabolic_squaremesh([0 1 0 1],dx,dt,tspan,:neumann)
u0 = u0_func(mesh.node)
prob = HeatProblem(u0,f,mesh)
sol = solve(prob,FEMDiffEqHeatImplicitEuler())
The code fails at the line where I try to create the mesh with the error message:
*UndefVarError: parabolic_squaremesh not defined
top-level scope at test.jl:22
All packages are installed without errors. However, I was not able to install the
using FiniteElementDiffEq which seems to be depreciated.
This functionality has not existed in many years. It was found because of a Google search turning up DifferentialEquations.jl v3.0, while v6.0 is the first version to support Julia 1.0. There's not much else to say about this other than you won't make it work on a modern version of Julia, and if you want to use it you'd have to drop back to something like Julia v0.6.
I'm currently working through this tutorial and I'm having trouble getting the png image to display. This is my program.
using DataFrames
using Gadfly
train_df = readtable("winequality-red.csv", separator=';')
_, count = hist(train_df["quality"])
class = sort(unique(train_df["quality"]))
value_counts = DataFrame(count=count, class=class)
#value_counts
p = plot(value_counts, x="class", y="count", Geom.bar(), Guide.title("Class distributions (\"quality\")"))
draw(PNG(14cm, 10cm), p)
the error I get is
LoadError("C:/Users/John/Desktop/helloworld.jl",12,MethodError(PNG,(140.0mm,100.0mm)))
I've tried some of the things mentioned in this discussion, however I haven't made any observable progress.
I was able to solve my problem by installing Cairo.
Pkg.add("Cairo")
and changing this line
draw(PNG(14cm, 10cm), p)
to
draw(PNG("chart.png", 14cm, 10cm), p)
and then opening chart.png with Julia Studio
I'm trying to create the Spectra object (.RData), just like suggested on ChemoSpec.pdf (see the code below), and I get an error message like this:
"could not find getManyCsv function"
How can I fix it? Any suggestion is appreciated. I have R version 3.1.0 and ChemoSpec version 2.0-2.
Here is the code:
getManyCsv(gr.crit = c("ICLPS", "PEPS"), gr.cols = c("red3", "dodgerblue4"),freq.unit = "ppm", int.unit = "peak intensity", descrip = "PS Study",out.file = "PS")
Cheers,
Awel
I had the same problem and found on:
http://cran.r-project.org/web/packages/ChemoSpec/NEWS
following:
##### Version 2.0.0
Date: 2013-12-07
>> normSpectra modified to avoid integer overflow.
>> Modified plotScree & plotScree2 so that data sets with less than 10 components plot.
>> Freshened up the README.md file.
>> To facilitate using expressions in plot titles, argument 'title' has been removed from all functions that use base or lattice graphics and now one should use 'main'. The 'title' argument remains for the rgl graphics functions. THIS WILL BREAK EARLIER CODE, hence the move to a new major version.
>> Semantic versioning is now in effect. See semver.org for details.
>> getManyCsv has been removed (deprecated for one year now). Use files2SpectraObject instead.
So it might be necessary to use files2SpectraObject instead of getManyCsv.
I would like to be able to edit the Fortran code that is referred to in the fGarch package.
More specifically I would like to edit the available conditional distributions that can be used by fGarch::garchFit, i.e. including the stable distribution and the generalised hyperbolic distribution.
So having looked into the garchFit() function, I have delved (deepish) into the code, and .aparchLLH.internal() is referred to from the garchFit() function and there is a line in there that refers to Fortran written code.
The specific line that I am referring to is the following bit of code:
fit <- .Fortran("garchllh", N = as.integer(N), Y = as.double(.series$x),
Z = as.double(.series$z), H = as.double(.series$h),
NF = as.integer(NF), X = as.double(params), DPARM = as.double(DPARM),
MDIST = as.integer(MDIST), MYPAR = as.integer(MYPAR),
F = as.double(0), PACKAGE = "fGarch")
I believe that the Fortran function garchllh is what I would like to edit, but do not know how to go about editing it so that I can introduce new distributions into the garchFit() function.
N.B. Just as a note, I do not have much experience in Fortran code, but would like to have a look at it to see if it can be edited and altered to fit for my purpose, so any help on the Fortran editing of code section would be much appreciated...
As mentioned in comments, you need to download the source -- a good place would be to start with install.packages("fGarch",type="source") and see that everything compiles properly. Then, look at the package source -- seems like you would need to do a pretty straightforward adjustment to dist.f, and probably add more changes to various places where MDIST is set -- start with grep MDIST *.R in the R directory of the extracted source. After you're done and tested, you could also talk to the package maintainers -- perhaps they would include your additions in the next version :)