# General Usage

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

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

**Page:** 477

---

## [Source code of a function](https://discourse.julialang.org/t/source-code-of-a-function/4499)

<div class="topic-metadata">

**Author:** [@rcnlee](https://discourse.julialang.org/u/rcnlee)\
**Replies:** 20\
**Last updated:** [March 3, 2022, 6:40pm UTC](https://discourse.julialang.org/t/source-code-of-a-function/4499 "2022-03-03T18:40:10Z")

</div>

Hello, Is it possible to recover the source code of a function as a string? For example, f(x,y) = 2sin(x+y)+1 Is there a function call on f that can get me s="2sin(x+y)+1"? Thanks!

---

## [Mapreduce, pass extra arguments to reduce/vcat of DataFrames](https://discourse.julialang.org/t/mapreduce-pass-extra-arguments-to-reduce-vcat-of-dataframes/77347)

<div class="topic-metadata">

**Author:** [@baptnz](https://discourse.julialang.org/u/baptnz)\
**Replies:** 10\
**Last updated:** [March 3, 2022, 5:30pm UTC](https://discourse.julialang.org/t/mapreduce-pass-extra-arguments-to-reduce-vcat-of-dataframes/77347 "2022-03-03T17:30:35Z")

</div>

I’m using a map+reduce combination to apply a function returning a DataFrame and combine all the results with vcat, f(p) = DataFrame(x = collect(1:10), y = p\[1\]\*rand(10), z = p\[2\]\*rand(10)) tmp = map(f, (\[1,2\], \[3,4\],…

---

## [What exactly is a \`Number\`?](https://discourse.julialang.org/t/what-exactly-is-a-number/77331)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 8\
**Last updated:** [March 3, 2022, 3:47pm UTC](https://discourse.julialang.org/t/what-exactly-is-a-number/77331 "2022-03-03T15:47:14Z")

</div>

Suppose I want to implement some “numbers” (which should at least be a ring in the mathematical sense) in Julia. The documentation says that Number is the abstract supertype for all number types. Does Julia put any assum…

---

## [Can't quote a Cmd with equals sign correctly](https://discourse.julialang.org/t/cant-quote-a-cmd-with-equals-sign-correctly/65963)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 6\
**Last updated:** [March 3, 2022, 12:26pm UTC](https://discourse.julialang.org/t/cant-quote-a-cmd-with-equals-sign-correctly/65963 "2022-03-03T12:26:09Z")

</div>

I’ve been happily using DrWatson for my latest project, using its convention for filenames. For example, if my simulation uses parameters Dict(:a=\>2, :b=\>7), my output data file might be named simulation\_a=2\_b=7.h5. Bu…

---

## [Keeping a "reference" to a struct field](https://discourse.julialang.org/t/keeping-a-reference-to-a-struct-field/77344)

<div class="topic-metadata">

**Author:** [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Replies:** 3\
**Last updated:** [March 3, 2022, 11:28am UTC](https://discourse.julialang.org/t/keeping-a-reference-to-a-struct-field/77344 "2022-03-03T11:28:39Z")

</div>

Edit: See my first reply below for a more correct MWE. Consider a struct like mutable struct Test a::Int end After t = Test(1) I would like to “bind” to the field so that after x = t.a t.a = 2 x will evaluate as…

---

## [Detecting non-ascii key presses?](https://discourse.julialang.org/t/detecting-non-ascii-key-presses/77148)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 4\
**Last updated:** [March 3, 2022, 8:57am UTC](https://discourse.julialang.org/t/detecting-non-ascii-key-presses/77148 "2022-03-03T08:57:56Z")

</div>

I have some posts that can detect ascii key presses but I can’t find any resource on how to detect if keys like LEFT or RIGHT are pressed. Basically, i want to wait for input of LEFT or Right and then do something then …

---

## [How to convert an "any" column in a dataframe containing strings and floats?](https://discourse.julialang.org/t/how-to-convert-an-any-column-in-a-dataframe-containing-strings-and-floats/77330)

<div class="topic-metadata">

**Author:** [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Replies:** 7\
**Last updated:** [March 3, 2022, 8:06am UTC](https://discourse.julialang.org/t/how-to-convert-an-any-column-in-a-dataframe-containing-strings-and-floats/77330 "2022-03-03T08:06:27Z")

</div>

I’m trying to convert a column of type “Any” in my dataframe to a column of type “Float64”. It seems that there are float values and string values in the column. First I tried: df\[!, :column2\] = tryparse.(Float64, df\[:…

---

## [Vector{Vector{T} where T} vs Vector{Vector{T}} where T](https://discourse.julialang.org/t/vector-vector-t-where-t-vs-vector-vector-t-where-t/2743)

<div class="topic-metadata">

**Author:** [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Replies:** 18\
**Last updated:** [March 3, 2022, 7:50am UTC](https://discourse.julialang.org/t/vector-vector-t-where-t-vs-vector-vector-t-where-t/2743 "2022-03-03T07:50:00Z")

</div>

I can see a lot of discussions around UnionAll and new where keyword on GitHub, but most comments seem to make sense only to people who track the topic for a long time. Is there any docs or drafts (except for news) about…

---

## [How to set series as NOT selected in Plotly interactive HTML](https://discourse.julialang.org/t/how-to-set-series-as-not-selected-in-plotly-interactive-html/76671)

<div class="topic-metadata">

**Author:** [@CaoHua](https://discourse.julialang.org/u/CaoHua)\
**Replies:** 2\
**Last updated:** [March 3, 2022, 5:05am UTC](https://discourse.julialang.org/t/how-to-set-series-as-not-selected-in-plotly-interactive-html/76671 "2022-03-03T05:05:04Z")

</div>

Dears, I am using Plotly as the backend to generate line chart, and save the chart as html file. There are several series/lines in the chart. And I would like to show just part of them as the default. How can I set up…

---

## [Does anyone have a progress bar for pmap?](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 4\
**Last updated:** [March 3, 2022, 12:20am UTC](https://discourse.julialang.org/t/does-anyone-have-a-progress-bar-for-pmap/11729 "2022-03-03T00:20:43Z")

</div>

I guess it’s been a while since anyone’s asked it, but does somebody have a working progress bar for pmap sitting around? Related to: Displaying Parallel Progress Bars - #5 by adamslc Way to add progress bar to map f…

---

## [How to adapt julia-1.0 code for julia-1.6](https://discourse.julialang.org/t/how-to-adapt-julia-1-0-code-for-julia-1-6/77229)

<div class="topic-metadata">

**Author:** [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Replies:** 14\
**Last updated:** [March 2, 2022, 10:06pm UTC](https://discourse.julialang.org/t/how-to-adapt-julia-1-0-code-for-julia-1-6/77229 "2022-03-02T22:06:07Z")

</div>

My julia code worked with version 1.0, but not with version 1.6. Adapting my code to version 1.6 appears to be not as simple as I hoped. Is there a text that explains how to do it?

---

## [Julia in laboratory](https://discourse.julialang.org/t/julia-in-laboratory/77171)

<div class="topic-metadata">

**Author:** [@Oto\_Brzobohaty](https://discourse.julialang.org/u/Oto_Brzobohaty)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 9:36pm UTC](https://discourse.julialang.org/t/julia-in-laboratory/77171 "2022-03-02T21:36:36Z")

</div>

Hi All, have you tried to control the experiments (data acquisition and instrument control) in laboratory using https://github.com/JaneliaSciComp/NIDAQ.jl together with some GUI interface? We would like to move from Lab…

---

## [Removing axes in Plots.jl 3D plot](https://discourse.julialang.org/t/removing-axes-in-plots-jl-3d-plot/9104)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 2\
**Last updated:** [March 2, 2022, 7:03pm UTC](https://discourse.julialang.org/t/removing-axes-in-plots-jl-3d-plot/9104 "2022-03-02T19:03:37Z")

</div>

Very much similar to Removing Grid and Plot Manipulation on PyPlot 3D Figures, I have a 3D plot drawn with Plots.jl (rather than PyPlot.jl) where I would like to remove the axes/box, i.e. I want the image to be floating …

---

## [Invoking a macro within the invocation of another macro](https://discourse.julialang.org/t/invoking-a-macro-within-the-invocation-of-another-macro/77313)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 0\
**Last updated:** [March 2, 2022, 4:20pm UTC](https://discourse.julialang.org/t/invoking-a-macro-within-the-invocation-of-another-macro/77313 "2022-03-02T16:20:58Z")

</div>

I’m still having trouble with Julia macros. I’ve defined some structs for implementing BNF grammars. I want my grammars to capture source locations. to this end, I’m trying to define a macro with which to wrap each st…

---

## [Different calculation results when using CPU vs. GPU with CUDA.jl](https://discourse.julialang.org/t/different-calculation-results-when-using-cpu-vs-gpu-with-cuda-jl/77150)

<div class="topic-metadata">

**Author:** [@Mari](https://discourse.julialang.org/u/Mari)\
**Replies:** 2\
**Last updated:** [March 2, 2022, 4:14pm UTC](https://discourse.julialang.org/t/different-calculation-results-when-using-cpu-vs-gpu-with-cuda-jl/77150 "2022-03-02T16:14:29Z")

</div>

Hi everyone, I am rather new to GPU programming and I am having difficulty understanding why I get different results when running a function on GPU vs. CPU. The function involves atomic operation, and even running it on…

---

## [MKL slower than openblas in intel cpu](https://discourse.julialang.org/t/mkl-slower-than-openblas-in-intel-cpu/77169)

<div class="topic-metadata">

**Author:** [@Jae-Mo\_Lihm](https://discourse.julialang.org/u/Jae-Mo_Lihm)\
**Replies:** 7\
**Last updated:** [March 2, 2022, 3:48pm UTC](https://discourse.julialang.org/t/mkl-slower-than-openblas-in-intel-cpu/77169 "2022-03-02T15:48:01Z")

</div>

I found MKL is ~1.5 times slower than openblas for matrix-matrix multiplication (both without multithreading). Since I’m using intel CPU, I expected MKL to be faster. Is there anything obviously wrong in this benchmark?…

---

## [Varargs and type aliasing](https://discourse.julialang.org/t/varargs-and-type-aliasing/77089)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 9\
**Last updated:** [March 2, 2022, 3:31pm UTC](https://discourse.julialang.org/t/varargs-and-type-aliasing/77089 "2022-03-02T15:31:06Z")

</div>

I tried to create a type alias of Vararg (with a specific number of arguments) as follows. const FormArgs{K,D} = Vararg{StaticVector{D}, K} However, if I try FormArgs{3,2} it does not produce Vararg{StaticVector{2},3} …

---

## [Performance of using CartesianIndices with MArray](https://discourse.julialang.org/t/performance-of-using-cartesianindices-with-marray/77167)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 2\
**Last updated:** [March 2, 2022, 3:29pm UTC](https://discourse.julialang.org/t/performance-of-using-cartesianindices-with-marray/77167 "2022-03-02T15:29:10Z")

</div>

Multidimensional algorithms built on CartesianIndices seem to have significant performance overhead when applied to StaticArrays.MArray​s, but not regular Array​s. Writing several functions with nested loops for differe…

---

## [Typos in Julia](https://discourse.julialang.org/t/typos-in-julia/77267)

<div class="topic-metadata">

**Author:** [@ameresv](https://discourse.julialang.org/u/ameresv)\
**Replies:** 3\
**Last updated:** [March 2, 2022, 2:19pm UTC](https://discourse.julialang.org/t/typos-in-julia/77267 "2022-03-02T14:19:41Z")

</div>

This could be a silly question, but why this -\> is accepted and → does not? The latter does really help me in the readability of my code and, in my case, is obtained with alt + 26. Is there a future development on it? …

---

## [Extracting elements from dictionary containing a struct, where the struct is made up of a dictionary containing a nested struct](https://discourse.julialang.org/t/extracting-elements-from-dictionary-containing-a-struct-where-the-struct-is-made-up-of-a-dictionary-containing-a-nested-struct/77288)

<div class="topic-metadata">

**Author:** [@Christian\_Brunbjerg](https://discourse.julialang.org/u/Christian_Brunbjerg)\
**Replies:** 6\
**Last updated:** [March 2, 2022, 1:48pm UTC](https://discourse.julialang.org/t/extracting-elements-from-dictionary-containing-a-struct-where-the-struct-is-made-up-of-a-dictionary-containing-a-nested-struct/77288 "2022-03-02T13:48:24Z")

</div>

\#Initializing the 2 structs struct inner value::Float64 end struct outer inner::Any end #Initializing the 2 dictionaries outer\_dic = Dict() inner\_dic = Dict() #Defining the values for the inner dictionary inne…

---

## [Why doesn't FixedPointNumbers.jl allow comparison with integers?](https://discourse.julialang.org/t/why-doesnt-fixedpointnumbers-jl-allow-comparison-with-integers/77214)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 3\
**Last updated:** [March 2, 2022, 1:18pm UTC](https://discourse.julialang.org/t/why-doesnt-fixedpointnumbers-jl-allow-comparison-with-integers/77214 "2022-03-02T13:18:59Z")

</div>

I am using FixedPointNumbers.jl to implement an approximation algorithm, and I have been running into the following issue: julia\> using FixedPointNumbers julia\> FP = Fixed{Int16, 4} Q11f4 (alias for Fixed{Int16, 4}) jul…

---

## [\`show\` method for \`Function\` subtype](https://discourse.julialang.org/t/show-method-for-function-subtype/77297)

<div class="topic-metadata">

**Author:** [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 12:32pm UTC](https://discourse.julialang.org/t/show-method-for-function-subtype/77297 "2022-03-02T12:32:08Z")

</div>

julia\> struct MyFunction \<: Function x end julia\> (f::MyFunction)(arg) = f.x\*arg julia\> Base.show(io::IO, f::MyFunction) = println(io, "MyFunction with x=$(f.x)") julia\> f = MyFunction(3) (::My…

---

## [Modify custom solver to deal with multidimensional arrays](https://discourse.julialang.org/t/modify-custom-solver-to-deal-with-multidimensional-arrays/74845)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 10\
**Last updated:** [March 2, 2022, 11:57am UTC](https://discourse.julialang.org/t/modify-custom-solver-to-deal-with-multidimensional-arrays/74845 "2022-03-02T11:57:59Z")

</div>

Some time ago @longemen3000 shared with me his custom nl equation solver written with NLSolvers here. It works well when the system is provided as a vector. I tried to modify it to accept systems provided with multidimen…

---

## [Adding Guide.manual\_color\_key to Geom.ribbon plot with hex codes](https://discourse.julialang.org/t/adding-guide-manual-color-key-to-geom-ribbon-plot-with-hex-codes/77281)

<div class="topic-metadata">

**Author:** [@colebrookson](https://discourse.julialang.org/u/colebrookson)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 10:29am UTC](https://discourse.julialang.org/t/adding-guide-manual-color-key-to-geom-ribbon-plot-with-hex-codes/77281 "2022-03-02T10:29:40Z")

</div>

I’m assuming I’m just missing something, but I can’t find how to do this in the docs. Say I have a plot from the following data using DataFrames, Gadfly, Distributions # make some data x = range(0, 2π, length=100) y1…

---

## [Mapreduce with broadcasting](https://discourse.julialang.org/t/mapreduce-with-broadcasting/77053)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 9\
**Last updated:** [March 2, 2022, 10:28am UTC](https://discourse.julialang.org/t/mapreduce-with-broadcasting/77053 "2022-03-02T10:28:50Z")

</div>

I want to perform a mapreduce over multiple iterators that don’t have the same dimensions, but which can be broadcast together. For example: arr1 = rand(1, 1, 3) arr2 = rand(100, 100, 1) mapreduce(+, \*, arr1, arr2; dim…

---

## [How to append elements to a CuArray or delete some entries from it in GPU kernel function](https://discourse.julialang.org/t/how-to-append-elements-to-a-cuarray-or-delete-some-entries-from-it-in-gpu-kernel-function/77180)

<div class="topic-metadata">

**Author:** [@Mari](https://discourse.julialang.org/u/Mari)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 10:26am UTC](https://discourse.julialang.org/t/how-to-append-elements-to-a-cuarray-or-delete-some-entries-from-it-in-gpu-kernel-function/77180 "2022-03-02T10:26:49Z")

</div>

Hi everyone, I am looking for a way to be able to efficiently append or delete some entries of a CuArray in the kernels being run on GPU . Also I guess that “append” and “delete” must be perfumed atomically. I am rather…

---

## [Predict not defined](https://discourse.julialang.org/t/predict-not-defined/77276)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 3\
**Last updated:** [March 2, 2022, 8:48am UTC](https://discourse.julialang.org/t/predict-not-defined/77276 "2022-03-02T08:48:24Z")

</div>

I run the following example in Common MLJ Workflows · MLJ (alan-turing-institute.github.io) using MLJ,DataFrames crabs = load\_crabs() |\> DataFrames.DataFrame schema(crabs) y, X = unpack(crabs, ==(:sp), !in(\[:index, :sex…

---

## [Is it possible to use x² to mean taking square x^2](https://discourse.julialang.org/t/is-it-possible-to-use-x-to-mean-taking-square-x-2/76137)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 13\
**Last updated:** [March 2, 2022, 7:58am UTC](https://discourse.julialang.org/t/is-it-possible-to-use-x-to-mean-taking-square-x-2/76137 "2022-03-02T07:58:19Z")

</div>

Say, x^2 can be written as x², tanspose(M) can be written as Mᵀ, and so on?

---

## [How to plot more ticks in AlgebraOfGraphics or Makie?](https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261)

<div class="topic-metadata">

**Author:** [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Replies:** 1\
**Last updated:** [March 1, 2022, 10:40pm UTC](https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261 "2022-03-01T22:40:19Z")

</div>

I have this code to plot a time-series: using AlgebraOfGraphics data( (; x=1:100, y=randn(100)) ) \* mapping(:x, :y) \* visual(Lines) |\> draw It produces this plot: Question: how to add more ticks to x and/or y …

---

## [How to sample data without using external packages?](https://discourse.julialang.org/t/how-to-sample-data-without-using-external-packages/77240)

<div class="topic-metadata">

**Author:** [@Dharik\_Arsath](https://discourse.julialang.org/u/Dharik_Arsath)\
**Replies:** 12\
**Last updated:** [March 1, 2022, 9:05pm UTC](https://discourse.julialang.org/t/how-to-sample-data-without-using-external-packages/77240 "2022-03-01T21:05:41Z")

</div>

I am trying to sample data from population within loop but that produces way too much allocations and making my algorithms lot slower. I need a way to sample data with no more than 1 allocation. How should I proceed??? I…

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

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