# General Usage

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

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

**Page:** 400

---

## [Functions in function](https://discourse.julialang.org/t/functions-in-function/86958)

<div class="topic-metadata">

**Author:** [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Replies:** 13\
**Last updated:** [September 9, 2022, 8:54am UTC](https://discourse.julialang.org/t/functions-in-function/86958 "2022-09-09T08:54:00Z")

</div>

I have 2 functions: f1(a1; a2=1, a3="a") # a4, a5, ... f2(b1; b2='k', b3=2.0) # b4, b5, ... I want to write a function which includes both functions and accepts all parameters of functions. What is the best way to do t…

---

## [Large Tikhonov inverse of Matrix -\> CUDA?](https://discourse.julialang.org/t/large-tikhonov-inverse-of-matrix-cuda/86971)

<div class="topic-metadata">

**Author:** [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Replies:** 0\
**Last updated:** [September 9, 2022, 7:45am UTC](https://discourse.julialang.org/t/large-tikhonov-inverse-of-matrix-cuda/86971 "2022-09-09T07:45:39Z")

</div>

Hi, I want to explicitly obtain a Tikhonov inverse of an ill-conditioned matrix, for example: julia\> using LinearAlgebra julia\> BLAS.set\_num\_threads(12) julia\> function Tikhonov(M, λ=1e-15) Tm = inv(M'…

---

## [How to make code that reads and writes to a variable thread safe?](https://discourse.julialang.org/t/how-to-make-code-that-reads-and-writes-to-a-variable-thread-safe/86961)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 1\
**Last updated:** [September 9, 2022, 7:23am UTC](https://discourse.julialang.org/t/how-to-make-code-that-reads-and-writes-to-a-variable-thread-safe/86961 "2022-09-09T07:23:05Z")

</div>

The following (pseudo)code is not thread-safe: mutable struct MutableState x::Int end function f(state) y = state.x z = y^2 state.x = z end state = MutableState(3) # now run f(state) in parallel f…

---

## [Named args of a function](https://discourse.julialang.org/t/named-args-of-a-function/86965)

<div class="topic-metadata">

**Author:** [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Replies:** 1\
**Last updated:** [September 8, 2022, 10:02pm UTC](https://discourse.julialang.org/t/named-args-of-a-function/86965 "2022-09-08T22:02:02Z")

</div>

I have a function with named args: f1(a1; a2=1, a3="a") I have the Symbols :a2 and :a3 but this does not work: f1(a1; :a2=1, :a3="a") Given the symbols how do I assign a value to the named arguments of f1 in the func…

---

## [Question about global variable behavior](https://discourse.julialang.org/t/question-about-global-variable-behavior/86956)

<div class="topic-metadata">

**Author:** [@Brian\_Becsi](https://discourse.julialang.org/u/Brian_Becsi)\
**Replies:** 4\
**Last updated:** [September 8, 2022, 7:27pm UTC](https://discourse.julialang.org/t/question-about-global-variable-behavior/86956 "2022-09-08T19:27:48Z")

</div>

Hello! I am trying to code Cramer’s rule from linear algebra in Julia. I am running into some variable behavior I don’t quite understand. Here’s the code (forgive the lack of “verbatim” I’m not sure how to format in dis…

---

## [Utilizing @turbo / @tturbo in Performance Critical Code](https://discourse.julialang.org/t/utilizing-turbo-tturbo-in-performance-critical-code/86940)

<div class="topic-metadata">

**Author:** [@nosewitz](https://discourse.julialang.org/u/nosewitz)\
**Replies:** 4\
**Last updated:** [September 8, 2022, 7:22pm UTC](https://discourse.julialang.org/t/utilizing-turbo-tturbo-in-performance-critical-code/86940 "2022-09-08T19:22:36Z")

</div>

I am writing a KNN prediction algorithm from scratch and I wanted to see if I can squeeze even more performance out of with LoopVectorization’s @turbo macros. However when trying to compile the method, it seems that init…

---

## [LoopVectorization Pre-compilation error](https://discourse.julialang.org/t/loopvectorization-pre-compilation-error/86886)

<div class="topic-metadata">

**Author:** [@MHaensel](https://discourse.julialang.org/u/MHaensel)\
**Replies:** 4\
**Last updated:** [September 8, 2022, 6:17pm UTC](https://discourse.julialang.org/t/loopvectorization-pre-compilation-error/86886 "2022-09-08T18:17:04Z")

</div>

Hi. First of all, this is my first post here and I apologize in advance should I have violated any of the usual “style rules” for this kind of question and also for it potentially being a bit naive. The issue I am facin…

---

## [Optional submodule that does type piracy](https://discourse.julialang.org/t/optional-submodule-that-does-type-piracy/86950)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 1\
**Last updated:** [September 8, 2022, 5:46pm UTC](https://discourse.julialang.org/t/optional-submodule-that-does-type-piracy/86950 "2022-09-08T17:46:34Z")

</div>

I am making a package where a small subset of the functionality currently requires type piracy. I’d like to make users have to explicitly import this package separately from the main package in order to access this funct…

---

## [How to connect two dictionary together?](https://discourse.julialang.org/t/how-to-connect-two-dictionary-together/86938)

<div class="topic-metadata">

**Author:** [@frank20000](https://discourse.julialang.org/u/frank20000)\
**Replies:** 2\
**Last updated:** [September 8, 2022, 1:29pm UTC](https://discourse.julialang.org/t/how-to-connect-two-dictionary-together/86938 "2022-09-08T13:29:30Z")

</div>

Hi there, Do you know of any easy way of connecting two or more tuples together? A simple example that explains one of the thing I need is this situation: I have a dictionary that maps a set of pairs to a value (1,2) …

---

## [Pluto noobie questions](https://discourse.julialang.org/t/pluto-noobie-questions/86887)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 9\
**Last updated:** [September 8, 2022, 1:21pm UTC](https://discourse.julialang.org/t/pluto-noobie-questions/86887 "2022-09-08T13:21:14Z")

</div>

How does one hide cell output of the cell in Pluto? Putting ; at the end of the line does not seem to work. Also, when I have created a notebook for the first time and a ran a cell with using, Pluto initiated system-wid…

---

## [How to measure a length of an edge?](https://discourse.julialang.org/t/how-to-measure-a-length-of-an-edge/86833)

<div class="topic-metadata">

**Author:** [@Optimization](https://discourse.julialang.org/u/Optimization)\
**Replies:** 3\
**Last updated:** [September 7, 2022, 6:16am UTC](https://discourse.julialang.org/t/how-to-measure-a-length-of-an-edge/86833 "2022-09-07T06:16:43Z")

</div>

When calling edges(g) in Graph.jl , it gives a list. Is there any function that returns the length of and edge in a weighted graph? I know it might seems strange to ask this as we already know the weight (length) of eac…

---

## [Finalize for modules?](https://discourse.julialang.org/t/finalize-for-modules/86934)

<div class="topic-metadata">

**Author:** [@sfuerst](https://discourse.julialang.org/u/sfuerst)\
**Replies:** 1\
**Last updated:** [September 8, 2022, 11:33am UTC](https://discourse.julialang.org/t/finalize-for-modules/86934 "2022-09-08T11:33:22Z")

</div>

I’m working on a package that is using MPI in the background, and are calling MPI.Init() in the modules init function. But I have no idea how I can detect that the module is unloaded (or the Julia session is finished) to…

---

## [Getting first element of a possibly empty Eduction (Transducers.jl)](https://discourse.julialang.org/t/getting-first-element-of-a-possibly-empty-eduction-transducers-jl/86932)

<div class="topic-metadata">

**Author:** [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Replies:** 0\
**Last updated:** [September 8, 2022, 9:54am UTC](https://discourse.julialang.org/t/getting-first-element-of-a-possibly-empty-eduction-transducers-jl/86932 "2022-09-08T09:54:17Z")

</div>

Consider the following eduction julia\> using Transducers julia\> ed = (rand() for i in 1:10) |\> Filter(\<(0.1)) Base.Generator{UnitRange{Int64}, var"#1#2"} |\> Filter(Fix2) Getting the first element is tricky becau…

---

## [Namedtuple destructuring in macro fails roughly due to macro hygiene (since gensym goes eagerly)](https://discourse.julialang.org/t/namedtuple-destructuring-in-macro-fails-roughly-due-to-macro-hygiene-since-gensym-goes-eagerly/86172)

<div class="topic-metadata">

**Author:** [@o314](https://discourse.julialang.org/u/o314)\
**Replies:** 2\
**Last updated:** [September 8, 2022, 9:14am UTC](https://discourse.julialang.org/t/namedtuple-destructuring-in-macro-fails-roughly-due-to-macro-hygiene-since-gensym-goes-eagerly/86172 "2022-09-08T09:14:35Z")

</div>

Here is the situation f(x) = (; a=2x, b=x\*x) macro ma(x) quote f($x) end end macro mb(x) quote nt = f($x) (; nt.a, nt.b) end end macro mc(x) quote (; a,b) = f($x) …

---

## [Nonlinear fiting with posibility to fix some of the parameters](https://discourse.julialang.org/t/nonlinear-fiting-with-posibility-to-fix-some-of-the-parameters/86874)

<div class="topic-metadata">

**Author:** [@Oto\_Brzobohaty](https://discourse.julialang.org/u/Oto_Brzobohaty)\
**Replies:** 4\
**Last updated:** [September 8, 2022, 8:22am UTC](https://discourse.julialang.org/t/nonlinear-fiting-with-posibility-to-fix-some-of-the-parameters/86874 "2022-09-08T08:22:19Z")

</div>

Dear all, I am trying to figure out how to fit nonlinear function to my data using Optim package. Here is example # data x and y using Optim model(x,p) = p\[1\] .+ p\[2\] .\* x .+ p\[3\] .\*x.^2 loss\_function(p) = sum((mo…

---

## [SCATTERPLOT new color to each marker](https://discourse.julialang.org/t/scatterplot-new-color-to-each-marker/86905)

<div class="topic-metadata">

**Author:** [@naturalmechanics](https://discourse.julialang.org/u/naturalmechanics)\
**Replies:** 1\
**Last updated:** [September 8, 2022, 6:59am UTC](https://discourse.julialang.org/t/scatterplot-new-color-to-each-marker/86905 "2022-09-08T06:59:33Z")

</div>

Hi I want to make a scatterplot, where each marker has an unique color. Consider this code: xVals = \[\] yVals = \[\] cellVals = \[\] cols = \[\] my\_function() # this function will fill up xVals, yVals, and cellVals mx = m…

---

## [Finite difference stencils in 2D with mixed orders](https://discourse.julialang.org/t/finite-difference-stencils-in-2d-with-mixed-orders/86868)

<div class="topic-metadata">

**Author:** [@damuir](https://discourse.julialang.org/u/damuir)\
**Replies:** 5\
**Last updated:** [September 8, 2022, 5:57am UTC](https://discourse.julialang.org/t/finite-difference-stencils-in-2d-with-mixed-orders/86868 "2022-09-08T05:57:02Z")

</div>

Apologies if this topic has been covered or if there is a good guide for this (I have been looking for a while, including at source code for more advanced packages but I can’t wrap my head around if/how they do this sort…

---

## [Will Distributed.jl support Infiniband?](https://discourse.julialang.org/t/will-distributed-jl-support-infiniband/86899)

<div class="topic-metadata">

**Author:** [@deltaeecs](https://discourse.julialang.org/u/deltaeecs)\
**Replies:** 3\
**Last updated:** [September 8, 2022, 2:08am UTC](https://discourse.julialang.org/t/will-distributed-jl-support-infiniband/86899 "2022-09-08T02:08:46Z")

</div>

I use the iterative solvers on a slurm cluster using DistributedArrays and I have to communicate data between workers every iteration, which is really slow because no InfiniBand support (10~200times slower than in-node d…

---

## [Profiling and line numbers](https://discourse.julialang.org/t/profiling-and-line-numbers/86897)

<div class="topic-metadata">

**Author:** [@JackStrauss](https://discourse.julialang.org/u/JackStrauss)\
**Replies:** 6\
**Last updated:** [September 7, 2022, 4:39pm UTC](https://discourse.julialang.org/t/profiling-and-line-numbers/86897 "2022-09-07T16:39:18Z")

</div>

Hello I was looking to find where our code spends all its time, and tried Profile.print(). It gave me a few thousand lines of output. I am sure the answer to my query is in there, but I don’t know where to start looking…

---

## [Revise.jl bug when updating a package (on Windows)](https://discourse.julialang.org/t/revise-jl-bug-when-updating-a-package-on-windows/85941)

<div class="topic-metadata">

**Author:** [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Replies:** 7\
**Last updated:** [September 7, 2022, 3:37pm UTC](https://discourse.julialang.org/t/revise-jl-bug-when-updating-a-package-on-windows/85941 "2022-09-07T15:37:13Z")

</div>

If I run pkg"update PkgA" when I already have PkgA loaded, is there anyway to ask Revise to start using the new version?

---

## [\`Revise.jl\` dosn't work on \`include\`ed files](https://discourse.julialang.org/t/revise-jl-dosnt-work-on-include-ed-files/26872)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 5\
**Last updated:** [September 7, 2022, 1:04pm UTC](https://discourse.julialang.org/t/revise-jl-dosnt-work-on-include-ed-files/26872 "2022-09-07T13:04:15Z")

</div>

I am having trouble with Revise.jl. I have files setup like this: Tvaccine.jl module Tvaccine using Parameters using Distributions include("entities.jl") export main, world function main() …

---

## [ML estimation of MA(q) model?](https://discourse.julialang.org/t/ml-estimation-of-ma-q-model/86883)

<div class="topic-metadata">

**Author:** [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Replies:** 0\
**Last updated:** [September 7, 2022, 1:00pm UTC](https://discourse.julialang.org/t/ml-estimation-of-ma-q-model/86883 "2022-09-07T13:00:42Z")

</div>

I’m looking for code to estimate a Gaussian MA(2) model by full information maximum likelihood. I have found several Kalman filtering packages that could do the job, but I was wondering if anyone has code for the special…

---

## [Errors with package Plots, error message attached Plots v1.32.0](https://discourse.julialang.org/t/errors-with-package-plots-error-message-attached-plots-v1-32-0/86876)

<div class="topic-metadata">

**Author:** [@pjh35](https://discourse.julialang.org/u/pjh35)\
**Replies:** 0\
**Last updated:** [September 7, 2022, 10:33am UTC](https://discourse.julialang.org/t/errors-with-package-plots-error-message-attached-plots-v1-32-0/86876 "2022-09-07T10:33:38Z")

</div>

Precompiling project… ✗ GR ✗ Plots ✗ StatsPlots 0 dependencies successfully precompiled in 27 seconds. 300 already precompiled. 3 dependencies errored. To see a full report either run import Pkg; Pkg.precompile() or…

---

## [Nlp examples of using wordtokenizers.jil for email addresses](https://discourse.julialang.org/t/nlp-examples-of-using-wordtokenizers-jil-for-email-addresses/86859)

<div class="topic-metadata">

**Author:** [@bww00](https://discourse.julialang.org/u/bww00)\
**Replies:** 0\
**Last updated:** [September 6, 2022, 9:15pm UTC](https://discourse.julialang.org/t/nlp-examples-of-using-wordtokenizers-jil-for-email-addresses/86859 "2022-09-06T21:15:55Z")

</div>

Does anyone have examples for using WordTokenizers.jil for email addresses Thanks

---

## [Package naming policies for Julia packages within conda-forge](https://discourse.julialang.org/t/package-naming-policies-for-julia-packages-within-conda-forge/86659)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 15\
**Last updated:** [September 6, 2022, 8:50pm UTC](https://discourse.julialang.org/t/package-naming-policies-for-julia-packages-within-conda-forge/86659 "2022-09-06T20:50:18Z")

</div>

We have a few cases of Python packages depending on Julia packages and vice versa. I’ve posed the question about what to call Julia packages within conda-forge so that they may be referred to as explicitly dependencies. …

---

## [Julia Int function](https://discourse.julialang.org/t/julia-int-function/86852)

<div class="topic-metadata">

**Author:** [@Leon6](https://discourse.julialang.org/u/Leon6)\
**Replies:** 2\
**Last updated:** [September 6, 2022, 6:36pm UTC](https://discourse.julialang.org/t/julia-int-function/86852 "2022-09-06T18:36:28Z")

</div>

Are there any major changes for the Int function? This below script worked in previous versions. Now I’m getting lots of errors for the latest version of Julia: Cruise = Int.(TT\[:,1\]), I’m currently on Version 1.7.…

---

## [Anyone working on Apache Sketches for Julia?](https://discourse.julialang.org/t/anyone-working-on-apache-sketches-for-julia/86847)

<div class="topic-metadata">

**Author:** [@vargasje](https://discourse.julialang.org/u/vargasje)\
**Replies:** 0\
**Last updated:** [September 6, 2022, 5:01pm UTC](https://discourse.julialang.org/t/anyone-working-on-apache-sketches-for-julia/86847 "2022-09-06T17:01:30Z")

</div>

Anyone working on Apache Sketches for Julia? The link to the Apache site is below: https://datasketches.apache.org/

---

## [Fixing missing marker in plot legend when first value in series is NaN](https://discourse.julialang.org/t/fixing-missing-marker-in-plot-legend-when-first-value-in-series-is-nan/86658)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 2\
**Last updated:** [September 6, 2022, 4:45pm UTC](https://discourse.julialang.org/t/fixing-missing-marker-in-plot-legend-when-first-value-in-series-is-nan/86658 "2022-09-06T16:45:56Z")

</div>

When using the GR backend for Plots.jl, I noticed that for a series with a marker, the marker will not show up in the legend of a plot if the first entry in the series is NaN. MWE: using Plots; gr() plot(\[NaN,2,3\], mar…

---

## [Organizing package with both gpu- and cpu implemntations](https://discourse.julialang.org/t/organizing-package-with-both-gpu-and-cpu-implemntations/86846)

<div class="topic-metadata">

**Author:** [@ykkan](https://discourse.julialang.org/u/ykkan)\
**Replies:** 0\
**Last updated:** [September 6, 2022, 4:21pm UTC](https://discourse.julialang.org/t/organizing-package-with-both-gpu-and-cpu-implemntations/86846 "2022-09-06T16:21:19Z")

</div>

Hi everyone, I am trying to develop a package which provides both gpu-parallelized implementation and cpu-parallelized implementation. How should I organize the project directory? In particular, how should I manage the …

---

## [Using atomic operations in Julia 1.6](https://discourse.julialang.org/t/using-atomic-operations-in-julia-1-6/86812)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 10\
**Last updated:** [September 6, 2022, 3:28pm UTC](https://discourse.julialang.org/t/using-atomic-operations-in-julia-1-6/86812 "2022-09-06T15:28:09Z")

</div>

I’d like to implement the following pattern: mutable struct A @atomic x::Int end a = A(3) @atomic a.x = 4 # in a multithreaded environment However, I don’t want to drop compatibility with Julia 1.6 and it seems th…

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

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