12,847 questions
4
votes
2
answers
130
views
Parallel computing in R using Julia
This is kinda of a niche question because it requires having working with Julia and R at the same time, but I've hit a wall with an issue when using {furrr} to process code in parallel and I decided ...
2
votes
1
answer
136
views
CairoMakie contour custom labels
I am trying to make a contour plot with Makie.
I would like to have custom labels on the lines. So instead of the number on the contour, it displays some text (particularly the variable I have as ...
1
vote
0
answers
57
views
How to make @info in julia print full array?
The @info collapses the array and also tries to print it as column which makes no sense for logging. How to tell it to print full array?
Without overriding the default printing/show functions globally ...
Advice
1
vote
4
replies
97
views
Acyclic shifting of arrays (`eoshift`) in Julia
Circular shifting cshift in fortran as an equivalent in Julia : circshift. But I'am seeking an equivalent of eoshift (https://fortranwiki.org/fortran/show/eoshift) which is a acyclic shifting that ...
-2
votes
0
answers
64
views
The system cannot find the file specified. (os error 2) [in Julia]
I got this error for updating Julia to the latest version using Juliaup:
PS C:\Users\Shayan> juliaup update
Checking for new Julia versions
Checking for new version on channel 'nightly' is taking a ...
2
votes
1
answer
63
views
How to make my plot legend be inside the axis?
I would like the legend to my scatter/line plot to be inside the axis of the plot it is informing, but I can only seem to get a legend if is has its own axis, which becomes a problem when I want three ...
0
votes
0
answers
39
views
VS Code not displaying with GraphViz
I'm trying to run the below code.
using Catlab
using Catlab.CategoricalAlgebra
using Catlab.Theories
using Catlab.Graphs
using Catlab.Graphics
@present SchGraph(FreeSchema) begin
V::Ob
E::Ob
src::...
-2
votes
1
answer
151
views
Is multi dispatch function as fast as the plain function?
NOTE: The answer is not so simple, see update below
Is the multi dispatch function call with ::Type{Algo1} as fast as the plain function?
Simple version
algo1_Init() = 0.0
@inline algo1_update(state) =...
2
votes
3
answers
121
views
How to create Vector{Any}?
I want to create an array that would accept any type (it fail):
values = fill((; some=missing), 10)
values[1] = (; some=1)
without writing bloated code like this
values = Vector{NamedTuple{(:some,),...
1
vote
1
answer
80
views
How to run a script using a specific version (environment) created with juliaup
As a newbie in Julia, I want to use a specific environment for a new project using juliaup as a version/environment manager. But every time that I create, activate and add a package, when I want to ...
1
vote
1
answer
85
views
Efficient multicore for loop in Julia
How to implement @parallel_map macro?
results = @parallel_map for i in 1:10
i^2
end
So that it won't use Any like code below (I assume it slow down code)?
results = Vector{Any}(undef, 10) # ...
1
vote
1
answer
60
views
How does one "get" the information of a root type as interval in julia
I'm using the package IntervalRootFinding for finding the zeros of a function. By design, the package returns an array with the zeros as an interval, like:
11-element Vector{Root{Interval{Float64}}}:
...
3
votes
1
answer
41
views
Julia suplot with gr() widths not uniform
Julia 1.11.7 (Also tried in 1.10.1) on Linux.
Plots v1.41.1
using Plots; gr()
titles = hcat(["X "*string(x) for x in collect(15:-1:8)'], ["X "*string(x) for x in collect(0:7)'])
...
0
votes
0
answers
65
views
Julia ModelingToolkit Method for Dx(var) * Dx(var)
I am trying to use the Julia language to solve a system of partial differential equations. I found the modeling tool kit to be quite helpful. I can solve the unsteady heat equation for multiple ...
0
votes
1
answer
56
views
How to interpolate string literal with "text" prefix?
How to implement text"Hi $(1+2)" # => Hi 3?
If possible I would like to keep following structure:
macro bind_doc()
quote
text(s::AbstractString) = println(s)
macro text_str(...
2
votes
2
answers
95
views
How to get source of function in Julia?
How to get source of function for report generation, without copy pasting?
code(text) = println(text)
μ_model(period, vol_q, Q) = begin
lp = log(period)
exp(Q[1] + Q[2]lp + Q[3]vol_q)
end
code(...
3
votes
1
answer
116
views
Parametric struct with type of member depending on value type of struct
I'm trying to write a parametric struct where one of the parameters is a Boolean value type, and where the type of a member should depend on the value of this Boolean. The struct should also inherit ...
4
votes
2
answers
189
views
Why is breaking out of a for loop slower than iterating the whole vector?
I pass in a vector that is sorted in descending order and manually sum until a certain integer is reached. In the first function below, I let the for loop continue until the end, but in the second ...
0
votes
1
answer
45
views
Per-type constants depending on type parameter
I have a value-parametric struct
struct T{p}
...
end
where p::Int is expected. For each concrete type T{p}, I want to maintain a global(!) constant with value f(p) for some function f. The point ...
0
votes
1
answer
159
views
The problem with installing julia in VS code
I updated from julia version 1.11.5 (everything worked well) to version 1.11.6. And VS code stopped seeing Julia and I can't write programs in it.
"You must have Julia installed for the best ...
2
votes
1
answer
96
views
Making an Gif of Plots using Makie
I have a function that generates plots in Makie. I want to compute a bunch of these plots and turn it into a gif.
The data for these plots is usually difficult to compute, so maybe at best I can ...
2
votes
1
answer
201
views
Cannot get the same sequence of random numbers with Julia and Rust, despite using the same seed and the same method
I have written a simulation in Rust which was previously written in Julia. I need to make sure that the results confirm; the simulation relies heavily on random numbers. I don't want to use any brute-...
0
votes
0
answers
110
views
How to make parallel within the parallel?
Right now I am running a model optimization to optimize one set of parameter for several sites (in total 47 sites, i.e. the cost function sum over these 47 results). Site computation is independent ...
2
votes
3
answers
50
views
Saving/accessing DefaultTestSet created from Test.@testset?
I am looking to parse the results from the @testset macro from Test.jl, but am having trouble accessing the DefaultTestSet that is created implicitly. I am looking to run a testset, and save the ...
1
vote
1
answer
71
views
Run file in REPL by default with run button
By default the run button (triangle) in VS Code runs as new process, not in REPL. This is only available in the drop down next to it. Is it possible to set running in REPL as default?
Note: I am ...
0
votes
0
answers
101
views
Is using Quarto with Julia & Plotly (via Plots) broken?
I used to be able create HTML output from Quarto using Julia and Plotly to get semi-interactive figures.
But it does not work anymore and I am not able to figure out why. Here is an MWE.
_quarto.yml ...
0
votes
0
answers
48
views
What can corrupt memory in Julia -- "probably modified after bring freed?"
I am very new to Julia. I am working on a project written in Julia and I am using the following script:
import Pkg
Pkg.activate(@__DIR__)
project_root = normpath(joinpath(@__DIR__, "..", &...
0
votes
0
answers
68
views
Julia code seems to take longer the longer the number of threads it's been run
Essentially I'm following the example in the guide
(posting only the relevant part, the full example is at this repo
embryos = [fertilising_room(population_model) for _ in 1:POPULATION_SIZE]
chunks = ...
3
votes
2
answers
100
views
Round everything to 4 decimal places
Is there global setting to round everything that's printed to the terminal in Julia to 4 decimal places?
Any print - float, arrays, matrices, dataframes, structures - if it has float it should be ...
1
vote
1
answer
95
views
Why doesn't Symbolics.expand work in matrices?
I'm working with Julia's Symbolics.jl and I'm trying to compare two symbolic matrices.
However, since Symbolics.isequal function checks for structural- instead of mathematical-equivalence it is ...
1
vote
1
answer
60
views
Interaction of user-defined parametric type definitions
I do not understand how constructors interact with the type system at all in the following circumstance.
struct Monomial{T<:Number}
coeff::T
exp::Int
end
struct Poly{T<:Number}
exprs:...
3
votes
2
answers
59
views
promote_rule and type conversion for custom types in Julia
I am confused about how one can get automatic type conversion in Julia. This goes especially for function arguments.
Here is dummy code behaving in a way that I wouldn't expect:
import Base: convert, ...
2
votes
1
answer
56
views
How to multithread creation of Array Julia
I have some list of parameters and some complicated function that computes something based on these parameters. I then want to compute some list in the following way:
params = [1,2,3]
func(x) = x+1
...
0
votes
1
answer
89
views
Julia can't execute REPL properly in VS Code
Every time I press Shift + Enter to execute the line, I see broken julia output in REPL.
With different runs it breaks characters at different positions, sometimes it's s sometimes so etc.
The REPL ...
1
vote
1
answer
39
views
Heatmap from CairoMakie for irregular lattice Julia
I want to make a heatmap of values that are compute over a triangular lattice.
The issue is, that this seems to not display correctly.
For example, the following code gives the following output:
using ...
1
vote
1
answer
79
views
arrows2d function unavailable in CairoMakie
I am trying to run the following code in Jupyter notebook:
f = Figure(size = (800, 800))
Axis(f[1, 1], backgroundcolor = "black")
xs = LinRange(0, 2pi, 20)
ys = LinRange(0, 3pi, 20)
us = [...
0
votes
0
answers
60
views
Unable to install package in Julia
I am trying to follow a tutorial which requires the Lathe package.
To install the package, I did:
using Pkg
Pkg.add("Lathe")
This returns the error:
Resolving package versions...
ERROR: ...
0
votes
0
answers
47
views
Debugging Julia functions launched in python environment using juliacall
I am using the Python library juliacall to be able to run functions written in Julia within a Python framework.
I am using Visual Studio Code IDE with the Julia and Python extensions that offer nice ...
1
vote
1
answer
54
views
Setting location of Julia logs to NOT be in $JULIA_DEPOT_PATHS/logs
On a multi-user Linux platform, you want to install a Julia environment once while it is being used by many users (possibly at the same time). One can create a central installation of a Julia ...
1
vote
1
answer
85
views
How can I check the type of a variable in Julia?
in Julia, im trying to check the type of a variable and i expected it to show both the type and the value like 'int 10'. but when i use typeof(x), it just shows the type, e.g., Int64. how can i ...
0
votes
1
answer
165
views
Julia's Pkg.instantiate() fails with ERROR: expected package Arrow to be registered, error due to registry processing failure.:
I am on a standard Windows machine trying to set up a new Julia project, but I'm completely unable to install any packages. Every attempt to run Pkg.instantiate() fails with the exact same error, the ...
-1
votes
2
answers
72
views
How does Manifest.toml get modified while coding from VSCode?
I have been trying to contribute to a project that is owned by someone else, and hosted on a remote github repository. The project is written in Julia and I am using VScode as the editor.
However, I ...
0
votes
0
answers
32
views
Julia upgrade performed not upgrading into Jupyter notebook kernel
I upgraded Julia to version 1.10.9 but the Jupyter kernel to which the Julia extension is configured seems not to recognise this upgrade.
How can I ensure that the Julia upgrade is also extended to ...
1
vote
1
answer
50
views
Can I replace an operator in a Julia function when wrapped for testing?
I'm writing a Julia package for testing the behaviour of floating point addition.
module TestModule
const base_add = Base.:+
# used for storing information when addition is done
mutable struct ...
0
votes
0
answers
22
views
How to use S3.delete_objects from AWS.jl in Julia?
I want to delete multiple objects from S3 with AWS.jl.
Looping over S3.delete_object() works fine, but is not that fast.
using AWS
@service S3
bucket = "my_bucket"
keys = ["tmp/file1&...
1
vote
0
answers
54
views
Selectively disable precompilation of standard library package in Julia
Perhaps a slightly obscure issue, but does anybody know of a way (short of building a custom system image) to disable precompilation of the Downloads package in Julia 1.11?
Background: my org's (maybe ...
0
votes
0
answers
43
views
Profiling window from ProfileView is not displayed
I have tried a tutorial for ProfileView (https://github.com/timholy/ProfileView.jl):
function profile_test(n)
for i = 1:n
A = randn(100,100,20)
m = maximum(A)
Am = ...
1
vote
1
answer
90
views
How can I protect a variable from the garbage collector in Julia when using ccall?
I am having trouble protecting a buffer from being garbage collected while using my own MPI bindings in Julia. In particular I am using this function:
function Recv(buf::Ref{T}, count::C_int, datatype:...
0
votes
2
answers
104
views
Match with regex only returning the first result?
Not sure whether this is intended behaviour, but it confuses me: When I do
match(r"\d+", "10, 11, 12") I only get the first match, in this case m.match <- "10".
m....
1
vote
1
answer
76
views
Is it legal for a non-primitive type to be constant but modified in Julia?
Here is some example Julia code.
module ExampleModule
const d = Dict{String, Any}()
const i = 32
function print_d()
println(d)
end
function modify_d()
global d
d["new_key"] = ...