# General Usage

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

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

**Page:** 735

---

## [How to import a local module into another in different separate files](https://discourse.julialang.org/t/how-to-import-a-local-module-into-another-in-different-separate-files/42058)

<div class="topic-metadata">

**Author:** [@abannsunny](https://discourse.julialang.org/u/abannsunny)\
**Replies:** 11\
**Last updated:** [June 26, 2020, 1:00pm UTC](https://discourse.julialang.org/t/how-to-import-a-local-module-into-another-in-different-separate-files/42058 "2020-06-26T13:00:40Z")

</div>

I wanted to know how to import a local module in a file into another in a different file. so for instance, I have a situation like this: #inside main.jl include("M2.jl") include("M1.jl") function DoSomething(inputStr…

---

## [Poor performance of \`lock(l) do\` closures, caused by poor performance of capturing closures](https://discourse.julialang.org/t/poor-performance-of-lock-l-do-closures-caused-by-poor-performance-of-capturing-closures/42067)

<div class="topic-metadata">

**Author:** [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Replies:** 11\
**Last updated:** [June 26, 2020, 2:45am UTC](https://discourse.julialang.org/t/poor-performance-of-lock-l-do-closures-caused-by-poor-performance-of-capturing-closures/42067 "2020-06-26T02:45:38Z")

</div>

Multithreading is hard. Correctly and safely locking and unlocking can be hard. For these reasons, we prefer abstractions that help us do things safely and correctly. One such abstraction is the lock() method that take…

---

## [Function with multiple arguments with all subsets of variables](https://discourse.julialang.org/t/function-with-multiple-arguments-with-all-subsets-of-variables/42022)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 7\
**Last updated:** [June 26, 2020, 2:08am UTC](https://discourse.julialang.org/t/function-with-multiple-arguments-with-all-subsets-of-variables/42022 "2020-06-26T02:08:31Z")

</div>

I have to construct a set of functions that I want to optimize. The set consists of functions with all subsets I can build with p variables. If p is small, that’s easy. For example, with p=2, I can build 2^2-1=3 function…

---

## [C types interchangeability with Julia types](https://discourse.julialang.org/t/c-types-interchangeability-with-julia-types/42083)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 0\
**Last updated:** [June 26, 2020, 12:26am UTC](https://discourse.julialang.org/t/c-types-interchangeability-with-julia-types/42083 "2020-06-26T00:26:02Z")

</div>

I wrote a wrapper of C library. Here is one of C functions: extern "C" bool start(char\* nodeName) and Julia equivalent: export start function start(nodeName::String) ccall((:start, "libsimc.so"), Bool, (Cstring,), …

---

## [Worker on cluster : Package not found in current path](https://discourse.julialang.org/t/worker-on-cluster-package-not-found-in-current-path/40887)

<div class="topic-metadata">

**Author:** [@amitjamadagni](https://discourse.julialang.org/u/amitjamadagni)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 11:16pm UTC](https://discourse.julialang.org/t/worker-on-cluster-package-not-found-in-current-path/40887 "2020-06-25T23:16:15Z")

</div>

Hello, I have been trying to get some packages to run on a cluster. I have set the variable JULIA\_DEPOT\_PATH to a custom folder where I have installed the required packages and my job script looks as follows: #========…

---

## [Images - Kernel sizes and ImageAxes](https://discourse.julialang.org/t/images-kernel-sizes-and-imageaxes/41858)

<div class="topic-metadata">

**Author:** [@mirestrepo](https://discourse.julialang.org/u/mirestrepo)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 9:53pm UTC](https://discourse.julialang.org/t/images-kernel-sizes-and-imageaxes/41858 "2020-06-25T21:53:46Z")

</div>

Hi All, This is probably a naive question. Given an image stack with z-spacing that is not the same as x and y, what is the correct way to handle the size for example of the σshape for the laplacian of gaussian? I hav…

---

## [What is the fastest way to update a particular row of a matrix using dot syntax?](https://discourse.julialang.org/t/what-is-the-fastest-way-to-update-a-particular-row-of-a-matrix-using-dot-syntax/36160)

<div class="topic-metadata">

**Author:** [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)\
**Replies:** 21\
**Last updated:** [June 25, 2020, 7:58pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-way-to-update-a-particular-row-of-a-matrix-using-dot-syntax/36160 "2020-06-25T19:58:17Z")

</div>

Hi, I have a square matrix M, and I would like to update it in-place such that the kth column is multiplied by some scalar s. I’ve tried implementing it with dot syntax and simple rolling out of the for loop. function …

---

## [Request: I can't understand why a result of matrix multiplication in Julia like this](https://discourse.julialang.org/t/request-i-cant-understand-why-a-result-of-matrix-multiplication-in-julia-like-this/42050)

<div class="topic-metadata">

**Author:** [@Hyeonji-Ryu](https://discourse.julialang.org/u/Hyeonji-Ryu)\
**Replies:** 2\
**Last updated:** [June 25, 2020, 4:39pm UTC](https://discourse.julialang.org/t/request-i-cant-understand-why-a-result-of-matrix-multiplication-in-julia-like-this/42050 "2020-06-25T16:39:23Z")

</div>

Hello, I’m a student using Julia in my project making deep learning model. I usually use ‘matrix multiplication’ a lot in my code. then, I found some result is weird. I think it’s better to show some examples than to …

---

## [Parallel computing using Optim](https://discourse.julialang.org/t/parallel-computing-using-optim/41948)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 5\
**Last updated:** [June 25, 2020, 3:55pm UTC](https://discourse.julialang.org/t/parallel-computing-using-optim/41948 "2020-06-25T15:55:49Z")

</div>

Hello, I’m running the program below on a 32 cpu/64 thread system without much of anything else running on it. If I use anything beyond 16 cores then the execution time in the second run is effectively flat. This is t…

---

## [Mathematical symbols in Julia](https://discourse.julialang.org/t/mathematical-symbols-in-julia/41960)

<div class="topic-metadata">

**Author:** [@Chris\_Anderson](https://discourse.julialang.org/u/Chris_Anderson)\
**Replies:** 12\
**Last updated:** [June 25, 2020, 5:06am UTC](https://discourse.julialang.org/t/mathematical-symbols-in-julia/41960 "2020-06-25T05:06:28Z")

</div>

I’m not sure if this is the right place for this, so I apologize if it’s misplaced. I was wondering if there was something in Julia equivalent to LaTeX. I study mathematics and so could use something like LaTeX, but if…

---

## [\`rand() + I\` vs \`rand() .+ I\`](https://discourse.julialang.org/t/rand-i-vs-rand-i/41985)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 7\
**Last updated:** [June 25, 2020, 3:15pm UTC](https://discourse.julialang.org/t/rand-i-vs-rand-i/41985 "2020-06-25T15:15:02Z")

</div>

What is the difference between rand() + I and rand() .+ I? (I is from using LinearAlgebra). The first one works, but second on throws error. julia\> rand() + I 1.04893935660533 julia\> rand() .+ I ERROR: MethodError: no…

---

## [Plotting the evolution of the optimization using Optim.jl](https://discourse.julialang.org/t/plotting-the-evolution-of-the-optimization-using-optim-jl/41978)

<div class="topic-metadata">

**Author:** [@cmey](https://discourse.julialang.org/u/cmey)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 1:52pm UTC](https://discourse.julialang.org/t/plotting-the-evolution-of-the-optimization-using-optim-jl/41978 "2020-06-25T13:52:19Z")

</div>

Hi! What’s a good strategy to plot the evolution of the solution x during the optimization using Optim.jl? Note: I’m looking for the value of the solution, not the value of the objective function nor the value of the gr…

---

## [Help eliminating allocations](https://discourse.julialang.org/t/help-eliminating-allocations/42019)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 6\
**Last updated:** [June 25, 2020, 1:51pm UTC](https://discourse.julialang.org/t/help-eliminating-allocations/42019 "2020-06-25T13:51:22Z")

</div>

Hi! I need to reproduce a code in a Kernel include file. In a part, it computes the size of an array of chars. Initially, I was doing something like this, which perfectly mimics the behavior in the .h: function test(a:…

---

## [\[ANN\] BaremetalPi.jl 0.1.1](https://discourse.julialang.org/t/ann-baremetalpi-jl-0-1-1/42007)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 2\
**Last updated:** [June 25, 2020, 1:32pm UTC](https://discourse.julialang.org/t/ann-baremetalpi-jl-0-1-1/42007 "2020-06-25T13:32:15Z")

</div>

Hi! Just a small announcement. I just release the version 0.1.1 of BaremetalPi.jl. It should be available in the next few hours. The greatest change is that I manage to provide functions to transfer information using S…

---

## [Parrallel programming2](https://discourse.julialang.org/t/parrallel-programming2/42027)

<div class="topic-metadata">

**Author:** [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 10:46am UTC](https://discourse.julialang.org/t/parrallel-programming2/42027 "2020-06-25T10:46:40Z")

</div>

Hello im trying to run this for loop parallel on evwery Process but still getting Error ,I Triyed it in 2 ways, can someone Help please?thanks using Distributed addprocs(2) @everywhere using DistributedArrays @every…

---

## [Any way to speed up sorting a dataframe? A more efficient sortperm would be great](https://discourse.julialang.org/t/any-way-to-speed-up-sorting-a-dataframe-a-more-efficient-sortperm-would-be-great/41995)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 2\
**Last updated:** [June 25, 2020, 9:55am UTC](https://discourse.julialang.org/t/any-way-to-speed-up-sorting-a-dataframe-a-more-efficient-sortperm-would-be-great/41995 "2020-06-25T09:55:46Z")

</div>

Consideirng a DataFrame using DataFrames using Random: randstring M = 100\_000\_000 str\_base = \[randstring(8) for i in 1:1\_000\_000\] df = DataFrame(int = rand(Int32, M), float=rand(M), str = rand(str\_base, M)) @time sort!…

---

## [Constructors for \`UnionAll\` types](https://discourse.julialang.org/t/constructors-for-unionall-types/41999)

<div class="topic-metadata">

**Author:** [@mhauru](https://discourse.julialang.org/u/mhauru)\
**Replies:** 2\
**Last updated:** [June 25, 2020, 9:44am UTC](https://discourse.julialang.org/t/constructors-for-unionall-types/41999 "2020-06-25T09:44:14Z")

</div>

I have a simple type with two parameters, something like julia\> struct Thingy{N, T} a::NTuple{N, T} end and I try to define the following constructors for it, where the second parameter is fixed: jul…

---

## [What are some good ways to compute terms in recurrence relations?](https://discourse.julialang.org/t/what-are-some-good-ways-to-compute-terms-in-recurrence-relations/42016)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 9\
**Last updated:** [June 25, 2020, 8:57am UTC](https://discourse.julialang.org/t/what-are-some-good-ways-to-compute-terms-in-recurrence-relations/42016 "2020-06-25T08:57:04Z")

</div>

Doing a google search on “recurrence relations Julia” shows up MathToolkit.jl which has not been updated for a while and it’s got a neat function for detecting recurrence relations but not for solving them given the coef…

---

## [Speeding up repeated optimizations within a large loop](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901)

<div class="topic-metadata">

**Author:** [@asyadav](https://discourse.julialang.org/u/asyadav)\
**Replies:** 7\
**Last updated:** [June 25, 2020, 7:22am UTC](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901 "2020-06-25T07:22:59Z")

</div>

Hi there! I’m trying to solve an economic model with many discrete and continuous choices and a fairly large state space. My approach essentially boils down to solving several constrained optimization problems, using Opt…

---

## [ERROR: MethodError: no method matching -(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Float64)](https://discourse.julialang.org/t/error-methoderror-no-method-matching-steprangelen-float64-base-twiceprecision-float64-base-twiceprecision-float64-float64/41993)

<div class="topic-metadata">

**Author:** [@hafez\_ahmad](https://discourse.julialang.org/u/hafez_ahmad)\
**Replies:** 6\
**Last updated:** [June 25, 2020, 2:35am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-steprangelen-float64-base-twiceprecision-float64-base-twiceprecision-float64-float64/41993 "2020-06-25T02:35:45Z")

</div>

why I am getting error? any help appreciated T=0.5; Parameters of ODE system a=\[N, x0 ,xN ,c\]; x=range(x0,step=xN,stop=N); Exact solution uexc=exp.(-(x-T-2).\*(x-T-2)); ERROR: MethodError: no method matching -(::Step…

---

## [Adding parameters to custom layers in Flux](https://discourse.julialang.org/t/adding-parameters-to-custom-layers-in-flux/42018)

<div class="topic-metadata">

**Author:** [@jmurray](https://discourse.julialang.org/u/jmurray)\
**Replies:** 0\
**Last updated:** [June 25, 2020, 1:01am UTC](https://discourse.julialang.org/t/adding-parameters-to-custom-layers-in-flux/42018 "2020-06-25T01:01:17Z")

</div>

At the output of my Flux model, I need to un-normalize one of the outputs. I only need to store a single variable value somewhere (I think the best place is in a custom layer), but I don’t know how to store an ancillary …

---

## [Package publishing documentation](https://discourse.julialang.org/t/package-publishing-documentation/17926)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 5\
**Last updated:** [June 24, 2020, 10:19pm UTC](https://discourse.julialang.org/t/package-publishing-documentation/17926 "2020-06-24T22:19:55Z")

</div>

Is there any documentation for the publishing of new Julia packages? I couldn’t find anything. Thanks!

---

## [Struct with abstract-type field](https://discourse.julialang.org/t/struct-with-abstract-type-field/8743)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 22\
**Last updated:** [June 24, 2020, 7:49pm UTC](https://discourse.julialang.org/t/struct-with-abstract-type-field/8743 "2020-06-24T19:49:08Z")

</div>

If I define a field inside a struct with an abstract type (for instance AbstractArray), am I making it unnecessarily hard for inference to guess the type?

---

## [Correct way to transparently use SQLite.jl responses or (legacy) text files as a data source](https://discourse.julialang.org/t/correct-way-to-transparently-use-sqlite-jl-responses-or-legacy-text-files-as-a-data-source/41825)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 3\
**Last updated:** [June 24, 2020, 5:51pm UTC](https://discourse.julialang.org/t/correct-way-to-transparently-use-sqlite-jl-responses-or-legacy-text-files-as-a-data-source/41825 "2020-06-24T17:51:02Z")

</div>

I’ve really been enjoying SQLight.jl as a back end that just works. Is there any high level documentation on the relationship between SQLight.jl, Tables.jl, and DataFrames.jl? Background: Unfortunately, the package I’m…

---

## [Deparametrising types](https://discourse.julialang.org/t/deparametrising-types/41939)

<div class="topic-metadata">

**Author:** [@mhauru](https://discourse.julialang.org/u/mhauru)\
**Replies:** 4\
**Last updated:** [June 24, 2020, 5:15pm UTC](https://discourse.julialang.org/t/deparametrising-types/41939 "2020-06-24T17:15:57Z")

</div>

I’m running into trouble having parametric types that I would sometimes like to refer to by their deparametrised UnionAll versions, while only having instances of the types available. Here’s a heavily simplified mock-up…

---

## [Processing audio streams in Julia](https://discourse.julialang.org/t/processing-audio-streams-in-julia/41957)

<div class="topic-metadata">

**Author:** [@Phil\_Tomson](https://discourse.julialang.org/u/Phil_Tomson)\
**Replies:** 1\
**Last updated:** [June 24, 2020, 4:42pm UTC](https://discourse.julialang.org/t/processing-audio-streams-in-julia/41957 "2020-06-24T16:42:17Z")

</div>

I’m looking for a way to process audio streams in Julia. Specifically I’d like to be able to open up a stream from web radio stations and do some machine learning on the data stream. It looks like AudioIO.jl used to be …

---

## [Declare vector type or not / views / subarrays](https://discourse.julialang.org/t/declare-vector-type-or-not-views-subarrays/41975)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 5\
**Last updated:** [June 24, 2020, 2:44pm UTC](https://discourse.julialang.org/t/declare-vector-type-or-not-views-subarrays/41975 "2020-06-24T14:44:01Z")

</div>

Consider the example, in which I want to perform some calculations on a part of vector: julia\> f( x :: Vector{Float64} ) = (x\[1\]^2 + x\[2\]^2 + x\[3\]^2) f (generic function with 1 method) julia\> g( x :: AbstractArray ) = …

---

## [How to determine if an object is callable?](https://discourse.julialang.org/t/how-to-determine-if-an-object-is-callable/2897)

<div class="topic-metadata">

**Author:** [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)\
**Replies:** 21\
**Last updated:** [June 24, 2020, 6:54am UTC](https://discourse.julialang.org/t/how-to-determine-if-an-object-is-callable/2897 "2020-06-24T06:54:22Z")

</div>

How do I determine if an object is callable?

---

## [Segmentation fault: 11 caused by Pkg.update()](https://discourse.julialang.org/t/segmentation-fault-11-caused-by-pkg-update/41926)

<div class="topic-metadata">

**Author:** [@nmatzke](https://discourse.julialang.org/u/nmatzke)\
**Replies:** 1\
**Last updated:** [June 24, 2020, 6:43am UTC](https://discourse.julialang.org/t/segmentation-fault-11-caused-by-pkg-update/41926 "2020-06-24T06:43:25Z")

</div>

Hi folks! I just installed Julia 1.4 on my Mac OSX 10.13. It seems to work fine, but then when I type Pkg.update() I get: \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | …

---

## [A bug with diff() for a UnitRange input?](https://discourse.julialang.org/t/a-bug-with-diff-for-a-unitrange-input/41963)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 2\
**Last updated:** [June 24, 2020, 4:12am UTC](https://discourse.julialang.org/t/a-bug-with-diff-for-a-unitrange-input/41963 "2020-06-24T04:12:39Z")

</div>

I ran across the following bug in Julia 1.5.0-beta1.0 in diff() when the input is of type UnitRange. The output is also very weird for StepRangeLen inputs. My understanding is that UnitRange is an AbstractArray type. I t…

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

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