# General Usage

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

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

**Page:** 792

---

## [Adding documentation string in metaprogramming function definition eval loop](https://discourse.julialang.org/t/adding-documentation-string-in-metaprogramming-function-definition-eval-loop/34156)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 3\
**Last updated:** [February 4, 2020, 10:50am UTC](https://discourse.julialang.org/t/adding-documentation-string-in-metaprogramming-function-definition-eval-loop/34156 "2020-02-04T10:50:20Z")

</div>

I have this nice codeblock: for (dim, Dim) in (("time", :Time), ("zonal", :Lon)) @eval begin # """ # $(dim)average(a::DimensionalArray, i=end) # Return the $(dim)-averaged \`a\` (average ac…

---

## [How to optimaly comprssing and save long strings ( 10^6 char and more)](https://discourse.julialang.org/t/how-to-optimaly-comprssing-and-save-long-strings-10-6-char-and-more/34133)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 4\
**Last updated:** [February 4, 2020, 10:40am UTC](https://discourse.julialang.org/t/how-to-optimaly-comprssing-and-save-long-strings-10-6-char-and-more/34133 "2020-02-04T10:40:06Z")

</div>

how to optimaly comprssing and save long strings ( 10^6 char and more) HDF5 I cant do “compress” another oprtions ? Formats? Paul

---

## [Code introspection recommendations/advice](https://discourse.julialang.org/t/code-introspection-recommendations-advice/34118)

<div class="topic-metadata">

**Author:** [@BrucePBon](https://discourse.julialang.org/u/BrucePBon)\
**Replies:** 2\
**Last updated:** [February 4, 2020, 10:19am UTC](https://discourse.julialang.org/t/code-introspection-recommendations-advice/34118 "2020-02-04T10:19:42Z")

</div>

After some testing I obtained that calling the C FFTW library directly from julia is much faster (x5 faster) than using the FFTW julia package. Now I want to understand where this difference might be coming from, therefo…

---

## [Best practice way to check if method is defined for given arguments](https://discourse.julialang.org/t/best-practice-way-to-check-if-method-is-defined-for-given-arguments/34152)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 2\
**Last updated:** [February 4, 2020, 9:49am UTC](https://discourse.julialang.org/t/best-practice-way-to-check-if-method-is-defined-for-given-arguments/34152 "2020-02-04T09:49:28Z")

</div>

What’s the clean, best-practice way to check if a method is defined for a given set of arguments, from within package code? I want to check if certain required methods/traits are implemented for given arguments/types bef…

---

## [Pkg operations without updating registry](https://discourse.julialang.org/t/pkg-operations-without-updating-registry/34151)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 3\
**Last updated:** [February 4, 2020, 9:47am UTC](https://discourse.julialang.org/t/pkg-operations-without-updating-registry/34151 "2020-02-04T09:47:48Z")

</div>

Is it possibly to run Pkg operations like add and instantiate without updating the registry? Since my registry is on NFS, updating it is slow, and having it update every few minutes when doing a lot of package operations…

---

## [Workspace in Julia](https://discourse.julialang.org/t/workspace-in-julia/34122)

<div class="topic-metadata">

**Author:** [@shiroghost](https://discourse.julialang.org/u/shiroghost)\
**Replies:** 16\
**Last updated:** [February 3, 2020, 11:13pm UTC](https://discourse.julialang.org/t/workspace-in-julia/34122 "2020-02-03T23:13:51Z")

</div>

Hi all, New to Julia, but with experience in HPC. I am looking for a canonical way to have module variables that can be shared between the different functions of the module without having to pass these variables as argu…

---

## [Try Julia in the Documentation](https://discourse.julialang.org/t/try-julia-in-the-documentation/34111)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [February 3, 2020, 10:21pm UTC](https://discourse.julialang.org/t/try-julia-in-the-documentation/34111 "2020-02-03T22:21:05Z")

</div>

Recently I stumbled over the c sharp docs and I like the way that I just could try c sharp in the browser. Since Julia has a repl I thought this would be a nice feature for the Julia documentation.

---

## [How to create SharedArrays on other workers](https://discourse.julialang.org/t/how-to-create-sharedarrays-on-other-workers/33619)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 9\
**Last updated:** [February 3, 2020, 5:48pm UTC](https://discourse.julialang.org/t/how-to-create-sharedarrays-on-other-workers/33619 "2020-02-03T17:48:05Z")

</div>

I am trying to create a SharedArray on a different worker in julia 1.3.0. Consider the following code snippet: using Distributed addprocs(1) using SharedArrays f = @spawnat 2 SharedVector{Float64}(10) fetch(f) If I …

---

## [Calculating a standardization function from scratch](https://discourse.julialang.org/t/calculating-a-standardization-function-from-scratch/34117)

<div class="topic-metadata">

**Author:** [@PyDataBlog](https://discourse.julialang.org/u/PyDataBlog)\
**Replies:** 6\
**Last updated:** [February 3, 2020, 4:18pm UTC](https://discourse.julialang.org/t/calculating-a-standardization-function-from-scratch/34117 "2020-02-03T16:18:47Z")

</div>

Hi, I am trying to create a standardization function from scratch to scale features: Here’s my current implementation: # Standardize training features function scale\_features(X) μ = mean(X, dims=1) σ = std(X, d…

---

## [Functions of Functions Performance in a Loop](https://discourse.julialang.org/t/functions-of-functions-performance-in-a-loop/34116)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 2\
**Last updated:** [February 3, 2020, 3:45pm UTC](https://discourse.julialang.org/t/functions-of-functions-performance-in-a-loop/34116 "2020-02-03T15:45:42Z")

</div>

For the following two loops, in which a function of a function is called in one, and the computation is more explicit in the other, there is a significant amount of memory allocation in the former. It also takes a perf…

---

## [Operation across the matching dimension of an array with a vector](https://discourse.julialang.org/t/operation-across-the-matching-dimension-of-an-array-with-a-vector/34120)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 3\
**Last updated:** [February 3, 2020, 3:44pm UTC](https://discourse.julialang.org/t/operation-across-the-matching-dimension-of-an-array-with-a-vector/34120 "2020-02-03T15:44:15Z")

</div>

Hi there, I am trying to apply a bivariate function f across an arbitrary dimensional array A and a vector B. I want to apply this function across the dimension of A that matches length with B. For example if A is 3-dim…

---

## [Help to avoid a type-instability](https://discourse.julialang.org/t/help-to-avoid-a-type-instability/34097)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 13\
**Last updated:** [February 3, 2020, 2:01pm UTC](https://discourse.julialang.org/t/help-to-avoid-a-type-instability/34097 "2020-02-03T14:01:42Z")

</div>

Hi! I need to construct a struct that has a vector with elements of another structure as in this code: mutable struct A{T} value::T end mutable struct B v::Vector{A} end get\_data(a::A{T}) where T = a.value ge…

---

## [Calling a Method object](https://discourse.julialang.org/t/calling-a-method-object/34112)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 1\
**Last updated:** [February 3, 2020, 12:14pm UTC](https://discourse.julialang.org/t/calling-a-method-object/34112 "2020-02-03T12:14:23Z")

</div>

Is there any way to do this? julia\> m = @which sin(1) sin(x::Real) in Base.Math at special/trig.jl:53 julia\> m(20) ERROR: MethodError: objects of type Method are not callable Stacktrace: \[1\] top-level scope at REPL\[5\]…

---

## [Operator algebra design](https://discourse.julialang.org/t/operator-algebra-design/34104)

<div class="topic-metadata">

**Author:** [@Sleort](https://discourse.julialang.org/u/Sleort)\
**Replies:** 4\
**Last updated:** [February 3, 2020, 11:47am UTC](https://discourse.julialang.org/t/operator-algebra-design/34104 "2020-02-03T11:47:42Z")

</div>

Although I can easily construct an operator algebra in Julia using closures, I wonder if this is the best/most “Julian” way of doing it. As an example, take the following code import Base: +, -, \*, / abstract type Abst…

---

## [Dict can't find a key it already said is there?](https://discourse.julialang.org/t/dict-cant-find-a-key-it-already-said-is-there/34088)

<div class="topic-metadata">

**Author:** [@rmz](https://discourse.julialang.org/u/rmz)\
**Replies:** 6\
**Last updated:** [February 3, 2020, 7:33am UTC](https://discourse.julialang.org/t/dict-cant-find-a-key-it-already-said-is-there/34088 "2020-02-03T07:33:34Z")

</div>

I’m confused I have this piece of code (see below, the important part is the the push! … line), it will push a value to a set located in a dict at a key (called “coord”) that we have already verified exists in the dict …

---

## [Help to reduce very long compilation time](https://discourse.julialang.org/t/help-to-reduce-very-long-compilation-time/34052)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 10\
**Last updated:** [February 2, 2020, 10:56pm UTC](https://discourse.julialang.org/t/help-to-reduce-very-long-compilation-time/34052 "2020-02-02T22:56:11Z")

</div>

Hi! I am building a package to create text user interfaces in Julia using ncurses: TextUserInterfaces.jl Now, I am facing a very, very slow compilation time. For example, the following code just initialize NCurses, cre…

---

## [Type hierarchy graphic in docs build](https://discourse.julialang.org/t/type-hierarchy-graphic-in-docs-build/34066)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 7\
**Last updated:** [February 2, 2020, 7:42pm UTC](https://discourse.julialang.org/t/type-hierarchy-graphic-in-docs-build/34066 "2020-02-02T19:42:23Z")

</div>

Is there any pre-existing method for generating a type hierarchy as a graphic image for a Documenter build? My goal is to have the graphic generated automatically.

---

## [Rolling maxima](https://discourse.julialang.org/t/rolling-maxima/33845)

<div class="topic-metadata">

**Author:** [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)\
**Replies:** 24\
**Last updated:** [February 2, 2020, 6:08pm UTC](https://discourse.julialang.org/t/rolling-maxima/33845 "2020-02-02T18:08:18Z")

</div>

Hi all fine people here! I am just interested in knowing if anyone here sees any performance improvements in my code. Either algorithmically or Julia specific. The code in question is a function which calculates local …

---

## [Comparing Mutable Structs](https://discourse.julialang.org/t/comparing-mutable-structs/10944)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 11\
**Last updated:** [February 2, 2020, 5:59pm UTC](https://discourse.julialang.org/t/comparing-mutable-structs/10944 "2020-02-02T17:59:26Z")

</div>

dear wizards—is this intended behavior? julia\> mutable struct S; x::Int; end#struct## julia\> v= \[ S(1), S(2) \] 2-element Array{S,1}: S(1) S(2) julia\> v==deepcopy(v) ## only when v is mutable false julia\> v==copy(…

---

## [Custom stateful transducer performance](https://discourse.julialang.org/t/custom-stateful-transducer-performance/34065)

<div class="topic-metadata">

**Author:** [@Jakub\_Wronowski](https://discourse.julialang.org/u/Jakub_Wronowski)\
**Replies:** 5\
**Last updated:** [February 2, 2020, 3:21pm UTC](https://discourse.julialang.org/t/custom-stateful-transducer-performance/34065 "2020-02-02T15:21:10Z")

</div>

Hi, I am trying to implement a custom stateful transducer, but I am not happy with performance I got. using Transducers using Transducers: Transducer, R\_, next, inner, xform using Transducers: start, complete, wrap, unw…

---

## [Exporting (all) names from a module (Clang related)](https://discourse.julialang.org/t/exporting-all-names-from-a-module-clang-related/33828)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 10\
**Last updated:** [February 2, 2020, 2:08pm UTC](https://discourse.julialang.org/t/exporting-all-names-from-a-module-clang-related/33828 "2020-02-02T14:08:29Z")

</div>

I have the following: module CLib using CEnum include("common.jl") include("api.jl") end And naturally I want to automagically export everything that comes in from common and api. Currently if i do using CLib An…

---

## [Creating Artifacts.toml for existing tarball](https://discourse.julialang.org/t/creating-artifacts-toml-for-existing-tarball/33365)

<div class="topic-metadata">

**Author:** [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Replies:** 9\
**Last updated:** [February 2, 2020, 1:33pm UTC](https://discourse.julialang.org/t/creating-artifacts-toml-for-existing-tarball/33365 "2020-02-02T13:33:59Z")

</div>

I’m trying to figure out how to create an Artifacts.toml to download some data that my package depends on. I’m creating a setup\_artifacts.jl script to create it. Here’s what I have so far: using Pkg.Artifacts using Pkg…

---

## [Input parsing for macros without "parantheses"](https://discourse.julialang.org/t/input-parsing-for-macros-without-parantheses/34068)

<div class="topic-metadata">

**Author:** [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Replies:** 2\
**Last updated:** [February 1, 2020, 11:37pm UTC](https://discourse.julialang.org/t/input-parsing-for-macros-without-parantheses/34068 "2020-02-01T23:37:53Z")

</div>

Let’s consider the macro @mymacro which parses some input arguments which are separated by commas as shown below. macro mymacro(expr...) # ... does something with expr return expr end @mymacro(x' = x, x∈X, …

---

## [Broadcasting for a block diagonal matrix](https://discourse.julialang.org/t/broadcasting-for-a-block-diagonal-matrix/34024)

<div class="topic-metadata">

**Author:** [@teored90](https://discourse.julialang.org/u/teored90)\
**Replies:** 5\
**Last updated:** [February 1, 2020, 7:39pm UTC](https://discourse.julialang.org/t/broadcasting-for-a-block-diagonal-matrix/34024 "2020-02-01T19:39:55Z")

</div>

I would like to implement a more efficient broadcast for basic arithmetic operators for the BlockDiagonal type of BlockDiagonals.jl. At the moment the broadcasting causes many allocations, I suppose because it falls back…

---

## [API for specifying which version of a function to use in a package](https://discourse.julialang.org/t/api-for-specifying-which-version-of-a-function-to-use-in-a-package/34047)

<div class="topic-metadata">

**Author:** [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Replies:** 5\
**Last updated:** [February 1, 2020, 1:39pm UTC](https://discourse.julialang.org/t/api-for-specifying-which-version-of-a-function-to-use-in-a-package/34047 "2020-02-01T13:39:04Z")

</div>

In IntervalArithmetic.jl we need a way to choose between different versions of a function (e.g. the power function) that have different performance / accuracy tradeoffs. Is there a standard way to have an API for that? …

---

## [Resetting a variable to the unsigned state](https://discourse.julialang.org/t/resetting-a-variable-to-the-unsigned-state/34051)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 7\
**Last updated:** [February 1, 2020, 1:31am UTC](https://discourse.julialang.org/t/resetting-a-variable-to-the-unsigned-state/34051 "2020-02-01T01:31:58Z")

</div>

Hi, I’m trying to convert all package global variables to const global, but some of them must be reset at the end (their state is checked at some code point). As an example julia\> a = Array{GMT.GMTcpt,1}(undef,1) 1-el…

---

## [MCMC in Economics?](https://discourse.julialang.org/t/mcmc-in-economics/34050)

<div class="topic-metadata">

**Author:** [@fratrik](https://discourse.julialang.org/u/fratrik)\
**Replies:** 1\
**Last updated:** [January 31, 2020, 11:35pm UTC](https://discourse.julialang.org/t/mcmc-in-economics/34050 "2020-01-31T23:35:04Z")

</div>

Has anyone used one of the MCMC libraries for sampling in macroeconomics? I see that @Tamas\_Papp has developed a library that only depends on the likelihood. However, it looks like Mamba.jl more closely maps onto the so…

---

## [Duality problem](https://discourse.julialang.org/t/duality-problem/34045)

<div class="topic-metadata">

**Author:** [@mahsap58](https://discourse.julialang.org/u/mahsap58)\
**Replies:** 0\
**Last updated:** [January 31, 2020, 7:25pm UTC](https://discourse.julialang.org/t/duality-problem/34045 "2020-01-31T19:25:14Z")

</div>

Hi i am trying to use the ValueShapes package for getting the dual variables of my primal problem i faced this error Failed to precompile ValueShapes \[136a8f8c-c49b-4edb-8b98-f3d64d48be8f\] No deps.jl file could be foun…

---

## [Do I need ATOM and/or JUNO to use Julia if I have a PC with ONLY command line?](https://discourse.julialang.org/t/do-i-need-atom-and-or-juno-to-use-julia-if-i-have-a-pc-with-only-command-line/34043)

<div class="topic-metadata">

**Author:** [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Replies:** 3\
**Last updated:** [January 31, 2020, 6:57pm UTC](https://discourse.julialang.org/t/do-i-need-atom-and-or-juno-to-use-julia-if-i-have-a-pc-with-only-command-line/34043 "2020-01-31T18:57:53Z")

</div>

Hello I have a machine with ONLY command line. So, do I have to install Atom and/or Juno to use Julia? or IJulia? I will use Julia to do AI with tensorflow, knet, etc Thank you very much

---

## [Package LsqFit not found in current path - calling julia via PyJulia](https://discourse.julialang.org/t/package-lsqfit-not-found-in-current-path-calling-julia-via-pyjulia/34031)

<div class="topic-metadata">

**Author:** [@Kethex](https://discourse.julialang.org/u/Kethex)\
**Replies:** 0\
**Last updated:** [January 31, 2020, 3:19pm UTC](https://discourse.julialang.org/t/package-lsqfit-not-found-in-current-path-calling-julia-via-pyjulia/34031 "2020-01-31T15:19:05Z")

</div>

Hello! I’m using Julia 1.4. I’m trying to make a Python program which calls upon Julia using \[PyJulia\] (GitHub - JuliaPy/pyjulia: python interface to julia) and calls a .jl file I have stored in the same directory. This…

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

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