# General Usage

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

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

**Page:** 570

---

## [Surprising (?) behaviour of assignment-update operators](https://discourse.julialang.org/t/surprising-behaviour-of-assignment-update-operators/65431)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 8\
**Last updated:** [July 28, 2021, 1:57pm UTC](https://discourse.julialang.org/t/surprising-behaviour-of-assignment-update-operators/65431 "2021-07-28T13:57:29Z")

</div>

It seems like f -= a is actually exactly equivalent to f = f - a. This surprised me because I’d naively expected -= to be update-in-place, so that I wouldn’t need a View when f is an Array slice, but actually it seems I …

---

## [Plot with x-axis in radians with ticks at multiples of pi](https://discourse.julialang.org/t/plot-with-x-axis-in-radians-with-ticks-at-multiples-of-pi/65325)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 3\
**Last updated:** [July 27, 2021, 8:33am UTC](https://discourse.julialang.org/t/plot-with-x-axis-in-radians-with-ticks-at-multiples-of-pi/65325 "2021-07-27T08:33:27Z")

</div>

I have a plot where the x-axis is an angle in radians. Is there an easy way to make the ticks and the tick labels be multiples of pi? For example, I would like to obtain a figure like this:

---

## [Why does broadcast operation allocate?](https://discourse.julialang.org/t/why-does-broadcast-operation-allocate/65428)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [July 28, 2021, 11:06am UTC](https://discourse.julialang.org/t/why-does-broadcast-operation-allocate/65428 "2021-07-28T11:06:21Z")

</div>

Why does this broadcasting allocate? julia\> a = rand(241); b = rand(241); julia\> @time a .-= b; 0.111315 seconds (188.85 k allocations: 11.037 MiB, 99.59% compilation time) julia\> @time a .-= b; 0.000016 seconds (…

---

## [Julia 1.6 Stacktrace](https://discourse.julialang.org/t/julia-1-6-stacktrace/57981)

<div class="topic-metadata">

**Author:** [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)\
**Replies:** 20\
**Last updated:** [July 28, 2021, 1:16am UTC](https://discourse.julialang.org/t/julia-1-6-stacktrace/57981 "2021-07-28T01:16:28Z")

</div>

Hi good folks! I like the idea of trying to make the fairly cluttered stacktrace more readable by “syntax” highlighting. However, I don’t get the choices introduced in 1.6 at all. The filename and row number are probabl…

---

## [Modify a dictionary under a new name modifies the original dictionary](https://discourse.julialang.org/t/modify-a-dictionary-under-a-new-name-modifies-the-original-dictionary/65398)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 6\
**Last updated:** [July 27, 2021, 8:00pm UTC](https://discourse.julialang.org/t/modify-a-dictionary-under-a-new-name-modifies-the-original-dictionary/65398 "2021-07-27T20:00:07Z")

</div>

x=Dict( row=\> DataFrame( y=1) ) z=x push!(z, y=2) x gives me 1,2 How do I get it to only give me 1?

---

## [Why does my devectorized code keep allocating memory?](https://discourse.julialang.org/t/why-does-my-devectorized-code-keep-allocating-memory/62727)

<div class="topic-metadata">

**Author:** [@WouterJRV](https://discourse.julialang.org/u/WouterJRV)\
**Replies:** 14\
**Last updated:** [July 27, 2021, 6:50pm UTC](https://discourse.julialang.org/t/why-does-my-devectorized-code-keep-allocating-memory/62727 "2021-07-27T18:50:17Z")

</div>

I am trying to solve a complex Ginzburg-Landau equation in Julia, defined by function CGLfun!(du,u,p,t) NBmat,gridsize,η,g,V,α,σ=p du.=1im\*(1 .-1im\*η).\*(NBmat\*u.-4\*u)/gridsize^2 +(.-(1im).\*V+α.-(σ.+1im\*g).\*abs2.(u))…

---

## [From Float type to Integer](https://discourse.julialang.org/t/from-float-type-to-integer/65392)

<div class="topic-metadata">

**Author:** [@juls](https://discourse.julialang.org/u/juls)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 5:18pm UTC](https://discourse.julialang.org/t/from-float-type-to-integer/65392 "2021-07-27T17:18:15Z")

</div>

Hi, I wanted to obtain integer output instead of float type output from functions: floor(4.56), ceil(4.56). I would be glad to know how to obtain integer output for the same. Also, I read in documentation, interger di…

---

## [New Julia install: Downloading artifacts fails behind proxy](https://discourse.julialang.org/t/new-julia-install-downloading-artifacts-fails-behind-proxy/43816)

<div class="topic-metadata">

**Author:** [@danburns](https://discourse.julialang.org/u/danburns)\
**Replies:** 2\
**Last updated:** [July 27, 2021, 4:40pm UTC](https://discourse.julialang.org/t/new-julia-install-downloading-artifacts-fails-behind-proxy/43816 "2021-07-27T16:40:32Z")

</div>

I am installing Julia 1.4.2 on a new computer (MacOS), which is behind an http/https proxy. I have exported environment variables in the shell to set proxy variables: HTTP\_PROXY=http://\<company.server\>:3128 HTTPS\_PROXY=…

---

## [How can I find the subset of dataframe that contain elements with Number datatype?](https://discourse.julialang.org/t/how-can-i-find-the-subset-of-dataframe-that-contain-elements-with-number-datatype/65388)

<div class="topic-metadata">

**Author:** [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Replies:** 2\
**Last updated:** [July 27, 2021, 4:32pm UTC](https://discourse.julialang.org/t/how-can-i-find-the-subset-of-dataframe-that-contain-elements-with-number-datatype/65388 "2021-07-27T16:32:29Z")

</div>

Hi, I am trying to find subset of dataframe having elements with Number datatypes. But I couldn’t find any single function to find the subset. So I have implemented as #df is the dataframe with columns having Number an…

---

## [LoopVectorization triggers segfault or deadlock for complex finite difference stencil](https://discourse.julialang.org/t/loopvectorization-triggers-segfault-or-deadlock-for-complex-finite-difference-stencil/65217)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 3:54pm UTC](https://discourse.julialang.org/t/loopvectorization-triggers-segfault-or-deadlock-for-complex-finite-difference-stencil/65217 "2021-07-27T15:54:04Z")

</div>

I have written a finite difference 4th-order stencil generator macro and use the @tturbo to accelerate my loop. My code gives perfect results for a single thread run, but triggers either a segfault or a deadlock in multi…

---

## [Registered package not showing up in general when running docs](https://discourse.julialang.org/t/registered-package-not-showing-up-in-general-when-running-docs/65381)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 3:33pm UTC](https://discourse.julialang.org/t/registered-package-not-showing-up-in-general-when-running-docs/65381 "2021-07-27T15:33:32Z")

</div>

Hi there, I registered TypeClasses 1.1.0 however my documenter run within github actions is not able to find it I get Run julia --project=docs -e ' Resolving package versions... Installing known registries into \`…

---

## [How to create an empty TimeArray](https://discourse.julialang.org/t/how-to-create-an-empty-timearray/65372)

<div class="topic-metadata">

**Author:** [@Yuan\_Jiun\_Thai](https://discourse.julialang.org/u/Yuan_Jiun_Thai)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 2:55pm UTC](https://discourse.julialang.org/t/how-to-create-an-empty-timearray/65372 "2021-07-27T14:55:47Z")

</div>

How could I create an empty Time Array? I would like to “vcat” a few TimeArrays using for loop, but I would need an empty TimeArray to initialize the for loop. May I know how could I do that?

---

## [How to do I define a struct A which refer a struct B which refer A?](https://discourse.julialang.org/t/how-to-do-i-define-a-struct-a-which-refer-a-struct-b-which-refer-a/65373)

<div class="topic-metadata">

**Author:** [@zwtechnb](https://discourse.julialang.org/u/zwtechnb)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 2:16pm UTC](https://discourse.julialang.org/t/how-to-do-i-define-a-struct-a-which-refer-a-struct-b-which-refer-a/65373 "2021-07-27T14:16:00Z")

</div>

For example: mutable struct A a::Int b::Ref{B} end mutable struct B b::Int a::Ref{A} end

---

## [Subtype or enum, which is prefer?](https://discourse.julialang.org/t/subtype-or-enum-which-is-prefer/65359)

<div class="topic-metadata">

**Author:** [@HaoxuanGuo](https://discourse.julialang.org/u/HaoxuanGuo)\
**Replies:** 8\
**Last updated:** [July 27, 2021, 2:10pm UTC](https://discourse.julialang.org/t/subtype-or-enum-which-is-prefer/65359 "2021-07-27T14:10:47Z")

</div>

abstract type AbstractFruit end struct Apple \<: AbstractFruit end struct Banana \<: AbstractFruit end struct Pear \<: AbstractFruit end color(::Apple) = :red color(::Banana) = :yellow color(::Pear) = :green and @enum Fr…

---

## [Get path to julia install?](https://discourse.julialang.org/t/get-path-to-julia-install/65315)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 4\
**Last updated:** [July 27, 2021, 1:47pm UTC](https://discourse.julialang.org/t/get-path-to-julia-install/65315 "2021-07-27T13:47:56Z")

</div>

I’ve been doing some memory profiling using --track-allocation=all. This puts output files in the same location as the source files, including in the base julia install, e.g. base/multidimensional.jl.27819.mem. Now I kno…

---

## [How do you indicate that a field should be private?](https://discourse.julialang.org/t/how-do-you-indicate-that-a-field-should-be-private/65339)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 3\
**Last updated:** [July 27, 2021, 12:32pm UTC](https://discourse.julialang.org/t/how-do-you-indicate-that-a-field-should-be-private/65339 "2021-07-27T12:32:25Z")

</div>

In C#/Java we can do so with the private keyword, in Python we can use the underscore. I found this discussion on Github, but it’s from 2015. Is the accepted convention to use the underscore? struct Example \_this\_f…

---

## [Julia + named pipe crashing bash](https://discourse.julialang.org/t/julia-named-pipe-crashing-bash/65362)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 10:17am UTC](https://discourse.julialang.org/t/julia-named-pipe-crashing-bash/65362 "2021-07-27T10:17:52Z")

</div>

@bkamins proposes in this post a way to use Julia over a named pipe. Executing the code mkfifo pipe julia \<pipe \>log.txt 2\>err.txt & exec 3\>pipe echo "1+2" \>&3 echo "X" \>&3 echo "exit()" \>&3 cat log.txt cat err.txt i…

---

## [BoundsError: attempt to access 0-element Array{Any,1} at index \[1\]](https://discourse.julialang.org/t/boundserror-attempt-to-access-0-element-array-any-1-at-index-1/65360)

<div class="topic-metadata">

**Author:** [@kip0d](https://discourse.julialang.org/u/kip0d)\
**Replies:** 3\
**Last updated:** [July 27, 2021, 10:12am UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-0-element-array-any-1-at-index-1/65360 "2021-07-27T10:12:09Z")

</div>

Hello, this is my code: distvec = \[\] for indm = 1:M global distvec distvec\[indm\] = -(-Nvec\[1\]\* px\[indm\]- Nvec\[2\]\* py\[indm\]- Nvec\[3\]\* pz\[indm\])/sqrt(Nvec\[1\]^2+Nvec\[2\]^2+Nvec\[3\]^2) end The error I get: BoundsEr…

---

## [Creating an AbstractDataFrame subtype](https://discourse.julialang.org/t/creating-an-abstractdataframe-subtype/36451)

<div class="topic-metadata">

**Author:** [@DrPapa](https://discourse.julialang.org/u/DrPapa)\
**Replies:** 21\
**Last updated:** [July 27, 2021, 9:12am UTC](https://discourse.julialang.org/t/creating-an-abstractdataframe-subtype/36451 "2021-07-27T09:12:53Z")

</div>

I wish to create a new subtype of AbstractDataFrame that has a single DataFrame member. I then want to forward the AbstractDataFrame interface to the DataFrame member. Something like: using DataFrames using Lazy struct…

---

## [Add testing for memory allocations](https://discourse.julialang.org/t/add-testing-for-memory-allocations/49398)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 13\
**Last updated:** [July 27, 2021, 8:32am UTC](https://discourse.julialang.org/t/add-testing-for-memory-allocations/49398 "2021-07-27T08:32:21Z")

</div>

In the last few days I have been working in eliminating all unnecessary allocations in a package, found some type-instabilities, etc, and everything is much better now. I created, then, a set of tests to evaluate if, in…

---

## [(L-)BFGS for a user-defined function](https://discourse.julialang.org/t/l-bfgs-for-a-user-defined-function/65309)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 6\
**Last updated:** [July 27, 2021, 6:28am UTC](https://discourse.julialang.org/t/l-bfgs-for-a-user-defined-function/65309 "2021-07-27T06:28:12Z")

</div>

Hi, I have a complex nonlinear user-defined function (blackbox) that I am trying to minimize using BFGS or L-BFGS. I found this library, but I can’t use it. I think it works only for simple algebraic expressions, it th…

---

## [Check distributed Task status](https://discourse.julialang.org/t/check-distributed-task-status/65341)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 0\
**Last updated:** [July 27, 2021, 3:19am UTC](https://discourse.julialang.org/t/check-distributed-task-status/65341 "2021-07-27T03:19:41Z")

</div>

I am running a long session which contains an@distributed job. I forgot to assign the @distributed Task to a variable and now I don’t have a reference to it. Now I want to check when it’s finished. Is it possible to find…

---

## [JuliaFormatter.jl Alignment Help](https://discourse.julialang.org/t/juliaformatter-jl-alignment-help/65313)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 3\
**Last updated:** [July 27, 2021, 1:26am UTC](https://discourse.julialang.org/t/juliaformatter-jl-alignment-help/65313 "2021-07-27T01:26:42Z")

</div>

I’ve been experimenting with JuliaFormatter v0.15.1 with 1.6.2 and I’ve had some trouble using the alignment flags. I have not changed any default settings or defined a JuliaFormatter.toml file. Here’s the contents of m…

---

## [Reduce allocations and speed up](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 15\
**Last updated:** [July 27, 2021, 1:12am UTC](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221 "2021-07-27T01:12:50Z")

</div>

Hi there, in my attempt to teach myself Julia, I’m solving Project Euler problems. The following code works and give the correct answer, although I was expecting better performance, as the time is similar to what I got …

---

## [Could this function be faster?](https://discourse.julialang.org/t/could-this-function-be-faster/64710)

<div class="topic-metadata">

**Author:** [@babaq](https://discourse.julialang.org/u/babaq)\
**Replies:** 13\
**Last updated:** [July 27, 2021, 12:03am UTC](https://discourse.julialang.org/t/could-this-function-be-faster/64710 "2021-07-27T00:03:20Z")

</div>

Hi, I recently have to read raw images from a camera. The pixel format is Mono color 12bit packed. I first tried a MATLAB version which managed to read&unpack in ~30ms for a 2080\*2080 image. Here is a julia version…

---

## [How to change from random walk ro self avoiding random walk in Julia](https://discourse.julialang.org/t/how-to-change-from-random-walk-ro-self-avoiding-random-walk-in-julia/65268)

<div class="topic-metadata">

**Author:** [@Struggling\_Student](https://discourse.julialang.org/u/Struggling_Student)\
**Replies:** 7\
**Last updated:** [July 26, 2021, 9:42pm UTC](https://discourse.julialang.org/t/how-to-change-from-random-walk-ro-self-avoiding-random-walk-in-julia/65268 "2021-07-26T21:42:19Z")

</div>

Could someone help me to change the random walk to self-avoiding random walk? I tried to do that but without success. Below is the code for the random walk, that works: using StatsBase, LinearAlgebra # Here I defined t…

---

## [Discussion on ThreadPools.jl](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 5\
**Last updated:** [July 26, 2021, 6:59pm UTC](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283 "2021-07-26T18:59:02Z")

</div>

Continuing the discussion from Multithreaded compute farm: @tkf could you explain this a little more? I always assumed / hoped that ThreadPools would eventually be made obsolete by Julia’s evolution, but I haven’t seen…

---

## [Setfield fails for structs with "label"-like type annotations](https://discourse.julialang.org/t/setfield-fails-for-structs-with-label-like-type-annotations/65324)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [July 26, 2021, 6:27pm UTC](https://discourse.julialang.org/t/setfield-fails-for-structs-with-label-like-type-annotations/65324 "2021-07-26T18:27:37Z")

</div>

Is this expected to fail? julia\> using Setfield julia\> struct C{S,T} i::T end julia\> c = C{Float64,Int}(1) C{Float64, Int64}(1) julia\> @set! c.i = 2 ERROR: MethodError: no method matching C(::Int64) …

---

## [Fastest way to partition array, given a condition](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 26\
**Last updated:** [July 26, 2021, 6:27pm UTC](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243 "2021-07-26T18:27:00Z")

</div>

I need to sort (usually small, i. e. 5 to 20 elements, but the algorithm cannot scale badly) arrays, but only partially. That is, I need that the elements get split into elements smaller than a cutoff, and elements great…

---

## [How to make linspace work with one point?](https://discourse.julialang.org/t/how-to-make-linspace-work-with-one-point/5335)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 8\
**Last updated:** [July 26, 2021, 5:30pm UTC](https://discourse.julialang.org/t/how-to-make-linspace-work-with-one-point/5335 "2021-07-26T17:30:38Z")

</div>

Currently, linspace(1,10,1) returns ERROR: ArgumentError: linspace(1.0, 10.0, 1): endpoints differ What’s the way to use multiple dispatch to grab the value of 1 and make a method like: linspace(a,b,1) = a:1.0:a I…

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

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