# General Usage

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

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

**Page:** 741

---

## [Use of Base.@propagate\_inbounds in OffsetArrays.jl](https://discourse.julialang.org/t/use-of-base-propagate-inbounds-in-offsetarrays-jl/41313)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 2\
**Last updated:** [June 13, 2020, 10:50am UTC](https://discourse.julialang.org/t/use-of-base-propagate-inbounds-in-offsetarrays-jl/41313 "2020-06-13T10:50:46Z")

</div>

I am trying to understand how Base.@propagate\_inbounds works by studying its use in OffsetArrays.jl. Currently setindex! is implemented as @propagate\_inbounds function Base.setindex!(A::OffsetArray{T,N}, val, I::Vararg{…

---

## [How to only return values from the last time step in a saving callback?](https://discourse.julialang.org/t/how-to-only-return-values-from-the-last-time-step-in-a-saving-callback/41276)

<div class="topic-metadata">

**Author:** [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Replies:** 1\
**Last updated:** [June 13, 2020, 7:47am UTC](https://discourse.julialang.org/t/how-to-only-return-values-from-the-last-time-step-in-a-saving-callback/41276 "2020-06-13T07:47:05Z")

</div>

I’ve tried these combinations and haven’t found the correct one yet. cb\_save = SavingCallback(saving\_func, saved\_values, saveat=sol.t\[end\]) cb\_save = SavingCallback(saving\_func, saved\_values, save\_start=false,save\_ever…

---

## [Efficient closures](https://discourse.julialang.org/t/efficient-closures/41262)

<div class="topic-metadata">

**Author:** [@tfr](https://discourse.julialang.org/u/tfr)\
**Replies:** 4\
**Last updated:** [June 13, 2020, 6:18am UTC](https://discourse.julialang.org/t/efficient-closures/41262 "2020-06-13T06:18:23Z")

</div>

Hello. I have a function of many variables, hermite\_interpolation(t, t\_array, f\_array, df\_array), and I want to use this function as the argument of another function, that I shall call do\_something(pulse). However, the …

---

## [Macro through variable assignment](https://discourse.julialang.org/t/macro-through-variable-assignment/41280)

<div class="topic-metadata">

**Author:** [@Magalame](https://discourse.julialang.org/u/Magalame)\
**Replies:** 3\
**Last updated:** [June 13, 2020, 3:42am UTC](https://discourse.julialang.org/t/macro-through-variable-assignment/41280 "2020-06-13T03:42:40Z")

</div>

I want to use two macros (@m1(x), @m2(y)), so that the behaviour of @m2(y) would defer depending on if y = @m1(x) or not. Is this achievable as such? Or do I need to wrap the output of @m1 in a “label” type that would t…

---

## [Gamma function at a negative whole number: a cautionary tale](https://discourse.julialang.org/t/gamma-function-at-a-negative-whole-number-a-cautionary-tale/41307)

<div class="topic-metadata">

**Author:** [@billmclean](https://discourse.julialang.org/u/billmclean)\
**Replies:** 2\
**Last updated:** [June 13, 2020, 3:09am UTC](https://discourse.julialang.org/t/gamma-function-at-a-negative-whole-number-a-cautionary-tale/41307 "2020-06-13T03:09:00Z")

</div>

Consider the following results: julia\> using SpecialFunctions julia\> gamma(-1.999) 500.4623295054461 julia\> gamma(-2.0) ERROR: DomainError with -2.0: NaN result for non-NaN input. julia\> gamma(-2.001) -499.5395437293…

---

## [Reading a file with blank last line](https://discourse.julialang.org/t/reading-a-file-with-blank-last-line/41257)

<div class="topic-metadata">

**Author:** [@binarygcd](https://discourse.julialang.org/u/binarygcd)\
**Replies:** 1\
**Last updated:** [June 12, 2020, 10:48pm UTC](https://discourse.julialang.org/t/reading-a-file-with-blank-last-line/41257 "2020-06-12T22:48:02Z")

</div>

I made a code for a problem that gets its inputs from a file. The inputs are integers and the last line is blank. Below are the ones I’ve tried. for line in eachline() isempty(strip(line)) && break n = parse(Int…

---

## [Understanding environments and DrWatson](https://discourse.julialang.org/t/understanding-environments-and-drwatson/41294)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 5\
**Last updated:** [June 12, 2020, 8:20pm UTC](https://discourse.julialang.org/t/understanding-environments-and-drwatson/41294 "2020-06-12T20:20:46Z")

</div>

Suppose I have a package that looks like this module MyPkg using Distributions, DataFrames function a() end end There is an associated environment with this that has Project.toml.Manifest.toml files that tell MyP…

---

## [Why are my linear interpolations 10x faster in MATLAB?](https://discourse.julialang.org/t/why-are-my-linear-interpolations-10x-faster-in-matlab/41232)

<div class="topic-metadata">

**Author:** [@elenev](https://discourse.julialang.org/u/elenev)\
**Replies:** 26\
**Last updated:** [June 12, 2020, 8:35pm UTC](https://discourse.julialang.org/t/why-are-my-linear-interpolations-10x-faster-in-matlab/41232 "2020-06-12T20:35:06Z")

</div>

The consensus on this forum seems to be that Interpolations.jl is extremely fast, so I must not be using it in a smart way. Here’s an MWE of the Matlab code I’m trying to adapt to Julia. If some stuff looks weird (e.g. …

---

## [Using a specific commit or branch when \`using mypkg\`](https://discourse.julialang.org/t/using-a-specific-commit-or-branch-when-using-mypkg/41293)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 3\
**Last updated:** [June 12, 2020, 7:02pm UTC](https://discourse.julialang.org/t/using-a-specific-commit-or-branch-when-using-mypkg/41293 "2020-06-12T19:02:01Z")

</div>

I have a simulation model that is in the form of a Julia package, i.e. I can do using mypkg and call the function run(). This works fine, but I have several scientific projects that use this model and each project is sli…

---

## [Large CPU time overhead RK4 ODE solver for parabolic problem](https://discourse.julialang.org/t/large-cpu-time-overhead-rk4-ode-solver-for-parabolic-problem/41174)

<div class="topic-metadata">

**Author:** [@egcjm](https://discourse.julialang.org/u/egcjm)\
**Replies:** 15\
**Last updated:** [June 12, 2020, 7:00pm UTC](https://discourse.julialang.org/t/large-cpu-time-overhead-rk4-ode-solver-for-parabolic-problem/41174 "2020-06-12T19:00:34Z")

</div>

I am solving a simple periodic vector parabolic equation using DifferentialEquations’ RK4() ODE solver. The code below is self contained. For the parameters specified, the ODE solver on my computer takes 0.23s (average …

---

## [How can I tell if a compilation is happening?](https://discourse.julialang.org/t/how-can-i-tell-if-a-compilation-is-happening/41292)

<div class="topic-metadata">

**Author:** [@miak](https://discourse.julialang.org/u/miak)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 6:57pm UTC](https://discourse.julialang.org/t/how-can-i-tell-if-a-compilation-is-happening/41292 "2020-06-12T18:57:24Z")

</div>

If I have a type struct Foo{N} end and N is intended to be a value, do methods on Foo{N} where N get compiled for each value of N or each type? For example, if I have a function foo\_stuff(f::Foo{N}) where {N} and I call …

---

## [Lyapunov spectrum](https://discourse.julialang.org/t/lyapunov-spectrum/41281)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 0\
**Last updated:** [June 12, 2020, 4:45pm UTC](https://discourse.julialang.org/t/lyapunov-spectrum/41281 "2020-06-12T16:45:16Z")

</div>

I have a bit of confusion using the function lyapunovs(ds::DynamicalSystem, N \[, k::Int | Q0\]; kwargs...) -\> λs in ChaosTools.lyapunovs. I am not sure if the second argument N can be seen as the number of time steps, o…

---

## [Function callback with GtkSwitch](https://discourse.julialang.org/t/function-callback-with-gtkswitch/41287)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 0\
**Last updated:** [June 12, 2020, 5:29pm UTC](https://discourse.julialang.org/t/function-callback-with-gtkswitch/41287 "2020-06-12T17:29:18Z")

</div>

Hi all- I’m trying to create a function callback for GtkSwitch. What I current have does not work: using Gtk win = GtkWindow() switch = Gtk.GtkSwitchLeaf() f(x) = println("Swiched!") signal\_connect(f, switch, :activate…

---

## [Give data by cmd?](https://discourse.julialang.org/t/give-data-by-cmd/41254)

<div class="topic-metadata">

**Author:** [@Ravinder\_Ram](https://discourse.julialang.org/u/Ravinder_Ram)\
**Replies:** 7\
**Last updated:** [June 12, 2020, 5:20pm UTC](https://discourse.julialang.org/t/give-data-by-cmd/41254 "2020-06-12T17:20:49Z")

</div>

let’s suppose i make function sum(x,y) { x + y}. I want to input(data) by cmd. how to do that?

---

## [Match exact \`axes\`, something more strict than broadcasting or \`map!\`](https://discourse.julialang.org/t/match-exact-axes-something-more-strict-than-broadcasting-or-map/41206)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 5:08pm UTC](https://discourse.julialang.org/t/match-exact-axes-something-more-strict-than-broadcasting-or-map/41206 "2020-06-12T17:08:17Z")

</div>

Is there an operation that is strict in the sense that the destination has to exactly equal the axes of the source? using OffsetArrays s = 1 a5\_10 = fill(0, 10:15) a5\_0 = fill(1, 0:5) a4\_0 = fill(2, 0:4) a5\_10 .= s # a…

---

## [Multi Way Summary](https://discourse.julialang.org/t/multi-way-summary/41269)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 3\
**Last updated:** [June 12, 2020, 4:08pm UTC](https://discourse.julialang.org/t/multi-way-summary/41269 "2020-06-12T16:08:15Z")

</div>

All I am looking for a simple way to perform a summary on multiple levels Attached is a screenshot from SAS, which shows what I am trying to achieve (consider the first row as well as the subsequent 26 rows). Is there …

---

## [Why there are different execution times for same function calls](https://discourse.julialang.org/t/why-there-are-different-execution-times-for-same-function-calls/41259)

<div class="topic-metadata">

**Author:** [@akhil\_teja](https://discourse.julialang.org/u/akhil_teja)\
**Replies:** 4\
**Last updated:** [June 12, 2020, 3:37pm UTC](https://discourse.julialang.org/t/why-there-are-different-execution-times-for-same-function-calls/41259 "2020-06-12T15:37:54Z")

</div>

Below is my Code: function bisection(custom\_func,starting::T,ending::K) where {T\<:Real,K\<:Real} if custom\_func(starting)==0 return starting elseif custom\_func(ending)==0 return ending elseif …

---

## [Setting an upper and lower limit on a differential equation](https://discourse.julialang.org/t/setting-an-upper-and-lower-limit-on-a-differential-equation/41144)

<div class="topic-metadata">

**Author:** [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Replies:** 14\
**Last updated:** [June 12, 2020, 2:56pm UTC](https://discourse.julialang.org/t/setting-an-upper-and-lower-limit-on-a-differential-equation/41144 "2020-06-12T14:56:51Z")

</div>

This is the last piece I need for my model to work, yet the result keeps going over what I thought I had set the limit to. The simplified scenario is: there is a fishing boat - on the boat work is done - the amount of w…

---

## [Can we have \`String\`s/\`Cmd\`s as type parameter?](https://discourse.julialang.org/t/can-we-have-string-s-cmd-s-as-type-parameter/31647)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 12:06pm UTC](https://discourse.julialang.org/t/can-we-have-string-s-cmd-s-as-type-parameter/31647 "2020-06-12T12:06:33Z")

</div>

I am working on Julia 1.3 and find we can have Numbers, Symbols and Chars, etc., as type parameters, but they cannot be Strings, Cmds, etc. julia\> struct A{T} end julia\> A{333}() A{333}() julia\> A{"fd"}() ERROR…

---

## [Cant install OpenSpecFun\_jll](https://discourse.julialang.org/t/cant-install-openspecfun-jll/33593)

<div class="topic-metadata">

**Author:** [@mariok90](https://discourse.julialang.org/u/mariok90)\
**Replies:** 50\
**Last updated:** [June 12, 2020, 9:45am UTC](https://discourse.julialang.org/t/cant-install-openspecfun-jll/33593 "2020-06-12T09:45:35Z")

</div>

When I install JuMP I get the following error. Any idea on how to fix this? Installed OpenSpecFun\_jll ──── v0.5.3+1 ERROR: Unable to automatically install 'OpenSpecFun' from '/homes2/ivw/kendzior/.julia/packages/OpenSpe…

---

## [Off diagonal elements of Matrix](https://discourse.julialang.org/t/off-diagonal-elements-of-matrix/41169)

<div class="topic-metadata">

**Author:** [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Replies:** 14\
**Last updated:** [June 12, 2020, 9:37am UTC](https://discourse.julialang.org/t/off-diagonal-elements-of-matrix/41169 "2020-06-12T09:37:28Z")

</div>

Hi, what is the Julia-way of obtaining off-diagonal elements of a matrix flattend as a vector, e.g. A = \[1 2; 3 4\] offdiag(A) = \[2, 3\] I stumbled across diagind but could not figure out how to do it neatly. Best, ja…

---

## [How to insatll 'OpenBLAS' manually?](https://discourse.julialang.org/t/how-to-insatll-openblas-manually/41185)

<div class="topic-metadata">

**Author:** [@jkwwwwow](https://discourse.julialang.org/u/jkwwwwow)\
**Replies:** 5\
**Last updated:** [June 12, 2020, 8:38am UTC](https://discourse.julialang.org/t/how-to-insatll-openblas-manually/41185 "2020-06-12T08:38:56Z")

</div>

When I try to add POMDPSimulators I met the following error: julia\> import Pkg julia\> Pkg.add("POMDPSimulators") Updating registry at \`~/.julia/registries/General\` Updating git-repo \`https://github.com/JuliaRegis…

---

## [Cannot \`convert\` an object of type Random.\_GLOBAL\_RNG to an object of type Random.MersenneTwister](https://discourse.julialang.org/t/cannot-convert-an-object-of-type-random-global-rng-to-an-object-of-type-random-mersennetwister/41172)

<div class="topic-metadata">

**Author:** [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 8:20am UTC](https://discourse.julialang.org/t/cannot-convert-an-object-of-type-random-global-rng-to-an-object-of-type-random-mersennetwister/41172 "2020-06-12T08:20:06Z")

</div>

Here is the error: ERROR: LoadError: MethodError: Cannot \`convert\` an object of type Random.\_GLOBAL\_RNG to an object of type Random.MersenneTwister Closest candidates are: convert(::Type{S}, ::T) where {S, T\<:Categori…

---

## [Anonymous function applied to multiple arguments](https://discourse.julialang.org/t/anonymous-function-applied-to-multiple-arguments/41221)

<div class="topic-metadata">

**Author:** [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Replies:** 13\
**Last updated:** [June 12, 2020, 1:10am UTC](https://discourse.julialang.org/t/anonymous-function-applied-to-multiple-arguments/41221 "2020-06-12T01:10:22Z")

</div>

What is the correct syntax for the following: julia\> xV = 1:5; yV = 2:6; julia\> findall((x,y) -\> ((x \> 2) & (y \> 4)), (xV, yV)) The docs only have examples with one argument.

---

## [Error while using @time on a Multi-threaded Julia function!](https://discourse.julialang.org/t/error-while-using-time-on-a-multi-threaded-julia-function/41189)

<div class="topic-metadata">

**Author:** [@Saad\_Mahmud](https://discourse.julialang.org/u/Saad_Mahmud)\
**Replies:** 9\
**Last updated:** [June 12, 2020, 12:51am UTC](https://discourse.julialang.org/t/error-while-using-time-on-a-multi-threaded-julia-function/41189 "2020-06-12T00:51:05Z")

</div>

I am trying to time a Julia function and inside that function, I am using Multiple threads. Example of the code is given below: function function1(input) @threads for i in 1:N #does something with the input end end for…

---

## [Query.jl @mutate command does not preserve column types](https://discourse.julialang.org/t/query-jl-mutate-command-does-not-preserve-column-types/41231)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 4\
**Last updated:** [June 12, 2020, 12:46am UTC](https://discourse.julialang.org/t/query-jl-mutate-command-does-not-preserve-column-types/41231 "2020-06-12T00:46:02Z")

</div>

I have a dataframe that I read from CSV. I.e. df = CSV.read("myfile.csv" , header=1, select=(i, name) -\> i \< 5 && return true) The parser automatically gets the correct type of each column 92×5 DataFrame │ Row │ neck …

---

## [How to Calculate and Plot Fit Residuals from Numerical Integration to High Precision](https://discourse.julialang.org/t/how-to-calculate-and-plot-fit-residuals-from-numerical-integration-to-high-precision/41094)

<div class="topic-metadata">

**Author:** [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Replies:** 11\
**Last updated:** [June 11, 2020, 10:37pm UTC](https://discourse.julialang.org/t/how-to-calculate-and-plot-fit-residuals-from-numerical-integration-to-high-precision/41094 "2020-06-11T22:37:22Z")

</div>

Hi, I am learning how to use Numerical Integration, and want to test how well the Num Integration fits the analytical/theoretical model, by subtracting the model from the Num Integration results, and plotting & examining…

---

## [An incorrect result warning for OpenBLAS Archlinux users](https://discourse.julialang.org/t/an-incorrect-result-warning-for-openblas-archlinux-users/29436)

<div class="topic-metadata">

**Author:** [@mratsim](https://discourse.julialang.org/u/mratsim)\
**Replies:** 2\
**Last updated:** [June 11, 2020, 9:03pm UTC](https://discourse.julialang.org/t/an-incorrect-result-warning-for-openblas-archlinux-users/29436 "2020-06-11T21:03:18Z")

</div>

The default OpenBLAS packaged in Archlinux can produce wrong results for float64. This is due to the fact that in Archlinux, the blas package (from netlib reference implementation) has been separated into blas for Fortr…

---

## [Variable scope in for loop](https://discourse.julialang.org/t/variable-scope-in-for-loop/41228)

<div class="topic-metadata">

**Author:** [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)\
**Replies:** 2\
**Last updated:** [June 11, 2020, 8:41pm UTC](https://discourse.julialang.org/t/variable-scope-in-for-loop/41228 "2020-06-11T20:41:33Z")

</div>

Hi, Please see the following code: for i = 1:2 a = 7 for i = 3 a = 9 end @show a @show i end which has the output: a = 9 i = 1 a = 9 i = 2 My question is, why is the value of “i” not modi…

---

## [Install julia packages on cluster, presumably behind a proxy](https://discourse.julialang.org/t/install-julia-packages-on-cluster-presumably-behind-a-proxy/41226)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 0\
**Last updated:** [June 11, 2020, 7:54pm UTC](https://discourse.julialang.org/t/install-julia-packages-on-cluster-presumably-behind-a-proxy/41226 "2020-06-11T19:54:09Z")

</div>

I had no trouble installing Julia on my laptop / office computer etc., but I’m trying to set it up on the front of a cluster, and on a completely fresh download of 1.4.2 (curl https://julialang-s3.julialang.org/bin/linux…

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

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