# General Usage

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

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

**Page:** 759

---

## [Huge difference between passing a type, or using a hardcoded-type (in benchmarks)?](https://discourse.julialang.org/t/huge-difference-between-passing-a-type-or-using-a-hardcoded-type-in-benchmarks/38561)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 6\
**Last updated:** [May 1, 2020, 6:49pm UTC](https://discourse.julialang.org/t/huge-difference-between-passing-a-type-or-using-a-hardcoded-type-in-benchmarks/38561 "2020-05-01T18:49:27Z")

</div>

I do not understand why there is a 30x difference between these two implementations. I guess I am doing some dumb (benchmarking) mistake because the produced LLVM code seems to be equal. Note that I am using a large buf…

---

## [Broadcasting trig functions to SparseArrays.SparseMatrixCSC](https://discourse.julialang.org/t/broadcasting-trig-functions-to-sparsearrays-sparsematrixcsc/38570)

<div class="topic-metadata">

**Author:** [@woochangchung](https://discourse.julialang.org/u/woochangchung)\
**Replies:** 3\
**Last updated:** [May 1, 2020, 6:24pm UTC](https://discourse.julialang.org/t/broadcasting-trig-functions-to-sparsearrays-sparsematrixcsc/38570 "2020-05-01T18:24:52Z")

</div>

I have noticed some difference in behaviors when broadcasting trig functions to SparseArrays.SparseMatrixCSC objects. Here is an example. Let x be a SparseArrays.SparseMatrixCSC{Complex{Float64},Int64} object. It has 1…

---

## [Type Float32 has no field data](https://discourse.julialang.org/t/type-float32-has-no-field-data/35397)

<div class="topic-metadata">

**Author:** [@Eldho.Ashna](https://discourse.julialang.org/u/Eldho.Ashna)\
**Replies:** 4\
**Last updated:** [May 1, 2020, 5:49pm UTC](https://discourse.julialang.org/t/type-float32-has-no-field-data/35397 "2020-05-01T17:49:16Z")

</div>

Hi all, When I ran the following code snippet from JuliaAcademy, using Printf train\_loss = Float64\[\] test\_loss = Float64\[\] function update\_loss!() push!(train\_loss, L(trainbatch...).data) push!(test\_loss, L(tes…

---

## [About type declarations](https://discourse.julialang.org/t/about-type-declarations/38514)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 7\
**Last updated:** [May 1, 2020, 4:10pm UTC](https://discourse.julialang.org/t/about-type-declarations/38514 "2020-05-01T16:10:15Z")

</div>

What is the difference between the following two cases (if there is any difference at all): struct Bar{F} f::F end struct Foo bar::Bar end and: struct Bar{F} f::F end struct Foo{F} bar::Bar{F} end Are both …

---

## [Not clear why cumsum! doesn't work in this simple case](https://discourse.julialang.org/t/not-clear-why-cumsum-doesnt-work-in-this-simple-case/38510)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 4\
**Last updated:** [May 1, 2020, 3:17pm UTC](https://discourse.julialang.org/t/not-clear-why-cumsum-doesnt-work-in-this-simple-case/38510 "2020-05-01T15:17:07Z")

</div>

The source vector is a column of x and the destination vector is a different column of x. There is nothing in the documentation or source code that says that the base array can’t be the same. Seems to defeat the purpos…

---

## [Unsigned long in ccall](https://discourse.julialang.org/t/unsigned-long-in-ccall/38557)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 6\
**Last updated:** [May 1, 2020, 2:46pm UTC](https://discourse.julialang.org/t/unsigned-long-in-ccall/38557 "2020-05-01T14:46:16Z")

</div>

I need to call a MPFR library function whose signature is int mpfr\_sub\_ui(mpfr\_t rop, mpfr\_t op1, unsigned long int op2, mpfr\_rnd\_t rnd). The manual says that unsigned long is an Int on Unix and an Int32 on Windows. Is …

---

## [How to improve this code](https://discourse.julialang.org/t/how-to-improve-this-code/38535)

<div class="topic-metadata">

**Author:** [@hmemy](https://discourse.julialang.org/u/hmemy)\
**Replies:** 4\
**Last updated:** [May 1, 2020, 9:35am UTC](https://discourse.julialang.org/t/how-to-improve-this-code/38535 "2020-05-01T09:35:29Z")

</div>

Hi, I have a large number of key dictionaries inside a dictionary named data. I would like to iterate over the collection of dicts to find the bus of type 12, which must be only one in the collection. I came up with th…

---

## [How to train a combination of models in Flux?](https://discourse.julialang.org/t/how-to-train-a-combination-of-models-in-flux/38489)

<div class="topic-metadata">

**Author:** [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Replies:** 2\
**Last updated:** [May 1, 2020, 9:29am UTC](https://discourse.julialang.org/t/how-to-train-a-combination-of-models-in-flux/38489 "2020-05-01T09:29:46Z")

</div>

I have two models m1 and m2. Here is my code: using Flux function even\_mask(x) s1, s2 = size(x) weight\_mask = zeros(s1, s2) weight\_mask\[2:2:s1,:\] = ones(Int(s1/2), s2) return weight\_mask end function o…

---

## [CSV misbehavior](https://discourse.julialang.org/t/csv-misbehavior/38484)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 4\
**Last updated:** [May 1, 2020, 6:11am UTC](https://discourse.julialang.org/t/csv-misbehavior/38484 "2020-05-01T06:11:14Z")

</div>

hello all, I have 2 similar files saved as comma delimited (CSV) I can read only one of them. When I try to read the other one I get this message

---

## [Metaprogramming using eval and struct: BUG getting UndefVarError: not defined](https://discourse.julialang.org/t/metaprogramming-using-eval-and-struct-bug-getting-undefvarerror-not-defined/37937)

<div class="topic-metadata">

**Author:** [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Replies:** 22\
**Last updated:** [May 1, 2020, 3:22am UTC](https://discourse.julialang.org/t/metaprogramming-using-eval-and-struct-bug-getting-undefvarerror-not-defined/37937 "2020-05-01T03:22:04Z")

</div>

I am trying to read parameters from a .csv file for which the name of parameter and its values are given in the .csv file. For that I am trying to simply evaluate a simple expression involving putting the value of the …

---

## [Libraries for converting Expr to executable julia codes?](https://discourse.julialang.org/t/libraries-for-converting-expr-to-executable-julia-codes/38521)

<div class="topic-metadata">

**Author:** [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Replies:** 0\
**Last updated:** [May 1, 2020, 2:35am UTC](https://discourse.julialang.org/t/libraries-for-converting-expr-to-executable-julia-codes/38521 "2020-05-01T02:35:35Z")

</div>

I’m trying to lift some uses of macro libraries into develop-only time, in which I have to generate julia codes from Expr. It’s okay even if the conversion is incomplete, I have methods to handle them if some Expr canno…

---

## [Show entire matrix](https://discourse.julialang.org/t/show-entire-matrix/1437)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 8\
**Last updated:** [May 1, 2020, 1:16am UTC](https://discourse.julialang.org/t/show-entire-matrix/1437 "2020-05-01T01:16:07Z")

</div>

I have some narrow but long matrix (dataframe-like), and I’d like it to be displayed entirely in IJulia (or in the REPL). display(m) cuts it in the middle and shows only ~25 rows. show and print show everything, but the …

---

## [Inferring correct environment based on file being run?](https://discourse.julialang.org/t/inferring-correct-environment-based-on-file-being-run/38358)

<div class="topic-metadata">

**Author:** [@jackf](https://discourse.julialang.org/u/jackf)\
**Replies:** 5\
**Last updated:** [April 30, 2020, 11:45pm UTC](https://discourse.julialang.org/t/inferring-correct-environment-based-on-file-being-run/38358 "2020-04-30T23:45:05Z")

</div>

I have a local package (call it Foo) that I have devd. In the src folder I have a file called main.jl that I’d like to run by calling julia src/main.jl. Currently, I have to call julia --project main.jl to use the correc…

---

## [How to call constructor of parametric family of types efficiently](https://discourse.julialang.org/t/how-to-call-constructor-of-parametric-family-of-types-efficiently/38503)

<div class="topic-metadata">

**Author:** [@SEA](https://discourse.julialang.org/u/SEA)\
**Replies:** 6\
**Last updated:** [April 30, 2020, 8:38pm UTC](https://discourse.julialang.org/t/how-to-call-constructor-of-parametric-family-of-types-efficiently/38503 "2020-04-30T20:38:23Z")

</div>

I would like to call the constructor of several parametric families of types efficiently, while only having access to a concrete instance of a type. Also, I am trying to avoid having to write a separate method for each f…

---

## [Develop a local version of a registered package and submit changes as a pull request](https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 7:21pm UTC](https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868 "2020-04-30T19:21:42Z")

</div>

I’ve been working through how one would go about making changes to a registered Julia package and submit the changes as a pull request. I haven’t found one source that explains the whole process, so I thought I’d share w…

---

## [DataFrames unicode output disable?](https://discourse.julialang.org/t/dataframes-unicode-output-disable/38491)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 6\
**Last updated:** [April 30, 2020, 6:18pm UTC](https://discourse.julialang.org/t/dataframes-unicode-output-disable/38491 "2020-04-30T18:18:47Z")

</div>

I use cygwin for most of my work and as an April fool’s joke, they decided to break unicode output in terminals (interestingly the cygwin shell terminal AND ALL the X-window terminals are broken, meaning it’s a top-level…

---

## [Add Julia function within R package without Julia install (or hiding it)](https://discourse.julialang.org/t/add-julia-function-within-r-package-without-julia-install-or-hiding-it/38488)

<div class="topic-metadata">

**Author:** [@virgile-baudrot](https://discourse.julialang.org/u/virgile-baudrot)\
**Replies:** 2\
**Last updated:** [April 30, 2020, 4:47pm UTC](https://discourse.julialang.org/t/add-julia-function-within-r-package-without-julia-install-or-hiding-it/38488 "2020-04-30T16:47:37Z")

</div>

I would like to provide some simple functions I developed in Julia for R user through an R package. With JuliaCall, it should be easy, but I have some difficulties to make a link between Julia objects and functions in th…

---

## [SQLite/DBInterface confusion](https://discourse.julialang.org/t/sqlite-dbinterface-confusion/38458)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 5\
**Last updated:** [April 30, 2020, 4:37pm UTC](https://discourse.julialang.org/t/sqlite-dbinterface-confusion/38458 "2020-04-30T16:37:43Z")

</div>

Looks like something’s changed since i last used it. I went to the doc’s and saw this, DBInterface.execute(db::SQLite.DB, sql::String, \[params\]) huh. i don’t remember DBInterface… ok, installed it, then tried: db…

---

## [How do modify marker thickness in Plots.jl?](https://discourse.julialang.org/t/how-do-modify-marker-thickness-in-plots-jl/38437)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 1\
**Last updated:** [April 30, 2020, 2:42pm UTC](https://discourse.julialang.org/t/how-do-modify-marker-thickness-in-plots-jl/38437 "2020-04-30T14:42:42Z")

</div>

Is there a way to change the thickness of the line-type markers (e.g. :xcross and :cross) in Plots.jl? I’m using the GR backend, if it matters. I’d expect the following to give a marker with pretty thick lines, but neit…

---

## [Need help finishing a groupby random sampling function](https://discourse.julialang.org/t/need-help-finishing-a-groupby-random-sampling-function/38485)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 0\
**Last updated:** [April 30, 2020, 1:58pm UTC](https://discourse.julialang.org/t/need-help-finishing-a-groupby-random-sampling-function/38485 "2020-04-30T13:58:41Z")

</div>

Hi how’s it going, I have a function that takes in a dataframe, groups by a column, and takes a random sample of that column. I want to set some condition that says “If the size of this subdataframe is less than 20, don’…

---

## [Make \` Array{T}(undef, ...) \` fill with a value for debugging?](https://discourse.julialang.org/t/make-array-t-undef-fill-with-a-value-for-debugging/38471)

<div class="topic-metadata">

**Author:** [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Replies:** 12\
**Last updated:** [April 30, 2020, 1:24pm UTC](https://discourse.julialang.org/t/make-array-t-undef-fill-with-a-value-for-debugging/38471 "2020-04-30T13:24:39Z")

</div>

Is there a way to force array allocation to fill with a specific value, eg NaN? I often find myself debugging bugs that don’t appear when the array happens to be filled with zeros, so this would make these bugs reproduci…

---

## [New line in substitution string?](https://discourse.julialang.org/t/new-line-in-substitution-string/21891)

<div class="topic-metadata">

**Author:** [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Replies:** 7\
**Last updated:** [April 30, 2020, 9:32am UTC](https://discourse.julialang.org/t/new-line-in-substitution-string/21891 "2020-04-30T09:32:10Z")

</div>

How does one put a new line (\\n) in a substitution string? e.g.: println(replace("test string", r"(test string)" =\> s"\\1 \\n line 2")) Id like it to return: test string line 2 But I get: Bad replacement string: \\1 \\n…

---

## [Clang.jl ignoring #define starting with underscore](https://discourse.julialang.org/t/clang-jl-ignoring-define-starting-with-underscore/38426)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 2\
**Last updated:** [April 30, 2020, 7:04am UTC](https://discourse.julialang.org/t/clang-jl-ignoring-define-starting-with-underscore/38426 "2020-04-30T07:04:00Z")

</div>

I have some header files which I’d like to wrap with Clang.jl. Why does it ignore definitions starting with underscore such as: #define \_VAR (1) If I remove the underscore, it works fine: #define VAR (1) const VAR =…

---

## [How to break out of exactly the current loop?](https://discourse.julialang.org/t/how-to-break-out-of-exactly-the-current-loop/38457)

<div class="topic-metadata">

**Author:** [@Yusen\_Liu](https://discourse.julialang.org/u/Yusen_Liu)\
**Replies:** 4\
**Last updated:** [April 30, 2020, 12:58am UTC](https://discourse.julialang.org/t/how-to-break-out-of-exactly-the-current-loop/38457 "2020-04-30T00:58:29Z")

</div>

Hi all, I know the use of break, which is that a ‘break’ statement inside such a loop exits the entire nest of loops, not just the inner one. What if I just want to exit the inner one? For instance for i in 1:5, j in…

---

## [How would you plot a 3d histogram (or lego plot as people call it)](https://discourse.julialang.org/t/how-would-you-plot-a-3d-histogram-or-lego-plot-as-people-call-it/38427)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 5\
**Last updated:** [April 29, 2020, 9:46pm UTC](https://discourse.julialang.org/t/how-would-you-plot-a-3d-histogram-or-lego-plot-as-people-call-it/38427 "2020-04-29T21:46:14Z")

</div>

Hi how’s it going? I want to make a 3d histogram, or a lego plot. What would be the best way of going about this? For a hypothetical example, say x = \[1,2,3,4,5\], y = \[0,5,30,10,15\] and z = \[50,100,150,200,250\] Here i…

---

## [DiffEqFlux.sciml\_train resulting parameters](https://discourse.julialang.org/t/diffeqflux-sciml-train-resulting-parameters/38409)

<div class="topic-metadata">

**Author:** [@Matthew\_Overlin](https://discourse.julialang.org/u/Matthew_Overlin)\
**Replies:** 4\
**Last updated:** [April 29, 2020, 4:48pm UTC](https://discourse.julialang.org/t/diffeqflux-sciml-train-resulting-parameters/38409 "2020-04-29T16:48:21Z")

</div>

I am following an example here. The neural network is defined as Chain(Dense(2,50,tanh),Dense(50,2)). The resulting “.minimizer” array of values has 252 entries. How are each of these entries mapped to the W1, b1, W2,…

---

## [Skip layer with masked weights in Flux](https://discourse.julialang.org/t/skip-layer-with-masked-weights-in-flux/38419)

<div class="topic-metadata">

**Author:** [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Replies:** 0\
**Last updated:** [April 29, 2020, 12:44pm UTC](https://discourse.julialang.org/t/skip-layer-with-masked-weights-in-flux/38419 "2020-04-29T12:44:51Z")

</div>

I know that I could define an skip layer in Flux, like below: struct Skip inner end (m::Skip) = x .+ m.inner(x) But how could I multiply m.inner(x) by an sparse weight mask? How could I define the layer?

---

## [Draw vectors on scatter plot with flipped axis](https://discourse.julialang.org/t/draw-vectors-on-scatter-plot-with-flipped-axis/38416)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 2\
**Last updated:** [April 29, 2020, 11:59am UTC](https://discourse.julialang.org/t/draw-vectors-on-scatter-plot-with-flipped-axis/38416 "2020-04-29T11:59:04Z")

</div>

Hi all- Is there a way to draw a vector with flipped axes? In the example, the vectors are drawn in two places (and without an error in the correct place). using Plots m1 = (x=350,y=250) m2 = (x=375,y=26) vm = (x=m1…

---

## [Makie scene, wait for input](https://discourse.julialang.org/t/makie-scene-wait-for-input/28860)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 3\
**Last updated:** [April 29, 2020, 4:51am UTC](https://discourse.julialang.org/t/makie-scene-wait-for-input/28860 "2020-04-29T04:51:31Z")

</div>

I want a loop using Makie where: scene rendered user input collected user terminates input (keys entered, window closed) advances to next scene What would I need to do to implement the wait-then-advance-on-input par…

---

## [Strange memory allocation with DistributedArrays](https://discourse.julialang.org/t/strange-memory-allocation-with-distributedarrays/38325)

<div class="topic-metadata">

**Author:** [@mipiro](https://discourse.julialang.org/u/mipiro)\
**Replies:** 11\
**Last updated:** [April 29, 2020, 3:51am UTC](https://discourse.julialang.org/t/strange-memory-allocation-with-distributedarrays/38325 "2020-04-29T03:51:37Z")

</div>

Hello! I noticed a strange thing while I was playing with distributed arrays. Here is an example of the code: using Distributed; addprocs(2) @everywhere using DistributedArrays function create\_big\_darray(n) darr =…

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

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