# General Usage

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

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

**Page:** 507

---

## [Setup \`@benchmark\` inside function: setup not defined](https://discourse.julialang.org/t/setup-benchmark-inside-function-setup-not-defined/73251)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 5\
**Last updated:** [December 17, 2021, 1:42pm UTC](https://discourse.julialang.org/t/setup-benchmark-inside-function-setup-not-defined/73251 "2021-12-17T13:42:43Z")

</div>

Why am I getting this error? And how to setup a benchmark inside a function? In the global scope this works: julia\> using BenchmarkTools julia\> let a = rand(10) setup = begin x = d…

---

## [Memory allocation with \`view\` and array assignment](https://discourse.julialang.org/t/memory-allocation-with-view-and-array-assignment/67109)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 12\
**Last updated:** [December 17, 2021, 1:19pm UTC](https://discourse.julialang.org/t/memory-allocation-with-view-and-array-assignment/67109 "2021-12-17T13:19:17Z")

</div>

Hey, I was wondering about this code: julia\> x = randn((2048, 2048)); julia\> z = copy(x); julia\> using BenchmarkTools julia\> @btime $z\[2:2000, 2:2000\] = view($x, 2:2000, 2:2000); 5.386 ms (0 allocations: 0 bytes) …

---

## [Round float addition](https://discourse.julialang.org/t/round-float-addition/73130)

<div class="topic-metadata">

**Author:** [@n90](https://discourse.julialang.org/u/n90)\
**Replies:** 9\
**Last updated:** [December 17, 2021, 10:55am UTC](https://discourse.julialang.org/t/round-float-addition/73130 "2021-12-17T10:55:50Z")

</div>

Can I round 0.1 + 0.2 to 0.30 not the default 0.30000000000000004 in Julia.

---

## [Parameter identification with Optim.jl to optimize a first order output error-model](https://discourse.julialang.org/t/parameter-identification-with-optim-jl-to-optimize-a-first-order-output-error-model/73218)

<div class="topic-metadata">

**Author:** [@Volker](https://discourse.julialang.org/u/Volker)\
**Replies:** 2\
**Last updated:** [December 17, 2021, 7:43am UTC](https://discourse.julialang.org/t/parameter-identification-with-optim-jl-to-optimize-a-first-order-output-error-model/73218 "2021-12-17T07:43:36Z")

</div>

Hello, I would like to start with Optim.jl to optimize some dynamical systems. The following code should optmize the parameters of a linear output error model which approximates a nonlinear system. using Optim functio…

---

## [How to stack up multiple 3-dimension matrices into one?](https://discourse.julialang.org/t/how-to-stack-up-multiple-3-dimension-matrices-into-one/73225)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 8\
**Last updated:** [December 17, 2021, 12:20am UTC](https://discourse.julialang.org/t/how-to-stack-up-multiple-3-dimension-matrices-into-one/73225 "2021-12-17T00:20:53Z")

</div>

For example, I could have 10 Matrices like the below (A) stored in 10 NetCDF files: A = rand(5, 3, 2); My goal is to read them all out and stack them up into a new matrix B with the size of size(B) = (5, 3, 20). I tri…

---

## [Replacing missing values in a matrix is super slow](https://discourse.julialang.org/t/replacing-missing-values-in-a-matrix-is-super-slow/73213)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 38\
**Last updated:** [December 17, 2021, 12:50am UTC](https://discourse.julialang.org/t/replacing-missing-values-in-a-matrix-is-super-slow/73213 "2021-12-17T00:50:46Z")

</div>

I have a matrix with the size of 360x180x1200. It contains lots of values that are equal to 100000002004087734272. I assume those are missing value indicators. I tried to use the below command to replace them with NaNs,…

---

## [Can PyPlot generate plots from multiple threads?](https://discourse.julialang.org/t/can-pyplot-generate-plots-from-multiple-threads/68876)

<div class="topic-metadata">

**Author:** [@g2g](https://discourse.julialang.org/u/g2g)\
**Replies:** 4\
**Last updated:** [December 17, 2021, 12:39am UTC](https://discourse.julialang.org/t/can-pyplot-generate-plots-from-multiple-threads/68876 "2021-12-17T00:39:47Z")

</div>

I’m new to Julia but already impressed because Julia is 4x faster than GNU Octave at generating the approximately 6000 frames of a 3D plot animation (30 minutes versus 120 minutes) I am making. I am hoping to be able to …

---

## [Package metrics](https://discourse.julialang.org/t/package-metrics/73235)

<div class="topic-metadata">

**Author:** [@hros](https://discourse.julialang.org/u/hros)\
**Replies:** 0\
**Last updated:** [December 17, 2021, 12:11am UTC](https://discourse.julialang.org/t/package-metrics/73235 "2021-12-17T00:11:05Z")

</div>

As @logankilpatrick notes in his recent blog post, the package manager is one of the best features of Julia. There are many well known, and actively developed packages. However, there are some packages which are either…

---

## [CI tests in Ubuntu 20.04 started to fail recently](https://discourse.julialang.org/t/ci-tests-in-ubuntu-20-04-started-to-fail-recently/73233)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 0\
**Last updated:** [December 16, 2021, 11:34pm UTC](https://discourse.julialang.org/t/ci-tests-in-ubuntu-20-04-started-to-fail-recently/73233 "2021-12-16T23:34:46Z")

</div>

Hi, since two days the GMT.jl CI tests start to fail (well, they don’t even start) with an cryptic error message saying: ERROR: LoadError: LoadError: could not load library "/home/runner/gmt-install-dir/lib/libgmt.so" /…

---

## [How to store matrices as an element in a vector array?](https://discourse.julialang.org/t/how-to-store-matrices-as-an-element-in-a-vector-array/73230)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [December 16, 2021, 9:21pm UTC](https://discourse.julialang.org/t/how-to-store-matrices-as-an-element-in-a-vector-array/73230 "2021-12-16T21:21:47Z")

</div>

I have 16 matrices with the size of 360x180. My goal is to store them in a cell array like in Matlab, i.e., A = \[\]; for i=1:16 A{i} = Matrix i; end I thought I could do the same thing in Julia as below: A = \[\]; for i …

---

## [Infinity symbol](https://discourse.julialang.org/t/infinity-symbol/73204)

<div class="topic-metadata">

**Author:** [@ko56](https://discourse.julialang.org/u/ko56)\
**Replies:** 11\
**Last updated:** [December 16, 2021, 8:43pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204 "2021-12-16T20:43:06Z")

</div>

Is there any reason that Julia does not allow Inf to be typed in as \\infty?

---

## [How can I control the threads in lower level in multithreading function?](https://discourse.julialang.org/t/how-can-i-control-the-threads-in-lower-level-in-multithreading-function/73227)

<div class="topic-metadata">

**Author:** [@Nova](https://discourse.julialang.org/u/Nova)\
**Replies:** 2\
**Last updated:** [December 16, 2021, 8:23pm UTC](https://discourse.julialang.org/t/how-can-i-control-the-threads-in-lower-level-in-multithreading-function/73227 "2021-12-16T20:23:21Z")

</div>

I applied multithreading on a for loop that results in runtime speedup. I have 12 cores on my system and by adjusting the number of threads (e.g. 4, 8, and 12), I observe an improvement in runtime. However, the runtime i…

---

## [Checking the symmetry of a matrix](https://discourse.julialang.org/t/checking-the-symmetry-of-a-matrix/73206)

<div class="topic-metadata">

**Author:** [@Rajesh\_Nakka](https://discourse.julialang.org/u/Rajesh_Nakka)\
**Replies:** 5\
**Last updated:** [December 16, 2021, 3:56pm UTC](https://discourse.julialang.org/t/checking-the-symmetry-of-a-matrix/73206 "2021-12-16T15:56:09Z")

</div>

I am trying to check the symmetry of a matrix which I was expecting to be symmetric. I have printed A^T -A to check the deviation from symmetry. It is actually populated with very small numbers, as shown below. 0.0 …

---

## [Symbolics.jl: Simplify divisions assuming a variable is not zero](https://discourse.julialang.org/t/symbolics-jl-simplify-divisions-assuming-a-variable-is-not-zero/68406)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 2\
**Last updated:** [September 19, 2021, 12:09pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplify-divisions-assuming-a-variable-is-not-zero/68406 "2021-09-19T12:09:54Z")

</div>

How can I use Symbolics.jl to simplify divisions assuming a variable is not zero? For example, I would like to get 1 from julia\> using Symbolics julia\> @variables x 1-element Vector{Num}: x julia\> simplify(x / x) # …

---

## [Sincos slightly slower than sin and cos](https://discourse.julialang.org/t/sincos-slightly-slower-than-sin-and-cos/73207)

<div class="topic-metadata">

**Author:** [@markmbaum](https://discourse.julialang.org/u/markmbaum)\
**Replies:** 2\
**Last updated:** [December 16, 2021, 3:14pm UTC](https://discourse.julialang.org/t/sincos-slightly-slower-than-sin-and-cos/73207 "2021-12-16T15:14:32Z")

</div>

I have some pieces of code that require lots of sin and cos evaluations and I’m looking for ways to accelerate. I noticed that the sincos function seems slightly slower than calling sin and cos alone. julia\> using Bench…

---

## [Function \`apply\`, that calls a function with a tuple of arguments?](https://discourse.julialang.org/t/function-apply-that-calls-a-function-with-a-tuple-of-arguments/72898)

<div class="topic-metadata">

**Author:** [@bert](https://discourse.julialang.org/u/bert)\
**Replies:** 13\
**Last updated:** [December 12, 2021, 4:03am UTC](https://discourse.julialang.org/t/function-apply-that-calls-a-function-with-a-tuple-of-arguments/72898 "2021-12-12T04:03:33Z")

</div>

Julia makes it very easy to map/broadcast a function over a collection of argument tuples. But I don’t think it makes it so easy to map/broadcast multiple functions over one tuple of arguments. We can do this: f.((1, 2…

---

## [PyCall error, number of arguments in a ccall function](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 2\
**Last updated:** [December 16, 2021, 2:18pm UTC](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143 "2021-12-16T14:18:56Z")

</div>

I have a script that calls functions from the Python OpenCV module via PyCall. Everything was working fine the other day, not sure what changed in my configuration. I use PyCall with my system python at /usr/bin/python3.…

---

## [Same response of NODE for different parameter vectors despite nn results are different](https://discourse.julialang.org/t/same-response-of-node-for-different-parameter-vectors-despite-nn-results-are-different/69608)

<div class="topic-metadata">

**Author:** [@Volker](https://discourse.julialang.org/u/Volker)\
**Replies:** 1\
**Last updated:** [December 16, 2021, 12:40pm UTC](https://discourse.julialang.org/t/same-response-of-node-for-different-parameter-vectors-despite-nn-results-are-different/69608 "2021-12-16T12:40:25Z")

</div>

Hi, I’m getting sometimes the same predictions result of my node model for different parameter vectors despite that the neural network return different outputs for the different parameter vectors. Can somebody tell me w…

---

## [Support for MDF format](https://discourse.julialang.org/t/support-for-mdf-format/7162)

<div class="topic-metadata">

**Author:** [@jayveesea](https://discourse.julialang.org/u/jayveesea)\
**Replies:** 13\
**Last updated:** [December 16, 2021, 12:18pm UTC](https://discourse.julialang.org/t/support-for-mdf-format/7162 "2021-12-16T12:18:14Z")

</div>

It would be great if the MDF format was supported like HDF5 is. Some examples are here for matlab and here (and here) for python. It’s also now supported natively by matlab. Just to be clear, I’m not referring to this…

---

## [Defining a macro in a local scope?](https://discourse.julialang.org/t/defining-a-macro-in-a-local-scope/73148)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 8\
**Last updated:** [December 16, 2021, 11:57am UTC](https://discourse.julialang.org/t/defining-a-macro-in-a-local-scope/73148 "2021-12-16T11:57:10Z")

</div>

I’m trying to define a macro whose expansion references a local variable. Here’s my example: struct Reference source::Union{Nothing, LineNumberNode} registry::Dict key end let r = Dict() macro ref(…

---

## [Memory management and PackageCompiler libraries](https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980)

<div class="topic-metadata">

**Author:** [@originalsouth](https://discourse.julialang.org/u/originalsouth)\
**Replies:** 8\
**Last updated:** [December 16, 2021, 10:37am UTC](https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980 "2021-12-16T10:37:33Z")

</div>

Hello, I have a question regarding memory management when retrieving arbitrary sized memory blocks from a library compiled by the PackageCompiler. In https://github.com/originalsouth/RandomPack I have created a dummy p…

---

## [How can I configure Pkg to use specific git](https://discourse.julialang.org/t/how-can-i-configure-pkg-to-use-specific-git/71420)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 4\
**Last updated:** [December 16, 2021, 9:19am UTC](https://discourse.julialang.org/t/how-can-i-configure-pkg-to-use-specific-git/71420 "2021-12-16T09:19:01Z")

</div>

After I upgrade to MacOS Monterey, my Homebrew installed git does not work. I have uninstalled that git. Now I can use the Xcode git (/usr/bin/git) in the terminal. But when I add/update a github repo, I get the followin…

---

## [Performance when chaining multiple macros](https://discourse.julialang.org/t/performance-when-chaining-multiple-macros/73173)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 2\
**Last updated:** [December 16, 2021, 12:22am UTC](https://discourse.julialang.org/t/performance-when-chaining-multiple-macros/73173 "2021-12-16T00:22:42Z")

</div>

I’m aware that macros such as @muladd from MuladdMacro.jl, @views, and @inbounds are occasionally very useful for performance. Might there be any problems with combining them in general? For example, is the following cha…

---

## [Julia download links broken?](https://discourse.julialang.org/t/julia-download-links-broken/73171)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 4\
**Last updated:** [December 15, 2021, 11:47pm UTC](https://discourse.julialang.org/t/julia-download-links-broken/73171 "2021-12-15T23:47:21Z")

</div>

Is it just me or are other folks having an issue where all the julialang-s3.julialang.org... links on are broken? If other folks have this issue I’ll file it on github, but it could just be me.

---

## [Positions in an array](https://discourse.julialang.org/t/positions-in-an-array/73157)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 6\
**Last updated:** [December 15, 2021, 9:53pm UTC](https://discourse.julialang.org/t/positions-in-an-array/73157 "2021-12-15T21:53:58Z")

</div>

Hello! I have a 15360x3 array and the last column may only assume three different values: -1, 1, or 2. I’d like to obtain arrays with the positions in this array where the third column assumes each of these possible val…

---

## [Automatically build a system image on package installation](https://discourse.julialang.org/t/automatically-build-a-system-image-on-package-installation/45907)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 16\
**Last updated:** [December 15, 2021, 7:22pm UTC](https://discourse.julialang.org/t/automatically-build-a-system-image-on-package-installation/45907 "2021-12-15T19:22:28Z")

</div>

For colleagues used to a workflow centered around running Python scripts from the command line, I was wondering if a similar workflow with Julia could be facilitated by automatically building a system image containing re…

---

## ["kill" internal execution](https://discourse.julialang.org/t/kill-internal-execution/73144)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 4\
**Last updated:** [December 15, 2021, 6:59pm UTC](https://discourse.julialang.org/t/kill-internal-execution/73144 "2021-12-15T18:59:15Z")

</div>

Is it possible to “kill” the execution of a function under some condition? The use case here would be for benchmarking. That is, I want to run several benchmarks, but I don’t want any of them to take more than some ammo…

---

## [Values of arrays changed unexpectedly due to storage allocation issue?](https://discourse.julialang.org/t/values-of-arrays-changed-unexpectedly-due-to-storage-allocation-issue/73135)

<div class="topic-metadata">

**Author:** [@MichaelGao](https://discourse.julialang.org/u/MichaelGao)\
**Replies:** 7\
**Last updated:** [December 15, 2021, 4:57pm UTC](https://discourse.julialang.org/t/values-of-arrays-changed-unexpectedly-due-to-storage-allocation-issue/73135 "2021-12-15T16:57:34Z")

</div>

Not sure whether I am asking this question in the correct section. I wanted to build a solver for the 1D advection-dispersion-equation, with Dirichlet boundary condition at the influx end and Neumann BC at the efflux en…

---

## [Why do large NTuples Allocate?](https://discourse.julialang.org/t/why-do-large-ntuples-allocate/73145)

<div class="topic-metadata">

**Author:** [@jg-854](https://discourse.julialang.org/u/jg-854)\
**Replies:** 6\
**Last updated:** [December 15, 2021, 3:13pm UTC](https://discourse.julialang.org/t/why-do-large-ntuples-allocate/73145 "2021-12-15T15:13:35Z")

</div>

I was surprised to find that generating Tuples via generators causes allocations for large generators… Using BenchmarkTools @btime NTuple{5,Float64}(1.0 for i=1:5) 1.500 ns (0 allocations: 0 bytes) @btime NTuple{50…

---

## [Problem with PyPlot library](https://discourse.julialang.org/t/problem-with-pyplot-library/73147)

<div class="topic-metadata">

**Author:** [@GalloLuigi](https://discourse.julialang.org/u/GalloLuigi)\
**Replies:** 2\
**Last updated:** [December 15, 2021, 2:59pm UTC](https://discourse.julialang.org/t/problem-with-pyplot-library/73147 "2021-12-15T14:59:05Z")

</div>

Hi, until yesterday I was able to use PyPlot. I got this error this morning Someone can help me?

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

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