# General Usage

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

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

**Page:** 429

---

## [How to map a function over the given axis of a multi-dimension array and return another array?](https://discourse.julialang.org/t/how-to-map-a-function-over-the-given-axis-of-a-multi-dimension-array-and-return-another-array/83586)

<div class="topic-metadata">

**Author:** [@zhangqian](https://discourse.julialang.org/u/zhangqian)\
**Replies:** 4\
**Last updated:** [July 1, 2022, 3:27pm UTC](https://discourse.julialang.org/t/how-to-map-a-function-over-the-given-axis-of-a-multi-dimension-array-and-return-another-array/83586 "2022-07-01T15:27:32Z")

</div>

I am trying to rotate some images, so I want to write something like np.array(list(map(lambda x: rotate(x), images))) in python, where the variable images is an array of shape \[N, H, W\]. Is there a method in julia that…

---

## [How to share function f() arguments with Threads.@spawn?](https://discourse.julialang.org/t/how-to-share-function-f-arguments-with-threads-spawn/83627)

<div class="topic-metadata">

**Author:** [@bienpierre](https://discourse.julialang.org/u/bienpierre)\
**Replies:** 0\
**Last updated:** [July 1, 2022, 2:37pm UTC](https://discourse.julialang.org/t/how-to-share-function-f-arguments-with-threads-spawn/83627 "2022-07-01T14:37:15Z")

</div>

Dear all, First of all, sorry if element has been questioned before. I have the following code with multi-threads ($ julia --threads=4 when launching Julia ): : import Base.Threads.@spawn mutable struct MyStructTest…

---

## [Underperformant mapreduce](https://discourse.julialang.org/t/underperformant-mapreduce/83624)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 0\
**Last updated:** [July 1, 2022, 2:10pm UTC](https://discourse.julialang.org/t/underperformant-mapreduce/83624 "2022-07-01T14:10:29Z")

</div>

Conceptually, shouldn’t the mapreduce version be faster than the reduce version? Granted, the difference is not much, but there are consistently some nanoseconds missing. julia\> N = 5115; julia\> a1 = rand(Bool, N); j…

---

## [Translation of Julia's document in Persian language](https://discourse.julialang.org/t/translation-of-julias-document-in-persian-language/83620)

<div class="topic-metadata">

**Author:** [@MahanBakhshi](https://discourse.julialang.org/u/MahanBakhshi)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 2:07pm UTC](https://discourse.julialang.org/t/translation-of-julias-document-in-persian-language/83620 "2022-07-01T14:07:42Z")

</div>

Hello I want to translate Julia’s document into Farsi language. My question is, will that original document be available or not? Otherwise, what way do you suggest to make it available to the public through Julia’s ma…

---

## [Creative DSLs in Julia](https://discourse.julialang.org/t/creative-dsls-in-julia/83616)

<div class="topic-metadata">

**Author:** [@Federalsaw](https://discourse.julialang.org/u/Federalsaw)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 1:23pm UTC](https://discourse.julialang.org/t/creative-dsls-in-julia/83616 "2022-07-01T13:23:15Z")

</div>

So for a while I’ve been trying to write a simple DSL that allows the user to simply create abstract art by writing code, but I don’t know where to start. Could someone recommend me some libraries/resources to help me a…

---

## [Bezier Curve with Javis.jl: gif is not showing](https://discourse.julialang.org/t/bezier-curve-with-javis-jl-gif-is-not-showing/83606)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 10:39am UTC](https://discourse.julialang.org/t/bezier-curve-with-javis-jl-gif-is-not-showing/83606 "2022-07-01T10:39:40Z")

</div>

I am trying the code below but the gif is not produced. It only says: animate\_bezier(generic function with 1 method) I try some methods to produce gif but still no gif created. using Plots # for the LaTeX labels in th…

---

## [Looping over variables names properly](https://discourse.julialang.org/t/looping-over-variables-names-properly/80468)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 19\
**Last updated:** [July 1, 2022, 9:55am UTC](https://discourse.julialang.org/t/looping-over-variables-names-properly/80468 "2022-07-01T09:55:06Z")

</div>

I have a few arrays, say x, y, z, and I want to take all of their means and put them into new variables as x\_mean = mean(x). Is there a way to do this in a for loop? Something like for a in \["x", "y", "z"\] $a\_mean …

---

## [How to update a data set using another data set?](https://discourse.julialang.org/t/how-to-update-a-data-set-using-another-data-set/80203)

<div class="topic-metadata">

**Author:** [@mostafa1342004](https://discourse.julialang.org/u/mostafa1342004)\
**Replies:** 5\
**Last updated:** [July 1, 2022, 9:30am UTC](https://discourse.julialang.org/t/how-to-update-a-data-set-using-another-data-set/80203 "2022-07-01T09:30:33Z")

</div>

I have a master data set and I like to update some of its values using a transaction data set. There are some key columns for finding the rows that must be updated in both data sets. I know about update! function but the…

---

## [Segfault when using PackageCompiler on aarch64 on Julia 1.6.0 and up](https://discourse.julialang.org/t/segfault-when-using-packagecompiler-on-aarch64-on-julia-1-6-0-and-up/60722)

<div class="topic-metadata">

**Author:** [@sonicrules1234](https://discourse.julialang.org/u/sonicrules1234)\
**Replies:** 4\
**Last updated:** [July 1, 2022, 8:25am UTC](https://discourse.julialang.org/t/segfault-when-using-packagecompiler-on-aarch64-on-julia-1-6-0-and-up/60722 "2022-07-01T08:25:52Z")

</div>

It worked just fine before upgrading to Julia 1.6.0. Now when I try to use compile\_app it gives a segfault part way through. It doesn’t crash, but I haven’t tried waiting long after the segfault. \[westly08:06~\]$ julia…

---

## [Why other calculation will effect the time consumed by Threads.@threads](https://discourse.julialang.org/t/why-other-calculation-will-effect-the-time-consumed-by-threads-threads/83602)

<div class="topic-metadata">

**Author:** [@wly](https://discourse.julialang.org/u/wly)\
**Replies:** 0\
**Last updated:** [July 1, 2022, 8:17am UTC](https://discourse.julialang.org/t/why-other-calculation-will-effect-the-time-consumed-by-threads-threads/83602 "2022-07-01T08:17:49Z")

</div>

When I test my code, I found that the time consumed by Threads.@threads in actual environment is bigger than the test environment. And I think the reason is that other calculation in the actual environment effects the pe…

---

## [String representation of unitful types](https://discourse.julialang.org/t/string-representation-of-unitful-types/83535)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 6:43am UTC](https://discourse.julialang.org/t/string-representation-of-unitful-types/83535 "2022-07-01T06:43:15Z")

</div>

julia\> typeof(1.0u"kg/m^3") \<: Number true julia\> typeof(1.0u"kg/m^3") Quantity{Float64, 𝐌 𝐋 ^-3, Unitful.FreeUnits{(kg, m^-3), 𝐌 𝐋 ^-3, nothing}} julia\> Quantity{Float64, 𝐌 𝐋 ^-3, Unitful.FreeUnits{(kg, m^-3), 𝐌 𝐋 ^…

---

## [Array comprehension: Can someone explain this typeof result?](https://discourse.julialang.org/t/array-comprehension-can-someone-explain-this-typeof-result/83597)

<div class="topic-metadata">

**Author:** [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Replies:** 7\
**Last updated:** [July 1, 2022, 6:23am UTC](https://discourse.julialang.org/t/array-comprehension-can-someone-explain-this-typeof-result/83597 "2022-07-01T06:23:02Z")

</div>

Running the code below, I expected Vector{Float64} for both cases. Is there an explanation for why I don’t get this for the g function? function ff(y) function a(x) x\>y ? x : "" end return a end g…

---

## [Bug with initializing extra rows in sparse arrays](https://discourse.julialang.org/t/bug-with-initializing-extra-rows-in-sparse-arrays/83594)

<div class="topic-metadata">

**Author:** [@jsbryan4](https://discourse.julialang.org/u/jsbryan4)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 2:36am UTC](https://discourse.julialang.org/t/bug-with-initializing-extra-rows-in-sparse-arrays/83594 "2022-07-01T02:36:59Z")

</div>

I found what I believe to be a bug in SparseArrays. If I try to make a sparse array with more rows than the max row number It fails with the error: 11×10 SparseMatrixCSC{Any, Int64} with 100 stored entries: ERROR: Metho…

---

## [Indexing StaticArrays](https://discourse.julialang.org/t/indexing-staticarrays/83574)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 8\
**Last updated:** [June 30, 2022, 10:50pm UTC](https://discourse.julialang.org/t/indexing-staticarrays/83574 "2022-06-30T22:50:59Z")

</div>

This is such a basic question that I almost feel bad asking it, but it would be nice to get some clarification and examples of how others are using StaticArrays.jl. I’ve found this thread, but I think my question is slig…

---

## [Understand Macro interconnections in OpenCL.jl package](https://discourse.julialang.org/t/understand-macro-interconnections-in-opencl-jl-package/83581)

<div class="topic-metadata">

**Author:** [@ImreMD](https://discourse.julialang.org/u/ImreMD)\
**Replies:** 0\
**Last updated:** [June 30, 2022, 8:31pm UTC](https://discourse.julialang.org/t/understand-macro-interconnections-in-opencl-jl-package/83581 "2022-06-30T20:31:43Z")

</div>

When you look in the OpenCL implementation code you stumble upon two macros one is ‘’‘@check’‘’ define in src/ macros.jl the other one ‘’‘@ocl\_func’‘’. @check is responsible for running the clfunc =\> $(esc(clfunc)), but …

---

## [Create Unit Circle with its Sin Cos Animation](https://discourse.julialang.org/t/create-unit-circle-with-its-sin-cos-animation/83467)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 21\
**Last updated:** [June 30, 2022, 3:33pm UTC](https://discourse.julialang.org/t/create-unit-circle-with-its-sin-cos-animation/83467 "2022-06-30T15:33:57Z")

</div>

I want to create animation that a circle will rotate around a unit circle, and the second plot the circle move along the sine function, and the third plot the circle move along the cosine function. Which package for anim…

---

## [Docstring not rendering underscore](https://discourse.julialang.org/t/docstring-not-rendering-underscore/15818)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 5\
**Last updated:** [June 30, 2022, 12:31pm UTC](https://discourse.julialang.org/t/docstring-not-rendering-underscore/15818 "2022-06-30T12:31:55Z")

</div>

I have a docstring which is quoted in triple " When I use ?my\_fn the help which is shown, is missing SOME underscores, but not all. I tried masking the underscores with a backslash but that will not be parsed by julia. …

---

## [Weird error after defining Base.show method for custom DataType](https://discourse.julialang.org/t/weird-error-after-defining-base-show-method-for-custom-datatype/83562)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 2\
**Last updated:** [June 30, 2022, 11:12am UTC](https://discourse.julialang.org/t/weird-error-after-defining-base-show-method-for-custom-datatype/83562 "2022-06-30T11:12:22Z")

</div>

I don’t know if defining a new method of Base.show for a custom type (the type itself and not it instances) is something that someone shouldn’t do, but basically: i have a type Operator{T} where T is a Symbol, and instea…

---

## [Does @simd hang Base.Threads.@spawn?](https://discourse.julialang.org/t/does-simd-hang-base-threads-spawn/83114)

<div class="topic-metadata">

**Author:** [@Nick\_Matzke](https://discourse.julialang.org/u/Nick_Matzke)\
**Replies:** 11\
**Last updated:** [June 30, 2022, 10:14am UTC](https://discourse.julialang.org/t/does-simd-hang-base-threads-spawn/83114 "2022-06-30T10:14:19Z")

</div>

Hi all, I have an expensive function, f(x), that is embarassingly parallel. E.g. I have to run f(x) 300 times on different x, and each f(x) can take 20 seconds. I wrote a function to parallelize the above, and it work…

---

## [Overwriting Functions from another package in your package](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545)

<div class="topic-metadata">

**Author:** [@arbitrandomuser](https://discourse.julialang.org/u/arbitrandomuser)\
**Replies:** 3\
**Last updated:** [June 30, 2022, 10:06am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545 "2022-06-30T10:06:37Z")

</div>

I’m implementing a feature for Javis . Javis is an animation library . To draw every frame it uses Luxor . Now for this feature to be implemented I need to change the behaviour of a few functions in Javis. I am overwri…

---

## [Loading a precompiled module does not respect the module import order](https://discourse.julialang.org/t/loading-a-precompiled-module-does-not-respect-the-module-import-order/83560)

<div class="topic-metadata">

**Author:** [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Replies:** 0\
**Last updated:** [June 30, 2022, 9:34am UTC](https://discourse.julialang.org/t/loading-a-precompiled-module-does-not-respect-the-module-import-order/83560 "2022-06-30T09:34:52Z")

</div>

I’ve just made a package JuliaPythonAdaptor.jl that helps automatically setting up environment variables required by PythonCall.jl. Things works pretty fine if I use these two packages in REPL: # 'JuliaPythonAdaptor.\_\_…

---

## [DifferentialEquations.jl How to speed up the solver](https://discourse.julialang.org/t/differentialequations-jl-how-to-speed-up-the-solver/83549)

<div class="topic-metadata">

**Author:** [@Nalaka](https://discourse.julialang.org/u/Nalaka)\
**Replies:** 3\
**Last updated:** [June 30, 2022, 9:32am UTC](https://discourse.julialang.org/t/differentialequations-jl-how-to-speed-up-the-solver/83549 "2022-06-30T09:32:26Z")

</div>

I am using Julia to solve set of differential equations of a omni-wheeled mobile robot. It took 1264.41 sec (21.07 min) to solve the system (But in mathematica, it took less than 4s). In the time, it showed 99% time is f…

---

## [Efficient Evaluation of a Matrix of Function Products](https://discourse.julialang.org/t/efficient-evaluation-of-a-matrix-of-function-products/83466)

<div class="topic-metadata">

**Author:** [@martintb](https://discourse.julialang.org/u/martintb)\
**Replies:** 8\
**Last updated:** [June 30, 2022, 7:30am UTC](https://discourse.julialang.org/t/efficient-evaluation-of-a-matrix-of-function-products/83466 "2022-06-30T07:30:08Z")

</div>

Hi all, I’m trying to compute every product of two functions of a set of different functions fv (e.g., a set of wavefunctions) at different x to obtain a matrix y for each x of shape NxN where N is the number of functio…

---

## [Slicing and boolean indexing in multidimensional arrays](https://discourse.julialang.org/t/slicing-and-boolean-indexing-in-multidimensional-arrays/83522)

<div class="topic-metadata">

**Author:** [@bryce](https://discourse.julialang.org/u/bryce)\
**Replies:** 5\
**Last updated:** [June 30, 2022, 5:21am UTC](https://discourse.julialang.org/t/slicing-and-boolean-indexing-in-multidimensional-arrays/83522 "2022-06-30T05:21:20Z")

</div>

I’m curious why the following 3D array slicing works for the i index but not for the j index: T = Array(reshape(1:2\*3\*4, 2,3,4)) i = zeros(Bool, 2,3) i\[1,2:3\] .= 1 display(T\[i,:\]) j = zeros(Bool, 3,4) j\[1,2:3\] .= 1 disp…

---

## [Iterators.product OutOfMemoryError()](https://discourse.julialang.org/t/iterators-product-outofmemoryerror/83542)

<div class="topic-metadata">

**Author:** [@Yuri\_Mizusawa](https://discourse.julialang.org/u/Yuri_Mizusawa)\
**Replies:** 2\
**Last updated:** [June 30, 2022, 2:29am UTC](https://discourse.julialang.org/t/iterators-product-outofmemoryerror/83542 "2022-06-30T02:29:48Z")

</div>

Hi, I have the following code: ary\_comb\_n=collect(Iterators.product(n\_max\_O...)) Where n\_max\_O is an array with vectors like this \[ \[0,1,2,3,4\] ,\[0,1,2\] \]. Iterators.product gives me the combinatory of all the vec…

---

## [If then statement vs Grid](https://discourse.julialang.org/t/if-then-statement-vs-grid/83537)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 3\
**Last updated:** [June 30, 2022, 12:01am UTC](https://discourse.julialang.org/t/if-then-statement-vs-grid/83537 "2022-06-30T00:01:52Z")

</div>

My goal is to create a piecewise function in Julia parsimoniously. u(x,y) = y if x = 0 u(x,y) = y -1 if x \\neq 0 I get the following: julia\> FC(x) = (x==0):(0):(1) FC (generic function with 1 method) julia\> u(x,y) …

---

## [How to write a simple macro](https://discourse.julialang.org/t/how-to-write-a-simple-macro/83420)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 19\
**Last updated:** [June 29, 2022, 10:31pm UTC](https://discourse.julialang.org/t/how-to-write-a-simple-macro/83420 "2022-06-29T22:31:21Z")

</div>

I have lines similar to this a lot in my code: if chi\_factor \> 0.85 chi\_factor = 0.85 end I would like to write it like this: @limit chi\_factor 0.85 I cannot use a function for this because a function cannot chan…

---

## [Formatting the x-axis with hex values](https://discourse.julialang.org/t/formatting-the-x-axis-with-hex-values/83528)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 12\
**Last updated:** [June 29, 2022, 8:24pm UTC](https://discourse.julialang.org/t/formatting-the-x-axis-with-hex-values/83528 "2022-06-29T20:24:13Z")

</div>

I have the following code: using Plots p = histogram(randn(1000)\*10, bins=:scott, weights=repeat(1:5, outer=200)) p How can I achieve that the x axis shows hex values instead of decimal values?

---

## [Small-multiples plots in Plots.jl](https://discourse.julialang.org/t/small-multiples-plots-in-plots-jl/83529)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 2\
**Last updated:** [June 29, 2022, 8:21pm UTC](https://discourse.julialang.org/t/small-multiples-plots-in-plots-jl/83529 "2022-06-29T20:21:13Z")

</div>

I have time series for each state in the US. I have grouped the states by a geographic grouping factor. There are 8 state groups. I’d like to make 8 panels, one for each state group, within the panel I want each state t…

---

## [Build simple GUIs with MiniFB](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195)

<div class="topic-metadata">

**Author:** [@avik](https://discourse.julialang.org/u/avik)\
**Replies:** 40\
**Last updated:** [June 29, 2022, 4:37pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195 "2022-06-29T16:37:58Z")

</div>

I’d like to announce a little vacation project of mine. I’ve just released the first version of MiniFB.jl, a Julia wrapper around a small C library called MiniFB. MiniFB is possibly the simplest way to get a graphical w…

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

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