# General Usage

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

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

**Page:** 479

---

## [How to concatenate these two arrays?](https://discourse.julialang.org/t/how-to-concatenate-these-two-arrays/77129)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [February 26, 2022, 4:32pm UTC](https://discourse.julialang.org/t/how-to-concatenate-these-two-arrays/77129 "2022-02-26T16:32:59Z")

</div>

For example, I have two arrays A and B as below: A = rand(5,3); B = rand(5,3,2); How do I concatenate them into C with the size of 5,3,3, so that: C\[:, :, 1\] = A; C\[:, :, 2:3\] = B; Many thanks.

---

## [How do I add a new column to a dataframe in Julia using conditional logic?](https://discourse.julialang.org/t/how-do-i-add-a-new-column-to-a-dataframe-in-julia-using-conditional-logic/77103)

<div class="topic-metadata">

**Author:** [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Replies:** 5\
**Last updated:** [February 26, 2022, 2:57pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-new-column-to-a-dataframe-in-julia-using-conditional-logic/77103 "2022-02-26T14:57:03Z")

</div>

I want to create a new column in my dataframe. If another column equals zero, I want this column to equal zero. If it doesn’t, I would like this column to equal another column divided by a third column. I tried using the…

---

## [DSP.jl Side Effect on Dates](https://discourse.julialang.org/t/dsp-jl-side-effect-on-dates/77115)

<div class="topic-metadata">

**Author:** [@herm](https://discourse.julialang.org/u/herm)\
**Replies:** 2\
**Last updated:** [February 26, 2022, 2:29pm UTC](https://discourse.julialang.org/t/dsp-jl-side-effect-on-dates/77115 "2022-02-26T14:29:04Z")

</div>

Interestingly I found with Julia Version 1.7.2 (2022-02-06) for window the following side effect: No Bug using Dates datenow=Dates.format(Dates.now(),“yyyymmddTHHMMSSZ”) Buggy using DSP using Dates datenow=Dates.f…

---

## [Is there an efficient and elegant way to keep the top 2 values from an iterator](https://discourse.julialang.org/t/is-there-an-efficient-and-elegant-way-to-keep-the-top-2-values-from-an-iterator/77121)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 1\
**Last updated:** [February 26, 2022, 2:16pm UTC](https://discourse.julialang.org/t/is-there-an-efficient-and-elegant-way-to-keep-the-top-2-values-from-an-iterator/77121 "2022-02-26T14:16:05Z")

</div>

Consider an arbitrary itr that returns a sequence of values. Now maximum(itr) will return max value, is there a way to return the maximum 2 values? partialsort(collect(itr), 2) would do the trick but collect might be…

---

## [How to typeset in bold letters with \`annotate!()\` using Plots](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941)

<div class="topic-metadata">

**Author:** [@met-j](https://discourse.julialang.org/u/met-j)\
**Replies:** 8\
**Last updated:** [February 26, 2022, 12:49pm UTC](https://discourse.julialang.org/t/how-to-typeset-in-bold-letters-with-annotate-using-plots/76941 "2022-02-26T12:49:20Z")

</div>

How would I get a Bold font type in the annotate!() function using Plots with the GR backend?

---

## [@views throws an error in combination with a struct](https://discourse.julialang.org/t/views-throws-an-error-in-combination-with-a-struct/77090)

<div class="topic-metadata">

**Author:** [@pgoulart](https://discourse.julialang.org/u/pgoulart)\
**Replies:** 4\
**Last updated:** [February 26, 2022, 10:09am UTC](https://discourse.julialang.org/t/views-throws-an-error-in-combination-with-a-struct/77090 "2022-02-26T10:09:08Z")

</div>

I am not sure if this is a bug or just not allowed syntax for some reason. The @views macro throws an error under seemingly narrow circumstances as shown in the last line of the example below: struct Foo{T} a::Vec…

---

## [How to call functions defined in separate files in julia-1.6?](https://discourse.julialang.org/t/how-to-call-functions-defined-in-separate-files-in-julia-1-6/77098)

<div class="topic-metadata">

**Author:** [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Replies:** 4\
**Last updated:** [February 26, 2022, 9:47am UTC](https://discourse.julialang.org/t/how-to-call-functions-defined-in-separate-files-in-julia-1-6/77098 "2022-02-26T09:47:46Z")

</div>

In julia-1.0 I called a function"readdata()" that I defined in a file called “readdata”, from a start-up code in another file “main”. In julia-1.6 that does not seem to work anymore. I get “UndefVarError: readdata not d…

---

## [Fastest way to initialize StaticArray of dynamic size with state](https://discourse.julialang.org/t/fastest-way-to-initialize-staticarray-of-dynamic-size-with-state/77091)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 3\
**Last updated:** [February 26, 2022, 12:21am UTC](https://discourse.julialang.org/t/fastest-way-to-initialize-staticarray-of-dynamic-size-with-state/77091 "2022-02-26T00:21:49Z")

</div>

I’m constructing an SVector, but each value depends on the previous calculated value. This is still simple to do with sacollect, but then it has to box the input and so allocates (see example below). What is the optimal …

---

## [Warning dt\<dtmin in ODE Solver not solved with FAQ](https://discourse.julialang.org/t/warning-dt-dtmin-in-ode-solver-not-solved-with-faq/76999)

<div class="topic-metadata">

**Author:** [@gnicolosi](https://discourse.julialang.org/u/gnicolosi)\
**Replies:** 3\
**Last updated:** [February 25, 2022, 11:39pm UTC](https://discourse.julialang.org/t/warning-dt-dtmin-in-ode-solver-not-solved-with-faq/76999 "2022-02-25T23:39:12Z")

</div>

Dear all, I have run into the following issue, which is described in details also here: Frequently Asked Questions · DifferentialEquations.jl (sciml.ai). I have tried all suggestions on the link and made a great amount …

---

## [Large performance regression in nightly build](https://discourse.julialang.org/t/large-performance-regression-in-nightly-build/76440)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 6\
**Last updated:** [February 25, 2022, 11:05pm UTC](https://discourse.julialang.org/t/large-performance-regression-in-nightly-build/76440 "2022-02-25T23:05:13Z")

</div>

Update the 1.8dev version today and … | | |\_| | | | (\_| | | Version 1.8.0-DEV.1519 (2022-02-13) \_/ |\\\_\_'\_|\_|\_|\\\_\_'\_| | Commit 1978580e72 (1 day old master) |\_\_/ | julia\> cd("C:/v"); @time using…

---

## [Is this design pattern of \`::Val{}\` dispatching evil?](https://discourse.julialang.org/t/is-this-design-pattern-of-val-dispatching-evil/54365)

<div class="topic-metadata">

**Author:** [@korsbo](https://discourse.julialang.org/u/korsbo)\
**Replies:** 10\
**Last updated:** [February 25, 2022, 10:25pm UTC](https://discourse.julialang.org/t/is-this-design-pattern-of-val-dispatching-evil/54365 "2022-02-25T22:25:02Z")

</div>

I’d like some feedback on a seemingly functional design involving recursion and a whole lot of ::Val{} overloads. I think that my time in the Julia community has conditioned me to shy away from such dispatching and proba…

---

## [List of packages in a registry Julia 1.7+](https://discourse.julialang.org/t/list-of-packages-in-a-registry-julia-1-7/77082)

<div class="topic-metadata">

**Author:** [@thazhemadam](https://discourse.julialang.org/u/thazhemadam)\
**Replies:** 7\
**Last updated:** [February 25, 2022, 10:22pm UTC](https://discourse.julialang.org/t/list-of-packages-in-a-registry-julia-1-7/77082 "2022-02-25T22:22:25Z")

</div>

Previously, I could just run TOML.parsefile("General/Registry.toml")\["packages"\] to get the list of all the packages registered in the General registry. However, with Julia 1.7, the General directory has been replaced w…

---

## [Why would you create a subtype of \`Function\`?](https://discourse.julialang.org/t/why-would-you-create-a-subtype-of-function/77087)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 3\
**Last updated:** [February 25, 2022, 9:58pm UTC](https://discourse.julialang.org/t/why-would-you-create-a-subtype-of-function/77087 "2022-02-25T21:58:03Z")

</div>

I am curious about the utility of creating abstract or concrete subtypes of Function. Aside from syntactic convenience, I am not sure of the distinction between a singleton type that is given several methods and a funct…

---

## [PythonCall equivalent to PyCall's pytype\_mapping?](https://discourse.julialang.org/t/pythoncall-equivalent-to-pycalls-pytype-mapping/77086)

<div class="topic-metadata">

**Author:** [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Replies:** 0\
**Last updated:** [February 25, 2022, 5:37pm UTC](https://discourse.julialang.org/t/pythoncall-equivalent-to-pycalls-pytype-mapping/77086 "2022-02-25T17:37:24Z")

</div>

In SymPy.jl there is use of PyCall’s pytype\_mapping to automatically convert sympy objects in Python into a typed object in Julia. It looks like in PythonCall, the pyconvert\_add\_rule does something similar, but I can’t s…

---

## [How do I exit a function early and return nothing?](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078)

<div class="topic-metadata">

**Author:** [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Replies:** 2\
**Last updated:** [February 25, 2022, 4:08pm UTC](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078 "2022-02-25T16:08:25Z")

</div>

I have a function that takes a dataframe and performs some basic calculations. Sometimes when performing said calculations the data frame becomes empty (the details don’t matter). I’m having trouble checking if the dataf…

---

## [Efficient way of doing matmul along 3rd dimension](https://discourse.julialang.org/t/efficient-way-of-doing-matmul-along-3rd-dimension/77075)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 3\
**Last updated:** [February 25, 2022, 3:05pm UTC](https://discourse.julialang.org/t/efficient-way-of-doing-matmul-along-3rd-dimension/77075 "2022-02-25T15:05:35Z")

</div>

Hi, I’ve been looking for a way to do matmul operations along slices of the 3rd dims of a 3D tensor. I’ve had a look at Tullio.jl and TensorCast.jl but I’m not sure they are designed to do this. Basically I want to do …

---

## [SimpleContainerGenerator Error](https://discourse.julialang.org/t/simplecontainergenerator-error/77072)

<div class="topic-metadata">

**Author:** [@austinbean](https://discourse.julialang.org/u/austinbean)\
**Replies:** 0\
**Last updated:** [February 25, 2022, 2:18pm UTC](https://discourse.julialang.org/t/simplecontainergenerator-error/77072 "2022-02-25T14:18:59Z")

</div>

I’m trying to generate a Docker image so I can turn that into a Singularity image using SimpleContainerGenerator. I unfortunately get an error. I would love to fix this if anyone has advice! I have the following file …

---

## [Recursive @generated functions with function barriers causes allocations](https://discourse.julialang.org/t/recursive-generated-functions-with-function-barriers-causes-allocations/76910)

<div class="topic-metadata">

**Author:** [@jg-854](https://discourse.julialang.org/u/jg-854)\
**Replies:** 6\
**Last updated:** [February 25, 2022, 1:49pm UTC](https://discourse.julialang.org/t/recursive-generated-functions-with-function-barriers-causes-allocations/76910 "2022-02-25T13:49:48Z")

</div>

Hey! I am using generated functions in a recursive manner, and I have formed a contrived example which highlights how unnecessary allocations can occur. First, I will show you the efficient case @generated function Fac…

---

## [Code availability macro for \`pmap\`](https://discourse.julialang.org/t/code-availability-macro-for-pmap/77065)

<div class="topic-metadata">

**Author:** [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Replies:** 0\
**Last updated:** [February 25, 2022, 1:26pm UTC](https://discourse.julialang.org/t/code-availability-macro-for-pmap/77065 "2022-02-25T13:26:01Z")

</div>

Is there a macro similar to @distributed for for pmap (or some pmapreduce, which I’d love to have in official repos, btw), that takes care of making sure all functions and variables and everything is available at the wor…

---

## [How to remove the "snow" from Pluto notebooks](https://discourse.julialang.org/t/how-to-remove-the-snow-from-pluto-notebooks/77054)

<div class="topic-metadata">

**Author:** [@natema](https://discourse.julialang.org/u/natema)\
**Replies:** 2\
**Last updated:** [February 25, 2022, 12:51pm UTC](https://discourse.julialang.org/t/how-to-remove-the-snow-from-pluto-notebooks/77054 "2022-02-25T12:51:12Z")

</div>

When I start a Pluto notebook, the first cell contains the message Happy holiday! Remember to take care of yourself and your loved ones! and there’s an animation going on on the notebook, with falling snow. I would like …

---

## [How to generate plots in documentation?](https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009)

<div class="topic-metadata">

**Author:** [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Replies:** 1\
**Last updated:** [February 25, 2022, 12:42pm UTC](https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009 "2022-02-25T12:42:38Z")

</div>

Hi! My question is somewhat related to this topic, but its solution doesn’t work in my case. I’d like the code chunks within my docs/src/ directory to automatically generate images inside the docs upon deployment. In fa…

---

## [Valid path to Julia executable in VS Code on MacOS?](https://discourse.julialang.org/t/valid-path-to-julia-executable-in-vs-code-on-macos/77027)

<div class="topic-metadata">

**Author:** [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Replies:** 8\
**Last updated:** [February 25, 2022, 11:28am UTC](https://discourse.julialang.org/t/valid-path-to-julia-executable-in-vs-code-on-macos/77027 "2022-02-25T11:28:00Z")

</div>

I installed julia-1.6, VS Code, and setting julia.executablePath. When I try to run one of my Julia codes, I keep getting the message: “Could not start the Julia language server. Make sure the configuration setting jul…

---

## [Debugger usage: step over evaluations in function arguments, straight into the function](https://discourse.julialang.org/t/debugger-usage-step-over-evaluations-in-function-arguments-straight-into-the-function/77018)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 8\
**Last updated:** [February 25, 2022, 11:11am UTC](https://discourse.julialang.org/t/debugger-usage-step-over-evaluations-in-function-arguments-straight-into-the-function/77018 "2022-02-25T11:11:15Z")

</div>

When using Debugger.jl from the REPL, I often find I have a function call like @views foo!(a\[:,j,i\], b\[j\], c.bar) To actually step into the body of foo!(), I find myself first stepping into getindex()/getproperty()/etc…

---

## [Local problem solved by OS update](https://discourse.julialang.org/t/local-problem-solved-by-os-update/77049)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 0\
**Last updated:** [February 25, 2022, 8:15am UTC](https://discourse.julialang.org/t/local-problem-solved-by-os-update/77049 "2022-02-25T08:15:11Z")

</div>

EDIT: After other progams were acting up, I updated my OS. Now everything works just fine. The OP can be seen below, but I do not see any reason why anyone should read it. I am sorry for simply dumping a bunch of erro…

---

## [How to release memory with EzXML](https://discourse.julialang.org/t/how-to-release-memory-with-ezxml/76533)

<div class="topic-metadata">

**Author:** [@jade\_mackay](https://discourse.julialang.org/u/jade_mackay)\
**Replies:** 1\
**Last updated:** [February 25, 2022, 5:56am UTC](https://discourse.julialang.org/t/how-to-release-memory-with-ezxml/76533 "2022-02-25T05:56:55Z")

</div>

Is there any way to release the memory after using EzXML’s readxml(path) function? I have tried doc = readxml(path) doc = nothing GC.gc() Thanks!

---

## [Comprehension doesn't infer type of parametric type collection when empty](https://discourse.julialang.org/t/comprehension-doesnt-infer-type-of-parametric-type-collection-when-empty/77040)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 2\
**Last updated:** [February 25, 2022, 5:06am UTC](https://discourse.julialang.org/t/comprehension-doesnt-infer-type-of-parametric-type-collection-when-empty/77040 "2022-02-25T05:06:03Z")

</div>

When comprehension returns a empty collection of a parametric type, the type is lost. In simple code: struct A{T} a::T end vs = \[A(1), A(2), A(3), A(1.0), A(2.0), A(3.0)\] #6-element Vector{A}: # A{Int64}(1) # A{In…

---

## [Best way to extend a type doc string](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878)

<div class="topic-metadata">

**Author:** [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Replies:** 5\
**Last updated:** [February 25, 2022, 4:43am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878 "2022-02-25T04:43:15Z")

</div>

Pkg A defines some type Foo, and this includes the declaration of a document string. Pkg B extends the functionality of Foo objects and wants to extend, not replace, the type’s docstring. What’s a clean way to do this? …

---

## [Error when asking for sign of positive Irrational](https://discourse.julialang.org/t/error-when-asking-for-sign-of-positive-irrational/77015)

<div class="topic-metadata">

**Author:** [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Replies:** 3\
**Last updated:** [February 24, 2022, 10:51pm UTC](https://discourse.julialang.org/t/error-when-asking-for-sign-of-positive-irrational/77015 "2022-02-24T22:51:23Z")

</div>

This is an error julia\> sign(π) ERROR: InexactError: Bool(-1) Stacktrace: \[1\] Bool @ ./float.jl:158 \[inlined\] \[2\] convert @ ./number.jl:7 \[inlined\] \[3\] oftype(x::Bool, y::Int64) @ Base ./essentials.jl:396 \[…

---

## [Problems fitting a model using \`LsqFit.jl\`](https://discourse.julialang.org/t/problems-fitting-a-model-using-lsqfit-jl/77003)

<div class="topic-metadata">

**Author:** [@bhaveshshrimali](https://discourse.julialang.org/u/bhaveshshrimali)\
**Replies:** 2\
**Last updated:** [February 24, 2022, 6:35pm UTC](https://discourse.julialang.org/t/problems-fitting-a-model-using-lsqfit-jl/77003 "2022-02-24T18:35:39Z")

</div>

Hi everyone, It’s a long shot as the problem is quite niche, but I would still appreciate any help/comments from the community. Problem Description To put it briefly, I am interested in fitting a nonlinear model S(\\la…

---

## [Same code run multiple times gives wildly different timings](https://discourse.julialang.org/t/same-code-run-multiple-times-gives-wildly-different-timings/76976)

<div class="topic-metadata">

**Author:** [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Replies:** 39\
**Last updated:** [February 24, 2022, 4:52pm UTC](https://discourse.julialang.org/t/same-code-run-multiple-times-gives-wildly-different-timings/76976 "2022-02-24T16:52:40Z")

</div>

I have some code that heavily uses @tturbo from LoopVectorization for matmul-like operations. The main idea here is that I use Julia’s dispatch to pass settings to the algorithm. For example, I call fit!(option), and thi…

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

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