# General Usage

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

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

**Page:** 857

---

## [Julian way of MATLAB ismember function?](https://discourse.julialang.org/t/julian-way-of-matlab-ismember-function/3740)

<div class="topic-metadata">

**Author:** [@leejm516](https://discourse.julialang.org/u/leejm516)\
**Replies:** 16\
**Last updated:** [June 20, 2019, 2:24pm UTC](https://discourse.julialang.org/t/julian-way-of-matlab-ismember-function/3740 "2019-06-20T14:24:12Z")

</div>

Let two arrays a = \["1", "4", "7"\] and b = \["1","2","3,"4","5"\]. In MATLAB, \[Lia,Locb\] = ismember(a, b) will lead to Lia = \[1, 1, 0\] Locb = \[1, 4, 0\] Quickly looking over docs, I coudn’t find a Julian equivalent of…

---

## [Error:MethodError: no method matching getindex(::typeof(LCSlength), ::Int64)](https://discourse.julialang.org/t/error-no-method-matching-getindex-typeof-lcslength-int64/25464)

<div class="topic-metadata">

**Author:** [@diwas07](https://discourse.julialang.org/u/diwas07)\
**Replies:** 3\
**Last updated:** [June 20, 2019, 8:05am UTC](https://discourse.julialang.org/t/error-no-method-matching-getindex-typeof-lcslength-int64/25464 "2019-06-20T08:05:52Z")

</div>

Hello, I am new to programming. I am learning Julia through online resources. I tried to implement a code in dynamic programming to find Longest common sub sequence. But I get some error, that I do not understand. All…

---

## [Why is convert not called for parametric type?](https://discourse.julialang.org/t/why-is-convert-not-called-for-parametric-type/25376)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 5\
**Last updated:** [June 20, 2019, 6:29am UTC](https://discourse.julialang.org/t/why-is-convert-not-called-for-parametric-type/25376 "2019-06-20T06:29:07Z")

</div>

For parametric type, does the constructor not call convert automatically? julia\> struct Foo3{T} a::T b::Float64 end julia\> Foo3(1,2) ERROR: MethodError: no method matching Foo3(::Int64, ::I…

---

## [Julia plot not saved properly](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162)

<div class="topic-metadata">

**Author:** [@surajp92](https://discourse.julialang.org/u/surajp92)\
**Replies:** 8\
**Last updated:** [June 19, 2019, 9:38pm UTC](https://discourse.julialang.org/t/julia-plot-not-saved-properly/25162 "2019-06-19T21:38:21Z")

</div>

I am using Plots to create the XY plot and then saving it in the pdf format. But the text in the ylabel is not saved properly. The power of the 10 is not saved and the number appears like 1.0X10 instead of 1.0X10^-8. Bel…

---

## [Question about @threads](https://discourse.julialang.org/t/question-about-threads/25404)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 3\
**Last updated:** [June 19, 2019, 7:17pm UTC](https://discourse.julialang.org/t/question-about-threads/25404 "2019-06-19T19:17:50Z")

</div>

I have some workload and want to work on it using all threads. If I do Threads.@threads for \_ in 1:nthreads() # doit end Is it guaranteed, that all threads are used, or could it be that one thread occurs multiple …

---

## [Result diverges on 129th iteration?](https://discourse.julialang.org/t/result-diverges-on-129th-iteration/25453)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 3\
**Last updated:** [June 19, 2019, 7:01pm UTC](https://discourse.julialang.org/t/result-diverges-on-129th-iteration/25453 "2019-06-19T19:01:43Z")

</div>

My goal is to make the implementation of my qlog function specialized for MultiVector types. In the Grassmann.jl package, I have the generic Grassmann.qlog implementation, which has a lot of unnecessary allocations made…

---

## [Approach to avoid memory allocation with struct with abstract type fields](https://discourse.julialang.org/t/approach-to-avoid-memory-allocation-with-struct-with-abstract-type-fields/24822)

<div class="topic-metadata">

**Author:** [@sfriedowitz](https://discourse.julialang.org/u/sfriedowitz)\
**Replies:** 8\
**Last updated:** [June 19, 2019, 5:47pm UTC](https://discourse.julialang.org/t/approach-to-avoid-memory-allocation-with-struct-with-abstract-type-fields/24822 "2019-06-19T17:47:46Z")

</div>

I am working on some molecular simulation code, and am hitting a road block on figuring on a good design structure to avoid memory allocation for a container that will store different concrete subtypes of a single abstra…

---

## [How to plot a timeline](https://discourse.julialang.org/t/how-to-plot-a-timeline/25095)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 23\
**Last updated:** [June 19, 2019, 5:13pm UTC](https://discourse.julialang.org/t/how-to-plot-a-timeline/25095 "2019-06-19T17:13:25Z")

</div>

I want to ask how I can plot a timeline like this one in Julia

---

## [Dispatch on decorated (sub)types](https://discourse.julialang.org/t/dispatch-on-decorated-sub-types/25396)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 6\
**Last updated:** [June 19, 2019, 3:33pm UTC](https://discourse.julialang.org/t/dispatch-on-decorated-sub-types/25396 "2019-06-19T15:33:03Z")

</div>

I was just wondering on how one could do multiple dispatch when using a decorator pattern and subtypes. Imagine the following example abstract type A end struct A1 \<: A c::Int end struct A2 \<: A c::Float64 end …

---

## [Performance Help, Algorithm Is Not Scaling Well](https://discourse.julialang.org/t/performance-help-algorithm-is-not-scaling-well/25315)

<div class="topic-metadata">

**Author:** [@dburch](https://discourse.julialang.org/u/dburch)\
**Replies:** 15\
**Last updated:** [June 19, 2019, 3:02pm UTC](https://discourse.julialang.org/t/performance-help-algorithm-is-not-scaling-well/25315 "2019-06-19T15:02:58Z")

</div>

I have an array with arrays inside. I created an algorithm to find duplicated elements in arrays in the array. It works correctly, but when I start scaling up to thousands or tens of thousands of records, then it is not …

---

## [Does compilation time for methods depend on input?](https://discourse.julialang.org/t/does-compilation-time-for-methods-depend-on-input/25440)

<div class="topic-metadata">

**Author:** [@srb](https://discourse.julialang.org/u/srb)\
**Replies:** 5\
**Last updated:** [June 19, 2019, 1:12pm UTC](https://discourse.julialang.org/t/does-compilation-time-for-methods-depend-on-input/25440 "2019-06-19T13:12:16Z")

</div>

Just a simple questions about compile times, Say I have a function that takes an Integer argument and does some calculations depending on said integer. Does the compilation time depend on how big the integer is? Say, f…

---

## [Nested ArrayPartition cause reduce over an empty collection](https://discourse.julialang.org/t/nested-arraypartition-cause-reduce-over-an-empty-collection/25424)

<div class="topic-metadata">

**Author:** [@shipengcheng1230](https://discourse.julialang.org/u/shipengcheng1230)\
**Replies:** 0\
**Last updated:** [June 18, 2019, 8:40pm UTC](https://discourse.julialang.org/t/nested-arraypartition-cause-reduce-over-an-empty-collection/25424 "2019-06-18T20:40:40Z")

</div>

Hi, I was trying to simulate a physical system consisting of heterogeneous subpart sizes (i.e. arrays), so I use RecursiveArrayTools. Consider the following MWE: julia\> using DifferentialEquations julia\> function foo(d…

---

## [ERROR: Unsatisfiable requirements detected for package ASTInterpreter2 \[e6d88f4b\]](https://discourse.julialang.org/t/error-unsatisfiable-requirements-detected-for-package-astinterpreter2-e6d88f4b/22225)

<div class="topic-metadata">

**Author:** [@Mohammed\_Sabbah](https://discourse.julialang.org/u/Mohammed_Sabbah)\
**Replies:** 6\
**Last updated:** [June 18, 2019, 8:04pm UTC](https://discourse.julialang.org/t/error-unsatisfiable-requirements-detected-for-package-astinterpreter2-e6d88f4b/22225 "2019-06-18T20:04:51Z")

</div>

Hi, I am trying to add some packages but the following error arise: (v1.0) pkg\> add Makie Resolving package versions... ERROR: Unsatisfiable requirements detected for package ASTInterpreter2 \[e6d88f4b\]: ASTInterpreter…

---

## [How to specify the type of a Tracked CuArray?](https://discourse.julialang.org/t/how-to-specify-the-type-of-a-tracked-cuarray/25406)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 0\
**Last updated:** [June 18, 2019, 12:37pm UTC](https://discourse.julialang.org/t/how-to-specify-the-type-of-a-tracked-cuarray/25406 "2019-06-18T12:37:41Z")

</div>

Hello, I have a function that calls neural networks on the gpu and I would like to specify the return type for performances. using Flux net = Chain(Dense(3,2,relu)) |\> gpu function foo(net::Chain, input::CuArray{Float3…

---

## [Isbits functions with parameter arguments](https://discourse.julialang.org/t/isbits-functions-with-parameter-arguments/25397)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 4\
**Last updated:** [June 18, 2019, 12:02pm UTC](https://discourse.julialang.org/t/isbits-functions-with-parameter-arguments/25397 "2019-06-18T12:02:06Z")

</div>

Imagine, I have a function that depends on some parameters, like step functions in DIfferentialEuations.jl. I would like to define these parameters once and avoid passing them as arguments at every function call. As a so…

---

## [Install Juno, fails](https://discourse.julialang.org/t/install-juno-fails/24757)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 6\
**Last updated:** [June 18, 2019, 9:53am UTC](https://discourse.julialang.org/t/install-juno-fails/24757 "2019-06-18T09:53:08Z")

</div>

I have updated Atom and cannot install any package. The error should be related to the Atom as bellow, which shows “Self signed certificate in certificate chain”. I can install package from the command window using the c…

---

## [How to simplify type parameters and still be type stable?](https://discourse.julialang.org/t/how-to-simplify-type-parameters-and-still-be-type-stable/25387)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 5\
**Last updated:** [June 18, 2019, 9:52am UTC](https://discourse.julialang.org/t/how-to-simplify-type-parameters-and-still-be-type-stable/25387 "2019-06-18T09:52:49Z")

</div>

In my code I need to use type parameters to keep my structs type stable. E.g., struct Foo{A,B} a::A b::B end So far, so good. Now, imagine that the types A and B are also structs that in turn have type parameter…

---

## [Way to reclaim recently unassigned variable?](https://discourse.julialang.org/t/way-to-reclaim-recently-unassigned-variable/25385)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 1\
**Last updated:** [June 18, 2019, 5:21am UTC](https://discourse.julialang.org/t/way-to-reclaim-recently-unassigned-variable/25385 "2019-06-18T05:21:55Z")

</div>

Let’s say you’ve created some data object: cur\_dict = Dict() for i in 1:10000 cur\_dict\[i+rand()\] = i sleep(2) end Then you fat finger the previous code again so that cur\_dict is reset to Dict(). Is there a way to …

---

## [Write structure to HDF5 file and read a compound type from HDF5 into Julia structure](https://discourse.julialang.org/t/write-structure-to-hdf5-file-and-read-a-compound-type-from-hdf5-into-julia-structure/20358)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 3\
**Last updated:** [June 18, 2019, 1:58am UTC](https://discourse.julialang.org/t/write-structure-to-hdf5-file-and-read-a-compound-type-from-hdf5-into-julia-structure/20358 "2019-06-18T01:58:17Z")

</div>

How to write a structure in HDF5 file? using HDF5 mutable struct Foo a::Int b::Float64 end vect = \[1,2,3,4,5\] foo = Foo(1, 2.0) foovect = \[P(i, i/2) for i=1:5\] path = "/testfile.h5" h5write(path, "/vect", vect) …

---

## [Any way to figure out if a WeakRef is referenced elsewhere?](https://discourse.julialang.org/t/any-way-to-figure-out-if-a-weakref-is-referenced-elsewhere/25380)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [June 17, 2019, 10:45pm UTC](https://discourse.julialang.org/t/any-way-to-figure-out-if-a-weakref-is-referenced-elsewhere/25380 "2019-06-17T22:45:08Z")

</div>

If I have a WeakRef to an object, is there any more efficient way to figure out if its referenced elsewhere, other than just running a GC.gc() and checking if my WeakRef value has become nothing?

---

## [Generating plots(heatmap, surf, mesh) using cimgui and Cuda libraries](https://discourse.julialang.org/t/generating-plots-heatmap-surf-mesh-using-cimgui-and-cuda-libraries/24597)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 15\
**Last updated:** [June 17, 2019, 10:09pm UTC](https://discourse.julialang.org/t/generating-plots-heatmap-surf-mesh-using-cimgui-and-cuda-libraries/24597 "2019-06-17T22:09:13Z")

</div>

I have a problem, in which I have to generate some physical Field(Magnetic Field) in plot which value is dependent of 3 cartesian coordinates(x,y,z) and position of inducing elements(wires, poles, cables - line elements)…

---

## [How to define a set literal like Python?](https://discourse.julialang.org/t/how-to-define-a-set-literal-like-python/25352)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 9\
**Last updated:** [June 17, 2019, 9:51pm UTC](https://discourse.julialang.org/t/how-to-define-a-set-literal-like-python/25352 "2019-06-17T21:51:48Z")

</div>

In Python, we could write a set by {1, 2, 3}. In Julia, we have to write Set(\[1, 2, 3\]). Is there a way to define a set literal the same way as Python?

---

## [Spelling of sum(x\*y for (x,y) in zip(xs, ys)), e.g. linear combinations](https://discourse.julialang.org/t/spelling-of-sum-x-y-for-x-y-in-zip-xs-ys-e-g-linear-combinations/25379)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 3\
**Last updated:** [June 17, 2019, 9:10pm UTC](https://discourse.julialang.org/t/spelling-of-sum-x-y-for-x-y-in-zip-xs-ys-e-g-linear-combinations/25379 "2019-06-17T21:10:25Z")

</div>

Is there a good canonical spelling for taking a linear combination, e.g. combo(xs, ys) = sum(x\*y for (x,y) in zip(xs, ys)) basis = \[\[1,0\], \[1,1\]\] weights = \[0.5, 0.5\] julia\> combo(basis, weights) 2-element Array{Float6…

---

## [PR to stdlib](https://discourse.julialang.org/t/pr-to-stdlib/25369)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 3\
**Last updated:** [June 17, 2019, 3:26pm UTC](https://discourse.julialang.org/t/pr-to-stdlib/25369 "2019-06-17T15:26:11Z")

</div>

I wanted to add “default” functionality to TemrinalMenus.jl (so one could specify a default pre-selected item/s to the menus). So I \]dev TerminalMenus changed stuff in .julia/dev/TerminalMenus added documentations an…

---

## [How to get new random values at every run of a testset?](https://discourse.julialang.org/t/how-to-get-new-random-values-at-every-run-of-a-testset/25365)

<div class="topic-metadata">

**Author:** [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Replies:** 1\
**Last updated:** [June 17, 2019, 12:14pm UTC](https://discourse.julialang.org/t/how-to-get-new-random-values-at-every-run-of-a-testset/25365 "2019-06-17T12:14:51Z")

</div>

Hello, How can I have functions like randstring() generate new values at every run of a testset. For example, in the following test, I have to restart a julia session to get a different value from the previous executio…

---

## [Unexplained Allocation](https://discourse.julialang.org/t/unexplained-allocation/25332)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 8\
**Last updated:** [June 17, 2019, 10:38am UTC](https://discourse.julialang.org/t/unexplained-allocation/25332 "2019-06-17T10:38:11Z")

</div>

Here is a short code-snippet that confused me. I’d appreciate any explanation of this phenomenon? using BenchmarkTools f(A, B) = A, B g(A, B) = A A = rand(5) B = rand(5) @btime f($A, $B); # 10.919 ns (1 allocation: …

---

## [How to type a latex formula in editor Atom when using Julia?](https://discourse.julialang.org/t/how-to-type-a-latex-formula-in-editor-atom-when-using-julia/25358)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 6\
**Last updated:** [June 17, 2019, 9:05am UTC](https://discourse.julialang.org/t/how-to-type-a-latex-formula-in-editor-atom-when-using-julia/25358 "2019-06-17T09:05:35Z")

</div>

Hi, I have a quick question as the following. I was wondering, how to type a latex formula like e^2 in a .jl file when using Atom? Any suggestions?

---

## [Dynamically documenting fields in "dictionary-like" type](https://discourse.julialang.org/t/dynamically-documenting-fields-in-dictionary-like-type/25295)

<div class="topic-metadata">

**Author:** [@sebasguts](https://discourse.julialang.org/u/sebasguts)\
**Replies:** 5\
**Last updated:** [June 17, 2019, 8:48am UTC](https://discourse.julialang.org/t/dynamically-documenting-fields-in-dictionary-like-type/25295 "2019-06-17T08:48:27Z")

</div>

Dear all, I a trying to add dynamic documentation to fields of a “dictionary-like” type in GAP.jl, namely the type struct GlobalsType funcs::Dict{Symbol,Cuint} end There is only one global instance of this type, n…

---

## [Why the performance hit on this trivial vector wrapper broadcast?](https://discourse.julialang.org/t/why-the-performance-hit-on-this-trivial-vector-wrapper-broadcast/25335)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [June 17, 2019, 12:56am UTC](https://discourse.julialang.org/t/why-the-performance-hit-on-this-trivial-vector-wrapper-broadcast/25335 "2019-06-17T00:56:20Z")

</div>

I’ve got a trivial vector wrapper type implementing a minimal array interface: using Lazy struct VecWrapper{T, V\<:AbstractVector{T}} \<: AbstractVector{T} data :: V end @forward VecWrapper.data (Base.getindex, Base.…

---

## [Loop over function names to document them](https://discourse.julialang.org/t/loop-over-function-names-to-document-them/25328)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 1\
**Last updated:** [June 16, 2019, 11:51pm UTC](https://discourse.julialang.org/t/loop-over-function-names-to-document-them/25328 "2019-06-16T23:51:32Z")

</div>

I have written a set of functions, say foo!, bar!, etc., to do some operations that modify their first argument. Now say I want to have their complements foo, bar… that operate on a default value of that first argument, …

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

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