# Latest

**URL:** https://discourse.julialang.org/latest.md?page=1319

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 1320

---

## [Reduce allocations and speed up](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 15\
**Last updated:** [July 27, 2021, 1:12am UTC](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221 "2021-07-27T01:12:50Z")

</div>

Hi there, in my attempt to teach myself Julia, I’m solving Project Euler problems. The following code works and give the correct answer, although I was expecting better performance, as the time is similar to what I got …

---

## [Lecture: Your first Julia code](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331)

<div class="topic-metadata">

**Author:** [@amrnasr](https://discourse.julialang.org/u/amrnasr)\
**Replies:** 7\
**Last updated:** [July 27, 2021, 1:00am UTC](https://discourse.julialang.org/t/lecture-your-first-julia-code/65331 "2021-07-27T01:00:08Z")

</div>

Hello everyone! I’m new to programming, so I might need a lot of help! In the lecture (see topic), the include function doesn’t work. It always gives the error “could not open file”, although I have followed every step. …

---

## [Could this function be faster?](https://discourse.julialang.org/t/could-this-function-be-faster/64710)

<div class="topic-metadata">

**Author:** [@babaq](https://discourse.julialang.org/u/babaq)\
**Replies:** 13\
**Last updated:** [July 27, 2021, 12:03am UTC](https://discourse.julialang.org/t/could-this-function-be-faster/64710 "2021-07-27T00:03:20Z")

</div>

Hi, I recently have to read raw images from a camera. The pixel format is Mono color 12bit packed. I first tried a MATLAB version which managed to read&unpack in ~30ms for a 2080\*2080 image. Here is a julia version…

---

## [How to change from random walk ro self avoiding random walk in Julia](https://discourse.julialang.org/t/how-to-change-from-random-walk-ro-self-avoiding-random-walk-in-julia/65268)

<div class="topic-metadata">

**Author:** [@Struggling\_Student](https://discourse.julialang.org/u/Struggling_Student)\
**Replies:** 7\
**Last updated:** [July 26, 2021, 9:42pm UTC](https://discourse.julialang.org/t/how-to-change-from-random-walk-ro-self-avoiding-random-walk-in-julia/65268 "2021-07-26T21:42:19Z")

</div>

Could someone help me to change the random walk to self-avoiding random walk? I tried to do that but without success. Below is the code for the random walk, that works: using StatsBase, LinearAlgebra # Here I defined t…

---

## [DiffEqFlux Example codes not working](https://discourse.julialang.org/t/diffeqflux-example-codes-not-working/63383)

<div class="topic-metadata">

**Author:** [@Alex0](https://discourse.julialang.org/u/Alex0)\
**Replies:** 10\
**Last updated:** [July 26, 2021, 9:10pm UTC](https://discourse.julialang.org/t/diffeqflux-example-codes-not-working/63383 "2021-07-26T21:10:00Z")

</div>

Hello people, I am trying to get into the DiffEqFlux package and neural ODE networks, but the example code from the documentation of the package is not working for me. It raises the error: LoadError: ArgumentError: tu…

---

## [Why does \`sqrt\` behaves differently than \`√\`?](https://discourse.julialang.org/t/why-does-sqrt-behaves-differently-than/65328)

<div class="topic-metadata">

**Author:** [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Replies:** 8\
**Last updated:** [July 26, 2021, 8:49pm UTC](https://discourse.julialang.org/t/why-does-sqrt-behaves-differently-than/65328 "2021-07-26T20:49:57Z")

</div>

Despite being equal, they behave differently: julia\> sqrt.(\[4, 9\]) 2-element Vector{Float64}: 2.0 3.0 julia\> sqrt == √ true julia\> √.(\[4, 9\]) ERROR: syntax: invalid identifier name "." Stacktrace: \[1\] top-level sco…

---

## [Discussion on ThreadPools.jl](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 5\
**Last updated:** [July 26, 2021, 6:59pm UTC](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283 "2021-07-26T18:59:02Z")

</div>

Continuing the discussion from Multithreaded compute farm: @tkf could you explain this a little more? I always assumed / hoped that ThreadPools would eventually be made obsolete by Julia’s evolution, but I haven’t seen…

---

## [Setfield fails for structs with "label"-like type annotations](https://discourse.julialang.org/t/setfield-fails-for-structs-with-label-like-type-annotations/65324)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 6:27pm UTC](https://discourse.julialang.org/t/setfield-fails-for-structs-with-label-like-type-annotations/65324 "2021-07-26T18:27:37Z")

</div>

Is this expected to fail? julia\> using Setfield julia\> struct C{S,T} i::T end julia\> c = C{Float64,Int}(1) C{Float64, Int64}(1) julia\> @set! c.i = 2 ERROR: MethodError: no method matching C(::Int64) …

---

## [Fastest way to partition array, given a condition](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 26\
**Last updated:** [July 26, 2021, 6:27pm UTC](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243 "2021-07-26T18:27:00Z")

</div>

I need to sort (usually small, i. e. 5 to 20 elements, but the algorithm cannot scale badly) arrays, but only partially. That is, I need that the elements get split into elements smaller than a cutoff, and elements great…

---

## [How to make linspace work with one point?](https://discourse.julialang.org/t/how-to-make-linspace-work-with-one-point/5335)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 8\
**Last updated:** [July 26, 2021, 5:30pm UTC](https://discourse.julialang.org/t/how-to-make-linspace-work-with-one-point/5335 "2021-07-26T17:30:38Z")

</div>

Currently, linspace(1,10,1) returns ERROR: ArgumentError: linspace(1.0, 10.0, 1): endpoints differ What’s the way to use multiple dispatch to grab the value of 1 and make a method like: linspace(a,b,1) = a:1.0:a I…

---

## [Unable to use add\_agent!() function with keyword argument](https://discourse.julialang.org/t/unable-to-use-add-agent-function-with-keyword-argument/65321)

<div class="topic-metadata">

**Author:** [@imantha](https://discourse.julialang.org/u/imantha)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 5:40pm UTC](https://discourse.julialang.org/t/unable-to-use-add-agent-function-with-keyword-argument/65321 "2021-07-26T17:40:05Z")

</div>

Hi, Just curious to find out if it is possible to use keyword argument with add\_agent!() function. When I tried adding a keyword argument, I got the following error : LoadError: MethodError: No Method matching CasAgent…

---

## [How to transpose a 3d array?](https://discourse.julialang.org/t/how-to-transpose-a-3d-array/65311)

<div class="topic-metadata">

**Author:** [@Mitch](https://discourse.julialang.org/u/Mitch)\
**Replies:** 6\
**Last updated:** [July 26, 2021, 4:47pm UTC](https://discourse.julialang.org/t/how-to-transpose-a-3d-array/65311 "2021-07-26T16:47:32Z")

</div>

Hi, Is there an elegant way to transpose the first and second dimensions of a 3d array? For example, I’d like to go from an NxMxP array to an MxNxP array. I’ve read the documentation etc., but can’t seem to extrapolate…

---

## [My Turing.jl models](https://discourse.julialang.org/t/my-turing-jl-models/65258)

<div class="topic-metadata">

**Author:** [@Hakan\_Kjellerstrand](https://discourse.julialang.org/u/Hakan_Kjellerstrand)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 4:36pm UTC](https://discourse.julialang.org/t/my-turing-jl-models/65258 "2021-07-26T16:36:03Z")

</div>

I have now finished porting most of my WebPPL and BLOG models to Turing.jl. They are collected at My Julia Turing.jl (probabilistic programming) page and also available at my GitHub page: https://github.com/hakank/hakank…

---

## [Load package and use exported macro, all within a macro](https://discourse.julialang.org/t/load-package-and-use-exported-macro-all-within-a-macro/65316)

<div class="topic-metadata">

**Author:** [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)\
**Replies:** 0\
**Last updated:** [July 26, 2021, 3:46pm UTC](https://discourse.julialang.org/t/load-package-and-use-exported-macro-all-within-a-macro/65316 "2021-07-26T15:46:35Z")

</div>

Can someone please explain why the following errors? macro d(np::Integer) quote using Distributed addprocs($np) @everywhere begin using Pkg Pkg.activate(".") e…

---

## [Multithreaded compute farm](https://discourse.julialang.org/t/multithreaded-compute-farm/65047)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 26\
**Last updated:** [July 26, 2021, 3:14pm UTC](https://discourse.julialang.org/t/multithreaded-compute-farm/65047 "2021-07-26T15:14:14Z")

</div>

I searched for a function in Julia that creates a “compute farm” based on a channel: workers take tasks from a channel and put back 0 or more tasks to the same channel. (many mathematical problems seem to be approachable…

---

## [What is the difference between \`build\` and \`precompile\`?](https://discourse.julialang.org/t/what-is-the-difference-between-build-and-precompile/65304)

<div class="topic-metadata">

**Author:** [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Replies:** 1\
**Last updated:** [July 26, 2021, 3:01pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-build-and-precompile/65304 "2021-07-26T15:01:39Z")

</div>

According to pkg help: (@v1.6) pkg\> ?build build \[-v|--verbose\] pkg\[=uuid\] ... Run the build script in deps/build.jl for pkg and all of its dependencies in depth-first recursive order. If no packages are given, run…

---

## [Package merged into General but cannot be added to my local machine](https://discourse.julialang.org/t/package-merged-into-general-but-cannot-be-added-to-my-local-machine/55928)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 6\
**Last updated:** [July 26, 2021, 2:47pm UTC](https://discourse.julialang.org/t/package-merged-into-general-but-cannot-be-added-to-my-local-machine/55928 "2021-07-26T14:47:34Z")

</div>

I’ve registered a package like this but I cannot install it on my machine. (@v1.5) pkg\> add LazyFym ERROR: The following package names could not be resolved: \* LazyFym (not found in project, manifest or registry)

---

## [CUDA.@cuStaticSharedMem returning a Structure of Arrays](https://discourse.julialang.org/t/cuda-custaticsharedmem-returning-a-structure-of-arrays/65307)

<div class="topic-metadata">

**Author:** [@shiroghost](https://discourse.julialang.org/u/shiroghost)\
**Replies:** 0\
**Last updated:** [July 26, 2021, 2:13pm UTC](https://discourse.julialang.org/t/cuda-custaticsharedmem-returning-a-structure-of-arrays/65307 "2021-07-26T14:13:30Z")

</div>

Working on the GPU I usually find convenient to use Structure of Arrays. I use GitHub - JuliaArrays/StructArrays.jl: Efficient implementation of struct arrays in Julia For example, I use: struct pt x::Float64 Y::Float6…

---

## [Speed up column looping in matrix](https://discourse.julialang.org/t/speed-up-column-looping-in-matrix/65295)

<div class="topic-metadata">

**Author:** [@HJW019](https://discourse.julialang.org/u/HJW019)\
**Replies:** 6\
**Last updated:** [July 26, 2021, 1:54pm UTC](https://discourse.julialang.org/t/speed-up-column-looping-in-matrix/65295 "2021-07-26T13:54:23Z")

</div>

I am working on a project where one of the functions is the bottleneck of speed. The problem seems to do with accessing a large matrix. I’d appreciate any advice to improve the code. The problem is represented by the fo…

---

## [Underscore does not appear in VSCode terminal windows (Mint 20.2)](https://discourse.julialang.org/t/underscore-does-not-appear-in-vscode-terminal-windows-mint-20-2/65302)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 1\
**Last updated:** [July 26, 2021, 1:20pm UTC](https://discourse.julialang.org/t/underscore-does-not-appear-in-vscode-terminal-windows-mint-20-2/65302 "2021-07-26T13:20:54Z")

</div>

This is a small annoyance: the underscore character \_ does not appear in the terminal window of VSCode: the expected output is: julia\> Char('\_') '\_': ASCII/Unicode U+005F (category Pc: Punctuation, connector) julia\> …

---

## [Trying to understand method specializations involving CartesianIndices in julia's multidimensional.jl?](https://discourse.julialang.org/t/trying-to-understand-method-specializations-involving-cartesianindices-in-julias-multidimensional-jl/65294)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 10:16am UTC](https://discourse.julialang.org/t/trying-to-understand-method-specializations-involving-cartesianindices-in-julias-multidimensional-jl/65294 "2021-07-26T10:16:50Z")

</div>

Julia’s multidimensional.jl defines the methods ndims(::Type{CartesianIndices{N}}) where {N} = N ndims(::Type{CartesianIndices{N,TT}}) where {N,TT} = N I wonder if these may not be written concisely as ndims(::Type{\<:…

---

## [Parsing datetime string](https://discourse.julialang.org/t/parsing-datetime-string/65179)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 7\
**Last updated:** [July 26, 2021, 10:09am UTC](https://discourse.julialang.org/t/parsing-datetime-string/65179 "2021-07-26T10:09:12Z")

</div>

Hi all :slight\_smile: I want to parse the following datetime string but can’t find the right format. julia\> using Dates julia\> format = dateformat"y-m-dTH:M:S.s" dateformat"y-m-dTH:M:S.s" julia\> dt\_str = "2021-05-26T…

---

## [Track memory allocation not working correctly](https://discourse.julialang.org/t/track-memory-allocation-not-working-correctly/57543)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 8\
**Last updated:** [July 26, 2021, 9:50am UTC](https://discourse.julialang.org/t/track-memory-allocation-not-working-correctly/57543 "2021-07-26T09:50:47Z")

</div>

I’m currently a bit perplexed by --track\_allocation=user while I’m writing a blog post about BenchmarkTools and profiling. My test code is: function get\_primes(to) possible\_primes = collect(2:to) # iterate over…

---

## [\[ANN\] ThinModules.jl - lightweight module dependency resolver](https://discourse.julialang.org/t/ann-thinmodules-jl-lightweight-module-dependency-resolver/65256)

<div class="topic-metadata">

**Author:** [@Shuenhoy](https://discourse.julialang.org/u/Shuenhoy)\
**Replies:** 5\
**Last updated:** [July 26, 2021, 10:00am UTC](https://discourse.julialang.org/t/ann-thinmodules-jl-lightweight-module-dependency-resolver/65256 "2021-07-26T10:00:54Z")

</div>

Hello! This is a small package ThinModules.jl, which tries to avoid the manual maintenance of module orders. Please look at the example: using ThinModules @thinmod module MyModule # all submodules inside can have fr…

---

## [Generic Affine Expression in a constraint](https://discourse.julialang.org/t/generic-affine-expression-in-a-constraint/65275)

<div class="topic-metadata">

**Author:** [@Daniel\_Villamar](https://discourse.julialang.org/u/Daniel_Villamar)\
**Replies:** 1\
**Last updated:** [July 26, 2021, 9:00am UTC](https://discourse.julialang.org/t/generic-affine-expression-in-a-constraint/65275 "2021-07-26T09:00:34Z")

</div>

I am having a hard time with a NL model that I am creating. My model uses matrices and therefore my variable and constraints are arrays. I want to create an array of constraints that includes some calculations with my v…

---

## [VS Code Wishlist / little helpers](https://discourse.julialang.org/t/vs-code-wishlist-little-helpers/65274)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 3\
**Last updated:** [July 26, 2021, 8:59am UTC](https://discourse.julialang.org/t/vs-code-wishlist-little-helpers/65274 "2021-07-26T08:59:37Z")

</div>

Coming from Matlab and still learning the efficient use of VS Code. Please let me know if any items have been explained elsewhere. Emacs-like indenting via TAB-key. Good replacement found here. Explorer pane with…

---

## [How to improve performance of sum()](https://discourse.julialang.org/t/how-to-improve-performance-of-sum/64928)

<div class="topic-metadata">

**Author:** [@andrewkhardy](https://discourse.julialang.org/u/andrewkhardy)\
**Replies:** 19\
**Last updated:** [July 19, 2021, 8:13pm UTC](https://discourse.julialang.org/t/how-to-improve-performance-of-sum/64928 "2021-07-19T20:13:40Z")

</div>

Hello. I recently tried out Julia because I was hoping for a speed improvement over numpy.sum(). I’m trying to benchmark a sum for a 2D integral and so far my Julia code is much slower. I’m wondering if there’s any perf…

---

## [Problem with Distrubuted package](https://discourse.julialang.org/t/problem-with-distrubuted-package/65199)

<div class="topic-metadata">

**Author:** [@Sunny](https://discourse.julialang.org/u/Sunny)\
**Replies:** 6\
**Last updated:** [July 26, 2021, 8:03am UTC](https://discourse.julialang.org/t/problem-with-distrubuted-package/65199 "2021-07-26T08:03:24Z")

</div>

I just try to launch an example from the tutorial and immediately get the error: using Distributed using DifferentialEquations using Plots addprocs() @everywhere using DifferentialEquations # Linear ODE which starts a…

---

## [Outer constructor for Base.@kwdef with constrained parametric type](https://discourse.julialang.org/t/outer-constructor-for-base-kwdef-with-constrained-parametric-type/65286)

<div class="topic-metadata">

**Author:** [@Jae-Mo\_Lihm](https://discourse.julialang.org/u/Jae-Mo_Lihm)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 7:45am UTC](https://discourse.julialang.org/t/outer-constructor-for-base-kwdef-with-constrained-parametric-type/65286 "2021-07-26T07:45:05Z")

</div>

julia\> Base.@kwdef struct A1{T \<: Real} n::Int end julia\> A1{T}() where {T} = A1{T}(n=3) julia\> Base.@kwdef struct A2{T} n::Int end julia\> A2{T}() where {T} = A2{T}(n=3) julia\> A1{…

---

## [JuliaReach workshop materials uploaded](https://discourse.julialang.org/t/juliareach-workshop-materials-uploaded/65291)

<div class="topic-metadata">

**Author:** [@mforets](https://discourse.julialang.org/u/mforets)\
**Replies:** 0\
**Last updated:** [July 26, 2021, 6:47am UTC](https://discourse.julialang.org/t/juliareach-workshop-materials-uploaded/65291 "2021-07-26T06:47:21Z")

</div>

We have uploaded the materials for our workshop It’s all Set: A hands-on introduction to JuliaReach. The notebooks can be found here: GitHub - JuliaReach/JuliaCon-2021-Workshop-Its-All-Set: It's all Set: A hands-on intr…

[Previous page](https://discourse.julialang.org/latest.md?page=1318)

[Next page](https://discourse.julialang.org/latest.md?page=1320)
