# General Usage

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

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

**Page:** 566

---

## [\[Symbolics.jl\] Defining √2 as an (unevaluated) symbol](https://discourse.julialang.org/t/symbolics-jl-defining-2-as-an-unevaluated-symbol/65547)

<div class="topic-metadata">

**Author:** [@sbrisard](https://discourse.julialang.org/u/sbrisard)\
**Replies:** 18\
**Last updated:** [August 6, 2021, 12:43am UTC](https://discourse.julialang.org/t/symbolics-jl-defining-2-as-an-unevaluated-symbol/65547 "2021-08-06T00:43:39Z")

</div>

Hello, with a colleague of mine, we are trying to evaluate Symbolics.jl (vs. sympy/SymPy.jl vs. maxima vs. maple). A feature that we would really need would be to define √2 as a symbol, unevaluated. What we have in min…

---

## [How to speed up these functions?](https://discourse.julialang.org/t/how-to-speed-up-these-functions/65728)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 19\
**Last updated:** [August 6, 2021, 12:31am UTC](https://discourse.julialang.org/t/how-to-speed-up-these-functions/65728 "2021-08-06T00:31:36Z")

</div>

I have been working on estimating a model via indirect inference. For that to be feasible I need to speed up these functions that jointly comprise the auxiliary model. Can anyone spot optimizations? set up: using Linea…

---

## [How to prevent using global arrays in iteration in the module](https://discourse.julialang.org/t/how-to-prevent-using-global-arrays-in-iteration-in-the-module/65857)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 11\
**Last updated:** [August 5, 2021, 9:44pm UTC](https://discourse.julialang.org/t/how-to-prevent-using-global-arrays-in-iteration-in-the-module/65857 "2021-08-05T21:44:40Z")

</div>

I have an a little detailed question about how to prevent using global array in iterations in the module. Hopefully someone could give some advice on how to prevent using global arrays. module Mod global AAA=Array{Float…

---

## [Quantile! much faster when called twice with a scalar than once with a vector!](https://discourse.julialang.org/t/quantile-much-faster-when-called-twice-with-a-scalar-than-once-with-a-vector/65188)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 7\
**Last updated:** [August 5, 2021, 9:58pm UTC](https://discourse.julialang.org/t/quantile-much-faster-when-called-twice-with-a-scalar-than-once-with-a-vector/65188 "2021-08-05T21:58:33Z")

</div>

x = rand(Float32, 10000000); @time quantile!(x, \[0.02, 0.98\]) 0.196571 seconds (2 allocations: 160 bytes) 2-element Vector{Float64}: 0.02001022338867188 0.9800319683551788 @time quantile!(x, 0.02) 0.022732 second…

---

## [Do you know "La morra"](https://discourse.julialang.org/t/do-you-know-la-morra/65834)

<div class="topic-metadata">

**Author:** [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Replies:** 2\
**Last updated:** [August 5, 2021, 8:38pm UTC](https://discourse.julialang.org/t/do-you-know-la-morra/65834 "2021-08-05T20:38:51Z")

</div>

Buongiorno a tutti ! Morra is a very old game t learn something about it you can read the wiki or watch this video. Although it seems a little strange, good and bad players exist as well. The game isn’t based only on c…

---

## [Updating gui via callback using Gtk](https://discourse.julialang.org/t/updating-gui-via-callback-using-gtk/34804)

<div class="topic-metadata">

**Author:** [@Noobie76](https://discourse.julialang.org/u/Noobie76)\
**Replies:** 2\
**Last updated:** [February 18, 2020, 8:39pm UTC](https://discourse.julialang.org/t/updating-gui-via-callback-using-gtk/34804 "2020-02-18T20:39:55Z")

</div>

Hi, I’m currently working on a GUI interface for PDE solver with Glk. This Interface should be very basic and just should it make more comfortable to play around with system parameters to reach the best results ffor imag…

---

## [Runtime increasing as I do more replications](https://discourse.julialang.org/t/runtime-increasing-as-i-do-more-replications/65850)

<div class="topic-metadata">

**Author:** [@worldgiraffe2](https://discourse.julialang.org/u/worldgiraffe2)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 8:36pm UTC](https://discourse.julialang.org/t/runtime-increasing-as-i-do-more-replications/65850 "2021-08-05T20:36:12Z")

</div>

Hi, I’m a new Julia user and would greatly appreciate your help. Currently, I’m running a simulation with multiple replications, as below glob\_result = \[\] for i in 1:n\_rep Random.seed!(1234+i); model\_result = @…

---

## [Is Union{Missing, Float64} a concrete type?](https://discourse.julialang.org/t/is-union-missing-float64-a-concrete-type/65901)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 3\
**Last updated:** [August 5, 2021, 7:36pm UTC](https://discourse.julialang.org/t/is-union-missing-float64-a-concrete-type/65901 "2021-08-05T19:36:39Z")

</div>

I am optimising part of a small package and I am trying to remove type instabilities. Since I am working with incomplete time series, I am using Union{Missing, Float64} data. I have read online that you want to use concr…

---

## [Passing macro as function argument?](https://discourse.julialang.org/t/passing-macro-as-function-argument/65898)

<div class="topic-metadata">

**Author:** [@tbenst](https://discourse.julialang.org/u/tbenst)\
**Replies:** 5\
**Last updated:** [August 5, 2021, 6:07pm UTC](https://discourse.julialang.org/t/passing-macro-as-function-argument/65898 "2021-08-05T18:07:06Z")

</div>

I’m trying to benchmark various parallelization approaches, and realized I’m not sure how to change which macro is called…? Is this possible? function count\_threads(macro\_name=Threads.@threads) n = Threads.nthreads(…

---

## [Running a single Julia script simultaneously on different workers, each with different input parameters](https://discourse.julialang.org/t/running-a-single-julia-script-simultaneously-on-different-workers-each-with-different-input-parameters/65902)

<div class="topic-metadata">

**Author:** [@rachithaiyappa](https://discourse.julialang.org/u/rachithaiyappa)\
**Replies:** 0\
**Last updated:** [August 5, 2021, 6:01pm UTC](https://discourse.julialang.org/t/running-a-single-julia-script-simultaneously-on-different-workers-each-with-different-input-parameters/65902 "2021-08-05T18:01:30Z")

</div>

I’m trying to run a script main.jl simultaneously on multiple workers, each worker having a different input parameter for the script. The skeleton code looks something like this. This results in a could not open file err…

---

## [How to generate reproducible random numbers across versions via package manifest?](https://discourse.julialang.org/t/how-to-generate-reproducible-random-numbers-across-versions-via-package-manifest/65690)

<div class="topic-metadata">

**Author:** [@torgo](https://discourse.julialang.org/u/torgo)\
**Replies:** 27\
**Last updated:** [August 5, 2021, 5:36pm UTC](https://discourse.julialang.org/t/how-to-generate-reproducible-random-numbers-across-versions-via-package-manifest/65690 "2021-08-05T17:36:16Z")

</div>

I am trying to ensure that random numbers generated across different Julia versions are reproducible. I found this part of the documentation: https://docs.julialang.org/en/v1/stdlib/Random/#Reproducibility It has a pa…

---

## [Suggested workflow for handling c src dependencies in packages](https://discourse.julialang.org/t/suggested-workflow-for-handling-c-src-dependencies-in-packages/65899)

<div class="topic-metadata">

**Author:** [@DrPapa](https://discourse.julialang.org/u/DrPapa)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 5:27pm UTC](https://discourse.julialang.org/t/suggested-workflow-for-handling-c-src-dependencies-in-packages/65899 "2021-08-05T17:27:30Z")

</div>

I have a private package (lets call it MyPkg.jl) that requires wrapping a very minimal c library. This c library provides a small subset of the package’s total capabilities. I have been playing w/ BinaryBuilder and I’ve …

---

## [Specifying structs with variably nested NTuple fields](https://discourse.julialang.org/t/specifying-structs-with-variably-nested-ntuple-fields/65817)

<div class="topic-metadata">

**Author:** [@tchr](https://discourse.julialang.org/u/tchr)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 5:02pm UTC](https://discourse.julialang.org/t/specifying-structs-with-variably-nested-ntuple-fields/65817 "2021-08-05T17:02:12Z")

</div>

I suspect what I want isn’t possible but wanted to ask here to be certain (or to learn precisely why it isn’t possible). The setup for the question is as follows. Suppose I have a function: function nested\_ntuple(::Val…

---

## [Delivering Julia code to production computers](https://discourse.julialang.org/t/delivering-julia-code-to-production-computers/19586)

<div class="topic-metadata">

**Author:** [@vladimir](https://discourse.julialang.org/u/vladimir)\
**Replies:** 19\
**Last updated:** [August 5, 2021, 4:51pm UTC](https://discourse.julialang.org/t/delivering-julia-code-to-production-computers/19586 "2021-08-05T16:51:27Z")

</div>

In our MATLAB production projects, we can deliver (copy) our compiled MATLAB code with the corresponding MATLAB MCR to production computers without installing MATLAB MCR on them. This makes it easy to switch between diff…

---

## [Random and threads](https://discourse.julialang.org/t/random-and-threads/65769)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 13\
**Last updated:** [August 5, 2021, 4:24pm UTC](https://discourse.julialang.org/t/random-and-threads/65769 "2021-08-05T16:24:51Z")

</div>

Given the following snippet (assuming more than 1 thread): const NC = 3000; const z\_vec = zeros(NC); Threads.@threads for i = 1:NC z\_vec\[i\] = randn() end What statistical properties we should expect in 1.6.2 for z\_…

---

## [Rand-based Function Optimization](https://discourse.julialang.org/t/rand-based-function-optimization/65874)

<div class="topic-metadata">

**Author:** [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 12:53pm UTC](https://discourse.julialang.org/t/rand-based-function-optimization/65874 "2021-08-05T12:53:54Z")

</div>

Given a non-zero UInt8, I would like to randomly and uniformly select the index of a bit that is one. For example, if I get UInt8(14), the bitstring would be 00001110, and thus it would return UInt8(2), UInt8(3), and UIn…

---

## [Is there a package for useful for computational neuroscience rescearch?](https://discourse.julialang.org/t/is-there-a-package-for-useful-for-computational-neuroscience-rescearch/65882)

<div class="topic-metadata">

**Author:** [@development\_mentor](https://discourse.julialang.org/u/development_mentor)\
**Replies:** 0\
**Last updated:** [August 5, 2021, 12:49pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-useful-for-computational-neuroscience-rescearch/65882 "2021-08-05T12:49:05Z")

</div>

Does Julia have a package that would provide us with functions to simulate large networks of neurons, that would have custom structure.

---

## [Assignment to multiple targets - how does it work?](https://discourse.julialang.org/t/assignment-to-multiple-targets-how-does-it-work/11721)

<div class="topic-metadata">

**Author:** [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Replies:** 3\
**Last updated:** [August 5, 2021, 12:19pm UTC](https://discourse.julialang.org/t/assignment-to-multiple-targets-how-does-it-work/11721 "2021-08-05T12:19:15Z")

</div>

Given: julia\> a = zeros(5); b = zeros(5); R = collect(10:10:100); This naturally fails: julia\> a\[1:end\] = R ERROR: DimensionMismatch("tried to assign 10 elements to 5 destinations") Stacktrace: \[1\] throw\_setindex\_mis…

---

## [The question of forecasting](https://discourse.julialang.org/t/the-question-of-forecasting/65858)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 11:58am UTC](https://discourse.julialang.org/t/the-question-of-forecasting/65858 "2021-08-05T11:58:43Z")

</div>

Hello everyone, I’m working on forecasting time series data for power systems. I now have three years of meteorological data and corresponding power system data, and I want to predict the temporal changes of power syste…

---

## [Runtime dispatch when broadcasting a view indexed with CartesianIndex array](https://discourse.julialang.org/t/runtime-dispatch-when-broadcasting-a-view-indexed-with-cartesianindex-array/65870)

<div class="topic-metadata">

**Author:** [@JohnnyChen94](https://discourse.julialang.org/u/JohnnyChen94)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 10:14am UTC](https://discourse.julialang.org/t/runtime-dispatch-when-broadcasting-a-view-indexed-with-cartesianindex-array/65870 "2021-08-05T10:14:11Z")

</div>

Playing with JETTest.jl and I realize that there exists a runtime dispatch when view, broadcasting, and CartesianIndex array(not CartesianIndices) are used together. But haven’t observed any suspicious performance differ…

---

## [Is there a package to do DataFrames comparisons?](https://discourse.julialang.org/t/is-there-a-package-to-do-dataframes-comparisons/65713)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 4\
**Last updated:** [August 3, 2021, 2:18pm UTC](https://discourse.julialang.org/t/is-there-a-package-to-do-dataframes-comparisons/65713 "2021-08-03T14:18:43Z")

</div>

The a==b works really well if a and b are the same, but it doesn’t tell me what’s different if a and b are different e.g. some column name are different. I would if there’s a package for comparing dataFrame like proc co…

---

## [Tuple constructor forgets types](https://discourse.julialang.org/t/tuple-constructor-forgets-types/65730)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 23\
**Last updated:** [August 5, 2021, 9:24am UTC](https://discourse.julialang.org/t/tuple-constructor-forgets-types/65730 "2021-08-05T09:24:16Z")

</div>

Hi type lovers, just stumbled upon the following surprising behaviour julia\> typeof(Tuple{Type{Int}, Type{String}}((Int, String))) Tuple{DataType, DataType} This should be Tuple{Type{Int}, Type{String}} shouldn’t it? …

---

## [Threaded push! different for supposedly similar array initializations](https://discourse.julialang.org/t/threaded-push-different-for-supposedly-similar-array-initializations/65862)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 2\
**Last updated:** [August 5, 2021, 8:37am UTC](https://discourse.julialang.org/t/threaded-push-different-for-supposedly-similar-array-initializations/65862 "2021-08-05T08:37:04Z")

</div>

I have been using threads to assemble sparse matrices. Now I recently wanted to change the initialization of the indices arrays of length nt=Threads.nthreads() from something like \[Int\[\] for i=1:nt\] to fill(Int\[\],nt), wh…

---

## [How to define a const array first and give its length later in a function?](https://discourse.julialang.org/t/how-to-define-a-const-array-first-and-give-its-length-later-in-a-function/65790)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 7\
**Last updated:** [August 5, 2021, 8:06am UTC](https://discourse.julialang.org/t/how-to-define-a-const-array-first-and-give-its-length-later-in-a-function/65790 "2021-08-05T08:06:45Z")

</div>

I have a question, in a module, is it possible that I define a const array first with its length undetermined, and later in a function I set its length? Like, I do const A = Array{Float64,1} however its length is u…

---

## [Calling a macro from within a macro, revisited](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680)

<div class="topic-metadata">

**Author:** [@tjgreen](https://discourse.julialang.org/u/tjgreen)\
**Replies:** 15\
**Last updated:** [August 5, 2021, 4:07am UTC](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680 "2021-08-05T04:07:46Z")

</div>

Hi all, I have a question: am i seeing a bug in the macro expander, or am I misunderstanding its usage? I’m implementing a macro which delegates (most of) its work to another macro, and I’m running into some issues aro…

---

## [Measuring the time properly for nested for-loops with @parallel](https://discourse.julialang.org/t/measuring-the-time-properly-for-nested-for-loops-with-parallel/65841)

<div class="topic-metadata">

**Author:** [@Rick](https://discourse.julialang.org/u/Rick)\
**Replies:** 2\
**Last updated:** [August 5, 2021, 2:10am UTC](https://discourse.julialang.org/t/measuring-the-time-properly-for-nested-for-loops-with-parallel/65841 "2021-08-05T02:10:15Z")

</div>

Hi, I am trying to measure the total time used to execute a nested for-loops. I used @elapsed but it seems to only return the time used by one of the inner loops. A MWE is as follows: function f(m,n) s = SharedArray…

---

## [Custom promote\_rule not working](https://discourse.julialang.org/t/custom-promote-rule-not-working/65853)

<div class="topic-metadata">

**Author:** [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 1:35am UTC](https://discourse.julialang.org/t/custom-promote-rule-not-working/65853 "2021-08-05T01:35:15Z")

</div>

I’m running Julia 1.6.2. Not sure what’s going wrong here: struct Foo end Base.promote\_rule(::Type{Foo}, ::Type{Float64}) = Foo @show Base.promote(Foo, Float64) I get $ julia bug.jl Base.promote(Foo, Float64) = (Foo, …

---

## [How to draw a grid of text using Javis.jl?](https://discourse.julialang.org/t/how-to-draw-a-grid-of-text-using-javis-jl/65852)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 12:49am UTC](https://discourse.julialang.org/t/how-to-draw-a-grid-of-text-using-javis-jl/65852 "2021-08-05T00:49:56Z")

</div>

I am trying to draw a grid of text like this. here’s my code. But I can’t seem to figure how it works. I thought it’d be object at this location. using Javis function ground(args...) background("white") seth…

---

## [Ccall of a thread C function from REPL](https://discourse.julialang.org/t/ccall-of-a-thread-c-function-from-repl/65845)

<div class="topic-metadata">

**Author:** [@Lecrapouille](https://discourse.julialang.org/u/Lecrapouille)\
**Replies:** 0\
**Last updated:** [August 4, 2021, 10:32pm UTC](https://discourse.julialang.org/t/ccall-of-a-thread-c-function-from-repl/65845 "2021-08-04T22:32:44Z")

</div>

Hello, I’ve made a standalone GUI application in C++ and I can call it from Julia REPL. To achieve this, I exported a C function named int entry\_point() calling the GUI which loops for ever until the user close the wind…

---

## [DataFrames.jl (Tables.jl) is smart enough to consume my array of custom types...love it](https://discourse.julialang.org/t/dataframes-jl-tables-jl-is-smart-enough-to-consume-my-array-of-custom-types-love-it/65819)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 11\
**Last updated:** [August 4, 2021, 7:46pm UTC](https://discourse.julialang.org/t/dataframes-jl-tables-jl-is-smart-enough-to-consume-my-array-of-custom-types-love-it/65819 "2021-08-04T19:46:37Z")

</div>

First, I want to say that I love that this just works: using DataFrames using HTTP using JSON using Unmarshal const appid = # my appid const url = "https://api.openweathermap.org/data/2.5/onecall" params = Dict( …

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

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