# General Usage

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

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

**Page:** 260

---

## [Overloading a function within a loop](https://discourse.julialang.org/t/overloading-a-function-within-a-loop/102615)

<div class="topic-metadata">

**Author:** [@Daniel1](https://discourse.julialang.org/u/Daniel1)\
**Replies:** 1\
**Last updated:** [August 8, 2023, 8:35pm UTC](https://discourse.julialang.org/t/overloading-a-function-within-a-loop/102615 "2023-08-08T20:35:19Z")

</div>

This question is closely related to the package iTensors, but it is really a Julia programming question, no knowledge of the package is needed. I need to overload a function provided by the package. The canonical way to…

---

## [Define a function in global scope inside another function](https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597)

<div class="topic-metadata">

**Author:** [@Qfl3x](https://discourse.julialang.org/u/Qfl3x)\
**Replies:** 6\
**Last updated:** [August 8, 2023, 7:06pm UTC](https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597 "2023-08-08T19:06:52Z")

</div>

I want to define a function a(x) inside a function b(a), but make a in global scope, example: a(x) = 3 + x function b(a) global a(x) = a + x end This gives an error currently: ERROR: syntax: Global method definiti…

---

## [Mix of index-based and slice based indexing across different dimensions](https://discourse.julialang.org/t/mix-of-index-based-and-slice-based-indexing-across-different-dimensions/102603)

<div class="topic-metadata">

**Author:** [@AlexanderNenninger](https://discourse.julialang.org/u/AlexanderNenninger)\
**Replies:** 1\
**Last updated:** [August 8, 2023, 4:00pm UTC](https://discourse.julialang.org/t/mix-of-index-based-and-slice-based-indexing-across-different-dimensions/102603 "2023-08-08T16:00:39Z")

</div>

Given an k-dimensional array, e.g. A = LinearIndices((2,2,2)) 2×2×2 LinearIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}: \[:, :, 1\] = 1 3 2 4 \[:, :, 2\] = 5 7 6 8 and a list of row-c…

---

## [What does @inbounds actually mean?](https://discourse.julialang.org/t/what-does-inbounds-actually-mean/102592)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 8\
**Last updated:** [August 8, 2023, 12:40pm UTC](https://discourse.julialang.org/t/what-does-inbounds-actually-mean/102592 "2023-08-08T12:40:16Z")

</div>

In the discussion on https://github.com/JuliaLang/julia/issues/48245 it was mentioned that Just to be clear, the reason we want to remove it is it requires us to compile the code more conservatively, leading to signifi…

---

## [What else can cause "UNHANDLED TASK ERROR: EOFError: read end of file"?](https://discourse.julialang.org/t/what-else-can-cause-unhandled-task-error-eoferror-read-end-of-file/102596)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 0\
**Last updated:** [August 8, 2023, 10:29am UTC](https://discourse.julialang.org/t/what-else-can-cause-unhandled-task-error-eoferror-read-end-of-file/102596 "2023-08-08T10:29:01Z")

</div>

When using Pluto for long running Pluto notebooks, after some days, I am running into the following Worker 6 terminated. UNHANDLED TASK ERROR: EOFError: read end of file Stacktrace: \[1\] wait\_locked @ ./stream.jl:947…

---

## [Class of variables](https://discourse.julialang.org/t/class-of-variables/83892)

<div class="topic-metadata">

**Author:** [@uje](https://discourse.julialang.org/u/uje)\
**Replies:** 5\
**Last updated:** [August 8, 2023, 10:17am UTC](https://discourse.julialang.org/t/class-of-variables/83892 "2023-08-08T10:17:09Z")

</div>

The Julia 1.7.3 documentation says this: “”"A particular class of variable names is one that contains only underscores. These identifiers can only be assigned values but cannot be used to assign values to other variabl…

---

## [Cache Data Structure for Lazy Array](https://discourse.julialang.org/t/cache-data-structure-for-lazy-array/102388)

<div class="topic-metadata">

**Author:** [@AlexanderNenninger](https://discourse.julialang.org/u/AlexanderNenninger)\
**Replies:** 5\
**Last updated:** [August 8, 2023, 9:28am UTC](https://discourse.julialang.org/t/cache-data-structure-for-lazy-array/102388 "2023-08-08T09:28:00Z")

</div>

I’ve got an implementation of a lazy array (lazyarrays.jl · GitHub), the entries of which are computed on the fly by function calls. From what we can tell it’s already quite fast. Although many algorithms do access the s…

---

## [Type stability around of wrapped plan fft](https://discourse.julialang.org/t/type-stability-around-of-wrapped-plan-fft/102582)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 2\
**Last updated:** [August 8, 2023, 7:27am UTC](https://discourse.julialang.org/t/type-stability-around-of-wrapped-plan-fft/102582 "2023-08-08T07:27:43Z")

</div>

I have a simple struct wrapping a planned fft and I’m not really sure how to make it type stable I might need to write the type of the fft, but I’m not really sure how to do it (I cannot really interpret the type of a p…

---

## [Julia NaN check for NamedTuple](https://discourse.julialang.org/t/julia-nan-check-for-namedtuple/102583)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 4\
**Last updated:** [August 8, 2023, 7:00am UTC](https://discourse.julialang.org/t/julia-nan-check-for-namedtuple/102583 "2023-08-08T07:00:39Z")

</div>

How to check if NaN is in a given NamedTuple? For example, julia\> myarray = \[0, 1, 2, NaN\] 4-element Vector{Float64}: 0.0 1.0 2.0 NaN julia\> isnan.(myarray) 4-element BitVector: 0 0 0 1 julia\> mynt = (;…

---

## [\`view\` and \`\[ \]\` with "slice object"](https://discourse.julialang.org/t/view-and-with-slice-object/102285)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 5\
**Last updated:** [August 8, 2023, 1:01am UTC](https://discourse.julialang.org/t/view-and-with-slice-object/102285 "2023-08-08T01:01:11Z")

</div>

A tuple is often used to encapsulate a set of array sizes: sz = size(multi\_dim\_arr) and use sz later. In a similar manner, I sometimes want to encapsulate an array “slice” in an object, but I’m wondering what’s the best …

---

## [Would people like an introduction of a Julia debug mode? Possibly on by default in the REPL/Pluto/Jupyter](https://discourse.julialang.org/t/would-people-like-an-introduction-of-a-julia-debug-mode-possibly-on-by-default-in-the-repl-pluto-jupyter/102535)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [August 8, 2023, 12:05am UTC](https://discourse.julialang.org/t/would-people-like-an-introduction-of-a-julia-debug-mode-possibly-on-by-default-in-the-repl-pluto-jupyter/102535 "2023-08-08T00:05:15Z")

</div>

Julia has very few misfeatures. There are though a few footguns. I’m thinking Julia needs a debug mode (if not removing the footguns in 2.0). I’m thinking this debug mode should be on by default on master, both in the R…

---

## [Optimize for physical cores and caches](https://discourse.julialang.org/t/optimize-for-physical-cores-and-caches/102575)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 4\
**Last updated:** [August 7, 2023, 8:10pm UTC](https://discourse.julialang.org/t/optimize-for-physical-cores-and-caches/102575 "2023-08-07T20:10:46Z")

</div>

For some analysis where each thread is memory intensive on separate memory, using all logical cores might be suboptimal because then pairs of threads (hyperthreading) on a single core might be thrashing the caches. It se…

---

## [Windows pipeline capture](https://discourse.julialang.org/t/windows-pipeline-capture/102560)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 2\
**Last updated:** [August 7, 2023, 5:11pm UTC](https://discourse.julialang.org/t/windows-pipeline-capture/102560 "2023-08-07T17:11:24Z")

</div>

I am trying to capture stdout/stderr of a windows command. However, it does not seem to work: run(pipeline(\`cmd /C nonexisting.exe\`; stderr=devnull, stdout=devnull)) Produces: Stacktrace: \[1\] pipeline\_error @ .\\pr…

---

## [Callbacks within CallbackSet interfering with each other](https://discourse.julialang.org/t/callbacks-within-callbackset-interfering-with-each-other/102452)

<div class="topic-metadata">

**Author:** [@cmdenis](https://discourse.julialang.org/u/cmdenis)\
**Replies:** 2\
**Last updated:** [August 7, 2023, 4:57pm UTC](https://discourse.julialang.org/t/callbacks-within-callbackset-interfering-with-each-other/102452 "2023-08-07T16:57:31Z")

</div>

Hi there, I’m trying to use callbacks to create pulses to two identical systems ran through the same set of differential equations. It seems like putting the two Callbacks together results in the Callbacks somehow inter…

---

## [Embedding multiple interpreters](https://discourse.julialang.org/t/embedding-multiple-interpreters/102571)

<div class="topic-metadata">

**Author:** [@dlandahl](https://discourse.julialang.org/u/dlandahl)\
**Replies:** 0\
**Last updated:** [August 7, 2023, 4:21pm UTC](https://discourse.julialang.org/t/embedding-multiple-interpreters/102571 "2023-08-07T16:21:27Z")

</div>

I would like to allow users to write Julia-based plugins for my software, which is written in a C-like language. I had a look at the embedding manual which seems really straightforward. However, I don’t know what the rig…

---

## [Performance tip for Julia 1.9, docker and Pkg.precompile on older CPUs](https://discourse.julialang.org/t/performance-tip-for-julia-1-9-docker-and-pkg-precompile-on-older-cpus/102561)

<div class="topic-metadata">

**Author:** [@benguela](https://discourse.julialang.org/u/benguela)\
**Replies:** 0\
**Last updated:** [August 7, 2023, 12:50pm UTC](https://discourse.julialang.org/t/performance-tip-for-julia-1-9-docker-and-pkg-precompile-on-older-cpus/102561 "2023-08-07T12:50:28Z")

</div>

We deploy our apps in Docker containers and recently we upgraded to the 1.9 official Julia image. We started experiencing significant slow start up times when running our containers. Note that we run the Pkg.precompile i…

---

## [On the behavior of reversed iterators](https://discourse.julialang.org/t/on-the-behavior-of-reversed-iterators/102543)

<div class="topic-metadata">

**Author:** [@adienes](https://discourse.julialang.org/u/adienes)\
**Replies:** 45\
**Last updated:** [August 7, 2023, 10:47am UTC](https://discourse.julialang.org/t/on-the-behavior-of-reversed-iterators/102543 "2023-08-07T10:47:14Z")

</div>

in https://github.com/JuliaLang/julia/blob/3e04129d61e19fe2957680b39e03b350db8e8c0d/base/iterators.jl#L530 it is explicitly defined as reverse(f::Filter) = Filter(f.flt, reverse(f.itr)) I don’t think this is correct,…

---

## [Rounding DateTime string](https://discourse.julialang.org/t/rounding-datetime-string/102434)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 3\
**Last updated:** [August 7, 2023, 5:28am UTC](https://discourse.julialang.org/t/rounding-datetime-string/102434 "2023-08-07T05:28:43Z")

</div>

As discussed here https://discourse.julialang.org/t/parsing-datetime-string/ it’s quite a hassle to convert a datetime string to a DateTime object when the string contains more digits than DateTime can accommodate. Is…

---

## [References for network construction via symbolic\_discretize](https://discourse.julialang.org/t/references-for-network-construction-via-symbolic-discretize/102541)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 0\
**Last updated:** [August 6, 2023, 10:43pm UTC](https://discourse.julialang.org/t/references-for-network-construction-via-symbolic-discretize/102541 "2023-08-06T22:43:53Z")

</div>

I used the NeuralPDE to solve the ODE system by following the tutorial at NeuralPDE.jl. I used the construction with the Lux.jl package, which is presented at Defining Systems of PDEs for Physics-Informed Neural Networks…

---

## [How to run subset of tests?](https://discourse.julialang.org/t/how-to-run-subset-of-tests/102531)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 6\
**Last updated:** [August 6, 2023, 9:24pm UTC](https://discourse.julialang.org/t/how-to-run-subset-of-tests/102531 "2023-08-06T21:24:23Z")

</div>

Does Pkg.test support running only some test sets? I’d like to add a time-consuming testset to my code but don’t want to execute it every time.

---

## [Effect of Interpolation on ODE Gradient Computation](https://discourse.julialang.org/t/effect-of-interpolation-on-ode-gradient-computation/102525)

<div class="topic-metadata">

**Author:** [@George\_Stepaniants](https://discourse.julialang.org/u/George_Stepaniants)\
**Replies:** 7\
**Last updated:** [August 6, 2023, 8:36pm UTC](https://discourse.julialang.org/t/effect-of-interpolation-on-ode-gradient-computation/102525 "2023-08-06T20:36:52Z")

</div>

I am interested in understanding how to optimize the coefficients of an ODE (such as Lotka-Volterra) under some cost function given that this ODE is influenced by a set of controls c1(t), …, cn(t) for which I observe sim…

---

## [Multiway string substitution](https://discourse.julialang.org/t/multiway-string-substitution/102345)

<div class="topic-metadata">

**Author:** [@Denis\_Ivanov](https://discourse.julialang.org/u/Denis_Ivanov)\
**Replies:** 17\
**Last updated:** [August 6, 2023, 8:15pm UTC](https://discourse.julialang.org/t/multiway-string-substitution/102345 "2023-08-06T20:15:07Z")

</div>

I have set an ambitious goal of modeling some Wolfram Physics Project features into Julia. Because actually, Julia works faster and more efficiently, while the subject is very interesting. A bit later I will be happy to…

---

## [ParallelStencil.jl cannot initialize with parameterized backend](https://discourse.julialang.org/t/parallelstencil-jl-cannot-initialize-with-parameterized-backend/102536)

<div class="topic-metadata">

**Author:** [@jinfreedom](https://discourse.julialang.org/u/jinfreedom)\
**Replies:** 0\
**Last updated:** [August 6, 2023, 5:01pm UTC](https://discourse.julialang.org/t/parallelstencil-jl-cannot-initialize-with-parameterized-backend/102536 "2023-08-06T17:01:25Z")

</div>

Hi, I’m trying to use parallelstencil.jl with Threads or CUDA and ran into the following error: julia\> using ParallelStencil julia\> using CUDA julia\> pscheme=CUDA CUDA julia\> @init\_parallel\_stencil(pscheme, Float64, …

---

## [FFTW.jl support fftw\_plan\_many\_dft?](https://discourse.julialang.org/t/fftw-jl-support-fftw-plan-many-dft/102466)

<div class="topic-metadata">

**Author:** [@diadora77](https://discourse.julialang.org/u/diadora77)\
**Replies:** 6\
**Last updated:** [August 6, 2023, 4:52pm UTC](https://discourse.julialang.org/t/fftw-jl-support-fftw-plan-many-dft/102466 "2023-08-06T16:52:08Z")

</div>

Hi - I have a scenario where I’m working with a large number of 3d arrays and want to efficiently calculate FFT’s for each column. I’ve written a few test functions that iterate in various ways across columns in calcula…

---

## [Error with Relu activation function when solving problem on NeuralPDE](https://discourse.julialang.org/t/error-with-relu-activation-function-when-solving-problem-on-neuralpde/102418)

<div class="topic-metadata">

**Author:** [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Replies:** 20\
**Last updated:** [August 6, 2023, 12:14pm UTC](https://discourse.julialang.org/t/error-with-relu-activation-function-when-solving-problem-on-neuralpde/102418 "2023-08-06T12:14:35Z")

</div>

I tried to solve the ODE problem by PDESystem on NeuralPDE with relu as activation functions. chain =\[Lux.Chain(Dense(1,10,Lux.relu),Dense(10,20,Lux.relu),Dense(20,10,Lux.relu),Dense(10,1)) for \_ in 1:12\] @named pde\_sy…

---

## [Why does Symbolics.@variables return different types dependent on whether a single or multiple variables requested?](https://discourse.julialang.org/t/why-does-symbolics-variables-return-different-types-dependent-on-whether-a-single-or-multiple-variables-requested/102528)

<div class="topic-metadata">

**Author:** [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Replies:** 2\
**Last updated:** [August 6, 2023, 5:09am UTC](https://discourse.julialang.org/t/why-does-symbolics-variables-return-different-types-dependent-on-whether-a-single-or-multiple-variables-requested/102528 "2023-08-06T05:09:28Z")

</div>

See below. julia\> using Symbolics julia\> @variables x::Real 1-element Vector{Num}: x julia\> typeof( x ) Vector{Num} (alias for Array{Num, 1}) julia\> @variables x::Real y::Real 2-element Vector{Num}: x y julia\> ty…

---

## [Optimisers.jl cannot be used with Zygote.jl's implicit gradients](https://discourse.julialang.org/t/optimisers-jl-cannot-be-used-with-zygote-jls-implicit-gradients/102522)

<div class="topic-metadata">

**Author:** [@George\_Stepaniants](https://discourse.julialang.org/u/George_Stepaniants)\
**Replies:** 3\
**Last updated:** [August 5, 2023, 11:23pm UTC](https://discourse.julialang.org/t/optimisers-jl-cannot-be-used-with-zygote-jls-implicit-gradients/102522 "2023-08-05T23:23:11Z")

</div>

I’m having the following issue with using Zygote with Optimisers.jl. Here is an MRE: using Flux, Zygote m = Chain(Dense(10, 5, relu), Dense(5, 2)) gs = gradient(() -\> sum(m(x)), params(m)) opt = ADAM(); Flux.Optimis…

---

## [Symbolics build\_function and usage](https://discourse.julialang.org/t/symbolics-build-function-and-usage/101005)

<div class="topic-metadata">

**Author:** [@Whyborn](https://discourse.julialang.org/u/Whyborn)\
**Replies:** 1\
**Last updated:** [August 5, 2023, 10:59pm UTC](https://discourse.julialang.org/t/symbolics-build-function-and-usage/101005 "2023-08-05T22:59:29Z")

</div>

Hi, I’m having some trouble using the build\_function tool within the Symbolics package, and a question about how build\_function works. The issue I am having is that executing the function generated by build\_function co…

---

## [Precompile error with PlotlyJS and DataFrames](https://discourse.julialang.org/t/precompile-error-with-plotlyjs-and-dataframes/102523)

<div class="topic-metadata">

**Author:** [@jekyllstein](https://discourse.julialang.org/u/jekyllstein)\
**Replies:** 0\
**Last updated:** [August 5, 2023, 8:45pm UTC](https://discourse.julialang.org/t/precompile-error-with-plotlyjs-and-dataframes/102523 "2023-08-05T20:45:22Z")

</div>

I have a package that won’t successfully precompile because one of the plot methods in PlotlyBase that is extended to DataFrames isn’t recognized during precompilation. The package has the following Project.toml name =…

---

## [How to see if a variable is defined given the variable name](https://discourse.julialang.org/t/how-to-see-if-a-variable-is-defined-given-the-variable-name/102512)

<div class="topic-metadata">

**Author:** [@David\_Sagan](https://discourse.julialang.org/u/David_Sagan)\
**Replies:** 3\
**Last updated:** [August 5, 2023, 4:54pm UTC](https://discourse.julialang.org/t/how-to-see-if-a-variable-is-defined-given-the-variable-name/102512 "2023-08-05T16:54:42Z")

</div>

Given a variable that is a string. For example: str = “abc” I would like to check if the variable corresponding to the string (in this case abc) is defined. I tried @isdefined(Symbol(str)) but this generates an error…

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

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