Quantcast
Channel: First steps - JuliaLang
Browsing all 2795 articles
Browse latest View live

How to correctly handle one-element array vs scalar

I have a statement in my code where I need to compute the mean of an ND array A along the 1st dimension, which is M = mean(A,dims=1); However, sometimes A is just a scalar, in which case an error will...

View Article


Zygote in Turing: Mutating arrays is not supported

I am trying to use Zygote in Turing. Here’s my MWE @model function mwe(B, ::Type{T} = Vector{Float64}) where {T} μ = mapslices(lsexp, B; dims=[1])[1,:] end mwe_model = mwe([1.0 2; 3 4]) mwe_ch =...

View Article


Most efficient way to delete row without memory consuming

Would you suggest, how to delete row without consuming memory? I try the code but have not enough memory error. df = df[df.cl!=1,:] thank you in advance. 1 post - 1 participant Read full topic

View Article

Reduce: init for non-empty collections

I noticed that the docs for reduce say: reduce(op, itr; [init]) ... If provided, the initial value init must be a neutral element for op that will be returned for empty collections. It is unspecified...

View Article

Glade developed window not showing in compile but showing at julia prompt

Hi, Here is a sample of the code I am using to display a glade developed window. using Gtk, Gtk.ShortNames b = GtkBuilder(filename="/home/user/Documents/projects/Julia/gladeProjects/app.glade") win =...

View Article


Incorrect display of Array{Float64,2} numbers

Dear all, I am just starting to use Julia and I run into the following issue [Julia Version 1.4.1 (2020-04-14)]: julia> arr = [-498796.2749933266 408222.59838380764 -583210.404155956...

View Article

Newbie question about loop fusion and broadcasting

Dear JuliaLang, I’m excited to get started with Julia as a long-time Python user, tired of typing np.array. One thing that is really exciting to me is the ability to avoid writing my own ufuncs,...

View Article

I need help creating a macro that makes Julia evaluate my floating point...

I need a macro that takes any expression matching r"-?[0-9]+\Q.\E[0-9]+", and encloses it in a BigFloat constructor. For example, a macro that receives the source code below: @my_macro function f()...

View Article


What is the expected behavior for metapackages?

Wherein I attempt to install StatsKit: (@v1.4) pkg> add StatsKit Updating registry at `C:\Users\alanc\.julia\registries\General` Updating git-repo `https://github.com/JuliaRegistries/General.git`...

View Article


Creating a Weighted Graph

I would like to try using a weighted graph. To this end, I added SimpleWeightedGraphs to Atom, created an erdos_renyi directed graph, and then applied SimpleWeightedGraphs to this graph. const G =...

View Article

Fresh Arch Linux install: UndefVarError: backend not defined

I just created a new Arch Linux install, and while on my old Arch Linux install my Julia scripts run fine, on this fresh install this one keeps returning the error: UndefVarError: backend not defined...

View Article

I define t, then in a loop I'm told it's undefined, why?

I’ve written a Julia script that should be using Simpson’s rule to approximate the solution to: \displaystyle \int_0^{-\pi} \dfrac{dy}{\sqrt{-\frac{2g}{l} \sin{y}}} and compare it to the result...

View Article

Parallelizing a histogram

I am trying to parallelize a simple histogram: n_bins = 20000000 n_elem = 100000000 hist = zeros(Int64, n_bins) for i = 1:n_elem bin = rand(UInt64)%n_bins + 1 hist[bin] += 1 end In Fortran&OpenMP...

View Article


BenchmarkTools keep failing in a loop

I am trying to use BenchmarkTools to benchmark some of my algorithms but I keep getting an error I don’t really understand. Why does it keep failing in a loop? I think the @benchmark macro isn’t a...

View Article

Using replace with a function of the match

Hello, It’s easy to recuperate the matched substring in replace and do something like: julia> replace("foobar", r"b([a-z])r" => s"\1") "fooa" However I can’t pass the output to a function so for...

View Article


Trying to code a parallel for loop with shared sparse arrays

Having asked here how to code a parallel for loop, and getting a nice answer, I now find myself unable to find anything on how to do it with sparse arrays, as I couldn’t work out how to use sparse...

View Article

How to declare a Boolean variable?

I need to declare a Boolean variable but I don’t know how to use Bool. How should I do ? I need the variable “i” to assume two values (1, 0) using JuMP, Cbc Model1 =...

View Article


Image may be NSFW.
Clik here to view.

Trying to install Jupyter notebooks via JuliaPro

I have some students who are trying to install Jupyter notebooks to be used with JuliaPro, and one of them is running into an installation problem that I can’t figure out. She is using Windows 10, and...

View Article

Problem creating violin plots

Hi all, I’m new to Julia and I’m hoping to make some violin plots. I recently had version 1.1.1 downloaded and I found some sample code to create a violin plot using StatsPlots y = rand(100, 4) # Four...

View Article

Julia save ".rdata" equivalent

I can’t find a consensus for what would be a good .rdata file equivalent. I like rdata files because they are very compact and I can throw multiple objects into them. Any suggestions? 2 posts - 2...

View Article
Browsing all 2795 articles
Browse latest View live