# Latest

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

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

**Page:** 1338

---

## [Elegant broadcasting over Matrix{Any} with different functions](https://discourse.julialang.org/t/elegant-broadcasting-over-matrix-any-with-different-functions/64210)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 3:53am UTC](https://discourse.julialang.org/t/elegant-broadcasting-over-matrix-any-with-different-functions/64210 "2021-07-08T03:53:08Z")

</div>

How do I apply function f over the diagonal and g over off-diagonal of a matrix, and more generally over indices I and J? Here I and J are subsets of product of the row and column index sets. matrix = rand(3,3) result =…

---

## [Why isn't this function type stable?](https://discourse.julialang.org/t/why-isnt-this-function-type-stable/64244)

<div class="topic-metadata">

**Author:** [@Arrigo\_Benedetti](https://discourse.julialang.org/u/Arrigo_Benedetti)\
**Replies:** 1\
**Last updated:** [July 8, 2021, 1:32am UTC](https://discourse.julialang.org/t/why-isnt-this-function-type-stable/64244 "2021-07-08T01:32:10Z")

</div>

Let’s consider the function: using Sobol function fun\_pdf(img1::Matrix{T}, n\_skip) where T \<: Real (nrows, ncols) = size(img1) indx = SobolSeq(\[0, 0\], \[ncols - 1, nrows - 1\]) indx = skip(indx, n\_skip) …

---

## [Addition/Subtraction operations on sparse arrays](https://discourse.julialang.org/t/addition-subtraction-operations-on-sparse-arrays/64241)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 11:58pm UTC](https://discourse.julialang.org/t/addition-subtraction-operations-on-sparse-arrays/64241 "2021-07-07T23:58:33Z")

</div>

If I have a sparse array, is there a way to only broadcast operations onto the non-zero values in that array? I find myself needing this operation quite often. A broadcast will obviously perform the operation on every e…

---

## [Is it possible to create a struct instance without an explicit constructor?](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243)

<div class="topic-metadata">

**Author:** [@Visipi](https://discourse.julialang.org/u/Visipi)\
**Replies:** 1\
**Last updated:** [July 7, 2021, 11:47pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243 "2021-07-07T23:47:13Z")

</div>

I have this problem where I’m given a DataType for a mutable struct and I have a lot of values corresponding to all the fields for this struct. Trouble is that these values might be out of order so I have no way of loadi…

---

## [How to start a new Julia session from script](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848)

<div class="topic-metadata">

**Author:** [@Micah\_Mungal](https://discourse.julialang.org/u/Micah_Mungal)\
**Replies:** 27\
**Last updated:** [July 7, 2021, 11:46pm UTC](https://discourse.julialang.org/t/how-to-start-a-new-julia-session-from-script/63848 "2021-07-07T23:46:12Z")

</div>

I am currently working on solving a optimization problem using julia and gurobi. I need to solve this optimizaton problem around 500 times (each time uses a different set of data). However, instead of running a julia scr…

---

## [Scatter plot vector of (Static)vectors with Plots](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 5\
**Last updated:** [July 7, 2021, 10:15pm UTC](https://discourse.julialang.org/t/scatter-plot-vector-of-static-vectors-with-plots/64232 "2021-07-07T22:15:33Z")

</div>

Is there a more direct way to plot a vector of vectors as a scatter plot with plots? julia\> using Plots, StaticArrays julia\> points = rand(SVector{2,Float64},10); julia\> scatter(\[x\[1\] for x in points\],\[ x\[2\] for x in …

---

## [\`collect\` iterator in reverse](https://discourse.julialang.org/t/collect-iterator-in-reverse/64225)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 11\
**Last updated:** [July 7, 2021, 11:15pm UTC](https://discourse.julialang.org/t/collect-iterator-in-reverse/64225 "2021-07-07T23:15:07Z")

</div>

Is there a generic function for collecting an iterator in reverse? I’m looking for a more efficient version of the following: itr = (i for i = 1:10) # for example vec = reverse(collect(itr)) I don’t think the solution …

---

## [Successive optimization in JuMP](https://discourse.julialang.org/t/successive-optimization-in-jump/64056)

<div class="topic-metadata">

**Author:** [@Maria95](https://discourse.julialang.org/u/Maria95)\
**Replies:** 6\
**Last updated:** [July 7, 2021, 11:03pm UTC](https://discourse.julialang.org/t/successive-optimization-in-jump/64056 "2021-07-07T23:03:43Z")

</div>

Sorry for the long post but I thought it is better to give more information. The question itself is not too long! I have given the mathematical formulation below and also my Julia code. Possible solution approach If…

---

## [Interact.jl custom layout to @manipulate macro](https://discourse.julialang.org/t/interact-jl-custom-layout-to-manipulate-macro/51757)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 7\
**Last updated:** [July 7, 2021, 10:53pm UTC](https://discourse.julialang.org/t/interact-jl-custom-layout-to-manipulate-macro/51757 "2021-07-07T22:53:06Z")

</div>

based on this example from the Interact.jl docs function mycolorpicker() r = slider(0:255, label = "red") g = slider(0:255, label = "green") b = slider(0:255, label = "blue") output = Interact.@map Color…

---

## [Pkg.test() is orders of magnitude slower than include("test/runtests.jl")](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235)

<div class="topic-metadata">

**Author:** [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 9:23pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235 "2021-07-07T21:23:37Z")

</div>

If I run the following (starting Julia with only --project switch) include("test/runtests.jl") @time of my function gives 0.030818 seconds (130.79 k allocations: 7.158 MiB) But, if I run using Pkg; Pkg.test(;julia…

---

## [Specific layout for @layout macro in Plots.jl](https://discourse.julialang.org/t/specific-layout-for-layout-macro-in-plots-jl/64228)

<div class="topic-metadata">

**Author:** [@Nick\_k](https://discourse.julialang.org/u/Nick_k)\
**Replies:** 5\
**Last updated:** [July 7, 2021, 9:23pm UTC](https://discourse.julialang.org/t/specific-layout-for-layout-macro-in-plots-jl/64228 "2021-07-07T21:23:16Z")

</div>

I’m trying to generate a rather specific custom layout with the @layout macro. I’ve checked the documentation (http://docs.juliaplots.org/latest/layouts/#advanced-layouts), but it’s rather sparse and doesn’t quite give m…

---

## [Complex number in Symbolics](https://discourse.julialang.org/t/complex-number-in-symbolics/62243)

<div class="topic-metadata">

**Author:** [@GpuCoder](https://discourse.julialang.org/u/GpuCoder)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 7:50pm UTC](https://discourse.julialang.org/t/complex-number-in-symbolics/62243 "2021-07-07T19:50:17Z")

</div>

First Question: Is this a bug? Is there some other intended approach that avoids this issue? Symbolics.substitute(exp(z), z =\> pi\*im) MethodError: Num(::ComplexF64) is ambiguous. Candidates: (::Type{T})(z::Complex)…

---

## [Failed to use DiffEqOperator in fluidized bed simulation](https://discourse.julialang.org/t/failed-to-use-diffeqoperator-in-fluidized-bed-simulation/64143)

<div class="topic-metadata">

**Author:** [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Replies:** 0\
**Last updated:** [July 6, 2021, 10:25am UTC](https://discourse.julialang.org/t/failed-to-use-diffeqoperator-in-fluidized-bed-simulation/64143 "2021-07-06T10:25:37Z")

</div>

Hello all, I tried to use the DiffEqOperator.jl in fluidized bed simulation but failed. I am not sure if I defined the bc or derivative operator wrongly or it’s another problem. the test code are in the two files: fu…

---

## [Return solution at RK4 stages](https://discourse.julialang.org/t/return-solution-at-rk4-stages/64219)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 0\
**Last updated:** [July 7, 2021, 3:01pm UTC](https://discourse.julialang.org/t/return-solution-at-rk4-stages/64219 "2021-07-07T15:01:15Z")

</div>

Hi, Is there a way to access the solution at RK stages if I solve an ODE using the following line: prob = ODEProblem(lorenz,u0,tspan) sol = solve(prob, RK4(), dt=Δt,adaptive = false)

---

## [Pde heat diffusion solution](https://discourse.julialang.org/t/pde-heat-diffusion-solution/64027)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 33\
**Last updated:** [July 7, 2021, 2:47pm UTC](https://discourse.julialang.org/t/pde-heat-diffusion-solution/64027 "2021-07-07T14:47:00Z")

</div>

m = 100 delta\_z = 0.015 delta\_t = 0.15 z= delta\_z : delta\_z : 1-delta\_z print(z) j=1 n=1 while j\<=10 f(j)=1/(j\*(delta\_z)-1) a(j) = (1+((2\*(delta\_t))/((delta\_z)^2))+(((delta\_t)f(j))/(delta\_z))-((delta\_t)m(f(j)))) …

---

## [Documenter: publish in different languages?](https://discourse.julialang.org/t/documenter-publish-in-different-languages/64217)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 2:44pm UTC](https://discourse.julialang.org/t/documenter-publish-in-different-languages/64217 "2021-07-07T14:44:34Z")

</div>

Is it possible to publish documentation with Documenter in more than one language? For example by adding a flag somewhere for the reader to choose which language to read?

---

## [Using packages that were not added to the project's environment](https://discourse.julialang.org/t/using-packages-that-were-not-added-to-the-projects-environment/64159)

<div class="topic-metadata">

**Author:** [@yuvalw](https://discourse.julialang.org/u/yuvalw)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 2:41pm UTC](https://discourse.julialang.org/t/using-packages-that-were-not-added-to-the-projects-environment/64159 "2021-07-07T14:41:05Z")

</div>

Hello, New user of Pkg. I’ve noticed that If I open a new directory and create a new environment, i.e. \] activate ., I can run using \<SomePackage\> without adding it, as long as \<SomePackage\> is in my general environment…

---

## [Problem with Mutating array not supported in constructing a Wasserstein GAN in Flux](https://discourse.julialang.org/t/problem-with-mutating-array-not-supported-in-constructing-a-wasserstein-gan-in-flux/64203)

<div class="topic-metadata">

**Author:** [@gforchini](https://discourse.julialang.org/u/gforchini)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 1:16pm UTC](https://discourse.julialang.org/t/problem-with-mutating-array-not-supported-in-constructing-a-wasserstein-gan-in-flux/64203 "2021-07-07T13:16:49Z")

</div>

I am trying to construct a Wasserstein GAN as in Gulrajani, et al, Improved Training of Wasserstein GANs. Part of the code is below. The discriminator loss function contains a function of the derivatives of the discrimi…

---

## [(yet another) Zygote: mutating arrays is not supported](https://discourse.julialang.org/t/yet-another-zygote-mutating-arrays-is-not-supported/62294)

<div class="topic-metadata">

**Author:** [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Replies:** 10\
**Last updated:** [July 7, 2021, 1:11pm UTC](https://discourse.julialang.org/t/yet-another-zygote-mutating-arrays-is-not-supported/62294 "2021-07-07T13:11:25Z")

</div>

Hi all, thanks for the great work on Flux and Zygote! Quick summary: I’m training a simple (feedforward, relu) neural network on MNIST. If I use Flux.Losses.mse as a loss function, my code works If I use Flux.Losses.…

---

## [Typestable caching of multiple arrays with different eltype](https://discourse.julialang.org/t/typestable-caching-of-multiple-arrays-with-different-eltype/64197)

<div class="topic-metadata">

**Author:** [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 12:48pm UTC](https://discourse.julialang.org/t/typestable-caching-of-multiple-arrays-with-different-eltype/64197 "2021-07-07T12:48:05Z")

</div>

Hello, i was wondering, whether it is possible to code some kind of cache pool, where i can request cache arrays of various types. Each type of cache array should be only created once. I’ve tried # cache arbitrary arra…

---

## [Makie - Testing GLMakie with correct ReferenceTests](https://discourse.julialang.org/t/makie-testing-glmakie-with-correct-referencetests/64206)

<div class="topic-metadata">

**Author:** [@stroebel](https://discourse.julialang.org/u/stroebel)\
**Replies:** 1\
**Last updated:** [July 7, 2021, 11:40am UTC](https://discourse.julialang.org/t/makie-testing-glmakie-with-correct-referencetests/64206 "2021-07-07T11:40:14Z")

</div>

I am trying to get interactive plotting to work on my machine using either GLMakie or CairoMakie. Currently, both display a window with a black screen and then it seemingly crashes with no information. To try and see if…

---

## [Does Meshing.isosurface() work only with the exact value of iso in maching\_cube()](https://discourse.julialang.org/t/does-meshing-isosurface-work-only-with-the-exact-value-of-iso-in-maching-cube/64146)

<div class="topic-metadata">

**Author:** [@empet](https://discourse.julialang.org/u/empet)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 10:34am UTC](https://discourse.julialang.org/t/does-meshing-isosurface-work-only-with-the-exact-value-of-iso-in-maching-cube/64146 "2021-07-07T10:34:35Z")

</div>

I tried to use the function isosurface with marching\_cube, from Meshing.jl. I have volumetric data in an array of size(91, 109, 91), with Float64 values in the interval \[-3, 3\], and I wanted to get the mesh for the i…

---

## [Automatic differentiation with a for loop in the function definition](https://discourse.julialang.org/t/automatic-differentiation-with-a-for-loop-in-the-function-definition/64196)

<div class="topic-metadata">

**Author:** [@aymercan](https://discourse.julialang.org/u/aymercan)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 9:55am UTC](https://discourse.julialang.org/t/automatic-differentiation-with-a-for-loop-in-the-function-definition/64196 "2021-07-07T09:55:34Z")

</div>

Hi Julia community, I am using Julia for my economics research and this is my first question posted here. Hopefully it is a simple one that more experienced users can easily answer. I am trying to use automatic differe…

---

## [StaticArrays being used with DifferentialEquation callbacks](https://discourse.julialang.org/t/staticarrays-being-used-with-differentialequation-callbacks/64178)

<div class="topic-metadata">

**Author:** [@LionMod](https://discourse.julialang.org/u/LionMod)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 9:47am UTC](https://discourse.julialang.org/t/staticarrays-being-used-with-differentialequation-callbacks/64178 "2021-07-07T09:47:50Z")

</div>

I’ve been improving performance of my differential equations with @SVector and @MVectorbut I’ve got stuck when it comes to using it with callbacks specifically PresetTimeCallback. The idea is there is a large spike in v…

---

## [Access y/xlim of a plot in Plots](https://discourse.julialang.org/t/access-y-xlim-of-a-plot-in-plots/11236)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 9:47am UTC](https://discourse.julialang.org/t/access-y-xlim-of-a-plot-in-plots/11236 "2021-07-07T09:47:27Z")

</div>

I’m plotting something with aspect\_ratio=1 (GR backend) and the resulting file (via savefig) has a lot of “air” surrounding the plot. I want to make it a bit more tight. using Plots plot(rand(10), aspect\_ratio = 1) save…

---

## [Error with power](https://discourse.julialang.org/t/error-with-power/64135)

<div class="topic-metadata">

**Author:** [@Broti](https://discourse.julialang.org/u/Broti)\
**Replies:** 13\
**Last updated:** [July 7, 2021, 9:06am UTC](https://discourse.julialang.org/t/error-with-power/64135 "2021-07-07T09:06:47Z")

</div>

I recently began to use Julia for an internship but I’m struggling to make a function that raises to the power of a counter. Here’s my code: function f(x,y) return x\*(1.0-x)+y; end function g(x,y) return x^2 en…

---

## [Debug why docstrings not showing in REPL help](https://discourse.julialang.org/t/debug-why-docstrings-not-showing-in-repl-help/64198)

<div class="topic-metadata">

**Author:** [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 9:03am UTC](https://discourse.julialang.org/t/debug-why-docstrings-not-showing-in-repl-help/64198 "2021-07-07T09:03:50Z")

</div>

How can I debug the docstrings not showing up in my REPL? julia\> """ Function Roger() prints Wilco """ "Function Roger() prints Wilco\\n" julia\> function Roger() println("Wilco") end Rog…

---

## [Function return type depends on an input flag : Bad?](https://discourse.julialang.org/t/function-return-type-depends-on-an-input-flag-bad/63486)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 15\
**Last updated:** [July 7, 2021, 8:14am UTC](https://discourse.julialang.org/t/function-return-type-depends-on-an-input-flag-bad/63486 "2021-07-07T08:14:53Z")

</div>

I have a function that calculates ‘sky’ loss and optionally its gradient. function \_sky\_loss\_gradient(x, loss\_only::Bool) # calculation loss\_only && return loss # more calculation return loss, grad end …

---

## [How to calculate sum of a matrix by row and store in pre-allocated diagnoal matrix](https://discourse.julialang.org/t/how-to-calculate-sum-of-a-matrix-by-row-and-store-in-pre-allocated-diagnoal-matrix/64160)

<div class="topic-metadata">

**Author:** [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Replies:** 6\
**Last updated:** [July 7, 2021, 7:50am UTC](https://discourse.julialang.org/t/how-to-calculate-sum-of-a-matrix-by-row-and-store-in-pre-allocated-diagnoal-matrix/64160 "2021-07-07T07:50:27Z")

</div>

basically what I want to do is calculate the sum of a matrix, say u, by column and store it in a pre-allocated diagonal matrix, say du, in a more efficient way than vi = sum(u, dims=2) for i = 1:length(vi) du\[i, i\] …

---

## [How to change .julia folder location](https://discourse.julialang.org/t/how-to-change-julia-folder-location/64193)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 7:38am UTC](https://discourse.julialang.org/t/how-to-change-julia-folder-location/64193 "2021-07-07T07:38:55Z")

</div>

Hey all, Usually the .julia folder location is in the home directory of the current user. I want to change that. But it for example on c:.julia. I read that therefore I have to change the global variable JULIA\_DEPOT\_PA…

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

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