# General Usage

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

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

**Page:** 803

---

## [\`show\` methods for types](https://discourse.julialang.org/t/show-methods-for-types/32578)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 1\
**Last updated:** [December 22, 2019, 3:40pm UTC](https://discourse.julialang.org/t/show-methods-for-types/32578 "2019-12-22T15:40:23Z")

</div>

In this issue, @jeff.bezanson advises that we shouldn’t override how types are printed. But in some cases, particularly for type-level representations as @thautwarm is developing (and are used heavily in Soss), the defa…

---

## [Mutable field in immutable type](https://discourse.julialang.org/t/mutable-field-in-immutable-type/3103)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 7\
**Last updated:** [December 22, 2019, 2:20pm UTC](https://discourse.julialang.org/t/mutable-field-in-immutable-type/3103 "2019-12-22T14:20:43Z")

</div>

I sometimes need to change the value in a single field of an instance of an immutable type. This is especially useful when an instance of this type is spread around different places and I need to update one of its values…

---

## [Break Dictionary arrange key](https://discourse.julialang.org/t/break-dictionary-arrange-key/32552)

<div class="topic-metadata">

**Author:** [@imrankhan\_juliaLang](https://discourse.julialang.org/u/imrankhan_juliaLang)\
**Replies:** 2\
**Last updated:** [December 22, 2019, 12:04pm UTC](https://discourse.julialang.org/t/break-dictionary-arrange-key/32552 "2019-12-22T12:04:52Z")

</div>

my dictionary keys is not same after set Set dictionary after set dictionary Code Result = Dict("Ada Boost" =\> Dict(), "Decision Tree" =\> Dict(), "Linear Model" =\> Dict(), …

---

## [Allocations with anonymous functions](https://discourse.julialang.org/t/allocations-with-anonymous-functions/32564)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 4\
**Last updated:** [December 21, 2019, 10:56pm UTC](https://discourse.julialang.org/t/allocations-with-anonymous-functions/32564 "2019-12-21T22:56:02Z")

</div>

I was experimenting with StaticArrays.jl, and noticed the following issue with memory allocations. Consider the following example code: using Random using StaticArrays function f1(X, h, D) Y = D.\*X- h; return …

---

## [Spherical Bessel functions](https://discourse.julialang.org/t/spherical-bessel-functions/32487)

<div class="topic-metadata">

**Author:** [@urp](https://discourse.julialang.org/u/urp)\
**Replies:** 9\
**Last updated:** [December 21, 2019, 8:21pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487 "2019-12-21T20:21:32Z")

</div>

Is “spherical Bessel function” available in any of the libraries in Julia? I am aware that SpecialFunctions.jl package has Bessel function.

---

## [Keeping modules "clean" when including files](https://discourse.julialang.org/t/keeping-modules-clean-when-including-files/32525)

<div class="topic-metadata">

**Author:** [@csavorgn](https://discourse.julialang.org/u/csavorgn)\
**Replies:** 2\
**Last updated:** [December 21, 2019, 5:11pm UTC](https://discourse.julialang.org/t/keeping-modules-clean-when-including-files/32525 "2019-12-21T17:11:44Z")

</div>

Hi, I’m writing a module to test the code of a project I’m working on. I though of using multiple files containing the input data and then combine them to obtain all the test cases I need. To better explain what I want…

---

## [Finalizer only works with mutable structs?](https://discourse.julialang.org/t/finalizer-only-works-with-mutable-structs/28777)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 74\
**Last updated:** [December 21, 2019, 4:36pm UTC](https://discourse.julialang.org/t/finalizer-only-works-with-mutable-structs/28777 "2019-12-21T16:36:57Z")

</div>

The finalizer function has the following doc string: finalizer(f, x) Register a function f(x) to be called when there are no program-accessible references to x, and return x. The type of x must be a mutable struct, o…

---

## [Performance of Float32 exponential](https://discourse.julialang.org/t/performance-of-float32-exponential/32549)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 4\
**Last updated:** [December 21, 2019, 3:07pm UTC](https://discourse.julialang.org/t/performance-of-float32-exponential/32549 "2019-12-21T15:07:28Z")

</div>

@LaurentPlagne and myself recently noticed the following surprising performances: julia\> using BenchmarkTools julia\> N = 100\_000 julia\> x32 = rand(Float32, N); julia\> x64 = Float64.(x32); julia\> sumExpStd(x) = sum(exp,…

---

## [Replacement of eigs?](https://discourse.julialang.org/t/replacement-of-eigs/13540)

<div class="topic-metadata">

**Author:** [@axsk](https://discourse.julialang.org/u/axsk)\
**Replies:** 9\
**Last updated:** [December 21, 2019, 11:58am UTC](https://discourse.julialang.org/t/replacement-of-eigs/13540 "2019-12-21T11:58:07Z")

</div>

Given a matrix A I need to compute the eigenvector matching the dominating eigenvalue. In 0.6 I used v = eigs(A, nev = 1, which=:LM) I cannot find anything similar in 1.0. How do I compute this eigenvector without co…

---

## [Unexpectedly long method signature in "Closest candidates" list](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 4\
**Last updated:** [December 21, 2019, 11:04am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537 "2019-12-21T11:04:31Z")

</div>

I just came across this frighteningly long method signature in the “Closest candidates” list of methods after a MethodError: julia\> x, y = \[1, 2\], \[3, 4\]; julia\> x \* y ERROR: MethodError: no method matching \*(::Array{I…

---

## [How can i convert number string array to int array](https://discourse.julialang.org/t/how-can-i-convert-number-string-array-to-int-array/32536)

<div class="topic-metadata">

**Author:** [@imrankhan\_juliaLang](https://discourse.julialang.org/u/imrankhan_juliaLang)\
**Replies:** 4\
**Last updated:** [December 21, 2019, 10:50am UTC](https://discourse.julialang.org/t/how-can-i-convert-number-string-array-to-int-array/32536 "2019-12-21T10:50:14Z")

</div>

Need help to convert string number array to int array Like \[“0”, “1”, “0”, “1”, “0”, “1”, “1”, “1”\] To \[0, 1, 0, 1, 0, 1, 1, 1\] NB: Without use this code \[parse(Int, x) for x in array\] because this method is too s…

---

## [A type from the same library passed via different paths is not considered identical](https://discourse.julialang.org/t/a-type-from-the-same-library-passed-via-different-paths-is-not-considered-identical/32528)

<div class="topic-metadata">

**Author:** [@fjarri](https://discourse.julialang.org/u/fjarri)\
**Replies:** 3\
**Last updated:** [December 21, 2019, 4:05am UTC](https://discourse.julialang.org/t/a-type-from-the-same-library-passed-via-different-paths-is-not-considered-identical/32528 "2019-12-21T04:05:23Z")

</div>

I’ve encountered a strange situation while setting up CI for one of my projects. I have a package LogProof that uses another package, DarkIntegers. DarkIntegers is in the Julia registry, LogProof isn’t. LogProof tests f…

---

## [Does julia support chaining of collections methods / function chaining at this point?](https://discourse.julialang.org/t/does-julia-support-chaining-of-collections-methods-function-chaining-at-this-point/32519)

<div class="topic-metadata">

**Author:** [@javadba](https://discourse.julialang.org/u/javadba)\
**Replies:** 1\
**Last updated:** [December 20, 2019, 7:30pm UTC](https://discourse.julialang.org/t/does-julia-support-chaining-of-collections-methods-function-chaining-at-this-point/32519 "2019-12-20T19:30:07Z")

</div>

There is a moderately long JIRA about function chaining https://github.com/JuliaLang/julia/issues/5571 . It is unclear what if anything resulted from that JIRA - and thus in what form chaining is presently supported. Cl…

---

## [What is going on with memory locality when accessing an array?](https://discourse.julialang.org/t/what-is-going-on-with-memory-locality-when-accessing-an-array/32486)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 6\
**Last updated:** [December 20, 2019, 6:37pm UTC](https://discourse.julialang.org/t/what-is-going-on-with-memory-locality-when-accessing-an-array/32486 "2019-12-20T18:37:23Z")

</div>

I presented an example of access to an array: read and write. The aspect of this that puzzles me is the unexpected win of the storage scheme where the accessed entries of the array are not adjacent in memory. Is there a…

---

## [Matrix Free transpose jacobian using AD](https://discourse.julialang.org/t/matrix-free-transpose-jacobian-using-ad/32511)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 7\
**Last updated:** [December 20, 2019, 4:35pm UTC](https://discourse.julialang.org/t/matrix-free-transpose-jacobian-using-ad/32511 "2019-12-20T16:35:43Z")

</div>

Hi, I would like to evaluate the transpose of the jacobian of a function F using ForwardDiff.jl or any AD. Is it possible? I read that reverse mode would provide this but failed to achieve this using ReverseDiff.jl. I …

---

## [Is there a simple way to generate uniform points within a given region?](https://discourse.julialang.org/t/is-there-a-simple-way-to-generate-uniform-points-within-a-given-region/29800)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 6\
**Last updated:** [December 20, 2019, 3:28pm UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-generate-uniform-points-within-a-given-region/29800 "2019-12-20T15:28:28Z")

</div>

I’m looking for a way to generate a mesh with given region. Basically I want things like the Fig 1 in https://doc.freefem.org/tutorials/poisson.html. What I need are just the vertices. The triangles are not important t…

---

## [Agent Based Model visualization in Gtk](https://discourse.julialang.org/t/agent-based-model-visualization-in-gtk/32518)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 0\
**Last updated:** [December 20, 2019, 3:13pm UTC](https://discourse.julialang.org/t/agent-based-model-visualization-in-gtk/32518 "2019-12-20T15:13:51Z")

</div>

Hi all- I would like to create a simple 2D visualization of an agent based model in Gtk. My current approach involves creating a window and drawing colored rectangles to represent agents, following the online documenta…

---

## [Can this loop be optimized further?](https://discourse.julialang.org/t/can-this-loop-be-optimized-further/32510)

<div class="topic-metadata">

**Author:** [@Dictino](https://discourse.julialang.org/u/Dictino)\
**Replies:** 7\
**Last updated:** [December 20, 2019, 2:51pm UTC](https://discourse.julialang.org/t/can-this-loop-be-optimized-further/32510 "2019-12-20T14:51:01Z")

</div>

I have this function to find an element in an array: function my\_findfirst(element,array) for i=1:length(array) if @inbounds (array\[i\]==element) return i end end return nothing end I’ve created thi…

---

## [Number of digits in xticks for Plots.jl](https://discourse.julialang.org/t/number-of-digits-in-xticks-for-plots-jl/14533)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 6\
**Last updated:** [December 20, 2019, 2:25pm UTC](https://discourse.julialang.org/t/number-of-digits-in-xticks-for-plots-jl/14533 "2019-12-20T14:25:23Z")

</div>

Hi all- I have a crowding issue on the scale of my x-axis because too many digits are displayed. I tried to round the values I pass to xticks, but that did not help. Is there any way to control the number of digits that…

---

## [Missing package error when running script with Julia GitHub Actions](https://discourse.julialang.org/t/missing-package-error-when-running-script-with-julia-github-actions/32509)

<div class="topic-metadata">

**Author:** [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Replies:** 2\
**Last updated:** [December 20, 2019, 1:57pm UTC](https://discourse.julialang.org/t/missing-package-error-when-running-script-with-julia-github-actions/32509 "2019-12-20T13:57:26Z")

</div>

Hey all, I am trying to run a script via GitHub actions. I set up and build Julia via those respective GitHub actions. But when I run my script, line 1 is using StackOverflow and even though I see it show up as installed…

---

## [Ignoring NaN in elementwise aggregations](https://discourse.julialang.org/t/ignoring-nan-in-elementwise-aggregations/32431)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 7\
**Last updated:** [December 20, 2019, 9:43am UTC](https://discourse.julialang.org/t/ignoring-nan-in-elementwise-aggregations/32431 "2019-12-20T09:43:04Z")

</div>

I would like to do calculations like mean(a\_bunch\_of\_similar\_arrays) but with NaNs quietly ignored. MWE with an inefficient and inelegant solution: A1 = \[NaN 1; 2 3\] A2 = \[1 NaN; 2 3\] As = \[A1, A2\] function elemen…

---

## [Multiply each slice of an array by a different number](https://discourse.julialang.org/t/multiply-each-slice-of-an-array-by-a-different-number/32501)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 7\
**Last updated:** [December 20, 2019, 9:05am UTC](https://discourse.julialang.org/t/multiply-each-slice-of-an-array-by-a-different-number/32501 "2019-12-20T09:05:59Z")

</div>

I want to multiply each slice of an array by a different number. I want to do it for arbitrary array and slice dimensions, inplace and efficient if possible. How to do this? Here is an example: Multipy each row of a mat…

---

## [Differences in collecting algebraic terms or not](https://discourse.julialang.org/t/differences-in-collecting-algebraic-terms-or-not/32488)

<div class="topic-metadata">

**Author:** [@Donkeyfish87](https://discourse.julialang.org/u/Donkeyfish87)\
**Replies:** 5\
**Last updated:** [December 19, 2019, 9:34pm UTC](https://discourse.julialang.org/t/differences-in-collecting-algebraic-terms-or-not/32488 "2019-12-19T21:34:11Z")

</div>

Why is there a difference between function sum\_of\_squares(n::Int) div(n\*(n+1)\*(2n+1), 6) end function square\_of\_sum(n::Int) div(n\*(n+1),2)^2 end function difference(n::Int) square\_of\_sum(n) - sum\_of\_square…

---

## [Efficient way to update a DataFrame stored in a bson file](https://discourse.julialang.org/t/efficient-way-to-update-a-dataframe-stored-in-a-bson-file/32482)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 3\
**Last updated:** [December 19, 2019, 8:30pm UTC](https://discourse.julialang.org/t/efficient-way-to-update-a-dataframe-stored-in-a-bson-file/32482 "2019-12-19T20:30:13Z")

</div>

Hi, I have two DataFrames: df and new\_df. These DataFrames have the same structure (i.e., the same columns). df is stored in a bson file and new\_df is computed by some code. I was wondering what is the most efficient w…

---

## [Avoid unnecessary computations with (sparse) Arrays](https://discourse.julialang.org/t/avoid-unnecessary-computations-with-sparse-arrays/32473)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 2\
**Last updated:** [December 19, 2019, 1:17pm UTC](https://discourse.julialang.org/t/avoid-unnecessary-computations-with-sparse-arrays/32473 "2019-12-19T13:17:21Z")

</div>

Hi, I would like to avoid unnecessary computations in computing shifts of matrices like for example 0\*I + 1\*J. I thought about the code below, but this is not really a viable strategy because I would like to dispatch on…

---

## [Are functions the same as closures in this case?](https://discourse.julialang.org/t/are-functions-the-same-as-closures-in-this-case/32467)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 8\
**Last updated:** [December 19, 2019, 12:28pm UTC](https://discourse.julialang.org/t/are-functions-the-same-as-closures-in-this-case/32467 "2019-12-19T12:28:10Z")

</div>

Are these functions/closures examples: function main() a = 1.0 b = 5.0 function f1(t) return a \* t + b end f2(t) = a \* t + b f3 = t -\> a \* t + b solver(f1, f2, f3) return nothing end the same w…

---

## [Handle differential equations with size varying state vector](https://discourse.julialang.org/t/handle-differential-equations-with-size-varying-state-vector/32377)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 2\
**Last updated:** [December 19, 2019, 9:54am UTC](https://discourse.julialang.org/t/handle-differential-equations-with-size-varying-state-vector/32377 "2019-12-19T09:54:20Z")

</div>

Hello, I am working on time marching of ODEs with size varying state vector. I would like to use the integrator interface of DifferentialEquations to do so. Here is a toy problem with the error. du is computed based on…

---

## [Can we exploit binary builder as a general way to distribute softwares?](https://discourse.julialang.org/t/can-we-exploit-binary-builder-as-a-general-way-to-distribute-softwares/32472)

<div class="topic-metadata">

**Author:** [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Replies:** 1\
**Last updated:** [December 19, 2019, 7:48am UTC](https://discourse.julialang.org/t/can-we-exploit-binary-builder-as-a-general-way-to-distribute-softwares/32472 "2019-12-19T07:48:23Z")

</div>

Often one may have a clean server without root. Building everything from source is okay but I recently found the treasure of binary builder artifacts at https://github.com/JuliaBinaryWrappers. I wrote an install script f…

---

## [Changing missing logic](https://discourse.julialang.org/t/changing-missing-logic/32449)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 6\
**Last updated:** [December 18, 2019, 8:45pm UTC](https://discourse.julialang.org/t/changing-missing-logic/32449 "2019-12-18T20:45:30Z")

</div>

I really like to use missing, but there are some instances where it becomes annoying. First, logical indexing. Second, when a package hasn’t implemented a safety method f(missing)=missing. For example, suppose I read in…

---

## [Creating a math website based on Julia](https://discourse.julialang.org/t/creating-a-math-website-based-on-julia/32448)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 3\
**Last updated:** [December 18, 2019, 8:10pm UTC](https://discourse.julialang.org/t/creating-a-math-website-based-on-julia/32448 "2019-12-18T20:10:50Z")

</div>

Recently, I have been making some nice webpages with the Julia Documenter and \\LaTeX. I also have a WordPress based website, which I am thinking of replacing with a Julia generated. What are the different options out t…

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

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