# General Usage

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

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

**Page:** 602

---

## [Memory allocations and performance with multithreading](https://discourse.julialang.org/t/memory-allocations-and-performance-with-multithreading/60831)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 8\
**Last updated:** [May 10, 2021, 2:30pm UTC](https://discourse.julialang.org/t/memory-allocations-and-performance-with-multithreading/60831 "2021-05-10T14:30:19Z")

</div>

I’m trying to take use of mulithreading to parallelize an internal loop, but while it works (correct answer and I can see CPU being used), there is a serious performance hit: function update(x, Δt) return x + 0.5 \* …

---

## [Allocations with closure and mul!](https://discourse.julialang.org/t/allocations-with-closure-and-mul/60744)

<div class="topic-metadata">

**Author:** [@geoffroyleconte](https://discourse.julialang.org/u/geoffroyleconte)\
**Replies:** 4\
**Last updated:** [May 10, 2021, 2:19pm UTC](https://discourse.julialang.org/t/allocations-with-closure-and-mul/60744 "2021-05-10T14:19:44Z")

</div>

Hi! I have an issue with allocations using the mul! function and a closure: using LinearAlgebra, Test struct operator{T} prod! end function operator(A :: AbstractArray{T}) where T prod! = (res, u, α, β) -\> m…

---

## [Function dispatch ignores keyword arguments](https://discourse.julialang.org/t/function-dispatch-ignores-keyword-arguments/60887)

<div class="topic-metadata">

**Author:** [@tqml](https://discourse.julialang.org/u/tqml)\
**Replies:** 3\
**Last updated:** [May 10, 2021, 12:59pm UTC](https://discourse.julialang.org/t/function-dispatch-ignores-keyword-arguments/60887 "2021-05-10T12:59:08Z")

</div>

Today I stumbled upon some weird Julia behavior. It seems that it is not possible to have multiple keyword-only functions with the same name. Is this a bug or intended behavior? f1(;a,b) = println("a,b") # defines f1 f1…

---

## [Chaining array of functions](https://discourse.julialang.org/t/chaining-array-of-functions/30958)

<div class="topic-metadata">

**Author:** [@DR59](https://discourse.julialang.org/u/DR59)\
**Replies:** 13\
**Last updated:** [May 10, 2021, 12:02pm UTC](https://discourse.julialang.org/t/chaining-array-of-functions/30958 "2021-05-10T12:02:39Z")

</div>

Suppose I have a 1d array of functions: f\_array = \[f1, f2, f3, f4\] This array can be of arbitrary length, and each function may have multiple inputs/outputs. How do I do a reduce style operation to make a new function…

---

## [Conda.jl: specify library version](https://discourse.julialang.org/t/conda-jl-specify-library-version/59915)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 1\
**Last updated:** [May 10, 2021, 10:50am UTC](https://discourse.julialang.org/t/conda-jl-specify-library-version/59915 "2021-05-10T10:50:27Z")

</div>

My package, ScikitLearn.jl, is not yet compatible with the latest scikit-learn library. Is there any way to specify that via Conda.jl? Alternatively, what’s the easiest way to Conda.add("scikit-learn", some\_version\_numbe…

---

## [How to dispatch a function aggregating columns in a grouped DataFrame?](https://discourse.julialang.org/t/how-to-dispatch-a-function-aggregating-columns-in-a-grouped-dataframe/60859)

<div class="topic-metadata">

**Author:** [@florian](https://discourse.julialang.org/u/florian)\
**Replies:** 1\
**Last updated:** [May 10, 2021, 9:14am UTC](https://discourse.julialang.org/t/how-to-dispatch-a-function-aggregating-columns-in-a-grouped-dataframe/60859 "2021-05-10T09:14:27Z")

</div>

I want to aggregate the columns of a DataFrame based on their types, i.e something like: function aggregate(v::Vector{T}) where T \<: Number sum(v) end function aggregate(v::Vector{String}) \[unique(v)\] end df =…

---

## [Prediction of time series](https://discourse.julialang.org/t/prediction-of-time-series/60858)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [May 10, 2021, 9:15am UTC](https://discourse.julialang.org/t/prediction-of-time-series/60858 "2021-05-10T09:15:26Z")

</div>

Hello everyone, I am studying the prediction problem of power system operation, which is a kind of multi-input multi-output model, can you recommend some novel Pkg or methods about time series multiple prediction? thank…

---

## [Is it possible to use a package function without loading the package?](https://discourse.julialang.org/t/is-it-possible-to-use-a-package-function-without-loading-the-package/60813)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 6\
**Last updated:** [May 10, 2021, 7:06am UTC](https://discourse.julialang.org/t/is-it-possible-to-use-a-package-function-without-loading-the-package/60813 "2021-05-10T07:06:35Z")

</div>

In R, I would do something like this: dt = data.table::fread("data.csv") My understanding is that in Julia I would need to do: using DataFrames; using CSV; df = CSV.File("data.csv") |\> DataFrame; The code in Julia i…

---

## [Possible slow fallback of adjoint matrix multiplication for different element types](https://discourse.julialang.org/t/possible-slow-fallback-of-adjoint-matrix-multiplication-for-different-element-types/60853)

<div class="topic-metadata">

**Author:** [@songxianxu](https://discourse.julialang.org/u/songxianxu)\
**Replies:** 0\
**Last updated:** [May 10, 2021, 6:16am UTC](https://discourse.julialang.org/t/possible-slow-fallback-of-adjoint-matrix-multiplication-for-different-element-types/60853 "2021-05-10T06:16:31Z")

</div>

I was running some matrix diagonalization and processing the eigenvectors. I notice that the script takes an unusually long time and I realize that it could be a problem of the adjoint matrix multiplication. Here is the…

---

## [Introductory ML model in Flux](https://discourse.julialang.org/t/introductory-ml-model-in-flux/60850)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 2\
**Last updated:** [May 10, 2021, 2:53am UTC](https://discourse.julialang.org/t/introductory-ml-model-in-flux/60850 "2021-05-10T02:53:13Z")

</div>

I am trying to trying to replicate Figure 8 (page 18) and Algorithm 6.1 (page 17) from this introductory ML paper for mathematicians. The figure for convenience is: where the ten points are classified as cateogry A (…

---

## [Array of Functions type matching](https://discourse.julialang.org/t/array-of-functions-type-matching/60843)

<div class="topic-metadata">

**Author:** [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 10:48pm UTC](https://discourse.julialang.org/t/array-of-functions-type-matching/60843 "2021-05-09T22:48:31Z")

</div>

I have an array of functions. If I try to pass that array to another function that has the parameter type of Array{Function, 1}, I get a type mismatch error. Here is a working example. function test() return functio…

---

## [Best way to store package specific user settings?](https://discourse.julialang.org/t/best-way-to-store-package-specific-user-settings/60626)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 8\
**Last updated:** [May 9, 2021, 3:17pm UTC](https://discourse.julialang.org/t/best-way-to-store-package-specific-user-settings/60626 "2021-05-09T15:17:25Z")

</div>

I want to add persistent theming back to Makie and I wanted to get a feel for what methods are out there and what the tradeoffs of different approaches are. One consideration is where to store settings files. Should we …

---

## [Clarification on accessing fields in a struct](https://discourse.julialang.org/t/clarification-on-accessing-fields-in-a-struct/60839)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 8:09pm UTC](https://discourse.julialang.org/t/clarification-on-accessing-fields-in-a-struct/60839 "2021-05-09T20:09:22Z")

</div>

I was reading this Stack Overflow question, and using this example: struct MyStruct a b end it asks how you can access a struct field using a String. Two answers we given, but I want clarification on the secon…

---

## [Rarely see usage of TimeArray](https://discourse.julialang.org/t/rarely-see-usage-of-timearray/56705)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 5:55pm UTC](https://discourse.julialang.org/t/rarely-see-usage-of-timearray/56705 "2021-05-09T17:55:29Z")

</div>

I really like the TimeArray data structure from TimeSeries.jl. It is more efficient and elegant than the ts and xts of R language. However, I rarely see people use TimeArray. I would like to know why.

---

## [Multithreading and generated code](https://discourse.julialang.org/t/multithreading-and-generated-code/60828)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 5\
**Last updated:** [May 9, 2021, 5:42pm UTC](https://discourse.julialang.org/t/multithreading-and-generated-code/60828 "2021-05-09T17:42:50Z")

</div>

A while back, I solved this problem, Performance and Allocation with Arrays of Functions. More recently, I wanted a multithreaded loop inside of this, so that the code now reads: function update(x, Δt) return x + 0…

---

## [Named Pipes between Julia and CSharp](https://discourse.julialang.org/t/named-pipes-between-julia-and-csharp/45845)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 5\
**Last updated:** [May 9, 2021, 2:51pm UTC](https://discourse.julialang.org/t/named-pipes-between-julia-and-csharp/45845 "2021-05-09T14:51:59Z")

</div>

Hi dear community :slight\_smile: I’m trying to communicate between Julia and CSharp with named pipes on Windows. I’m using following code in Csharp server: using (var pipe = new NamedPipeServerStream("cs", PipeDirecti…

---

## [Weighted linear regression with confidence interval fitted to error bars](https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval-fitted-to-error-bars/60743)

<div class="topic-metadata">

**Author:** [@Okarin99](https://discourse.julialang.org/u/Okarin99)\
**Replies:** 6\
**Last updated:** [May 9, 2021, 11:01am UTC](https://discourse.julialang.org/t/weighted-linear-regression-with-confidence-interval-fitted-to-error-bars/60743 "2021-05-09T11:01:23Z")

</div>

Hi, I’m pretty new to Data Science. I have some Data with measurement errors and I want to fit a linear model. using DataFrames using GLM using StatsPlots df = DataFrame(x = \[0.0, 0.0669873, 0.25, 0.5, 0.75, 0.933013…

---

## [How do I make a dispatch table using multiple dispatch instead of Dict?](https://discourse.julialang.org/t/how-do-i-make-a-dispatch-table-using-multiple-dispatch-instead-of-dict/60784)

<div class="topic-metadata">

**Author:** [@rpmuller](https://discourse.julialang.org/u/rpmuller)\
**Replies:** 20\
**Last updated:** [May 9, 2021, 8:03am UTC](https://discourse.julialang.org/t/how-do-i-make-a-dispatch-table-using-multiple-dispatch-instead-of-dict/60784 "2021-05-09T08:03:37Z")

</div>

In python, I often used a dictionary-based multiple dispatch table to send arguments to functions: dispatch = {(0,0):vrr\_ss,(0,1):vrr\_sp,(1,0):vrr\_ps} if a,b in dispatch: dispatch\[a,b\](args) The Julia version of this i…

---

## [Function with parameter: \`f(x,p)\` or \`f(x;p)\`](https://discourse.julialang.org/t/function-with-parameter-f-x-p-or-f-x-p/60745)

<div class="topic-metadata">

**Author:** [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Replies:** 9\
**Last updated:** [May 9, 2021, 7:43am UTC](https://discourse.julialang.org/t/function-with-parameter-f-x-p-or-f-x-p/60745 "2021-05-09T07:43:39Z")

</div>

I have been using the call with the key argument to provide parameters f(x;p=(a=1.1,b=2.2)) taking advantage of broadcasting without Ref. However, noticed f(x,p) is a common format as well. Any thoughts on which way is …

---

## [Issues running two TCP servers](https://discourse.julialang.org/t/issues-running-two-tcp-servers/60807)

<div class="topic-metadata">

**Author:** [@ligert123](https://discourse.julialang.org/u/ligert123)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 7:28am UTC](https://discourse.julialang.org/t/issues-running-two-tcp-servers/60807 "2021-05-09T07:28:14Z")

</div>

Hello, i am currently trying to run 2 TCP servers, one that will encrypt itself using MbedTLS and the other that will not. An issue i am having is that when a socket is opened on one of the servers and it is waiting to …

---

## [Is DistributedArrays still maintained?](https://discourse.julialang.org/t/is-distributedarrays-still-maintained/60808)

<div class="topic-metadata">

**Author:** [@vavrines](https://discourse.julialang.org/u/vavrines)\
**Replies:** 0\
**Last updated:** [May 9, 2021, 7:01am UTC](https://discourse.julialang.org/t/is-distributedarrays-still-maintained/60808 "2021-05-09T07:01:24Z")

</div>

Kind of wanna know the status of distributed computing. It looks like the DistributedArrays-related stuff hasn’t been developed for a long time. Is it recommendded to use MPI.jl uniformly?

---

## [Translating &variable to modern Julia](https://discourse.julialang.org/t/translating-variable-to-modern-julia/60797)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [May 8, 2021, 9:25pm UTC](https://discourse.julialang.org/t/translating-variable-to-modern-julia/60797 "2021-05-08T21:25:18Z")

</div>

https://github.com/acroy/Lasem.jl/blob/master/src/Lasem.jl#L45 is ccall((:lsm\_dom\_view\_set\_viewport\_pixels, liblasem), Void, (Ptr{Void}, Ptr{LsmBox} ), view, &viewport) which contains &viewport, currently invalid synt…

---

## [PackageCompiler error. @ccallable was already defined](https://discourse.julialang.org/t/packagecompiler-error-ccallable-was-already-defined/60697)

<div class="topic-metadata">

**Author:** [@jibaneza](https://discourse.julialang.org/u/jibaneza)\
**Replies:** 6\
**Last updated:** [May 8, 2021, 5:24pm UTC](https://discourse.julialang.org/t/packagecompiler-error-ccallable-was-already-defined/60697 "2021-05-08T17:24:23Z")

</div>

I get this error when trying to compile a fairly long code. I succeeded previously with Julia 1.5, having to manually edit out of some deps.jl file some hardcoded library paths. It wasn’t easy but it worked. Now, with mo…

---

## [Code specialization on literals for addition and multiplication operators](https://discourse.julialang.org/t/code-specialization-on-literals-for-addition-and-multiplication-operators/60775)

<div class="topic-metadata">

**Author:** [@Lecrapouille](https://discourse.julialang.org/u/Lecrapouille)\
**Replies:** 2\
**Last updated:** [May 8, 2021, 12:36pm UTC](https://discourse.julialang.org/t/code-specialization-on-literals-for-addition-and-multiplication-operators/60775 "2021-05-08T12:36:18Z")

</div>

Hi ! This code is working: struct MP v::Float64 end Base.:(\*)(x::MP, y::MP) = MP(x.v + y.v) Base.:(\*)(x::MP, y::Real) = MP(x.v + y) Base.:(\*)(x::Real, y::MP) = MP(x + y.v) But on a corner case, this is giving me corre…

---

## [Broadcasting setindex!](https://discourse.julialang.org/t/broadcasting-setindex/60168)

<div class="topic-metadata">

**Author:** [@skleinbo](https://discourse.julialang.org/u/skleinbo)\
**Replies:** 5\
**Last updated:** [May 8, 2021, 8:28am UTC](https://discourse.julialang.org/t/broadcasting-setindex/60168 "2021-05-08T08:28:08Z")

</div>

Let’s define the following composite type of an array and a counter. The counter is supposed to keep track of the number of changes made to the array. import Base: getindex, setindex!, size, length struct ArrayWithCoun…

---

## [@code\_warntype shows lots of Union{Nothing, Tuple{Int64, Int64}}](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748)

<div class="topic-metadata">

**Author:** [@rpmuller](https://discourse.julialang.org/u/rpmuller)\
**Replies:** 7\
**Last updated:** [May 8, 2021, 12:41am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748 "2021-05-08T00:41:35Z")

</div>

I’m working through @ChrisRackauckas excellent article 7 Julia Gotchas and How to Handle Them - Stochastic Lifestyle. One of his big recommendations is to use @code\_warntype. I already found an untyped container that ma…

---

## [Vcat and plot behavior inside Julia script](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720)

<div class="topic-metadata">

**Author:** [@scotttbecker](https://discourse.julialang.org/u/scotttbecker)\
**Replies:** 5\
**Last updated:** [May 8, 2021, 12:37am UTC](https://discourse.julialang.org/t/vcat-and-plot-behavior-inside-julia-script/60720 "2021-05-08T00:37:00Z")

</div>

Hi all, I must be doing something wrong. I can’t get vcat and plot to work inside a script. When I use them in the terminal the commands work fine but inside a script vcat returns no error and an empty dataframe. Plot h…

---

## [Manual reduction much faster than atomic\_add with @threads](https://discourse.julialang.org/t/manual-reduction-much-faster-than-atomic-add-with-threads/60721)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 7\
**Last updated:** [May 7, 2021, 11:30pm UTC](https://discourse.julialang.org/t/manual-reduction-much-faster-than-atomic-add-with-threads/60721 "2021-05-07T23:30:20Z")

</div>

In these examples, manually splitting and reducing the sum provides a good scaling, while using the Atomic operations is prohibitive: using Base.Threads, BenchmarkTools, Test function f\_manual() total\_Sum = zeros(n…

---

## [Arrows on trajectory as it evolves](https://discourse.julialang.org/t/arrows-on-trajectory-as-it-evolves/60733)

<div class="topic-metadata">

**Author:** [@Sahil\_Goyal](https://discourse.julialang.org/u/Sahil_Goyal)\
**Replies:** 6\
**Last updated:** [May 7, 2021, 8:35pm UTC](https://discourse.julialang.org/t/arrows-on-trajectory-as-it-evolves/60733 "2021-05-07T20:35:01Z")

</div>

I have a curve as it evolves with time, I need to have arrow on the curve something like shown in the figure. It was plotted using Mathematica. Plot not necessarily need not be against time it can be plot of x vs y.

---

## [Specifying which lines I want to be fast](https://discourse.julialang.org/t/specifying-which-lines-i-want-to-be-fast/60699)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 4\
**Last updated:** [May 7, 2021, 6:55pm UTC](https://discourse.julialang.org/t/specifying-which-lines-i-want-to-be-fast/60699 "2021-05-07T18:55:26Z")

</div>

I want most of my code to be interpreter-slow in order to avoid compiler latency, but one or two lines need to be compiled-fast. Is it possible to get both of those in the same session?

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

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