# General Usage

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

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

**Page:** 716

---

## [Chain multiple Chains in Flux](https://discourse.julialang.org/t/chain-multiple-chains-in-flux/44743)

<div class="topic-metadata">

**Author:** [@SubhadityaMukherjee](https://discourse.julialang.org/u/SubhadityaMukherjee)\
**Replies:** 2\
**Last updated:** [August 11, 2020, 3:03pm UTC](https://discourse.julialang.org/t/chain-multiple-chains-in-flux/44743 "2020-08-11T15:03:58Z")

</div>

Hello! Is there any way to Chain multiple chains in Flux? Say for example I want to reformat my model from multiple uses of the same layers with different parameters as follows. function conv\_block(in\_channels, out\_ch…

---

## [Tables.jl, UpROOT.jl and the speed](https://discourse.julialang.org/t/tables-jl-uproot-jl-and-the-speed/44737)

<div class="topic-metadata">

**Author:** [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Replies:** 5\
**Last updated:** [August 11, 2020, 10:26am UTC](https://discourse.julialang.org/t/tables-jl-uproot-jl-and-the-speed/44737 "2020-08-11T10:26:54Z")

</div>

EDITED: the post below shows the problem more clear. it takes 0.16 s to read 4 branches (colunms) and 2400 s when 16 branches (columns) are read Would anyone guess of the origin of such behavior I should be able…

---

## [2D array filled with consecutive integers](https://discourse.julialang.org/t/2d-array-filled-with-consecutive-integers/44738)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 1\
**Last updated:** [August 11, 2020, 9:48am UTC](https://discourse.julialang.org/t/2d-array-filled-with-consecutive-integers/44738 "2020-08-11T09:48:43Z")

</div>

I’m trying to learn my way around array API and I need a 2D array filled with consecutive integers for quick sanity tests. I used this array like object: w, h = 4, 3 a = reshape(1:w\*h, w, h) but it doesn’t work in case…

---

## [CPLEX install in Julia](https://discourse.julialang.org/t/cplex-install-in-julia/44724)

<div class="topic-metadata">

**Author:** [@dty](https://discourse.julialang.org/u/dty)\
**Replies:** 2\
**Last updated:** [August 11, 2020, 8:39am UTC](https://discourse.julialang.org/t/cplex-install-in-julia/44724 "2020-08-11T08:39:50Z")

</div>

First of all, I’ll follow Julia’s instructions CPLEX.jl Add environment statement in ENV\["CPLEX\_STUDIO\_BINARIES"\] = "C:/IBM/CPLEX\_Studio128/cplex/bin/x64\_win64" The error report is as follows ERROR: Failed to precompi…

---

## [Does Julia have something like #ifdef in C++ for conditional compile](https://discourse.julialang.org/t/does-julia-have-something-like-ifdef-in-c-for-conditional-compile/44721)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 3\
**Last updated:** [August 11, 2020, 6:53am UTC](https://discourse.julialang.org/t/does-julia-have-something-like-ifdef-in-c-for-conditional-compile/44721 "2020-08-11T06:53:18Z")

</div>

Is there anything like #ifndef or #if in C++ to ignore some code according to the constant definition. I want to ignore some code for the testing purpose.

---

## [What should one expect from the VSCode linter, now and in the future?](https://discourse.julialang.org/t/what-should-one-expect-from-the-vscode-linter-now-and-in-the-future/44630)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 5\
**Last updated:** [August 11, 2020, 6:29am UTC](https://discourse.julialang.org/t/what-should-one-expect-from-the-vscode-linter-now-and-in-the-future/44630 "2020-08-11T06:29:33Z")

</div>

I have been very excited to see the recent progress on the Julia VSCode plugin and I want to thank the people behind it for their great work. I am particularly interested in the linter, which I think could really boost …

---

## [Open file with system's default program](https://discourse.julialang.org/t/open-file-with-systems-default-program/3019)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 4\
**Last updated:** [August 11, 2020, 6:19am UTC](https://discourse.julialang.org/t/open-file-with-systems-default-program/3019 "2020-08-11T06:19:06Z")

</div>

Is there a cross platform way to open a file with the system’s default program, basically simulating a double click on the file’s icon? More specifically, the type of files that will get opened this way is a video file.…

---

## [Adding large matrix, why .+ is not the default?](https://discourse.julialang.org/t/adding-large-matrix-why-is-not-the-default/44708)

<div class="topic-metadata">

**Author:** [@raphaelchinchilla](https://discourse.julialang.org/u/raphaelchinchilla)\
**Replies:** 3\
**Last updated:** [August 10, 2020, 9:10pm UTC](https://discourse.julialang.org/t/adding-large-matrix-why-is-not-the-default/44708 "2020-08-10T21:10:40Z")

</div>

Take three large matrix A, B, C each with 1000x1000 elements. Here is the result for two benchmarks: using broadcasted operator “.+” @benchmark A.=A.+B.+C BenchmarkTools.Trial: memory estimate: 96 bytes allocs e…

---

## [Saving outputs in CSV file](https://discourse.julialang.org/t/saving-outputs-in-csv-file/44493)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 20\
**Last updated:** [August 10, 2020, 1:16pm UTC](https://discourse.julialang.org/t/saving-outputs-in-csv-file/44493 "2020-08-10T13:16:29Z")

</div>

This is my first time to use CSV to save outputs and i’m working on a small example to get used to it but it look like i’m still having troubles in it, here is the working example: using CSV using DataFrames function m…

---

## [What does this error mean: "WARN Infinite extent for field "rate": \[Infinity, -Infinity\] Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank""?](https://discourse.julialang.org/t/what-does-this-error-mean-warn-infinite-extent-for-field-rate-infinity-infinity-fontconfig-warning-etc-fonts-fonts-conf-line-86-unknown-element-blank/34587)

<div class="topic-metadata">

**Author:** [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Replies:** 1\
**Last updated:** [August 10, 2020, 12:29pm UTC](https://discourse.julialang.org/t/what-does-this-error-mean-warn-infinite-extent-for-field-rate-infinity-infinity-fontconfig-warning-etc-fonts-fonts-conf-line-86-unknown-element-blank/34587 "2020-08-10T12:29:20Z")

</div>

Hi This questions is related to this other one: https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546/12 The goal is to make a choropleth map. I was succesful in reading a topojson file. N…

---

## [Question about my Pkg](https://discourse.julialang.org/t/question-about-my-pkg/44668)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [August 10, 2020, 10:06am UTC](https://discourse.julialang.org/t/question-about-my-pkg/44668 "2020-08-10T10:06:01Z")

</div>

This is the modified program After downloading Pkg again, there is no change using LPVSpectral, Plots a=convert(Vector{Float64},rand(20)) λ = 0.02 # Regularization parameter λs = 1 # Regularization par…

---

## [Question about LPVSpectral](https://discourse.julialang.org/t/question-about-lpvspectral/44615)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 15\
**Last updated:** [August 10, 2020, 9:24am UTC](https://discourse.julialang.org/t/question-about-lpvspectral/44615 "2020-08-10T09:24:11Z")

</div>

this is my code using LPVSpectral, Plots a=convert(Vector{Float64},rand(20)) λ = 0.02 # Regularization parameter λs = 1 # Regularization parameter group-lasso normal = true # Use normalized basis functions N…

---

## [How to debug a mem leak in a CxxWrap'ed package?](https://discourse.julialang.org/t/how-to-debug-a-mem-leak-in-a-cxxwraped-package/44660)

<div class="topic-metadata">

**Author:** [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Replies:** 0\
**Last updated:** [August 10, 2020, 4:30am UTC](https://discourse.julialang.org/t/how-to-debug-a-mem-leak-in-a-cxxwraped-package/44660 "2020-08-10T04:30:29Z")

</div>

I’m running into an issue with a mem leak in a package that I wrapped using CxxWrap. I’ve run the offending program with --track-allocation=all, and that pointed to a for loop that retrieves objects from a file, but it …

---

## [Does it make any sense to define a new type name as const?](https://discourse.julialang.org/t/does-it-make-any-sense-to-define-a-new-type-name-as-const/44657)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 2\
**Last updated:** [August 10, 2020, 2:47am UTC](https://discourse.julialang.org/t/does-it-make-any-sense-to-define-a-new-type-name-as-const/44657 "2020-08-10T02:47:00Z")

</div>

I want to use a shorthand for a type name. Which of these two options should I go with? Vec2f = SVector{2, Float32} const Vec2f = SVector{2, Float32}

---

## [AssertionError: md isa Markdown.MD](https://discourse.julialang.org/t/assertionerror-md-isa-markdown-md/44607)

<div class="topic-metadata">

**Author:** [@zwwi](https://discourse.julialang.org/u/zwwi)\
**Replies:** 3\
**Last updated:** [August 10, 2020, 2:44am UTC](https://discourse.julialang.org/t/assertionerror-md-isa-markdown-md/44607 "2020-08-10T02:44:52Z")

</div>

I wanted to generate documentation for a project. I have a make.jl under the docs directory generated by PkgTemplate like the following: using Documenter using MyModule makedocs(; modules=\[MyModule\], authors="a…

---

## [Is there a package that introduces shell-like syntax using macros and the builtin pipeline?](https://discourse.julialang.org/t/is-there-a-package-that-introduces-shell-like-syntax-using-macros-and-the-builtin-pipeline/44639)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 9\
**Last updated:** [August 10, 2020, 2:38am UTC](https://discourse.julialang.org/t/is-there-a-package-that-introduces-shell-like-syntax-using-macros-and-the-builtin-pipeline/44639 "2020-08-10T02:38:06Z")

</div>

I am thinking of changing my primary script language to Julia. The pipeline and backtick command construction are awesome, but their syntax is not as simple and concise as traditional shells. Is there a package dedicated…

---

## [Bug in LinearAlgebra + Plots-PyPlot combo on intel i9-9900?](https://discourse.julialang.org/t/bug-in-linearalgebra-plots-pyplot-combo-on-intel-i9-9900/44097)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 25\
**Last updated:** [August 9, 2020, 9:49pm UTC](https://discourse.julialang.org/t/bug-in-linearalgebra-plots-pyplot-combo-on-intel-i9-9900/44097 "2020-08-09T21:49:16Z")

</div>

I have two computers with intel i9-9900 (new HP dekstop at work + Lenovo home computer), giving the same error on a simple problem – while my laptop (i7) and old work desktop (Dell, Xeon processor?) works fine. Here is t…

---

## [UDP socket sending response, lacking sendto](https://discourse.julialang.org/t/udp-socket-sending-response-lacking-sendto/44591)

<div class="topic-metadata">

**Author:** [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Replies:** 2\
**Last updated:** [August 9, 2020, 8:19am UTC](https://discourse.julialang.org/t/udp-socket-sending-response-lacking-sendto/44591 "2020-08-09T08:19:58Z")

</div>

Hi, I’m trying to establish UDP communication in Julia. For python I see there is a sendto method that lets me respond to the UDP socket UdpCommunication - Python Wiki it’s also in the linux sendto(2): send message on s…

---

## [Local vs global scope again](https://discourse.julialang.org/t/local-vs-global-scope-again/44227)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 30\
**Last updated:** [August 9, 2020, 5:33pm UTC](https://discourse.julialang.org/t/local-vs-global-scope-again/44227 "2020-08-09T17:33:01Z")

</div>

I still think the solution I proposed would work in this case (which is discussed in the 1.5 blog): I quote: Despite the “on paper” simplicity of the 1.0 scope rule, many people found it unintuitive and annoying. Consi…

---

## [Initializing an array with literals without allocating a temporary](https://discourse.julialang.org/t/initializing-an-array-with-literals-without-allocating-a-temporary/44590)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 18\
**Last updated:** [August 9, 2020, 7:32am UTC](https://discourse.julialang.org/t/initializing-an-array-with-literals-without-allocating-a-temporary/44590 "2020-08-09T07:32:48Z")

</div>

In this example: buf = Int64\[0, 0, 0, 0\] function foo(buf) buf\[1\] = 3 buf\[2\] = 1 buf\[3\] = 4 buf\[4\] = 1 nothing end function baz(buf) buf = \[3, 1, 4, 1\] nothing end foo doesn’t allocate, but is a bit ted…

---

## [Performance and memory regression with function wrappers in Julia 1.4+](https://discourse.julialang.org/t/performance-and-memory-regression-with-function-wrappers-in-julia-1-4/44589)

<div class="topic-metadata">

**Author:** [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Replies:** 4\
**Last updated:** [August 9, 2020, 3:12am UTC](https://discourse.julialang.org/t/performance-and-memory-regression-with-function-wrappers-in-julia-1-4/44589 "2020-08-09T03:12:16Z")

</div>

I was surprised to find that FunctionWrappers which return a closed-over value appear to be significantly slower and allocate memory in Julia 1.4 and 1.5, while they are faster and allocate no memory in Julia 1-1.3: Set…

---

## [Error with base/generic function calls](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174)

<div class="topic-metadata">

**Author:** [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Replies:** 4\
**Last updated:** [August 9, 2020, 12:28am UTC](https://discourse.julialang.org/t/error-with-base-generic-function-calls/44174 "2020-08-09T00:28:42Z")

</div>

I’m having trouble with functions seemingly disappearing as I get an UndefVarError. Specifically, in my case, the subtypes() function, although I think I encountered the same issue with DataFrames.valuecols(). I have n…

---

## [How do I put a parametrized struct into another parametrized container?](https://discourse.julialang.org/t/how-do-i-put-a-parametrized-struct-into-another-parametrized-container/44537)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 9\
**Last updated:** [August 8, 2020, 10:03pm UTC](https://discourse.julialang.org/t/how-do-i-put-a-parametrized-struct-into-another-parametrized-container/44537 "2020-08-08T22:03:08Z")

</div>

using DataStructures import Base.isless struct SEvent{F1} callback::F1 time::Float64 end function SEvent(callback::F1, time) where F1 SEvent{F1}(callback, time) end function isless(a::SEvent, b::SEvent) …

---

## [How do I define a macro within a function?](https://discourse.julialang.org/t/how-do-i-define-a-macro-within-a-function/44581)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 8\
**Last updated:** [August 8, 2020, 9:56pm UTC](https://discourse.julialang.org/t/how-do-i-define-a-macro-within-a-function/44581 "2020-08-08T21:56:06Z")

</div>

I want to define a macro within a function, that uses an input argument of the function: function runModel(; model::CoronaModel, n=10, simDuration=2) macro injectModel(name) quote function $(esc…

---

## [Zygote and setindex!](https://discourse.julialang.org/t/zygote-and-setindex/44554)

<div class="topic-metadata">

**Author:** [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Replies:** 0\
**Last updated:** [August 8, 2020, 8:12am UTC](https://discourse.julialang.org/t/zygote-and-setindex/44554 "2020-08-08T08:12:28Z")

</div>

I would like to use Zygote to differentiate through some code where I would usually use setindex!, e.g. A\[i, j\] += v where v is a scalar and A a matrix. My current approach is to use a custom OneHotMatrix struct OneHotM…

---

## [Saving data into array having struct data type](https://discourse.julialang.org/t/saving-data-into-array-having-struct-data-type/44567)

<div class="topic-metadata">

**Author:** [@musman](https://discourse.julialang.org/u/musman)\
**Replies:** 5\
**Last updated:** [August 8, 2020, 4:02pm UTC](https://discourse.julialang.org/t/saving-data-into-array-having-struct-data-type/44567 "2020-08-08T16:02:14Z")

</div>

Hi, newbie to Julia. I am trying to run the following \> struct Bus \> bus\_num::Int64 \> bus\_type::Int64 \> bus\_area::Int64 \> bus\_vmag::Float64 \> bus\_vangle::Float64 \> bus\_vnom::Float64 \> bus\_vmax::Float64 \> bus\_vmin::Floa…

---

## [Cannot achieve type-stability and get rid of allocations](https://discourse.julialang.org/t/cannot-achieve-type-stability-and-get-rid-of-allocations/44548)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 7\
**Last updated:** [August 8, 2020, 11:47am UTC](https://discourse.julialang.org/t/cannot-achieve-type-stability-and-get-rid-of-allocations/44548 "2020-08-08T11:47:40Z")

</div>

Here is a simple implementation of a two-pointer technique for sorted arrays: function f(xs, ys) i\_begin, i\_end = firstindex(xs), firstindex(xs) map(ys) do y i\_begin = something( findnext(x -\> x \>= y, xs…

---

## [Parametrizing a self-referential function field](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 11:46am UTC](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538 "2020-08-08T11:46:20Z")

</div>

My struct changes its input function to automatically get the struct as an argument. This works if I don’t type the struct, but I have no idea how I can type it. mutable struct CoronaModel{F1} # other fields omitted…

---

## [Preallocated variable length buffer with known maximum length](https://discourse.julialang.org/t/preallocated-variable-length-buffer-with-known-maximum-length/44550)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 13\
**Last updated:** [August 8, 2020, 11:00am UTC](https://discourse.julialang.org/t/preallocated-variable-length-buffer-with-known-maximum-length/44550 "2020-08-08T11:00:39Z")

</div>

In this code snippet: n = 9 buf = Int\[\] sizehint!(buf, n) function foo(buf) empty!(buf) for i in 1:rand(1:n) push!(buf, rand(1:n)) end end I intended to preallocate buf, so it foo(buf) can be called without…

---

## [Question about Plots](https://discourse.julialang.org/t/question-about-plots/44557)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 3\
**Last updated:** [August 8, 2020, 9:54am UTC](https://discourse.julialang.org/t/question-about-plots/44557 "2020-08-08T09:54:21Z")

</div>

using SingularSpectrumAnalysis, Plots # generate some data L = 20 # Window length K = 100 N = K\*L; # number of datapoints t = 1:N; # Time vector T = 20…

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

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