# General Usage

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

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

**Page:** 568

---

## [Best practice: put all using in the main \[package\].jl?](https://discourse.julialang.org/t/best-practice-put-all-using-in-the-main-package-jl/65716)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 3\
**Last updated:** [August 3, 2021, 8:38am UTC](https://discourse.julialang.org/t/best-practice-put-all-using-in-the-main-package-jl/65716 "2021-08-03T08:38:08Z")

</div>

I am developing a package named EOS.jl. The main file EOS.jl mainly includes other source files. I am wondering what is the best practice for the using of other registered packages. Should I put all using at the beginni…

---

## [How to define a Fortran type equivalent object in Julia](https://discourse.julialang.org/t/how-to-define-a-fortran-type-equivalent-object-in-julia/65721)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 2\
**Last updated:** [August 3, 2021, 7:47am UTC](https://discourse.julialang.org/t/how-to-define-a-fortran-type-equivalent-object-in-julia/65721 "2021-08-03T07:47:07Z")

</div>

I have a fortran type I defined as mean\_covar like below, type :: mean\_covar real(kind=r8), allocatable :: mu(:,:) real(kind=r8), allocatable :: sigma(:,:) real(kind=r8) :: w end type So that I can set some…

---

## [Can you use Gamezero for creating a reinforcement learning enviroment?](https://discourse.julialang.org/t/can-you-use-gamezero-for-creating-a-reinforcement-learning-enviroment/65727)

<div class="topic-metadata">

**Author:** [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 7:24am UTC](https://discourse.julialang.org/t/can-you-use-gamezero-for-creating-a-reinforcement-learning-enviroment/65727 "2021-08-03T07:24:27Z")

</div>

Hello, I know that there is ReinforcementLearning.jl package. But let’s say that I want to create a new enviroment for an agent. Can I do that with gamezero, reinforcement learning or some simulation package.

---

## [Populating matrix with elements - improve performance](https://discourse.julialang.org/t/populating-matrix-with-elements-improve-performance/65697)

<div class="topic-metadata">

**Author:** [@stst](https://discourse.julialang.org/u/stst)\
**Replies:** 3\
**Last updated:** [August 2, 2021, 10:27pm UTC](https://discourse.julialang.org/t/populating-matrix-with-elements-improve-performance/65697 "2021-08-02T22:27:58Z")

</div>

Does anybody have suggestions on how to speed up the following MWE? using BenchmarkTools function kernel0(t,r) # MWE K = Array{Float64}(undef,length(t),length(r)) for (it,t\_) in enumerate(t) if t\_ == 0.…

---

## [Julia: Gradation Plotting](https://discourse.julialang.org/t/julia-gradation-plotting/65683)

<div class="topic-metadata">

**Author:** [@yqqwe123](https://discourse.julialang.org/u/yqqwe123)\
**Replies:** 7\
**Last updated:** [August 2, 2021, 5:39pm UTC](https://discourse.julialang.org/t/julia-gradation-plotting/65683 "2021-08-02T17:39:11Z")

</div>

I try to plot (ReE,ImE) graph, here E = Re\[E\] + iIm\[E\] are the complex eigenvalues of a matrix H. However, in this code, the plotting is colored by some default color. I want to plot each (ReE,ImE) by coloring with blu…

---

## [16 GB large .julia/registries/General folder](https://discourse.julialang.org/t/16-gb-large-julia-registries-general-folder/65682)

<div class="topic-metadata">

**Author:** [@albheim](https://discourse.julialang.org/u/albheim)\
**Replies:** 4\
**Last updated:** [August 2, 2021, 5:09pm UTC](https://discourse.julialang.org/t/16-gb-large-julia-registries-general-folder/65682 "2021-08-02T17:09:08Z")

</div>

I have had julia installed for maybe two years now, and realised the .julia folder has grown quite big, around 25 GB. I didn’t think too much about it since I have a lot of packages installed and I also run some python a…

---

## [Help with parallelizing indirect inference estimation](https://discourse.julialang.org/t/help-with-parallelizing-indirect-inference-estimation/64487)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 17\
**Last updated:** [August 2, 2021, 3:32pm UTC](https://discourse.julialang.org/t/help-with-parallelizing-indirect-inference-estimation/64487 "2021-08-02T15:32:56Z")

</div>

I’m trying my hand at estimation via indirect inference, and created this script to experiment. I am wondering what is the best way to parallelize the computation. I think the critical functions are simulate and the line…

---

## [Dispatching by values is very slow - Feature or Problem?](https://discourse.julialang.org/t/dispatching-by-values-is-very-slow-feature-or-problem/65586)

<div class="topic-metadata">

**Author:** [@viraltux](https://discourse.julialang.org/u/viraltux)\
**Replies:** 30\
**Last updated:** [August 2, 2021, 3:13pm UTC](https://discourse.julialang.org/t/dispatching-by-values-is-very-slow-feature-or-problem/65586 "2021-08-02T15:13:05Z")

</div>

After learning in Faster default Base.sort! for Julia about Sorting Networks I thought that we surely must have a package in Julia for that, and surely we do: SortingNetworks.jl The problem is this: using SortingNetwo…

---

## [How to assign colors to bar plots in StatsPlots / Plots](https://discourse.julialang.org/t/how-to-assign-colors-to-bar-plots-in-statsplots-plots/60060)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 6\
**Last updated:** [August 2, 2021, 2:52pm UTC](https://discourse.julialang.org/t/how-to-assign-colors-to-bar-plots-in-statsplots-plots/60060 "2021-08-02T14:52:22Z")

</div>

Hi all, How do I assign colors to individual bars with StatsPlots. The following used to work with color. However something changed with Plots and now it does not work. using DataFrames, StatsPlots df = DataFrame(a = \[…

---

## [Does Roots.jl provide an API to obtain the trace of a root finding algorithm?](https://discourse.julialang.org/t/does-roots-jl-provide-an-api-to-obtain-the-trace-of-a-root-finding-algorithm/65654)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 5\
**Last updated:** [August 2, 2021, 1:08pm UTC](https://discourse.julialang.org/t/does-roots-jl-provide-an-api-to-obtain-the-trace-of-a-root-finding-algorithm/65654 "2021-08-02T13:08:21Z")

</div>

I only find that it can print out such information by the kwargs verbose=true. But how can I obtain this just like the Optim.jl which store all information in the returned value? I want to count the number of evaluations…

---

## [Bounding box of object in Makie](https://discourse.julialang.org/t/bounding-box-of-object-in-makie/64733)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 3\
**Last updated:** [August 2, 2021, 1:31pm UTC](https://discourse.julialang.org/t/bounding-box-of-object-in-makie/64733 "2021-08-02T13:31:16Z")

</div>

Given a Circle(Point(1,2), 3), is it possible to calculate the bounding box of it?

---

## [Identical functions repeated benchmarks show systematic differences](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 37\
**Last updated:** [August 2, 2021, 12:35pm UTC](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345 "2021-08-02T12:35:53Z")

</div>

I’m trying to write and benchmark sorting algorithms, and am having some trouble getting consistent benchmark results. I’ve simplified my problem to defining two identical sorting methods using the interface from base/so…

---

## [Eltypes of \`view\`s](https://discourse.julialang.org/t/eltypes-of-view-s/65606)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 10\
**Last updated:** [August 2, 2021, 3:07am UTC](https://discourse.julialang.org/t/eltypes-of-view-s/65606 "2021-08-02T03:07:10Z")

</div>

Let’s say I have a vector t = \[1, 2, missing\]. And I take sub\_t = view(t, 1:2). I know that no elements sub\_t contain missing values. Is there any way to make the eltype of sub\_t be Int instead of Union{Int, Missing}?

---

## [What happens if \`\`Pkg.add\`\` and \`\`Pkg.update\`\` fail or get interrupted?](https://discourse.julialang.org/t/what-happens-if-pkg-add-and-pkg-update-fail-or-get-interrupted/65574)

<div class="topic-metadata">

**Author:** [@ZHEN\_LIN](https://discourse.julialang.org/u/ZHEN_LIN)\
**Replies:** 6\
**Last updated:** [August 2, 2021, 12:50am UTC](https://discourse.julialang.org/t/what-happens-if-pkg-add-and-pkg-update-fail-or-get-interrupted/65574 "2021-08-02T00:50:49Z")

</div>

Will the failure or interruption of Pkg.add and Pkg.update cause any problems to the Julia packages I already have installed? I had Gurobi.jl in my Julia 1.4.2 and I was trying to update it to the most recent version by…

---

## [How to ignore docstring associated to specific function when @autodocs?](https://discourse.julialang.org/t/how-to-ignore-docstring-associated-to-specific-function-when-autodocs/65650)

<div class="topic-metadata">

**Author:** [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)\
**Replies:** 0\
**Last updated:** [August 1, 2021, 11:18pm UTC](https://discourse.julialang.org/t/how-to-ignore-docstring-associated-to-specific-function-when-autodocs/65650 "2021-08-01T23:18:39Z")

</div>

As per title. I thought I could just add Filter = name -\> string(name) != "name\_of\_exported\_function" within @autodocs, but it doesn’t work.

---

## [Convert UInt array to bitarray](https://discourse.julialang.org/t/convert-uint-array-to-bitarray/65622)

<div class="topic-metadata">

**Author:** [@Beh123](https://discourse.julialang.org/u/Beh123)\
**Replies:** 4\
**Last updated:** [August 1, 2021, 7:28pm UTC](https://discourse.julialang.org/t/convert-uint-array-to-bitarray/65622 "2021-08-01T19:28:39Z")

</div>

Hi everyone. I want to convert unit array to bitarrays. Next, I must convert each 20 bits to uint . Is there fast method for doing it? Best regards. x= BitArray(undef,1280×8) for i in 1:1280 x\[1+(i-1)×8:(i-1)×8+8\]=dig…

---

## [Annotation lik @foo\_str but for numbers?](https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638)

<div class="topic-metadata">

**Author:** [@tpoisot](https://discourse.julialang.org/u/tpoisot)\
**Replies:** 1\
**Last updated:** [August 1, 2021, 6:08pm UTC](https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638 "2021-08-01T18:08:42Z")

</div>

I can define a @foo\_str macro, which lets me write foo"something". Is there an equivalent mechanism for numbers? The closest I can think if in Julia would be something like 2im, so this can probably be achieved using uni…

---

## [Compute ratio of two variables with Symbolics.jl](https://discourse.julialang.org/t/compute-ratio-of-two-variables-with-symbolics-jl/65629)

<div class="topic-metadata">

**Author:** [@dpkwhan](https://discourse.julialang.org/u/dpkwhan)\
**Replies:** 0\
**Last updated:** [August 1, 2021, 1:21pm UTC](https://discourse.julialang.org/t/compute-ratio-of-two-variables-with-symbolics-jl/65629 "2021-08-01T13:21:08Z")

</div>

I have this equation defined: (10x-3y)/(13x-y) = 3/5 How can I simplify the above and get the ratio of x to y using Symbolics.jl or any other similar package. For example, x/y = 12/11

---

## [IRTools: how can I insert a shortcycling \`@ifsomething\` into IR?](https://discourse.julialang.org/t/irtools-how-can-i-insert-a-shortcycling-ifsomething-into-ir/65593)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 1\
**Last updated:** [August 1, 2021, 10:59am UTC](https://discourse.julialang.org/t/irtools-how-can-i-insert-a-shortcycling-ifsomething-into-ir/65593 "2021-08-01T10:59:01Z")

</div>

Hi there, I am experimenting with IRTools and IR. So far I understood that branches, including return statements, always have to be last in a block. Hence if I want to create a shortcycling statement like realised by …

---

## [DrWatson - how to organize simulations results for better usage](https://discourse.julialang.org/t/drwatson-how-to-organize-simulations-results-for-better-usage/65621)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 0\
**Last updated:** [August 1, 2021, 10:07am UTC](https://discourse.julialang.org/t/drwatson-how-to-organize-simulations-results-for-better-usage/65621 "2021-08-01T10:07:29Z")

</div>

I am using DrWatson, and many times I run Monte Carlo simulation which result in large data. As an example you can think of a time sequence, where each element in the sequence is a matrix. Sometimes, the simulation prep…

---

## [Why is this @simd loop faster than a while loop even if it has longer assembly?](https://discourse.julialang.org/t/why-is-this-simd-loop-faster-than-a-while-loop-even-if-it-has-longer-assembly/65585)

<div class="topic-metadata">

**Author:** [@louie4825](https://discourse.julialang.org/u/louie4825)\
**Replies:** 6\
**Last updated:** [August 1, 2021, 7:17am UTC](https://discourse.julialang.org/t/why-is-this-simd-loop-faster-than-a-while-loop-even-if-it-has-longer-assembly/65585 "2021-08-01T07:17:25Z")

</div>

Why does @simd here make the loop run faster even if the while version has shorter generated assembly? (Thiscode is part of a prime sieve implementation.) using BenchmarkTools # Auxillary functions begin const \_uint\_b…

---

## [Help: Unexpected error when using a macro in a for loop](https://discourse.julialang.org/t/help-unexpected-error-when-using-a-macro-in-a-for-loop/65555)

<div class="topic-metadata">

**Author:** [@josePereiro](https://discourse.julialang.org/u/josePereiro)\
**Replies:** 8\
**Last updated:** [July 31, 2021, 9:34pm UTC](https://discourse.julialang.org/t/help-unexpected-error-when-using-a-macro-in-a-for-loop/65555 "2021-07-31T21:34:07Z")

</div>

Hi, short history: I define a macro in a module, it works fine, but when I call this macro inside a for it fails. Here a full MWE. ## ---------------------------------------------------------------- # I wants a funct…

---

## [Convert float type array to Int](https://discourse.julialang.org/t/convert-float-type-array-to-int/65597)

<div class="topic-metadata">

**Author:** [@juls](https://discourse.julialang.org/u/juls)\
**Replies:** 6\
**Last updated:** [July 31, 2021, 8:17pm UTC](https://discourse.julialang.org/t/convert-float-type-array-to-int/65597 "2021-07-31T20:17:36Z")

</div>

Hi, I have been trying to convert the array type to Int for a = \[3.0 2.0;2.0 4.0;7.0 8.0\] I tried convert function and used loops but have not received the required output: a = \[3 2;2 4;7 8\] Thanks

---

## [Question ) What is the difference between putting @. and . for every algebraic operator?](https://discourse.julialang.org/t/question-what-is-the-difference-between-putting-and-for-every-algebraic-operator/65603)

<div class="topic-metadata">

**Author:** [@Zerosum](https://discourse.julialang.org/u/Zerosum)\
**Replies:** 6\
**Last updated:** [July 31, 2021, 8:00pm UTC](https://discourse.julialang.org/t/question-what-is-the-difference-between-putting-and-for-every-algebraic-operator/65603 "2021-07-31T20:00:26Z")

</div>

I am not sure if I am using the macro @. well. I thought I can avoid putting . (elementwise calculation) for + , -, / and so on by using the macro. For my project, I used it several times, but sometimes it doesn’t work.…

---

## [Comparing Numba and Julia for a complex matrix computation](https://discourse.julialang.org/t/comparing-numba-and-julia-for-a-complex-matrix-computation/63703)

<div class="topic-metadata">

**Author:** [@Ordens\_Ritter](https://discourse.julialang.org/u/Ordens_Ritter)\
**Replies:** 29\
**Last updated:** [July 31, 2021, 1:50pm UTC](https://discourse.julialang.org/t/comparing-numba-and-julia-for-a-complex-matrix-computation/63703 "2021-07-31T13:50:07Z")

</div>

I am think about slowly switching from Python to Julia. My main problem is the experience. Some years experience in writing code with python compared to: only read some books about Julia (as ‘Julia High Performance’ by A…

---

## [Multithreading simultaneously in two functions](https://discourse.julialang.org/t/multithreading-simultaneously-in-two-functions/65579)

<div class="topic-metadata">

**Author:** [@vkv](https://discourse.julialang.org/u/vkv)\
**Replies:** 3\
**Last updated:** [July 31, 2021, 12:30pm UTC](https://discourse.julialang.org/t/multithreading-simultaneously-in-two-functions/65579 "2021-07-31T12:30:46Z")

</div>

Is there a way to do use all 9 threads in the following functions? function f1() Threads.@threads for i in 1:3 println("MCMC") println("$(Threads.threadid())") sleep(3.0) end println(…

---

## [For DTable being built in Dagger.jl? Can I understand the rationale for having it vs just adding distributed arrays to DataFrames.jl?](https://discourse.julialang.org/t/for-dtable-being-built-in-dagger-jl-can-i-understand-the-rationale-for-having-it-vs-just-adding-distributed-arrays-to-dataframes-jl/65595)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 0\
**Last updated:** [July 31, 2021, 11:10am UTC](https://discourse.julialang.org/t/for-dtable-being-built-in-dagger-jl-can-i-understand-the-rationale-for-having-it-vs-just-adding-distributed-arrays-to-dataframes-jl/65595 "2021-07-31T11:10:13Z")

</div>

Would be interested in how the DTable in Dagger.jl works and the design behind it. I imagine it’s something like, it’s harder to overload the methods in DataFrame than to have this work with Dagger’s DAG approach.

---

## [IntervalRootFinding and Legendre polynomials: error](https://discourse.julialang.org/t/intervalrootfinding-and-legendre-polynomials-error/65541)

<div class="topic-metadata">

**Author:** [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Replies:** 1\
**Last updated:** [July 31, 2021, 9:54am UTC](https://discourse.julialang.org/t/intervalrootfinding-and-legendre-polynomials-error/65541 "2021-07-31T09:54:15Z")

</div>

When I try to find the roots of the 26th degree Legendre polynomial with IntervalRootFinding.jl, I get an error I can’t decode. julia\> using IntervalArithmetic julia\> using LegendrePolynomials julia\> using IntervalRoo…

---

## [Symbolic computations with functions having a variable number of arguments](https://discourse.julialang.org/t/symbolic-computations-with-functions-having-a-variable-number-of-arguments/65140)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 19\
**Last updated:** [July 31, 2021, 12:23am UTC](https://discourse.julialang.org/t/symbolic-computations-with-functions-having-a-variable-number-of-arguments/65140 "2021-07-31T00:23:46Z")

</div>

I’m looking for a Julia package that can rewrite symbolic expressions involving functions that don’t have a fixed number of arguments. For example, it should be easy to declare that some function f is multilinear (= line…

---

## [How To Implement Multi-Precision Functions?](https://discourse.julialang.org/t/how-to-implement-multi-precision-functions/65542)

<div class="topic-metadata">

**Author:** [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Replies:** 8\
**Last updated:** [July 30, 2021, 9:48pm UTC](https://discourse.julialang.org/t/how-to-implement-multi-precision-functions/65542 "2021-07-30T21:48:47Z")

</div>

Say you’re writing a mathematical function for which you want to support multiple precisions – Float16, Float32, Float64, and BigFloat (up to 256 bits). What is the best way to program the constants that are needed in t…

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

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