# General Usage

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

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

**Page:** 641

---

## [Regression using Categorical variables](https://discourse.julialang.org/t/regression-using-categorical-variables/7521)

<div class="topic-metadata">

**Author:** [@lukaebby](https://discourse.julialang.org/u/lukaebby)\
**Replies:** 16\
**Last updated:** [February 19, 2021, 10:23pm UTC](https://discourse.julialang.org/t/regression-using-categorical-variables/7521 "2021-02-19T22:23:45Z")

</div>

Can anyone tell me how to define categorical variables (with more than two levels) while performing regression in Julia…? Thanks say my data is my\_dataframe= DataFrame(class=\[3,1,3,2,1,2,1\],hist=\[34,36,38,40,42,44,46\]…

---

## [Preferred way to initialize read-only variable using mutations](https://discourse.julialang.org/t/preferred-way-to-initialize-read-only-variable-using-mutations/55504)

<div class="topic-metadata">

**Author:** [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Replies:** 3\
**Last updated:** [February 19, 2021, 9:18pm UTC](https://discourse.julialang.org/t/preferred-way-to-initialize-read-only-variable-using-mutations/55504 "2021-02-19T21:18:37Z")

</div>

I wonder what your preferred ways of initializing a read-only variable using imperative code are. This becomes important, e.g., when there are closures involved and Julia wants to box the variable. Something like funct…

---

## [\`show\` methods for arrays](https://discourse.julialang.org/t/show-methods-for-arrays/55623)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 7\
**Last updated:** [February 19, 2021, 8:47pm UTC](https://discourse.julialang.org/t/show-methods-for-arrays/55623 "2021-02-19T20:47:33Z")

</div>

I’m working on something I’m currently calling a TupleVector for representing an MCMC chain where each sample is a NamedTuple. Internally the structure is something like julia\> unwrap(tv) (a = \[1, 3, 4, 5\], b = \[\[0.3693…

---

## [Peformance Benckmark of HTTP.jl](https://discourse.julialang.org/t/peformance-benckmark-of-http-jl/55642)

<div class="topic-metadata">

**Author:** [@DataPsycho](https://discourse.julialang.org/u/DataPsycho)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 7:13pm UTC](https://discourse.julialang.org/t/peformance-benckmark-of-http-jl/55642 "2021-02-19T19:13:21Z")

</div>

Hi, Does any one one have a proper performance bench mark of HTTP.jl . I have build same service in 3 different framework GinTonic-GO, HTTP.jl - Julia, Flask-Restful - Python. I though I will get a lot better performanc…

---

## [Don't understand findmax()](https://discourse.julialang.org/t/dont-understand-findmax/55636)

<div class="topic-metadata">

**Author:** [@Ravinder\_Ram](https://discourse.julialang.org/u/Ravinder_Ram)\
**Replies:** 2\
**Last updated:** [February 19, 2021, 6:26pm UTC](https://discourse.julialang.org/t/dont-understand-findmax/55636 "2021-02-19T18:26:01Z")

</div>

findmax(model(preprocess(images\[i\]))) .- (0,1) code link code link

---

## [Speeding Up Function with ::Function and ::Vararg input](https://discourse.julialang.org/t/speeding-up-function-with-function-and-vararg-input/55551)

<div class="topic-metadata">

**Author:** [@markmbaum](https://discourse.julialang.org/u/markmbaum)\
**Replies:** 17\
**Last updated:** [February 19, 2021, 5:51pm UTC](https://discourse.julialang.org/t/speeding-up-function-with-function-and-vararg-input/55551 "2021-02-19T17:51:47Z")

</div>

I need help understanding how/if I can speed up a function that has a ::Function argument and a ::Vararg argument. I have several functions that do almost the same thing. They each receive a few vector arguments, calcul…

---

## [If I'm given a list of grammar rules like: (http://www.math.pitt.edu/~bard/bardwar](https://discourse.julialang.org/t/if-im-given-a-list-of-grammar-rules-like-http-www-math-pitt-edu-bard-bardwar/55632)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 5:26pm UTC](https://discourse.julialang.org/t/if-im-given-a-list-of-grammar-rules-like-http-www-math-pitt-edu-bard-bardwar/55632 "2021-02-19T17:26:39Z")

</div>

if I’m given a list of grammar rules like: full list \<name\>'=\<formula\> ... \<name\>(t)=\<formula\> volt \<name\>=\<formula\> ... \<name\>(t+1)=\<formula\> ... \<name\>=\<formula\> ... what is the “right” way to parse files that follo…

---

## [How to ensure no arguments are unintentionally mutated when testing a function in Julia](https://discourse.julialang.org/t/how-to-ensure-no-arguments-are-unintentionally-mutated-when-testing-a-function-in-julia/55611)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 5:09pm UTC](https://discourse.julialang.org/t/how-to-ensure-no-arguments-are-unintentionally-mutated-when-testing-a-function-in-julia/55611 "2021-02-19T17:09:38Z")

</div>

When testing Julia functions I sometimes want to check that none of the arguments are unintentionally mutated. It’s a bit labour intensive at the moment: I write code to backup the arguments via copy, call the function, …

---

## [Spdiag Matlab function in Julia](https://discourse.julialang.org/t/spdiag-matlab-function-in-julia/39604)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 7\
**Last updated:** [February 19, 2021, 4:45pm UTC](https://discourse.julialang.org/t/spdiag-matlab-function-in-julia/39604 "2021-02-19T16:45:08Z")

</div>

Is it possible to create an upper triangular matrix in Julia as fast as in Matlab, given the vectors that occupy “diagonal” positions? To be precise, spdiags allows to locate a vector on the diagonal (index=0) or the fir…

---

## [Can't Complie Makie](https://discourse.julialang.org/t/cant-complie-makie/55607)

<div class="topic-metadata">

**Author:** [@Nitish\_Dubey](https://discourse.julialang.org/u/Nitish_Dubey)\
**Replies:** 14\
**Last updated:** [February 19, 2021, 4:24pm UTC](https://discourse.julialang.org/t/cant-complie-makie/55607 "2021-02-19T16:24:16Z")

</div>

I am trying to use Makie but can’t build it here is the error message using Makie \[ Info: Precompiling Makie \[ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a\] ERROR: LoadError: UndefVarError: to\_gl\_text not defined Stacktrace: \[1…

---

## [Does splatting create a shallow copy?](https://discourse.julialang.org/t/does-splatting-create-a-shallow-copy/55566)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 7\
**Last updated:** [February 19, 2021, 3:53pm UTC](https://discourse.julialang.org/t/does-splatting-create-a-shallow-copy/55566 "2021-02-19T15:53:31Z")

</div>

A while ago I asked a question about shallow and deep copies and why a change in the copied array doesn’t reflect on the original. When you splat an array, does it create a shallow or deep copy? As explained in this an…

---

## [Do we need a policy against one-liner registered packages?](https://discourse.julialang.org/t/do-we-need-a-policy-against-one-liner-registered-packages/54999)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 23\
**Last updated:** [February 19, 2021, 1:39pm UTC](https://discourse.julialang.org/t/do-we-need-a-policy-against-one-liner-registered-packages/54999 "2021-02-19T13:39:40Z")

</div>

I’ve seen a few one or two line packages registered recently. I think the registration process should filter such out, as too soon. WIP is ok with a bit done, but it seem can be misused.

---

## [How do I attach size to a type?](https://discourse.julialang.org/t/how-do-i-attach-size-to-a-type/55614)

<div class="topic-metadata">

**Author:** [@minetest2048](https://discourse.julialang.org/u/minetest2048)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 1:02pm UTC](https://discourse.julialang.org/t/how-do-i-attach-size-to-a-type/55614 "2021-02-19T13:02:36Z")

</div>

I want to make a statically sized bit array, something like Bits{5} = \[0,0,0,0,0\] Bits{N} = \[0,...\] with length of N I want to restrict N to an integer. What do I put in the struct type declaration? struct Bits{???} …

---

## [I am trying to initialize a variable as \`arr = Vector{Tuple{Float64, Vector{Float](https://discourse.julialang.org/t/i-am-trying-to-initialize-a-variable-as-arr-vector-tuple-float64-vector-float/55613)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 12:51pm UTC](https://discourse.julialang.org/t/i-am-trying-to-initialize-a-variable-as-arr-vector-tuple-float64-vector-float/55613 "2021-02-19T12:51:09Z")

</div>

I am trying to initialize a variable as arr = Vector{Tuple{Float64, Vector{Float64}}}() because I will grow it with push! However, I would like to have more than that, the first type is fixed as Float64 but I want to h…

---

## [Say you have \`a=:b\`, how would place the value of \`a\` in an expression such that i](https://discourse.julialang.org/t/say-you-have-a-b-how-would-place-the-value-of-a-in-an-expression-such-that-i/55605)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 19, 2021, 7:26am UTC](https://discourse.julialang.org/t/say-you-have-a-b-how-would-place-the-value-of-a-in-an-expression-such-that-i/55605 "2021-02-19T07:26:05Z")

</div>

Say you have a=:b, how would place the value of a in an expression such that it is retained as the symbol :b and doesn’t become b? I.e. I want Expr(:vect, ???a???) -\> :(\[:b\]) and not :(\[b\]) Note that the original poste…

---

## [Vectorize an Array of Arrays](https://discourse.julialang.org/t/vectorize-an-array-of-arrays/55577)

<div class="topic-metadata">

**Author:** [@egvila](https://discourse.julialang.org/u/egvila)\
**Replies:** 5\
**Last updated:** [February 19, 2021, 7:02am UTC](https://discourse.julialang.org/t/vectorize-an-array-of-arrays/55577 "2021-02-19T07:02:47Z")

</div>

I have a two-dimensional Array containing two-dimensional arrays of various sizes, something like: nxm Array{Array{Float64,2},2}: zeros(3,3) ones(3,3) zeros(3,3) ones(2,2) zeros(2,2) ones(2,2) Is there a simp…

---

## [How can I test 3-arg \`show\` methods?\`@test sprint(?, x) == "expected"\`](https://discourse.julialang.org/t/how-can-i-test-3-arg-show-methods-test-sprint-x-expected/55591)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 2\
**Last updated:** [February 19, 2021, 4:53am UTC](https://discourse.julialang.org/t/how-can-i-test-3-arg-show-methods-test-sprint-x-expected/55591 "2021-02-19T04:53:08Z")

</div>

how can I test 3-arg show methods? @test sprint(????, x) == "expected" Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or p…

---

## [Adding a Project.toml to an existing package](https://discourse.julialang.org/t/adding-a-project-toml-to-an-existing-package/55592)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 2\
**Last updated:** [February 19, 2021, 1:46am UTC](https://discourse.julialang.org/t/adding-a-project-toml-to-an-existing-package/55592 "2021-02-19T01:46:03Z")

</div>

I’ve got a repo i’ve been developing, and I would like to start laying it out properly as a package that, in principle, someong could to an add to. However, I’d prefer not to trash what I already have. Is there a way I…

---

## [Why is seek zero-based?](https://discourse.julialang.org/t/why-is-seek-zero-based/55569)

<div class="topic-metadata">

**Author:** [@Benjia](https://discourse.julialang.org/u/Benjia)\
**Replies:** 3\
**Last updated:** [February 18, 2021, 11:59pm UTC](https://discourse.julialang.org/t/why-is-seek-zero-based/55569 "2021-02-18T23:59:20Z")

</div>

To go to the start of an IOStream, you have to do seek(io, 0). Why is this? I just spent about 30 minutes trying to debug an error caused by using seek(io, 1) instead.

---

## [Custom posterior distribution in Turing](https://discourse.julialang.org/t/custom-posterior-distribution-in-turing/55457)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 5\
**Last updated:** [February 18, 2021, 11:10pm UTC](https://discourse.julialang.org/t/custom-posterior-distribution-in-turing/55457 "2021-02-18T23:10:52Z")

</div>

Hello, I have the following simple Turing model: @model function opt(y, λ, sa, sb) α ~ Exponential(λ) β ~ Exponential(λ) end I would like to sample from a posterior custom distribution similar to: (beta(α, …

---

## [This must be an elementary question for the pros but how do I iterate over unique](https://discourse.julialang.org/t/this-must-be-an-elementary-question-for-the-pros-but-how-do-i-iterate-over-unique/55579)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 18, 2021, 10:21pm UTC](https://discourse.julialang.org/t/this-must-be-an-elementary-question-for-the-pros-but-how-do-i-iterate-over-unique/55579 "2021-02-18T22:21:23Z")

</div>

This must be an elementary question for the pros but how do I iterate over unique This must be an elementary question for the pros but how do I iterate over unique triplets. E.g. 1:5 triplets would give me (1,1,1), (1,…

---

## [Segmentation fault when embedding Julia code that uses Array](https://discourse.julialang.org/t/segmentation-fault-when-embedding-julia-code-that-uses-array/55056)

<div class="topic-metadata">

**Author:** [@Clonkk](https://discourse.julialang.org/u/Clonkk)\
**Replies:** 17\
**Last updated:** [February 18, 2021, 4:38pm UTC](https://discourse.julialang.org/t/segmentation-fault-when-embedding-julia-code-that-uses-array/55056 "2021-02-18T16:38:08Z")

</div>

Hello, I have an issue that I can’t figure out regarding returning memory allocated by Julia during embedding. I tried to simplify the C-code but it’s still a bit verbose : // Create an array jl\_array\_t \*jl\_make\_3d\_ar…

---

## [Returning a function multiple time to an array](https://discourse.julialang.org/t/returning-a-function-multiple-time-to-an-array/55541)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 1\
**Last updated:** [February 18, 2021, 1:46pm UTC](https://discourse.julialang.org/t/returning-a-function-multiple-time-to-an-array/55541 "2021-02-18T13:46:22Z")

</div>

i have this function that i’m trying to call it more than once and push the return value to an array function f(x,y) return s=x+y end for i=0:3 x=i\*pi/2 s=f(x,2) global X=\[\] push!(X,s) end X bu…

---

## [Emacs ESS and Windows](https://discourse.julialang.org/t/emacs-ess-and-windows/9175)

<div class="topic-metadata">

**Author:** [@TonyRubak](https://discourse.julialang.org/u/TonyRubak)\
**Replies:** 7\
**Last updated:** [February 18, 2021, 4:24pm UTC](https://discourse.julialang.org/t/emacs-ess-and-windows/9175 "2021-02-18T16:24:46Z")

</div>

I am trying to use emacs with ESS to work with Julia, but when I load Julia through emacs it hangs. Basically, the issue appears to be the same as https://github.com/emacs-ess/ESS/issues/162 where it is claimed that the …

---

## [ReadOnlyMemory](https://discourse.julialang.org/t/readonlymemory/54460)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 9\
**Last updated:** [February 18, 2021, 3:22pm UTC](https://discourse.julialang.org/t/readonlymemory/54460 "2021-02-18T15:22:07Z")

</div>

i’m trying to run a code for an mcmc samling , the code runs fine for an iteration of 1000 when i want to do the same for 2^20 iterations it shows me this error: beta:0.0 1123.840121 seconds (1.19 G allocations: 137.227…

---

## [Saving solution data from ODEIntegrator types](https://discourse.julialang.org/t/saving-solution-data-from-odeintegrator-types/55533)

<div class="topic-metadata">

**Author:** [@Libbum](https://discourse.julialang.org/u/Libbum)\
**Replies:** 2\
**Last updated:** [February 18, 2021, 1:39pm UTC](https://discourse.julialang.org/t/saving-solution-data-from-odeintegrator-types/55533 "2021-02-18T13:39:26Z")

</div>

Hi all, I’m not getting the output I expect when following the I/O: Saving and Loading Solution Data section of the DifferentialEquations.jl docs. I’ve solved my ODE via the integrator interface, so my type looks like …

---

## [Local package in git submodule](https://discourse.julialang.org/t/local-package-in-git-submodule/55530)

<div class="topic-metadata">

**Author:** [@andrekal](https://discourse.julialang.org/u/andrekal)\
**Replies:** 2\
**Last updated:** [February 18, 2021, 10:52am UTC](https://discourse.julialang.org/t/local-package-in-git-submodule/55530 "2021-02-18T10:52:03Z")

</div>

Hi, I am working on a project in which I develop a couple of different packages (and also keep a fork of a public package). I wanted to use git sub-modules to keep that in check. Specifically the tree looks something li…

---

## [Creating function that broadcast function over multiple keyword arguments](https://discourse.julialang.org/t/creating-function-that-broadcast-function-over-multiple-keyword-arguments/55491)

<div class="topic-metadata">

**Author:** [@matnbo](https://discourse.julialang.org/u/matnbo)\
**Replies:** 7\
**Last updated:** [February 18, 2021, 10:15am UTC](https://discourse.julialang.org/t/creating-function-that-broadcast-function-over-multiple-keyword-arguments/55491 "2021-02-18T10:15:11Z")

</div>

Dear all I come from the R community, and try to switch to Julia ) Assume I have a function f1 (fictive function below) f1 = function(x, y ; a = 1.5, b = 5) coef = a \* sum(x’y) + b (coef = coef, mod = 1) end whe…

---

## [Too many allocations?](https://discourse.julialang.org/t/too-many-allocations/55478)

<div class="topic-metadata">

**Author:** [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Replies:** 23\
**Last updated:** [February 18, 2021, 9:06am UTC](https://discourse.julialang.org/t/too-many-allocations/55478 "2021-02-18T09:06:28Z")

</div>

I’m thinking about optimizing performance and my mind initially goes to reducing the number of allocations. Below is a function with a loop that executes ~ 1,000,000 times. When I “time” the routine, I find that it exe…

---

## [Is it possible that \`JLD2\` /Julia can't read files from another drive? On Windows,](https://discourse.julialang.org/t/is-it-possible-that-jld2-julia-cant-read-files-from-another-drive-on-windows/55509)

<div class="topic-metadata">

**Author:** [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Replies:** 1\
**Last updated:** [February 18, 2021, 5:54am UTC](https://discourse.julialang.org/t/is-it-possible-that-jld2-julia-cant-read-files-from-another-drive-on-windows/55509 "2021-02-18T05:54:54Z")

</div>

Is it possible that JLD2 /Julia can’t read files from another drive? On Windows, my Julia extension is installed on C (infact, it’s installed in WSL2) and have an SD card thats assigned drive letter D for data files. But…

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

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