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

Prevent interpolation when Meta.parse a String to Expr

Hello everyone, if I want to parse the following string to expression s = "Z = A + 1" where A represents a variable defined elsewhere in the code, then how can I prevent interpolation when I pass this...

View Article


Image may be NSFW.
Clik here to view.

Optim.jl, showing trace

Is there a way of not showing the time spent in each iteration in Optim.jl while using the option show_trace=true? The current output is as follows: Screen Shot 2021-02-14 at 11.00.18 AM950×386 23.7...

View Article


Inconsistency of `?` to get help: syntax: invalid identifier name "?"

Sometimes I use ? to get help on a function. For a given function called f, I type ?f and then run the cell and it gives info for that function. But sometimes this doesn’t work. For example right now...

View Article

Creating a vector from a vector of values and a vector of indices to the...

I have a vector x that contains “actual values” and a vector y that contains indices (which are less than or equal to the length of x). I want to create a new vector z whose ith element is x[y[i]]. I...

View Article

Why is my package precompiled on every startup?

Hello, I’m relatively new to Julia and and just diving into the waters of creating a package. The Problem The problem that I am having is that every time I do using MyPkg for the first time in the...

View Article


Image may be NSFW.
Clik here to view.

How to Find the First Instance of a Value in an Array

Hi all, I was wondering why this wasn’t working: mylist = ["a", "b", "c"] findfirst(["a"], mylist) As I expected it to work in at least Julia 1.6. Instead I got a stacktrace that looked like this:...

View Article

Juno wont open julia

I am trying to run juno in atom because I hope it will be easier to debug code than it has been for me in vs studio but upon starting julia from juno I recieved the following error message: Julia...

View Article

Implement AbstractArray so that custom type is returned

I’d like to implement a 3-D vector type like the following: struct Vector3D x::Int y::Int z::Int end Julia has a rich collection of Array operations already defined that I’d love to take advantage of,...

View Article


Image may be NSFW.
Clik here to view.

Developing packages - help!

Hi Everyone, I just installed Juno along with Julia following Chris Rackauckas’ developing for julia tutorial. When I try to dev Surrogates (the package I want to develop) I get this error. ERROR:...

View Article


Is there a way to define a 'module' variable?

I’m struggling a bit with scopes. From the documentation, this works: module Bar x = 1 foo() = x export foo end using .Bar foo() But this does not: module Tofu counter = 0 f() = (counter += 1;...

View Article

Call @show in logging macro

Does anyone know how to call @show in logging macro, ex @info? I tried: julia> using Logging julia> @info “hi” [ Info: hi julia> message = “hi” “hi” julia> @info message [ Info: hi...

View Article

A question about closures

Hi, I’m trying to work out how to construct a closure for the following case: The Agents package has a random_agent(agent, condition) function and I want to call it with a condition closure. I though...

View Article

Stuck installing (downloading?): how to know what is going on?

I am trying to install DifferentialEquations in 1.6-rc1, but it always gets stuck: | | |_| | | | (_| | | Version 1.6.0-rc1 (2021-02-06) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release...

View Article


Image may be NSFW.
Clik here to view.

Need help with bar plot in Plots.jl

I’m using Plots.jl from inside Weave.jl to generate html. All looks good except I cannot locate how to plot grouped bar chart similar to below. image1314×1052 33.4 KB (Note: I saw similar questions...

View Article

Image may be NSFW.
Clik here to view.

Single module vs. submodules in a project

I have been reading a fair amount (a few references at end of post) about how to “correctly”, or better yet idiomatically, structure code in Julia. In general, there seems to be a strong sentiment...

View Article


How to avoid allocations when multiplying numbers with missings

Coming from R I have a hard time to use missings and ensure type stability. I guess that the following allocations in multiplication of numbers also relate to this issue. How can I avoid the memory...

View Article

Error to install JuMP

Hi there I have a Julia 1,5.3 on a windows machine. When installing JuMP I get the following error (@v1.5) pkg> add JuMP Resolving package versions… ERROR: Unsatisfiable requirements detected for...

View Article


Documenter.jl error after using StatsPlots

I have the error afet using StatsPlots: /home/runner/.julia/packages/GR/G9I5v/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No...

View Article

Compare patterns in byte array

How can I find the position in array “a”, where is pattern match from array “b”? Does standard library have implemented this functionality? a = [0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61] b...

View Article

Efficient Repeat: Array of single value

I want to define defaults for a read-only AbstractVector{Bool} argument to a function and so far used falses(n). However, this allocates a full BitArray. I guess should be a type similar to a Range...

View Article
Browsing all 2795 articles
Browse latest View live