# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=358

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

**Page:** 359

---

## [Issue with custom Flux loss function](https://discourse.julialang.org/t/issue-with-custom-flux-loss-function/91386)

<div class="topic-metadata">

**Author:** [@smickus](https://discourse.julialang.org/u/smickus)\
**Replies:** 0\
**Last updated:** [December 7, 2022, 7:37pm UTC](https://discourse.julialang.org/t/issue-with-custom-flux-loss-function/91386 "2022-12-07T19:37:27Z")

</div>

Hi I am trying to create a custom loss function in Flux which uses the output from the flux model as parameters to an ODE equation. However I am getting an error that I have been unable to solve. The code is the follo…

---

## [Is back propagation in Flux alway run on a single cpu core?](https://discourse.julialang.org/t/is-back-propagation-in-flux-alway-run-on-a-single-cpu-core/91379)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 0\
**Last updated:** [December 7, 2022, 6:07pm UTC](https://discourse.julialang.org/t/is-back-propagation-in-flux-alway-run-on-a-single-cpu-core/91379 "2022-12-07T18:07:08Z")

</div>

Hi, I am trainning a neural network with Flux on a machine with 56 cpu cores, but I found that it seems it is alway only one core working while Flux.train! is performed, and I can see multi cpu is running in the forwar…

---

## [Type system debug bool to elide code based on function parameter](https://discourse.julialang.org/t/type-system-debug-bool-to-elide-code-based-on-function-parameter/91378)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 0\
**Last updated:** [December 7, 2022, 6:06pm UTC](https://discourse.julialang.org/t/type-system-debug-bool-to-elide-code-based-on-function-parameter/91378 "2022-12-07T18:06:46Z")

</div>

I’m sure there is a known idiom for this, but I can’t find it at the moment. I want to write something like: function run(a, b, debugBool) # ... do lots of stuff debugBool && @show debug info # ... do lots of stu…

---

## [Custom Layer in Lux.jl](https://discourse.julialang.org/t/custom-layer-in-lux-jl/91371)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 1\
**Last updated:** [December 7, 2022, 5:36pm UTC](https://discourse.julialang.org/t/custom-layer-in-lux-jl/91371 "2022-12-07T17:36:39Z")

</div>

I am looking at the documentation on custom layers, and do not understand the line (l::LuxLinear)(x,ps,st) = ..... More specifically, I do not see where the variable l::LuxLinear is used further down when the model is ru…

---

## [Array of union causing 10x slowdown](https://discourse.julialang.org/t/array-of-union-causing-10x-slowdown/91341)

<div class="topic-metadata">

**Author:** [@Ininterrompue](https://discourse.julialang.org/u/Ininterrompue)\
**Replies:** 6\
**Last updated:** [December 7, 2022, 5:35pm UTC](https://discourse.julialang.org/t/array-of-union-causing-10x-slowdown/91341 "2022-12-07T17:35:39Z")

</div>

I have a type-stability question. In my 2D axisymmetric ray tracing code, I define an array of surfaces that has the type Union{Cone, Plane}, like surfaces = Matrix{Union{Cone, Plane}}(undef, 100, 2) All of them should…

---

## [Dict doesn't reuse deleted slots?](https://discourse.julialang.org/t/dict-doesnt-reuse-deleted-slots/45335)

<div class="topic-metadata">

**Author:** [@Christian\_Rorvik](https://discourse.julialang.org/u/Christian_Rorvik)\
**Replies:** 1\
**Last updated:** [December 7, 2022, 3:52pm UTC](https://discourse.julialang.org/t/dict-doesnt-reuse-deleted-slots/45335 "2022-12-07T15:52:16Z")

</div>

I’ve come upon a performance gotcha with Dict, wherein large amounts of insertions and deletions cause rehashing and allocations even when the load factor is stable. I don’t know much about hash table implementations, s…

---

## [Color of a parametric surface with Makie](https://discourse.julialang.org/t/color-of-a-parametric-surface-with-makie/91363)

<div class="topic-metadata">

**Author:** [@\_stla](https://discourse.julialang.org/u/_stla)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 3:39pm UTC](https://discourse.julialang.org/t/color-of-a-parametric-surface-with-makie/91363 "2022-12-07T15:39:01Z")

</div>

Hello, The code below plots the rounded cube shown on the image. The color = :yellow argument has no effect. How to plot the cube with a single color? The document of surface says nothing about the keywords arguments. u…

---

## [Base.@kwdef breaks in tests only](https://discourse.julialang.org/t/base-kwdef-breaks-in-tests-only/91356)

<div class="topic-metadata">

**Author:** [@eott-siz](https://discourse.julialang.org/u/eott-siz)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 3:13pm UTC](https://discourse.julialang.org/t/base-kwdef-breaks-in-tests-only/91356 "2022-12-07T15:13:42Z")

</div>

Julia v1.7.3 I have encountered a problem with using Base.@kwdef that only occurs in tests, not when code is executed normally. An example: File src/Example.jl: module Example Base.@kwdef mutable struct Foo bar :…

---

## [Read graphml](https://discourse.julialang.org/t/read-graphml/91085)

<div class="topic-metadata">

**Author:** [@ahmad88](https://discourse.julialang.org/u/ahmad88)\
**Replies:** 24\
**Last updated:** [December 7, 2022, 2:21pm UTC](https://discourse.julialang.org/t/read-graphml/91085 "2022-12-07T14:21:35Z")

</div>

I have graphs in Graphml format and I am trying to read the graph as follow loadgraph("tailorS1.graphml",graph,GraphIO.GraphML.GraphMLFormat()) but I got the following error: LoadError: UndefVarError: GraphML not defi…

---

## [Broadcast transformed data from single row to multiple columns](https://discourse.julialang.org/t/broadcast-transformed-data-from-single-row-to-multiple-columns/91275)

<div class="topic-metadata">

**Author:** [@daharn](https://discourse.julialang.org/u/daharn)\
**Replies:** 13\
**Last updated:** [December 7, 2022, 1:27pm UTC](https://discourse.julialang.org/t/broadcast-transformed-data-from-single-row-to-multiple-columns/91275 "2022-12-07T13:27:04Z")

</div>

Suppose I have a DataFrame like this df = DataFrame("a" =\> \[1,2\], "b" =\> \[3,4\]) 2×2 DataFrame Row │ a b │ Int64 Int64 ─────┼────────────── 1 │ 1 3 2 │ 2 4 and I want to calcu…

---

## [How does broadcasting work for a vector of \`RefArray\`s?](https://discourse.julialang.org/t/how-does-broadcasting-work-for-a-vector-of-refarray-s/91326)

<div class="topic-metadata">

**Author:** [@ArthurW](https://discourse.julialang.org/u/ArthurW)\
**Replies:** 3\
**Last updated:** [December 7, 2022, 11:41am UTC](https://discourse.julialang.org/t/how-does-broadcasting-work-for-a-vector-of-refarray-s/91326 "2022-12-07T11:41:52Z")

</div>

Hello. I’m having some trouble understanding Julia’s broadcast behaviour on a specific scenario. The following code works as expected: julia\> a = \[1, 2, 3\]; julia\> refs = \[Ref(a, i) for i in eachindex(a)\]; julia\> ref…

---

## [Artifacts.toml Cross Platform Example](https://discourse.julialang.org/t/artifacts-toml-cross-platform-example/91090)

<div class="topic-metadata">

**Author:** [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 10:25am UTC](https://discourse.julialang.org/t/artifacts-toml-cross-platform-example/91090 "2022-12-07T10:25:32Z")

</div>

How would one use Artifacts.toml to package a binary for Mac, Windows and Linux? I’d like to use these releases on each platform

---

## [How to write a summation in Julian?](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346)

<div class="topic-metadata">

**Author:** [@xArcoirisXx](https://discourse.julialang.org/u/xArcoirisXx)\
**Replies:** 6\
**Last updated:** [December 7, 2022, 8:10am UTC](https://discourse.julialang.org/t/how-to-write-a-summation-in-julian/91346 "2022-12-07T08:10:18Z")

</div>

How to write and solve a summation in Julian?

---

## [Mystery of kwargs](https://discourse.julialang.org/t/mystery-of-kwargs/38768)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 11\
**Last updated:** [December 7, 2022, 8:01am UTC](https://discourse.julialang.org/t/mystery-of-kwargs/38768 "2022-12-07T08:01:30Z")

</div>

I am completely flummoxed by using a dict as the kwargs input in a varargs function that uses keyword arguments. Read the manual many times but it leaves out a critical thing: how does the callee unpack the varargs? Th…

---

## [Is there a Symmetric Sparse Matrix Implementation in Julia?](https://discourse.julialang.org/t/is-there-a-symmetric-sparse-matrix-implementation-in-julia/91333)

<div class="topic-metadata">

**Author:** [@cdelv](https://discourse.julialang.org/u/cdelv)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 2:28am UTC](https://discourse.julialang.org/t/is-there-a-symmetric-sparse-matrix-implementation-in-julia/91333 "2022-12-07T02:28:31Z")

</div>

Hi, I want a symmetric sparse matrix that behaves like this using StaticArrays using Accessors A = zeros(SHermitianCompact{3}) A = @set A\[1,2\] = 1 3×3 SHermitianCompact{3, Float64, 6} with indices SOneTo(3)×SOneTo(3): …

---

## [When the ternary operator fails](https://discourse.julialang.org/t/when-the-ternary-operator-fails/91332)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 2:25am UTC](https://discourse.julialang.org/t/when-the-ternary-operator-fails/91332 "2022-12-07T02:25:13Z")

</div>

In the specific case where I want the ternary operator to give me an operator, it fails, but the if then else approach works. I expect there is an explanation, or maybe it is a bug. What does not work julia\> a = "1+2"…

---

## [Parsing keyword argument method call name?](https://discourse.julialang.org/t/parsing-keyword-argument-method-call-name/91334)

<div class="topic-metadata">

**Author:** [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)\
**Replies:** 0\
**Last updated:** [December 7, 2022, 2:02am UTC](https://discourse.julialang.org/t/parsing-keyword-argument-method-call-name/91334 "2022-12-07T02:02:28Z")

</div>

Hey everyone, I’m working on improving Term.jl’s stack trace functionality. The idea is to present nicely formatted stacktraces (hiding irrelevant info and highlighting useful stuff with color) However I find it har…

---

## [Wiki of known traps](https://discourse.julialang.org/t/wiki-of-known-traps/91329)

<div class="topic-metadata">

**Author:** [@tchebycheff](https://discourse.julialang.org/u/tchebycheff)\
**Replies:** 0\
**Last updated:** [December 7, 2022, 1:08am UTC](https://discourse.julialang.org/t/wiki-of-known-traps/91329 "2022-12-07T01:08:53Z")

</div>

Is there a wiki of known Julia traps? (fresh bruises from logpdfs of Distributions.jl and auto differentiation)

---

## [Weird Base.show behavior with custom Struct](https://discourse.julialang.org/t/weird-base-show-behavior-with-custom-struct/91321)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 3\
**Last updated:** [December 7, 2022, 12:16am UTC](https://discourse.julialang.org/t/weird-base-show-behavior-with-custom-struct/91321 "2022-12-07T00:16:58Z")

</div>

For some reason checking my custom Struct in the REPL differs from the Base.show() method I defined. Can anyone replicate and/or explain why this might be happening? Here is a MWE to (hopefully) replicate the behavior: …

---

## [How are vectors of vectors type coerced?](https://discourse.julialang.org/t/how-are-vectors-of-vectors-type-coerced/91322)

<div class="topic-metadata">

**Author:** [@jeffreyesun](https://discourse.julialang.org/u/jeffreyesun)\
**Replies:** 6\
**Last updated:** [December 6, 2022, 11:26pm UTC](https://discourse.julialang.org/t/how-are-vectors-of-vectors-type-coerced/91322 "2022-12-06T23:26:50Z")

</div>

I was having a bug in my code, which basically boils down to this. inds = \[1,2,3\] # Vector{Int} vals = \[1.5, 2.5, 3.5\] # Vector{Float64} ivvec = \[inds, vals\] # Vector{Vector{Float64}} ivvec\[2\]\[ivvec\[1\]\] #ERROR: Argument…

---

## [Question about macro and how to resolve/esc variables/expressions](https://discourse.julialang.org/t/question-about-macro-and-how-to-resolve-esc-variables-expressions/91309)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [December 6, 2022, 8:19pm UTC](https://discourse.julialang.org/t/question-about-macro-and-how-to-resolve-esc-variables-expressions/91309 "2022-12-06T20:19:08Z")

</div>

Hi all :slight\_smile: Here is a little example code. I’m interested in the local var \_error\_msg : local \_error\_msg = $(esc(sprint(showerror, error, catch\_backtrace()))) So what I want is the error and catch\_backtrace …

---

## [Show PyPlot](https://discourse.julialang.org/t/show-pyplot/91166)

<div class="topic-metadata">

**Author:** [@marllos](https://discourse.julialang.org/u/marllos)\
**Replies:** 9\
**Last updated:** [December 6, 2022, 5:55pm UTC](https://discourse.julialang.org/t/show-pyplot/91166 "2022-12-06T17:55:51Z")

</div>

Hello everyone! Please, I need help with a simple task: x = plot(…); …; close() How to show the graph again using x? I use Julia 1.8.3 e PyPlot

---

## [Juliaup not working](https://discourse.julialang.org/t/juliaup-not-working/91158)

<div class="topic-metadata">

**Author:** [@mb96](https://discourse.julialang.org/u/mb96)\
**Replies:** 6\
**Last updated:** [December 6, 2022, 5:02pm UTC](https://discourse.julialang.org/t/juliaup-not-working/91158 "2022-12-06T17:02:22Z")

</div>

Hi everyone, I installed juliaup yesterday on my Mac and it worked fine. However, today I am having trouble initializing the desired release. If I go to my terminal and type juliaup status I get: However, if I type…

---

## [Diffeq\_rd not found](https://discourse.julialang.org/t/diffeq-rd-not-found/91310)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 3\
**Last updated:** [December 6, 2022, 4:49pm UTC](https://discourse.julialang.org/t/diffeq-rd-not-found/91310 "2022-12-06T16:49:21Z")

</div>

@ChrisRackauckas Hi Chris, When using \[aae7a2af\] DiffEqFlux v1.52.0 \[0c46a032\] DifferentialEquations v7.6.0 I get an error: diffeq\_rd not found, when running code found at URL: model-zoo/ode.jl at da4156b4a9fb0d5…

---

## [Multiple windows in Visual Studio Code](https://discourse.julialang.org/t/multiple-windows-in-visual-studio-code/91301)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 1\
**Last updated:** [December 6, 2022, 1:56pm UTC](https://discourse.julialang.org/t/multiple-windows-in-visual-studio-code/91301 "2022-12-06T13:56:28Z")

</div>

I have two questions regarding Julia packages: if I run some Julia program during which several packages are precompiled, leave Visual Code, and return to it a month later, is there any reason precompilation should oc…

---

## [\`Core.Box\` around captured variable](https://discourse.julialang.org/t/core-box-around-captured-variable/91299)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 2\
**Last updated:** [December 6, 2022, 1:24pm UTC](https://discourse.julialang.org/t/core-box-around-captured-variable/91299 "2022-12-06T13:24:33Z")

</div>

If I define a variable inside an outer function that generates a closure, this variable gets boxed inside the closer. Does this affect performance and if yes, how do I best avoid it? Here is a simple MWE: julia\> functi…

---

## [Is it possible to set a floating point precision while evaluating jldoctest blocks in docstrings?](https://discourse.julialang.org/t/is-it-possible-to-set-a-floating-point-precision-while-evaluating-jldoctest-blocks-in-docstrings/59528)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 5\
**Last updated:** [December 6, 2022, 12:31pm UTC](https://discourse.julialang.org/t/is-it-possible-to-set-a-floating-point-precision-while-evaluating-jldoctest-blocks-in-docstrings/59528 "2022-12-06T12:31:23Z")

</div>

I’m not too familiar with Documenter, so this might have a solution that I’m not aware of. Is it possible to set a filter to compare only the first n digits of floating-point numbers in a jldoctest block? Either of a glo…

---

## [Read file directly into Vector{Char}](https://discourse.julialang.org/t/read-file-directly-into-vector-char/91292)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 14\
**Last updated:** [December 6, 2022, 10:25am UTC](https://discourse.julialang.org/t/read-file-directly-into-vector-char/91292 "2022-12-06T10:25:39Z")

</div>

I want to read a UTF8 encoded file into Vector{Char}. One way to do this is: data = collect(Char, read("input.txt")) However, this will perform a copy, first reading in the contents of the file, and then copying it ou…

---

## [Problem with rounding with big numbers](https://discourse.julialang.org/t/problem-with-rounding-with-big-numbers/4454)

<div class="topic-metadata">

**Author:** [@jgk99](https://discourse.julialang.org/u/jgk99)\
**Replies:** 2\
**Last updated:** [December 6, 2022, 10:05am UTC](https://discourse.julialang.org/t/problem-with-rounding-with-big-numbers/4454 "2022-12-06T10:05:41Z")

</div>

BigInt(big(2017.)^2017) does not generate the correct value which is generated by: big(2017)^2017. Why is their a rounding error with BigFloat?

---

## [Metaprogramming with @generated](https://discourse.julialang.org/t/metaprogramming-with-generated/91248)

<div class="topic-metadata">

**Author:** [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Replies:** 6\
**Last updated:** [December 6, 2022, 8:08am UTC](https://discourse.julialang.org/t/metaprogramming-with-generated/91248 "2022-12-06T08:08:34Z")

</div>

I would like to write a simple function where I give it the operator I would like to apply as a symbol and it returns a runnable function that I can actually use. e.g. @generated genmyfun( op , args) = :($op ( args )…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=357)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=359)
