# General Usage

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

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

**Page:** 727

---

## [Type check Array vs UnitRange inside a struct](https://discourse.julialang.org/t/type-check-array-vs-unitrange-inside-a-struct/43154)

<div class="topic-metadata">

**Author:** [@hdavid16](https://discourse.julialang.org/u/hdavid16)\
**Replies:** 1\
**Last updated:** [July 16, 2020, 3:45am UTC](https://discourse.julialang.org/t/type-check-array-vs-unitrange-inside-a-struct/43154 "2020-07-16T03:45:54Z")

</div>

Type checking seems to be off within structs when it comes to Arrays and UnitRanges. Defining a function with an argument that is of type Array forbids supplying a UnitRange as an input. However, when a struct is defined…

---

## [Variable not defined in module](https://discourse.julialang.org/t/variable-not-defined-in-module/43147)

<div class="topic-metadata">

**Author:** [@Lewis\_Liu](https://discourse.julialang.org/u/Lewis_Liu)\
**Replies:** 5\
**Last updated:** [July 15, 2020, 9:46pm UTC](https://discourse.julialang.org/t/variable-not-defined-in-module/43147 "2020-07-15T21:46:05Z")

</div>

module TestN1 sum=1 for i in 1:10 sum += i end end The code above doesn’t work. Is something wrong？ Julia version 1.4.2.

---

## [What is the Package Host URL?](https://discourse.julialang.org/t/what-is-the-package-host-url/43137)

<div class="topic-metadata">

**Author:** [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Replies:** 5\
**Last updated:** [July 15, 2020, 8:10pm UTC](https://discourse.julialang.org/t/what-is-the-package-host-url/43137 "2020-07-15T20:10:45Z")

</div>

I’m looking at the web form on JuliaHub. What is the Package Host URL? If the package URL is https://github.com/DrFoo/Bar.jl is the Package host URL https://github.com or something else? I think I’m missing something p…

---

## [Where do all the packages come from?](https://discourse.julialang.org/t/where-do-all-the-packages-come-from/43135)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 7\
**Last updated:** [July 15, 2020, 8:07pm UTC](https://discourse.julialang.org/t/where-do-all-the-packages-come-from/43135 "2020-07-15T20:07:07Z")

</div>

Today I was testing one of my packages with the nightly Julia. I noticed that the list of packages during “update” was several dozen entries long. I don’t know how it got so long: I’m pretty sure that most of these pack…

---

## [Multithreading throw segmentfault occationally](https://discourse.julialang.org/t/multithreading-throw-segmentfault-occationally/43132)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [July 15, 2020, 5:09pm UTC](https://discourse.julialang.org/t/multithreading-throw-segmentfault-occationally/43132 "2020-07-15T17:09:04Z")

</div>

Hi I’m wondering if this is some kind of known issue, basically I have one simulation task for each Task, and I spawn 72 threads to execute these tasks, then my code throw a segment fault from the BLAS when I create 160 …

---

## [Optimize combination of element-wise products and matrix multiplication](https://discourse.julialang.org/t/optimize-combination-of-element-wise-products-and-matrix-multiplication/43088)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 10\
**Last updated:** [July 15, 2020, 4:38pm UTC](https://discourse.julialang.org/t/optimize-combination-of-element-wise-products-and-matrix-multiplication/43088 "2020-07-15T16:38:31Z")

</div>

Hello everyone, I heavily use the following operation in my code: d = (A .\* B)\*c where A, B \\in R^{n\_x,n\_y}, c \\in R^{n\_y} and d \\in R^{n\_x}. I couldn’t find a faster way to compute this than the vectorized form d = (…

---

## [InPlace FFT Plan and view](https://discourse.julialang.org/t/inplace-fft-plan-and-view/43016)

<div class="topic-metadata">

**Author:** [@AmarjeetK](https://discourse.julialang.org/u/AmarjeetK)\
**Replies:** 4\
**Last updated:** [July 15, 2020, 4:25pm UTC](https://discourse.julialang.org/t/inplace-fft-plan-and-view/43016 "2020-07-15T16:25:02Z")

</div>

Hi All, I have this view problem with plan\_fft!, Part of the code is below: using FFTW L = (128,16,16); pad = 2; data = rand(ComplexF32,128,16,16); FFT\_buffer = zeros(ComplexF32,128,32,32); FFT\_buffer\[:,1:L\[2\],1:…

---

## [Updating the solution of ODE at every time step](https://discourse.julialang.org/t/updating-the-solution-of-ode-at-every-time-step/43096)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 5\
**Last updated:** [July 15, 2020, 3:14pm UTC](https://discourse.julialang.org/t/updating-the-solution-of-ode-at-every-time-step/43096 "2020-07-15T15:14:45Z")

</div>

I have a system of differential equations solved as following: ## Lets solve the ODE first without using Kalman Filters function theo\_ode!(du,u,p,t) du\[1\] = u\[2\] du\[2\] = -0.01\*u\[2\] - u\[1\] + sin(2\*t) end u₀ = \[0…

---

## [Should readdlm have a default typed value?](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128)

<div class="topic-metadata">

**Author:** [@jmg.duarte](https://discourse.julialang.org/u/jmg.duarte)\
**Replies:** 2\
**Last updated:** [July 15, 2020, 1:57pm UTC](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128 "2020-07-15T13:57:10Z")

</div>

Hello everyone! I’m currently developing a project which requires reading old text files, Fortran formated arrays. Which means I have huge text files like this: 0.0071435 0.00745535 0.00776577 0.00807047 0.…

---

## [Double quotes in run() function](https://discourse.julialang.org/t/double-quotes-in-run-function/43117)

<div class="topic-metadata">

**Author:** [@Bjorn\_De](https://discourse.julialang.org/u/Bjorn_De)\
**Replies:** 2\
**Last updated:** [July 15, 2020, 12:51pm UTC](https://discourse.julialang.org/t/double-quotes-in-run-function/43117 "2020-07-15T12:51:55Z")

</div>

Hi, I want to execute an external tool out of Julia using the run() function: run(\`gdal\_translate -of GTiff HDF4\_EOS:EOS\_GRID:"$(hdf\_path)":MODIS\_Grid\_16DAY\_500m\_VI:"500m 16 days NDVI" $gtiff\_path\`) which produces an …

---

## [Remove a package from dependencies](https://discourse.julialang.org/t/remove-a-package-from-dependencies/43056)

<div class="topic-metadata">

**Author:** [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Replies:** 7\
**Last updated:** [July 15, 2020, 11:03am UTC](https://discourse.julialang.org/t/remove-a-package-from-dependencies/43056 "2020-07-15T11:03:26Z")

</div>

I made a package that has Mamba in its dependencies and now i want to delete it, because whenever i use this package it shows me warnings about Mamba but the thing is that i don’t really know how can i remove Mamba from …

---

## [Multithreading a loop with ARPACK eigs()](https://discourse.julialang.org/t/multithreading-a-loop-with-arpack-eigs/43031)

<div class="topic-metadata">

**Author:** [@dehond](https://discourse.julialang.org/u/dehond)\
**Replies:** 6\
**Last updated:** [July 15, 2020, 9:30am UTC](https://discourse.julialang.org/t/multithreading-a-loop-with-arpack-eigs/43031 "2020-07-15T09:30:10Z")

</div>

I’m attempting to multithread a calculation in which I loop over a function that calls on ARPACK’s eigs(). However, whenever I insert the Threads.@threads macro in front of the loop I either get an error or Julia crashes…

---

## [Function type signature](https://discourse.julialang.org/t/function-type-signature/43101)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 24\
**Last updated:** [July 15, 2020, 9:17am UTC](https://discourse.julialang.org/t/function-type-signature/43101 "2020-07-15T09:17:31Z")

</div>

I defined two methods of a function, which I thought will have different type signatures: foo((a, b)) = print(a, "--", b) foo(a) = print(a) but I’m getting: julia\> methods(foo) # 1 method for generic function "foo": \[…

---

## [Control Arduino](https://discourse.julialang.org/t/control-arduino/29982)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 33\
**Last updated:** [July 15, 2020, 9:12am UTC](https://discourse.julialang.org/t/control-arduino/29982 "2020-07-15T09:12:43Z")

</div>

Hi! I want to control an LED strip (DotStar) from an Arduino UNO. Is there anything new in this domain? I managed to find these 3 resources: but maybe I missed something, perhaps this has some implications on that? …

---

## [Promote not working for nothing, while promote\_type works](https://discourse.julialang.org/t/promote-not-working-for-nothing-while-promote-type-works/43028)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 8\
**Last updated:** [July 15, 2020, 7:15am UTC](https://discourse.julialang.org/t/promote-not-working-for-nothing-while-promote-type-works/43028 "2020-07-15T07:15:50Z")

</div>

julia\> promote(nothing, 4) ERROR: promotion of types Nothing and Int64 failed to change any arguments Stacktrace: \[1\] error(::String, ::String, ::String) at ./error.jl:42 \[2\] sametype\_error(::Tuple{Nothing,Int64}) at .…

---

## [Initializing array of struct with literals](https://discourse.julialang.org/t/initializing-array-of-struct-with-literals/43073)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 7\
**Last updated:** [July 15, 2020, 6:00am UTC](https://discourse.julialang.org/t/initializing-array-of-struct-with-literals/43073 "2020-07-15T06:00:09Z")

</div>

I have: using Luxor pl = \[Point(0,0), Point(1,1), Point(2,0), Point(3,0), Point(4,0)\] where Luxor.Point is defined as: struct Point x::Float64 y::Float64 end Is there a way to initialize pl without repeating th…

---

## [Neural network in Flux.jl using CUDA is slower](https://discourse.julialang.org/t/neural-network-in-flux-jl-using-cuda-is-slower/43100)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 0\
**Last updated:** [July 15, 2020, 2:47am UTC](https://discourse.julialang.org/t/neural-network-in-flux-jl-using-cuda-is-slower/43100 "2020-07-15T02:47:13Z")

</div>

I definied the same neural network on CPU and GPU but the GPU version is slower, and it’s not due to data transfer as I have already cued the data. Can anyone shed light on this? I am on Julia 1.5rc1 and Flux 0.11 and C…

---

## [Help with NearestNeighbours and array reduction](https://discourse.julialang.org/t/help-with-nearestneighbours-and-array-reduction/43094)

<div class="topic-metadata">

**Author:** [@sparrowhawk](https://discourse.julialang.org/u/sparrowhawk)\
**Replies:** 0\
**Last updated:** [July 15, 2020, 1:13am UTC](https://discourse.julialang.org/t/help-with-nearestneighbours-and-array-reduction/43094 "2020-07-15T01:13:30Z")

</div>

Hi, I’m trying to find a list of points within range of given co-ordinates, using NearestNeighbours using NearestNeighbors coords = \[0. 1 0 1\] balltree = BallTree(coords) rsearch = 1.0 points = \[0.5, 0.5\] i…

---

## [Threads.nthreads() vs Activity Monitor number of threads (macOS)](https://discourse.julialang.org/t/threads-nthreads-vs-activity-monitor-number-of-threads-macos/43078)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 1\
**Last updated:** [July 14, 2020, 9:30pm UTC](https://discourse.julialang.org/t/threads-nthreads-vs-activity-monitor-number-of-threads-macos/43078 "2020-07-14T21:30:39Z")

</div>

I have Threads.nthreads() == 12, but the mac Activity Monitor shows 24 threads: Does anyone know why they’re different?

---

## [Fixing an "explicit requirement" problem](https://discourse.julialang.org/t/fixing-an-explicit-requirement-problem/43076)

<div class="topic-metadata">

**Author:** [@yha](https://discourse.julialang.org/u/yha)\
**Replies:** 1\
**Last updated:** [July 14, 2020, 7:52pm UTC](https://discourse.julialang.org/t/fixing-an-explicit-requirement-problem/43076 "2020-07-14T19:52:27Z")

</div>

I have an odd “Unsatisfiable requirements” problem: (@v1.4) pkg\> resolve ERROR: Unsatisfiable requirements detected for package JuliaFormatter \[98e50ef6\]: JuliaFormatter \[98e50ef6\] log: ├─possible versions are: \[0.1.0…

---

## [Loading modules on remote processes from within a function](https://discourse.julialang.org/t/loading-modules-on-remote-processes-from-within-a-function/43074)

<div class="topic-metadata">

**Author:** [@atteson](https://discourse.julialang.org/u/atteson)\
**Replies:** 1\
**Last updated:** [July 14, 2020, 7:50pm UTC](https://discourse.julialang.org/t/loading-modules-on-remote-processes-from-within-a-function/43074 "2020-07-14T19:50:25Z")

</div>

How can I load modules on remote processes from within a function in process 1. In other words, I’m looking to do something like this: addprocs(3) function load() @everywhere using Distributions end load()

---

## [Fast sum of two sparse matrices and the Hadamard product of sparse and dense matrices](https://discourse.julialang.org/t/fast-sum-of-two-sparse-matrices-and-the-hadamard-product-of-sparse-and-dense-matrices/43029)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 0\
**Last updated:** [July 14, 2020, 10:02am UTC](https://discourse.julialang.org/t/fast-sum-of-two-sparse-matrices-and-the-hadamard-product-of-sparse-and-dense-matrices/43029 "2020-07-14T10:02:22Z")

</div>

Hello all, I would like to obtain the sum of two sparse matrices (see question 1) and the Hadamard product of a sparse matrix and a dense matrix (see question 2). Below is my current implementation. However, it is quite…

---

## [Flux.jl issues](https://discourse.julialang.org/t/flux-jl-issues/43012)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 1\
**Last updated:** [July 14, 2020, 7:41am UTC](https://discourse.julialang.org/t/flux-jl-issues/43012 "2020-07-14T07:41:07Z")

</div>

I am a bit perplexed as to the issue here. I am trying to create a model using Flux critic\_model1 = Chain( boardmove -\> (reshape(boardmove\[1\], 4, 4, 1, 1), boardmove\[2\]), boardmove -\> (Conv((2,2), 1=\>64, relu)(…

---

## [VarArg Dispatch Issue / Possible Bug](https://discourse.julialang.org/t/vararg-dispatch-issue-possible-bug/42993)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [July 14, 2020, 6:07am UTC](https://discourse.julialang.org/t/vararg-dispatch-issue-possible-bug/42993 "2020-07-14T06:07:58Z")

</div>

julia\> typ = Vararg{Any,N} where N Vararg{Any,N} where N julia\> f(x::UnionAll) = :A f (generic function with 1 method) julia\> f(::Type{T}) where T = :B f (generic function with 2 methods) julia\> f(other) = :C f (gener…

---

## [High view description of the folders in .julia?](https://discourse.julialang.org/t/high-view-description-of-the-folders-in-julia/20506)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 8\
**Last updated:** [July 14, 2020, 4:39am UTC](https://discourse.julialang.org/t/high-view-description-of-the-folders-in-julia/20506 "2020-07-14T04:39:06Z")

</div>

Hello, where can I find a discussion, possibly user-centered, about the folders inside .jullia ? I have the following folders: clones compiled conda dev environments logs packages prefs registries What’s the role of …

---

## [An informal comparision of Julia Packages vs Matlab Toolboxes](https://discourse.julialang.org/t/an-informal-comparision-of-julia-packages-vs-matlab-toolboxes/42939)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [July 14, 2020, 12:31am UTC](https://discourse.julialang.org/t/an-informal-comparision-of-julia-packages-vs-matlab-toolboxes/42939 "2020-07-14T00:31:07Z")

</div>

Just a thought. I went to the “fileexchange” section of MatlabCentral to have a look at user-provided “toolboxes”, just out of curiosity. Maybe I just discovered hot water, but the comparison with Julia packages is as…

---

## [Can a BigInt be a type parameter?](https://discourse.julialang.org/t/can-a-bigint-be-a-type-parameter/42997)

<div class="topic-metadata">

**Author:** [@scheinerman](https://discourse.julialang.org/u/scheinerman)\
**Replies:** 13\
**Last updated:** [July 13, 2020, 11:24pm UTC](https://discourse.julialang.org/t/can-a-bigint-be-a-type-parameter/42997 "2020-07-13T23:24:55Z")

</div>

I am able to define a type struct foo{N} where N is an Int, but can I do this with N being a BigInt?

---

## [How to make a dividing line in editor?](https://discourse.julialang.org/t/how-to-make-a-dividing-line-in-editor/43006)

<div class="topic-metadata">

**Author:** [@SteveShelnanMa](https://discourse.julialang.org/u/SteveShelnanMa)\
**Replies:** 3\
**Last updated:** [July 13, 2020, 10:27pm UTC](https://discourse.julialang.org/t/how-to-make-a-dividing-line-in-editor/43006 "2020-07-13T22:27:19Z")

</div>

Hi I was just learning Julia by copying and running others’ codes and for some reason there’s a dividing horizontal line in my editor, which I think is elegant for coding I don’t understand how and why this line app…

---

## [Interpolation into Threads.@spawn macro fails for certain kinds of Structs](https://discourse.julialang.org/t/interpolation-into-threads-spawn-macro-fails-for-certain-kinds-of-structs/42964)

<div class="topic-metadata">

**Author:** [@pyrex41](https://discourse.julialang.org/u/pyrex41)\
**Replies:** 9\
**Last updated:** [July 13, 2020, 10:18pm UTC](https://discourse.julialang.org/t/interpolation-into-threads-spawn-macro-fails-for-certain-kinds-of-structs/42964 "2020-07-13T22:18:53Z")

</div>

According to the docs for Threads.@spawn, you can interpolate an argument via $ and it will spawn the task with a copy of the variable. I have found that when I use a custom struct that use SparseArrays, that this behavi…

---

## [Calculate (I/A)^(2/3) with no allocations with Unitful](https://discourse.julialang.org/t/calculate-i-a-2-3-with-no-allocations-with-unitful/42998)

<div class="topic-metadata">

**Author:** [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)\
**Replies:** 1\
**Last updated:** [July 13, 2020, 10:17pm UTC](https://discourse.julialang.org/t/calculate-i-a-2-3-with-no-allocations-with-unitful/42998 "2020-07-13T22:17:00Z")

</div>

See below. I’m trying to calculate this quantity without allocation. I know that exponentiation and units is tricky since a rational exponent is stored in the type of each unitful quantity, but even when I try to do all …

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

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