# General Usage

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

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

**Page:** 475

---

## [Checking if a vector of structs is contiguous in memory](https://discourse.julialang.org/t/checking-if-a-vector-of-structs-is-contiguous-in-memory/2759)

<div class="topic-metadata">

**Author:** [@vipstar](https://discourse.julialang.org/u/vipstar)\
**Replies:** 10\
**Last updated:** [March 10, 2022, 5:45pm UTC](https://discourse.julialang.org/t/checking-if-a-vector-of-structs-is-contiguous-in-memory/2759 "2022-03-10T17:45:34Z")

</div>

Hi, So I have an vector of tuples of floats, i.e.: Array{Tuple{Float64,Float64},1}(). I know that tuples are immutables and so theoretically this array should be contiguous in memory and there should be no pointers in t…

---

## [Struct of singleton Abstract types performance](https://discourse.julialang.org/t/struct-of-singleton-abstract-types-performance/77679)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 6\
**Last updated:** [March 10, 2022, 5:37pm UTC](https://discourse.julialang.org/t/struct-of-singleton-abstract-types-performance/77679 "2022-03-10T17:37:33Z")

</div>

I understand Julia not being fast when using structs of abstract types and I know that there is no such thing as singleton abstract types. However I would hope that it would be different when using Abstract types of whic…

---

## [How to shift the ticks of a heat map?](https://discourse.julialang.org/t/how-to-shift-the-ticks-of-a-heat-map/77682)

<div class="topic-metadata">

**Author:** [@Dan\_Micsa](https://discourse.julialang.org/u/Dan_Micsa)\
**Replies:** 0\
**Last updated:** [March 10, 2022, 1:10pm UTC](https://discourse.julialang.org/t/how-to-shift-the-ticks-of-a-heat-map/77682 "2022-03-10T13:10:42Z")

</div>

I try to see a correlation matrix in Julia.Plots and the axis are shifted half tick away from where I expect them. using Plots using PlotThemes rho = cor(Return1D) ticks\_ = (1:1:length(tickers)+1, tickers) size\_ = len…

---

## [Removing precompilation leads to lower allocations!?](https://discourse.julialang.org/t/removing-precompilation-leads-to-lower-allocations/73621)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 5\
**Last updated:** [March 10, 2022, 12:52pm UTC](https://discourse.julialang.org/t/removing-precompilation-leads-to-lower-allocations/73621 "2022-03-10T12:52:27Z")

</div>

In one of my packages I tried to lower import times, so I added a couple of typical usage examples in a “precompile” function. Something like function \_my\_precompile() # my "typical use case" code ... end functi…

---

## [Is Interact package dead?](https://discourse.julialang.org/t/is-interact-package-dead/77572)

<div class="topic-metadata">

**Author:** [@pao](https://discourse.julialang.org/u/pao)\
**Replies:** 8\
**Last updated:** [March 10, 2022, 12:10pm UTC](https://discourse.julialang.org/t/is-interact-package-dead/77572 "2022-03-10T12:10:31Z")

</div>

I see that it is impossible lo “add Interact” to both “v16.5” (LTS) and to “v17.2” … Please let me know … Thanks !!

---

## [Communication between two threads in Julia without blocking](https://discourse.julialang.org/t/communication-between-two-threads-in-julia-without-blocking/77637)

<div class="topic-metadata">

**Author:** [@Tine](https://discourse.julialang.org/u/Tine)\
**Replies:** 4\
**Last updated:** [March 10, 2022, 11:23am UTC](https://discourse.julialang.org/t/communication-between-two-threads-in-julia-without-blocking/77637 "2022-03-10T11:23:16Z")

</div>

Hi! I am building a system that consist of multiple threads doing different work. For the purpose of this post, I am simplifying the code. My system: using ThreadPools function work() (timer) -\> begin sto…

---

## [Locking a specific value using ReentrantLock](https://discourse.julialang.org/t/locking-a-specific-value-using-reentrantlock/77673)

<div class="topic-metadata">

**Author:** [@Tine](https://discourse.julialang.org/u/Tine)\
**Replies:** 5\
**Last updated:** [March 10, 2022, 10:57am UTC](https://discourse.julialang.org/t/locking-a-specific-value-using-reentrantlock/77673 "2022-03-10T10:57:36Z")

</div>

Is it possible to lock a specific value using ReentrantLock() Example: struct Person name::String age::Int64 number::Int64 end nancy = Person("Nancy", 34, 12345678) # What I do now lk = ReentrantLock() lo…

---

## [How to represent a value as a syntactically correct string](https://discourse.julialang.org/t/how-to-represent-a-value-as-a-syntactically-correct-string/77667)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 1\
**Last updated:** [March 10, 2022, 8:39am UTC](https://discourse.julialang.org/t/how-to-represent-a-value-as-a-syntactically-correct-string/77667 "2022-03-10T08:39:56Z")

</div>

Hello, how to represent a simple value as a syntactically correct string? for example, this is i do represent(s::Symbol)::String = "Symbol(\\"$s\\")" represent(:abc) # -\> "Symbol("abs")" # but have a bug Symbol("\\\\\\"a…

---

## [Reactive plot in Pluto or Jupyter?](https://discourse.julialang.org/t/reactive-plot-in-pluto-or-jupyter/77654)

<div class="topic-metadata">

**Author:** [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Replies:** 2\
**Last updated:** [March 10, 2022, 7:58am UTC](https://discourse.julialang.org/t/reactive-plot-in-pluto-or-jupyter/77654 "2022-03-10T07:58:19Z")

</div>

Hello, This is what I would like to do in Pluto or JupyterLab: Create a plot Click on this plot Get the coordinates into some variables (binding) Modify the plot To be run in Pluto or Jupyter Would that be possi…

---

## [What kind of julia object translates to C's FILE\*](https://discourse.julialang.org/t/what-kind-of-julia-object-translates-to-cs-file/77656)

<div class="topic-metadata">

**Author:** [@bluesmoon](https://discourse.julialang.org/u/bluesmoon)\
**Replies:** 2\
**Last updated:** [March 10, 2022, 1:54am UTC](https://discourse.julialang.org/t/what-kind-of-julia-object-translates-to-cs-file/77656 "2022-03-10T01:54:05Z")

</div>

I’m on Julia 1.6.5 and trying to redirect verbose messages from LibCURL to a file. In C this would be done by calling curl\_easy\_setopt(CURL \*handle, CURLOPT\_STDERR, FILE \*stream). What kind of a Julia object should I pa…

---

## [\`@nospecialize\` for variadic and keyword arguments](https://discourse.julialang.org/t/nospecialize-for-variadic-and-keyword-arguments/77517)

<div class="topic-metadata">

**Author:** [@calebwin](https://discourse.julialang.org/u/calebwin)\
**Replies:** 3\
**Last updated:** [March 9, 2022, 9:14pm UTC](https://discourse.julialang.org/t/nospecialize-for-variadic-and-keyword-arguments/77517 "2022-03-09T21:14:20Z")

</div>

I have a function pt: function pt( args::Union{AbstractFuture,PartitionType,PartitionTypeComposition,Vector}...; kwargs..., ) that has a whole bunch of specializations: (determined using SnoopCompile): var"#pt…

---

## [What is the difference between Pkg.resolve and Pkg.instantiate?](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 3\
**Last updated:** [March 9, 2022, 9:13pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643 "2022-03-09T21:13:19Z")

</div>

The documentation for resolve and instantiate don’t explain this thoroughly. When is Pkg.resolve useful? I notice that resolve fails if there is no registry installed. Whereas instantiate will automatically install a m…

---

## [How to find pairs of indices that meet specific criteria](https://discourse.julialang.org/t/how-to-find-pairs-of-indices-that-meet-specific-criteria/77119)

<div class="topic-metadata">

**Author:** [@Shouto](https://discourse.julialang.org/u/Shouto)\
**Replies:** 3\
**Last updated:** [February 26, 2022, 11:18pm UTC](https://discourse.julialang.org/t/how-to-find-pairs-of-indices-that-meet-specific-criteria/77119 "2022-02-26T23:18:59Z")

</div>

Hi all, Let E be an array such that E = \[3,5,3,5,3\] so E\[1\] = 3,…,E\[5\] = 3. I want to find and collect the pairs of two indices such that (E\[1\],E\[2\]), (E\[1\],E\[4\]),(E\[2\],E\[4\]), (E\[2\],E\[5\]), (E\[3\],E\[4\]), (E\[4\], E\[5\]). Th…

---

## [Getting gradient of taylorinteg](https://discourse.julialang.org/t/getting-gradient-of-taylorinteg/77632)

<div class="topic-metadata">

**Author:** [@Alseidon](https://discourse.julialang.org/u/Alseidon)\
**Replies:** 5\
**Last updated:** [March 9, 2022, 5:58pm UTC](https://discourse.julialang.org/t/getting-gradient-of-taylorinteg/77632 "2022-03-09T17:58:09Z")

</div>

Hi, I’m quite new to Julia, and currently trying out the gradient provided by ForwardDiff.jl. I tried using it on a function that calls taylorinteg from the TaylorIntegration.jl package ; I was expecting it to give a we…

---

## [Is there a way to handle test case names?](https://discourse.julialang.org/t/is-there-a-way-to-handle-test-case-names/76173)

<div class="topic-metadata">

**Author:** [@ReneUmmels](https://discourse.julialang.org/u/ReneUmmels)\
**Replies:** 5\
**Last updated:** [March 9, 2022, 5:16pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-handle-test-case-names/76173 "2022-03-09T17:16:39Z")

</div>

with @testset you can specify a set name can the same be done with @test somehow? Maybe by creating own extension for test macro, if so how? Background: Sometimes I want to have sets but also name the individual test …

---

## [Flux params restrictive](https://discourse.julialang.org/t/flux-params-restrictive/77428)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 9\
**Last updated:** [March 9, 2022, 2:45pm UTC](https://discourse.julialang.org/t/flux-params-restrictive/77428 "2022-03-09T14:45:01Z")

</div>

I’m working on integrating the Zygote.Params idea into my codes to simplify parameter wrangling, and I was struck by the fact that params!(p::Params, x::AbstractArray{\<:Number}, seen = IdSet()) = push!(p, x) only array…

---

## [VideoIO/GLMakie setting show\_axis for scene via plot attribute not supported anymore](https://discourse.julialang.org/t/videoio-glmakie-setting-show-axis-for-scene-via-plot-attribute-not-supported-anymore/77634)

<div class="topic-metadata">

**Author:** [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Replies:** 0\
**Last updated:** [March 9, 2022, 2:35pm UTC](https://discourse.julialang.org/t/videoio-glmakie-setting-show-axis-for-scene-via-plot-attribute-not-supported-anymore/77634 "2022-03-09T14:35:08Z")

</div>

Cheers, A basic example code from below is giving the output error as in the title of the post. SW versions as follows: Julia 1.6.5 VideoIO 1.0.0 GLMakie 0.5.4 Example code: using GLMakie using VideoIO f = VideoIO.t…

---

## [TaskFailedException with @threads macro with Dict](https://discourse.julialang.org/t/taskfailedexception-with-threads-macro-with-dict/77564)

<div class="topic-metadata">

**Author:** [@ekbrown](https://discourse.julialang.org/u/ekbrown)\
**Replies:** 4\
**Last updated:** [March 9, 2022, 8:06am UTC](https://discourse.julialang.org/t/taskfailedexception-with-threads-macro-with-dict/77564 "2022-03-09T08:06:27Z")

</div>

When using Julia v1.7.2, I get a TaskFailedException when trying to use the @threads macro on a for loop over a dictionary, even though a non-threaded for loop works correctly. I lock the DataFrame that is written to. Do…

---

## [Creating a struct from a YAML file](https://discourse.julialang.org/t/creating-a-struct-from-a-yaml-file/73743)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 20\
**Last updated:** [March 9, 2022, 6:08am UTC](https://discourse.julialang.org/t/creating-a-struct-from-a-yaml-file/73743 "2022-03-09T06:08:41Z")

</div>

I want to provide a struct with configuration variables (parameters) to my simulation. I have a yaml file like this one: system: log\_file: "data/log\_8700W\_8ms" # filename without extension \[replay only\] time\_l…

---

## [Avoiding array mutation with vector combinations for use in flux](https://discourse.julialang.org/t/avoiding-array-mutation-with-vector-combinations-for-use-in-flux/77425)

<div class="topic-metadata">

**Author:** [@vleon1234](https://discourse.julialang.org/u/vleon1234)\
**Replies:** 4\
**Last updated:** [March 9, 2022, 5:18am UTC](https://discourse.julialang.org/t/avoiding-array-mutation-with-vector-combinations-for-use-in-flux/77425 "2022-03-09T05:18:09Z")

</div>

Hi all, I’m working on a parameter estimation problem of an ODE system with two variables u1 and u2. As one part of an objective that I will use in the loss function, I want to calculate a vector of the product of combi…

---

## ['\\n' is not working in \`print\` for customized string literals](https://discourse.julialang.org/t/n-is-not-working-in-print-for-customized-string-literals/31517)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 3\
**Last updated:** [March 9, 2022, 3:02am UTC](https://discourse.julialang.org/t/n-is-not-working-in-print-for-customized-string-literals/31517 "2022-03-09T03:02:17Z")

</div>

I define a @c\_str macro for colored strings: using Rematch: @match function color\_string(str::AbstractString, color::AbstractChar) env = @match color begin 'b' =\> "\\033\[34m" 'r' =\> "\\033\[31m" …

---

## [How to sort a vector by an expensive function in place efficiently?](https://discourse.julialang.org/t/how-to-sort-a-vector-by-an-expensive-function-in-place-efficiently/77540)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 14\
**Last updated:** [March 8, 2022, 4:19pm UTC](https://discourse.julialang.org/t/how-to-sort-a-vector-by-an-expensive-function-in-place-efficiently/77540 "2022-03-08T16:19:20Z")

</div>

The normal sort!(...;by=f) sorts in place by a function, but it results in calling that function many more times than the length of the vector. I tried all the sorting algorithms included in Base and all of them resulted…

---

## [Avoid repeating the same \`using\` line for enclosed modules](https://discourse.julialang.org/t/avoid-repeating-the-same-using-line-for-enclosed-modules/2549)

<div class="topic-metadata">

**Author:** [@xqrongm](https://discourse.julialang.org/u/xqrongm)\
**Replies:** 7\
**Last updated:** [March 8, 2022, 1:28pm UTC](https://discourse.julialang.org/t/avoid-repeating-the-same-using-line-for-enclosed-modules/2549 "2022-03-08T13:28:22Z")

</div>

I want to write modules inside of a module. Is there a way to avoid repeating the same using line of code? module Module0 using Pkg1, Pkg2, Pkg3 module Module01 using Pkg1, Pkg2, Pkg3 some\_code\_1 end module Module02 …

---

## [Generic Structs in Dicts](https://discourse.julialang.org/t/generic-structs-in-dicts/77569)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 2\
**Last updated:** [March 8, 2022, 10:15am UTC](https://discourse.julialang.org/t/generic-structs-in-dicts/77569 "2022-03-08T10:15:11Z")

</div>

Hi all :slight\_smile: Does anyone know why the following doesn’t work? julia\> struct A{T} a::T end julia\> Dict{\<:A,Int} Dict{\<:A, Int64} julia\> Dict{\<:A,Int}() ERROR: MethodError: no method matching (Dict{\<:A, Int64}…

---

## [BenchmarkTools @benchmark beautiful histogram reuse](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 12\
**Last updated:** [March 7, 2022, 8:59pm UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053 "2022-03-07T20:59:36Z")

</div>

Dear Julianners, I saw the beautiful histogram unicode plots of BenchmarkTools of @benchmark BenchmarkTools.Trial: 10000 samples with 968 evaulations took a median time of 90.902 ns (0.00% GC) Time (mean ± σ): 94.…

---

## [Question about generics and \`Base.@kwdef\`](https://discourse.julialang.org/t/question-about-generics-and-base-kwdef/77514)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [March 7, 2022, 2:41pm UTC](https://discourse.julialang.org/t/question-about-generics-and-base-kwdef/77514 "2022-03-07T14:41:38Z")

</div>

Hi all :slight\_smile: What did I do wrong? The following doesn’t work. Base.@kwdef struct A{T} a::T = T() function A(a::T) where T new{T}(a) end end struct B end A{B}() ERROR: LoadError: MethodEr…

---

## [How to calculate a constant the first time a function is called?](https://discourse.julialang.org/t/how-to-calculate-a-constant-the-first-time-a-function-is-called/77506)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 5\
**Last updated:** [March 7, 2022, 2:27pm UTC](https://discourse.julialang.org/t/how-to-calculate-a-constant-the-first-time-a-function-is-called/77506 "2022-03-07T14:27:05Z")

</div>

Hello, how to calculate a constant the first time a function is called? not when compiling not every call foo() = (sleep(1); 1) # foo calculate a constant bar(x) = foo() + x # ???? # first call: @time bar(2) # -\> …

---

## [Force specialization on kwargs](https://discourse.julialang.org/t/force-specialization-on-kwargs/34789)

<div class="topic-metadata">

**Author:** [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)\
**Replies:** 15\
**Last updated:** [March 7, 2022, 1:46pm UTC](https://discourse.julialang.org/t/force-specialization-on-kwargs/34789 "2022-03-07T13:46:53Z")

</div>

If I have a function like this: f\_vararg(varargs::Int...) = tuple(varargs...) I can force specialization on varargs with either of the following: g\_vararg(varargs::Vararg{Int, N}) where {N} = tuple(varargs...) h\_vara…

---

## [Accessing a column value from DataFrameRow allocates](https://discourse.julialang.org/t/accessing-a-column-value-from-dataframerow-allocates/77481)

<div class="topic-metadata">

**Author:** [@Hawkes](https://discourse.julialang.org/u/Hawkes)\
**Replies:** 10\
**Last updated:** [March 7, 2022, 1:44pm UTC](https://discourse.julialang.org/t/accessing-a-column-value-from-dataframerow-allocates/77481 "2022-03-07T13:44:54Z")

</div>

Hi, I am a bit puzzled that the following code allocates. According to the docs, a DataFrameRow should be a view and this type of field setting in a Dict should not allocate IMHO. Am I using DataFrames wrong? NamedTuple…

---

## [Is there any R , python api available for flux.jl?](https://discourse.julialang.org/t/is-there-any-r-python-api-available-for-flux-jl/51236)

<div class="topic-metadata">

**Author:** [@Ravinder\_Ram](https://discourse.julialang.org/u/Ravinder_Ram)\
**Replies:** 3\
**Last updated:** [March 7, 2022, 12:41pm UTC](https://discourse.julialang.org/t/is-there-any-r-python-api-available-for-flux-jl/51236 "2022-03-07T12:41:18Z")

</div>

like dash, tensorflow, xgboost, lightgbm… have interface with R, python why R, python interface not available for flux.jl?

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

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