# Latest

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

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

**Page:** 1665

---

## [Initializing an array with literals without allocating a temporary](https://discourse.julialang.org/t/initializing-an-array-with-literals-without-allocating-a-temporary/44590)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 18\
**Last updated:** [August 9, 2020, 7:32am UTC](https://discourse.julialang.org/t/initializing-an-array-with-literals-without-allocating-a-temporary/44590 "2020-08-09T07:32:48Z")

</div>

In this example: buf = Int64\[0, 0, 0, 0\] function foo(buf) buf\[1\] = 3 buf\[2\] = 1 buf\[3\] = 4 buf\[4\] = 1 nothing end function baz(buf) buf = \[3, 1, 4, 1\] nothing end foo doesn’t allocate, but is a bit ted…

---

## [Get variable's value in JuMP](https://discourse.julialang.org/t/get-variables-value-in-jump/44596)

<div class="topic-metadata">

**Author:** [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Replies:** 2\
**Last updated:** [August 9, 2020, 5:41am UTC](https://discourse.julialang.org/t/get-variables-value-in-jump/44596 "2020-08-09T05:41:19Z")

</div>

Hi All, I have solved an optimization problem using Julia (1.3.1) and JuMP (0.21.3). I can print the model and see the constraints. I also can get the objective function’s value using (objective\_value(model)) . However,…

---

## [How can I plot violin plots at specific x-axis labels if my data is not in a dataframe?](https://discourse.julialang.org/t/how-can-i-plot-violin-plots-at-specific-x-axis-labels-if-my-data-is-not-in-a-dataframe/44544)

<div class="topic-metadata">

**Author:** [@pjentsch0](https://discourse.julialang.org/u/pjentsch0)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 5:04pm UTC](https://discourse.julialang.org/t/how-can-i-plot-violin-plots-at-specific-x-axis-labels-if-my-data-is-not-in-a-dataframe/44544 "2020-08-08T17:04:55Z")

</div>

For instance, the following code makes this figure: julia\> d = Normal() julia\> a = rand(d,10,1000) julia\> violin(collect(eachrow(a)),legend = false) If I have a vector of 10 x-axis points, say x\_pts = 1:10:100, then t…

---

## [Performance and memory regression with function wrappers in Julia 1.4+](https://discourse.julialang.org/t/performance-and-memory-regression-with-function-wrappers-in-julia-1-4/44589)

<div class="topic-metadata">

**Author:** [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Replies:** 4\
**Last updated:** [August 9, 2020, 3:12am UTC](https://discourse.julialang.org/t/performance-and-memory-regression-with-function-wrappers-in-julia-1-4/44589 "2020-08-09T03:12:16Z")

</div>

I was surprised to find that FunctionWrappers which return a closed-over value appear to be significantly slower and allocate memory in Julia 1.4 and 1.5, while they are faster and allocate no memory in Julia 1-1.3: Set…

---

## [Error with base/generic function calls](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174)

<div class="topic-metadata">

**Author:** [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Replies:** 4\
**Last updated:** [August 9, 2020, 12:28am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174 "2020-08-09T00:28:42Z")

</div>

I’m having trouble with functions seemingly disappearing as I get an UndefVarError. Specifically, in my case, the subtypes() function, although I think I encountered the same issue with DataFrames.valuecols(). I have n…

---

## [Missing talk recordings](https://discourse.julialang.org/t/missing-talk-recordings/44582)

<div class="topic-metadata">

**Author:** [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Replies:** 3\
**Last updated:** [August 8, 2020, 10:48pm UTC](https://discourse.julialang.org/t/missing-talk-recordings/44582 "2020-08-08T22:48:10Z")

</div>

There are a few talks that I missed live and would love to watch the recordings E.g. https://live.juliacon.org/talk/8NDYCT https://live.juliacon.org/talk/CA3SET the videos are missing on the conference web page, and …

---

## [How do I put a parametrized struct into another parametrized container?](https://discourse.julialang.org/t/how-do-i-put-a-parametrized-struct-into-another-parametrized-container/44537)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 9\
**Last updated:** [August 8, 2020, 10:03pm UTC](https://discourse.julialang.org/t/how-do-i-put-a-parametrized-struct-into-another-parametrized-container/44537 "2020-08-08T22:03:08Z")

</div>

using DataStructures import Base.isless struct SEvent{F1} callback::F1 time::Float64 end function SEvent(callback::F1, time) where F1 SEvent{F1}(callback, time) end function isless(a::SEvent, b::SEvent) …

---

## [Specifying loss functions in Flux.jl](https://discourse.julialang.org/t/specifying-loss-functions-in-flux-jl/44586)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 8\
**Last updated:** [August 8, 2020, 10:03pm UTC](https://discourse.julialang.org/t/specifying-loss-functions-in-flux-jl/44586 "2020-08-08T22:03:04Z")

</div>

I am trying to write loss functions for use in a simple Neural Network training. As I understand from the documentation loss functions should have the signature loss(ŷ, y). So to my mind something like loss(ŷ, y) = m…

---

## [How do I define a macro within a function?](https://discourse.julialang.org/t/how-do-i-define-a-macro-within-a-function/44581)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 8\
**Last updated:** [August 8, 2020, 9:56pm UTC](https://discourse.julialang.org/t/how-do-i-define-a-macro-within-a-function/44581 "2020-08-08T21:56:06Z")

</div>

I want to define a macro within a function, that uses an input argument of the function: function runModel(; model::CoronaModel, n=10, simDuration=2) macro injectModel(name) quote function $(esc…

---

## [Implementing discrete factor products](https://discourse.julialang.org/t/implementing-discrete-factor-products/44564)

<div class="topic-metadata">

**Author:** [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Replies:** 0\
**Last updated:** [August 8, 2020, 11:47am UTC](https://discourse.julialang.org/t/implementing-discrete-factor-products/44564 "2020-08-08T11:47:29Z")

</div>

I have an algorithm that involves computations over multidimensional arrays. I came across this blog post by Tim Holy: Multidimensional algorithms and iteration). I’m wondering whether the CartesianIndices data structu…

---

## [Merge to number](https://discourse.julialang.org/t/merge-to-number/44583)

<div class="topic-metadata">

**Author:** [@Fuad\_Sami](https://discourse.julialang.org/u/Fuad_Sami)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 9:51pm UTC](https://discourse.julialang.org/t/merge-to-number/44583 "2020-08-08T21:51:20Z")

</div>

hi all i have two arrays a and b find the maximum between a\[i\] and b\[i\] and return it if i have a = \[1,5,9,2\] and b =\[3,3,7,8,6,4\] the output will be res = \[3,5,9,8,6,4\] it is easy i know but i don’t know why my co…

---

## [Recommendation for thread-safe file access (ex .jld2)](https://discourse.julialang.org/t/recommendation-for-thread-safe-file-access-ex-jld2/44585)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [August 8, 2020, 8:28pm UTC](https://discourse.julialang.org/t/recommendation-for-thread-safe-file-access-ex-jld2/44585 "2020-08-08T20:28:41Z")

</div>

I have a for loop that uses the @threads macro, here is a simple example: Threads.@threads for i in 1:10 checks = load("myfile.jld2")\["checks"\] push!(checks,(i,i+1)) @save "myfile.jld2" checks end Currently…

---

## [Geting the image pixel using ImageView](https://discourse.julialang.org/t/geting-the-image-pixel-using-imageview/44555)

<div class="topic-metadata">

**Author:** [@kobied](https://discourse.julialang.org/u/kobied)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 6:59pm UTC](https://discourse.julialang.org/t/geting-the-image-pixel-using-imageview/44555 "2020-08-08T18:59:50Z")

</div>

Hello, I need to create a gui which has an image and some controllers. I’m using Gtk and ImageView, my quastion is, how can i get the image pixle that the mouse courser is clicked on? Thanks in ahead

---

## [Manipulating HTML DOM using Julia](https://discourse.julialang.org/t/manipulating-html-dom-using-julia/31765)

<div class="topic-metadata">

**Author:** [@Rajesh\_Talluri](https://discourse.julialang.org/u/Rajesh_Talluri)\
**Replies:** 3\
**Last updated:** [August 8, 2020, 5:47pm UTC](https://discourse.julialang.org/t/manipulating-html-dom-using-julia/31765 "2020-08-08T17:47:06Z")

</div>

Hi, I am trying to manipulate the DOM elements(e.g. adding a parent node and changing hierarchy of some nodes) of a HTML document. I could parse the HTML using Gumbo.jl. However, I could not manipulate the DOM using that…

---

## [Zygote and setindex!](https://discourse.julialang.org/t/zygote-and-setindex/44554)

<div class="topic-metadata">

**Author:** [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Replies:** 0\
**Last updated:** [August 8, 2020, 8:12am UTC](https://discourse.julialang.org/t/zygote-and-setindex/44554 "2020-08-08T08:12:28Z")

</div>

I would like to use Zygote to differentiate through some code where I would usually use setindex!, e.g. A\[i, j\] += v where v is a scalar and A a matrix. My current approach is to use a custom OneHotMatrix struct OneHotM…

---

## [How to pass auxiliary variables and constraints as "Defined variables" of AMPL in JuMP?](https://discourse.julialang.org/t/how-to-pass-auxiliary-variables-and-constraints-as-defined-variables-of-ampl-in-jump/44547)

<div class="topic-metadata">

**Author:** [@SOtani](https://discourse.julialang.org/u/SOtani)\
**Replies:** 2\
**Last updated:** [August 8, 2020, 4:42pm UTC](https://discourse.julialang.org/t/how-to-pass-auxiliary-variables-and-constraints-as-defined-variables-of-ampl-in-jump/44547 "2020-08-08T16:42:19Z")

</div>

I am considering how to pass auxiliary variables as “Defined variables” of AMPL in JuMP. Sample code model = JuMP.Model(optimizer\_with\_attributes(Ipopt.Optimizer)) @variable(model, x) @variable(model, y) @variable(mode…

---

## [License error for JuMP](https://discourse.julialang.org/t/license-error-for-jump/44576)

<div class="topic-metadata">

**Author:** [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Replies:** 1\
**Last updated:** [August 8, 2020, 4:34pm UTC](https://discourse.julialang.org/t/license-error-for-jump/44576 "2020-08-08T16:34:20Z")

</div>

Hi All, I have installed JuMP (“0.18.5”) and Gurobi (“0.6.0”). I have put a valid license for Gurobi in its corresponding folder. However, I get the following error when I want to solve my optimization problem. Can you …

---

## [Saving data into array having struct data type](https://discourse.julialang.org/t/saving-data-into-array-having-struct-data-type/44567)

<div class="topic-metadata">

**Author:** [@musman](https://discourse.julialang.org/u/musman)\
**Replies:** 5\
**Last updated:** [August 8, 2020, 4:02pm UTC](https://discourse.julialang.org/t/saving-data-into-array-having-struct-data-type/44567 "2020-08-08T16:02:14Z")

</div>

Hi, newbie to Julia. I am trying to run the following \> struct Bus \> bus\_num::Int64 \> bus\_type::Int64 \> bus\_area::Int64 \> bus\_vmag::Float64 \> bus\_vangle::Float64 \> bus\_vnom::Float64 \> bus\_vmax::Float64 \> bus\_vmin::Floa…

---

## [Poor results using WriteVTK?](https://discourse.julialang.org/t/poor-results-using-writevtk/44570)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 2\
**Last updated:** [August 8, 2020, 2:34pm UTC](https://discourse.julialang.org/t/poor-results-using-writevtk/44570 "2020-08-08T14:34:31Z")

</div>

Hello! I have made a very simple code to save point data + one point data array: using WriteVTK using Random using Test function write\_vtp(filename::String, points, attribute) polys = empty(MeshCell{WriteVTK.Pol…

---

## [Add two binary numbers](https://discourse.julialang.org/t/add-two-binary-numbers/44556)

<div class="topic-metadata">

**Author:** [@Fuad\_Sami](https://discourse.julialang.org/u/Fuad_Sami)\
**Replies:** 3\
**Last updated:** [August 8, 2020, 2:33pm UTC](https://discourse.julialang.org/t/add-two-binary-numbers/44556 "2020-08-08T14:33:32Z")

</div>

i need to add two binary number. in the first place how i display a binary number in julia ? i try a lot things but doesn’t work like , parse(Int,"111",2) or Int(0b110111) in python the code is like that def add…

---

## [Issues with AD of Hypergeometric function in narrow parameter band](https://discourse.julialang.org/t/issues-with-ad-of-hypergeometric-function-in-narrow-parameter-band/44523)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 6\
**Last updated:** [August 8, 2020, 1:38pm UTC](https://discourse.julialang.org/t/issues-with-ad-of-hypergeometric-function-in-narrow-parameter-band/44523 "2020-08-08T13:38:59Z")

</div>

Hello— Using AD with the Gauss 2F1 function has come up in some work I am doing. I am incredibly impressed by the performance and functionality of HypergeometricFunctions.jl, but I’m having a strange issue where only fo…

---

## [Fields of an anonymous function?](https://discourse.julialang.org/t/fields-of-an-anonymous-function/44562)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 8\
**Last updated:** [August 8, 2020, 1:19pm UTC](https://discourse.julialang.org/t/fields-of-an-anonymous-function/44562 "2020-08-08T13:19:30Z")

</div>

Looking at some examples of a package I came across this type of behavior: function f(n) a = n x -\> x^a end g = f(2) g.a # 2 Can someone point out where that is documented?

---

## [Initialize weights for Flux.Dense](https://discourse.julialang.org/t/initialize-weights-for-flux-dense/43590)

<div class="topic-metadata">

**Author:** [@zazizoma](https://discourse.julialang.org/u/zazizoma)\
**Replies:** 1\
**Last updated:** [August 8, 2020, 11:50am UTC](https://discourse.julialang.org/t/initialize-weights-for-flux-dense/43590 "2020-08-08T11:50:49Z")

</div>

Hello. I can’t figure out the syntax to initialize the weights for Flux.Dense. using Flux w0 = Float32\[1, 2, 3, 4\] nn = Dense(4, 1, relu; initW = w0) produces the following error. MethodError: objects of type Ar…

---

## [Cannot achieve type-stability and get rid of allocations](https://discourse.julialang.org/t/cannot-achieve-type-stability-and-get-rid-of-allocations/44548)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 7\
**Last updated:** [August 8, 2020, 11:47am UTC](https://discourse.julialang.org/t/cannot-achieve-type-stability-and-get-rid-of-allocations/44548 "2020-08-08T11:47:40Z")

</div>

Here is a simple implementation of a two-pointer technique for sorted arrays: function f(xs, ys) i\_begin, i\_end = firstindex(xs), firstindex(xs) map(ys) do y i\_begin = something( findnext(x -\> x \>= y, xs…

---

## [Parametrizing a self-referential function field](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 11:46am UTC](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538 "2020-08-08T11:46:20Z")

</div>

My struct changes its input function to automatically get the struct as an argument. This works if I don’t type the struct, but I have no idea how I can type it. mutable struct CoronaModel{F1} # other fields omitted…

---

## [Preallocated variable length buffer with known maximum length](https://discourse.julialang.org/t/preallocated-variable-length-buffer-with-known-maximum-length/44550)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 13\
**Last updated:** [August 8, 2020, 11:00am UTC](https://discourse.julialang.org/t/preallocated-variable-length-buffer-with-known-maximum-length/44550 "2020-08-08T11:00:39Z")

</div>

In this code snippet: n = 9 buf = Int\[\] sizehint!(buf, n) function foo(buf) empty!(buf) for i in 1:rand(1:n) push!(buf, rand(1:n)) end end I intended to preallocate buf, so it foo(buf) can be called without…

---

## [Question about Plots](https://discourse.julialang.org/t/question-about-plots/44557)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 3\
**Last updated:** [August 8, 2020, 9:54am UTC](https://discourse.julialang.org/t/question-about-plots/44557 "2020-08-08T09:54:21Z")

</div>

using SingularSpectrumAnalysis, Plots # generate some data L = 20 # Window length K = 100 N = K\*L; # number of datapoints t = 1:N; # Time vector T = 20…

---

## [Misterious appearance of Plots MIME output in Jupyterlab](https://discourse.julialang.org/t/misterious-appearance-of-plots-mime-output-in-jupyterlab/44485)

<div class="topic-metadata">

**Author:** [@alusiani](https://discourse.julialang.org/u/alusiani)\
**Replies:** 1\
**Last updated:** [August 8, 2020, 7:03am UTC](https://discourse.julialang.org/t/misterious-appearance-of-plots-mime-output-in-jupyterlab/44485 "2020-08-08T07:03:52Z")

</div>

I am puzzled by why a plot is shown in Jupyterlab despite I take all precautions for it not to be, when I call savefig(). In short, if I do using Plots plot(range, range.^2); savefig("a.pdf"); nothing in Jupyterlab, …

---

## [How can I display single spaced, multi-line text in Pluto?](https://discourse.julialang.org/t/how-can-i-display-single-spaced-multi-line-text-in-pluto/44483)

<div class="topic-metadata">

**Author:** [@jdad](https://discourse.julialang.org/u/jdad)\
**Replies:** 5\
**Last updated:** [August 8, 2020, 7:49am UTC](https://discourse.julialang.org/t/how-can-i-display-single-spaced-multi-line-text-in-pluto/44483 "2020-08-08T07:49:42Z")

</div>

Dear Pluto developers and users, I know that with Pluto, “print” goes to console, and that the (best?) way to get text displayed is to have cell result as markdown. I wanted to have “versioninfo()” displayed, which prin…

---

## [Optional arguments+splatting](https://discourse.julialang.org/t/optional-arguments-splatting/44505)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 5:24am UTC](https://discourse.julialang.org/t/optional-arguments-splatting/44505 "2020-08-08T05:24:07Z")

</div>

Julia’s creators say they are greedy - so am I. I want to create a function g that accepts a list of arguments (I am trying with a named tuple), and passes it on to a function f. I have 3 requirements The user of g m…

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

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