# General Usage

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

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

**Page:** 840

---

## [Julia integral calculation - community module or own module?](https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 17\
**Last updated:** [August 20, 2019, 2:41pm UTC](https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278 "2019-08-20T14:41:31Z")

</div>

I need to calculate some integrals in my program. Before using Julia i did it in C by using Complex Newton-Cotes formulas(Boole rule, Simpson rule and others): Here is the simplified example(only with Boole Rule): #inc…

---

## [How to use an expression in a anonymous function?](https://discourse.julialang.org/t/how-to-use-an-expression-in-a-anonymous-function/27756)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 1\
**Last updated:** [August 20, 2019, 12:05pm UTC](https://discourse.julialang.org/t/how-to-use-an-expression-in-a-anonymous-function/27756 "2019-08-20T12:05:58Z")

</div>

The following works: julia\> map(x -\> x^2 + 2x - 1, \[1,3,-1\]) 3-element Array{Int64,1}: 2 14 -2 But I need to calculate the function dynamically. I have: julia\> expr=Meta.parse("x^2 + 2x - 1") :((x ^ 2 + 2x) - 1) …

---

## [Wrong type returned by range in 2-dims case?](https://discourse.julialang.org/t/wrong-type-returned-by-range-in-2-dims-case/27736)

<div class="topic-metadata">

**Author:** [@szcf-weiya](https://discourse.julialang.org/u/szcf-weiya)\
**Replies:** 5\
**Last updated:** [August 20, 2019, 10:53am UTC](https://discourse.julialang.org/t/wrong-type-returned-by-range-in-2-dims-case/27736 "2019-08-20T10:53:07Z")

</div>

When I tried the following command to generate 2-dims linspace arrays, whose type should be Float, not Int r = range(\[1,1\],\[8,9\],length=10) # 10-element LinRange{Array{Int64,1}}: # \[1.0, 1.0\],\[1.77778, 1.88889\],\[2.55556…

---

## [Julia crashes when adding package with ssh, https works](https://discourse.julialang.org/t/julia-crashes-when-adding-package-with-ssh-https-works/25827)

<div class="topic-metadata">

**Author:** [@cstook](https://discourse.julialang.org/u/cstook)\
**Replies:** 6\
**Last updated:** [August 20, 2019, 8:40am UTC](https://discourse.julialang.org/t/julia-crashes-when-adding-package-with-ssh-https-works/25827 "2019-08-20T08:40:55Z")

</div>

Trying to add a unregistered package from my github account using ssh causes Julia to crash. I replaced my boot drive in my windows PC and I am in the process reinstalling everything. I have set up a new private/public…

---

## [Difference between Set{Int}() and BitSet()](https://discourse.julialang.org/t/difference-between-set-int-and-bitset/27737)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 2\
**Last updated:** [August 20, 2019, 8:33am UTC](https://discourse.julialang.org/t/difference-between-set-int-and-bitset/27737 "2019-08-20T08:33:26Z")

</div>

I want to compute the intersection of a matrix of sets. I came across BitSet in addition to Set{Int}, and the following benchmarks (which initialize a matrix of Set or BitSet) baffles me in terms of memory usage: julia\> …

---

## [Make Julia environments separation based on full version number](https://discourse.julialang.org/t/make-julia-environments-separation-based-on-full-version-number/27537)

<div class="topic-metadata">

**Author:** [@samo](https://discourse.julialang.org/u/samo)\
**Replies:** 11\
**Last updated:** [August 20, 2019, 8:04am UTC](https://discourse.julialang.org/t/make-julia-environments-separation-based-on-full-version-number/27537 "2019-08-20T08:04:49Z")

</div>

I would like to make Julia installations that create different environments based on the full Julia version number. That is instead of e.g. ~/.julia/environments/v1.0 ~/.julia/environments/v1.1 I would like to …

---

## [Threads are disabled if an error occurs](https://discourse.julialang.org/t/threads-are-disabled-if-an-error-occurs/27738)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 2\
**Last updated:** [August 20, 2019, 6:12am UTC](https://discourse.julialang.org/t/threads-are-disabled-if-an-error-occurs/27738 "2019-08-20T06:12:08Z")

</div>

When an error is thrown in a threaded loop, only one thread is used in threaded loops thereafter. julia\> function f!(a) Threads.@threads for i in eachindex(a) a\[i\] = Threads.threadid() …

---

## [Efficient multiplication of out-of-memory sparse matrix and an in-memory dense vector](https://discourse.julialang.org/t/efficient-multiplication-of-out-of-memory-sparse-matrix-and-an-in-memory-dense-vector/19663)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 7\
**Last updated:** [August 19, 2019, 12:27pm UTC](https://discourse.julialang.org/t/efficient-multiplication-of-out-of-memory-sparse-matrix-and-an-in-memory-dense-vector/19663 "2019-08-19T12:27:55Z")

</div>

Say I have a really huge sparse matrix A, and an equally huge dense vector v. I need to do A \* v. The structure of A is simple, like a -1 -1 4 -1 -1 stencil in 2D for example (in practice it’s a bit more complicated) so …

---

## [What exactly is the meaning of "get!(Set{Int}, intersections, highway.nodes\[I\])" in the following code?](https://discourse.julialang.org/t/what-exactly-is-the-meaning-of-get-set-int-intersections-highway-nodes-i-in-the-following-code/27690)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 3\
**Last updated:** [August 19, 2019, 10:33am UTC](https://discourse.julialang.org/t/what-exactly-is-the-meaning-of-get-set-int-intersections-highway-nodes-i-in-the-following-code/27690 "2019-08-19T10:33:21Z")

</div>

Hi, I was wondering, could anyone help me with clarifying a little bit of a line of the following code? ###################################### ### Find Intersections of Highways ### #####################################…

---

## [Julia OOP example](https://discourse.julialang.org/t/julia-oop-example/27568)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 9\
**Last updated:** [August 19, 2019, 12:58am UTC](https://discourse.julialang.org/t/julia-oop-example/27568 "2019-08-19T00:58:54Z")

</div>

I am a C++ and Python user and quite accustomed to OOP for some tasks. The following is a small example of using OOP style in Julia. Please give comments if there are better ways to do that. Thank! Hope it could help th…

---

## [Import a module within that same module for parallelisation](https://discourse.julialang.org/t/import-a-module-within-that-same-module-for-parallelisation/27667)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 4\
**Last updated:** [August 18, 2019, 9:30pm UTC](https://discourse.julialang.org/t/import-a-module-within-that-same-module-for-parallelisation/27667 "2019-08-18T21:30:09Z")

</div>

I have a bunch of functions within a module. I want to make a function that uses various other functions within that module in parallel. The solution that works in the REPL is to addprocs for the number of cores I have a…

---

## [Qr decomposition matrix type](https://discourse.julialang.org/t/qr-decomposition-matrix-type/27566)

<div class="topic-metadata">

**Author:** [@\_dominic](https://discourse.julialang.org/u/_dominic)\
**Replies:** 6\
**Last updated:** [August 18, 2019, 2:28pm UTC](https://discourse.julialang.org/t/qr-decomposition-matrix-type/27566 "2019-08-18T14:28:13Z")

</div>

I just want to compute a qr decomposition and pass the Q matrix to the log function using LinearAlgebra D = rand(Float64, 3, 3) Q, R = qr(D) W = log(Q) # Error Why is Q not a simple regular matrix type? How can I con…

---

## [Make clean changes package registration?](https://discourse.julialang.org/t/make-clean-changes-package-registration/27680)

<div class="topic-metadata">

**Author:** [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Replies:** 1\
**Last updated:** [August 18, 2019, 2:25pm UTC](https://discourse.julialang.org/t/make-clean-changes-package-registration/27680 "2019-08-18T14:25:36Z")

</div>

I frequently recompile the latest Julia master for experimental reasons. Occasionally the recompile fails and suggests that I do a make clean and try make again which pretty much resolves the issue. I’m wondering if the …

---

## [LinearIndices for non-1-based indices](https://discourse.julialang.org/t/linearindices-for-non-1-based-indices/26906)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 5\
**Last updated:** [August 17, 2019, 11:59pm UTC](https://discourse.julialang.org/t/linearindices-for-non-1-based-indices/26906 "2019-08-17T23:59:34Z")

</div>

I’m not sure if I understand LinearIndices and CartesianIndices correctly, but I think they provide a mapping between those index types, and are inverses of each other? This seems to be the case for normal 1-based indic…

---

## [Makie adjust scene limits + scale](https://discourse.julialang.org/t/makie-adjust-scene-limits-scale/27663)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 2\
**Last updated:** [August 17, 2019, 8:37pm UTC](https://discourse.julialang.org/t/makie-adjust-scene-limits-scale/27663 "2019-08-17T20:37:33Z")

</div>

I want to animate a sequence of lines, where the x values of each line are fixed, but the y values vary in scale. Something like this: julia\> using Makie julia\> scene = Scene(); y = Node(randn(10)); lines!(scene, y) j…

---

## [Is Shared Memory Parallel Tasks Possible in Julia?](https://discourse.julialang.org/t/is-shared-memory-parallel-tasks-possible-in-julia/27645)

<div class="topic-metadata">

**Author:** [@Gavinclarke](https://discourse.julialang.org/u/Gavinclarke)\
**Replies:** 4\
**Last updated:** [August 17, 2019, 7:23pm UTC](https://discourse.julialang.org/t/is-shared-memory-parallel-tasks-possible-in-julia/27645 "2019-08-17T19:23:21Z")

</div>

I looking to run separate tasks in parallel that are required to share access to a few variables that are constantly updated in a program that is latency-sensitive. I am starting to see that this may not be currently po…

---

## [Suppressing the label when using Plots or StatsPlots](https://discourse.julialang.org/t/suppressing-the-label-when-using-plots-or-statsplots/27658)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 1\
**Last updated:** [August 17, 2019, 5:26pm UTC](https://discourse.julialang.org/t/suppressing-the-label-when-using-plots-or-statsplots/27658 "2019-08-17T17:26:06Z")

</div>

When using scatter in the Plots or StatsPlots package it seems that I get a label by default. The only way I have found to suppress the label is to add a named argument label="". If I have a simple scatterplot of one v…

---

## [Typeof(f()) at compile time](https://discourse.julialang.org/t/typeof-f-at-compile-time/27615)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 4\
**Last updated:** [August 17, 2019, 2:53pm UTC](https://discourse.julialang.org/t/typeof-f-at-compile-time/27615 "2019-08-17T14:53:12Z")

</div>

typeof(f(x)) can be evaluated at compile-time, provided the return type of f(x) is inferrable. Why can’t we have a guarantee that this is always the case? For example, I tried this: julia\> f(x) = typeof(sin(x)) julia\> …

---

## [SVector vs Vec usage: Why do I have an 8x speedup in a simple example?](https://discourse.julialang.org/t/svector-vs-vec-usage-why-do-i-have-an-8x-speedup-in-a-simple-example/27647)

<div class="topic-metadata">

**Author:** [@davidbp](https://discourse.julialang.org/u/davidbp)\
**Replies:** 7\
**Last updated:** [August 17, 2019, 2:12pm UTC](https://discourse.julialang.org/t/svector-vs-vec-usage-why-do-i-have-an-8x-speedup-in-a-simple-example/27647 "2019-08-17T14:12:40Z")

</div>

Hello, I was playing with both SVector and Vec from StaticArrays and SIMD respectively. I was surprised obtaining an 8x speedup using SVector vs Vec. Am I using Vecin a non suitable example or maybe I’m not using it pr…

---

## [Separating values from Iterator.product() tuple](https://discourse.julialang.org/t/separating-values-from-iterator-product-tuple/27628)

<div class="topic-metadata">

**Author:** [@DocDave](https://discourse.julialang.org/u/DocDave)\
**Replies:** 6\
**Last updated:** [August 17, 2019, 2:10pm UTC](https://discourse.julialang.org/t/separating-values-from-iterator-product-tuple/27628 "2019-08-17T14:10:15Z")

</div>

I am calling a function many times using pmap(), where some of the arguments are passed each time while others are iterated over. To produce the correct permutations of the arguments I am utilising the Iterator library. …

---

## [Pmap throwing BoundsErrors when accessing SharedArray](https://discourse.julialang.org/t/pmap-throwing-boundserrors-when-accessing-sharedarray/27652)

<div class="topic-metadata">

**Author:** [@DocDave](https://discourse.julialang.org/u/DocDave)\
**Replies:** 0\
**Last updated:** [August 17, 2019, 12:21pm UTC](https://discourse.julialang.org/t/pmap-throwing-boundserrors-when-accessing-sharedarray/27652 "2019-08-17T12:21:29Z")

</div>

A code which I am writing is heavily numerical in nature, but ultimately it calculates a value for each point of a 4D array according to the values within multiple separate 4D arrays. Consequently, now that I have a work…

---

## [How to use dot notation when extending functions for a user-defined type?](https://discourse.julialang.org/t/how-to-use-dot-notation-when-extending-functions-for-a-user-defined-type/27638)

<div class="topic-metadata">

**Author:** [@kmundnic](https://discourse.julialang.org/u/kmundnic)\
**Replies:** 2\
**Last updated:** [August 17, 2019, 12:58am UTC](https://discourse.julialang.org/t/how-to-use-dot-notation-when-extending-functions-for-a-user-defined-type/27638 "2019-08-17T00:58:21Z")

</div>

Let’s say that I create a new struct called MyMatrix: import Base: size, getindex struct MyMatrix{T} \<: AbstractMatrix{T} X::Matrix{T} function MyMatrix(n::Int) new{Float64}(rand(n,n)) # For sake of th…

---

## [Julia equivalent of Python's "fsum" for floating point summation](https://discourse.julialang.org/t/julia-equivalent-of-pythons-fsum-for-floating-point-summation/17785)

<div class="topic-metadata">

**Author:** [@anon32405968](https://discourse.julialang.org/u/anon32405968)\
**Replies:** 53\
**Last updated:** [August 16, 2019, 9:37pm UTC](https://discourse.julialang.org/t/julia-equivalent-of-pythons-fsum-for-floating-point-summation/17785 "2019-08-16T21:37:59Z")

</div>

I have been looking for a Julia equivalent of Python’s fsum and have thus far been unable to find one. Is there an implementation already available? If not I will write my own and put it on Github for others to use. Fro…

---

## [Using BenchmarkTools with CUDAnative and CuArrays and running out of CPU or GPU memory](https://discourse.julialang.org/t/using-benchmarktools-with-cudanative-and-cuarrays-and-running-out-of-cpu-or-gpu-memory/27278)

<div class="topic-metadata">

**Author:** [@Josiah\_Slack](https://discourse.julialang.org/u/Josiah_Slack)\
**Replies:** 0\
**Last updated:** [August 7, 2019, 5:41pm UTC](https://discourse.julialang.org/t/using-benchmarktools-with-cudanative-and-cuarrays-and-running-out-of-cpu-or-gpu-memory/27278 "2019-08-07T17:41:54Z")

</div>

I’m doing some simple “get acquainted” experimenting with convolutions using DSP, CUDAnative, CUDAdrv and CuArrays. I’m creating random 3-d arrays - rand(Float32, N, N, N). I then create “device” versions of the arrays b…

---

## [BoundsError with Julia DataFrame](https://discourse.julialang.org/t/boundserror-with-julia-dataframe/27624)

<div class="topic-metadata">

**Author:** [@jaketothepast](https://discourse.julialang.org/u/jaketothepast)\
**Replies:** 2\
**Last updated:** [August 16, 2019, 6:12pm UTC](https://discourse.julialang.org/t/boundserror-with-julia-dataframe/27624 "2019-08-16T18:12:47Z")

</div>

Hello everybody, I am working on an AI experiment involving generating candidate solutions to a problem. My candidates are in the form of smaller dataframes derived from the larger dataset dataframe. The error I’m facin…

---

## [Does Julia language need Dependency Injection?](https://discourse.julialang.org/t/does-julia-language-need-dependency-injection/27527)

<div class="topic-metadata">

**Author:** [@zsykm](https://discourse.julialang.org/u/zsykm)\
**Replies:** 15\
**Last updated:** [August 16, 2019, 3:34pm UTC](https://discourse.julialang.org/t/does-julia-language-need-dependency-injection/27527 "2019-08-16T15:34:06Z")

</div>

Dependency Injection is widely used in Java, c# and some other languages as an important design pattern. How to do the same thing in Julia? Example will be appreciated. :slight\_smile:

---

## [Pkg: status/instantiate: "ERROR: IOError: stat: permission denied (EACCES)"](https://discourse.julialang.org/t/pkg-status-instantiate-error-ioerror-stat-permission-denied-eacces/27619)

<div class="topic-metadata">

**Author:** [@samo](https://discourse.julialang.org/u/samo)\
**Replies:** 0\
**Last updated:** [August 16, 2019, 3:31pm UTC](https://discourse.julialang.org/t/pkg-status-instantiate-error-ioerror-stat-permission-denied-eacces/27619 "2019-08-16T15:31:30Z")

</div>

When I do \] status or \] instantiate inside a folder with a Project.toml and a Manifest.toml file, I get the error: ERROR: IOError: stat: permission denied (EACCES) Here is the full shell output: omlins@daint106:/scrat…

---

## [FemtoCleaner and Deprecations upgrade](https://discourse.julialang.org/t/femtocleaner-and-deprecations-upgrade/27561)

<div class="topic-metadata">

**Author:** [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Replies:** 8\
**Last updated:** [August 16, 2019, 11:32am UTC](https://discourse.julialang.org/t/femtocleaner-and-deprecations-upgrade/27561 "2019-08-16T11:32:36Z")

</div>

This is important: there are many packages that are written in Julia 0.4, 0.5, 0.6, etc and are abandoned/unmaintained. One solution to help these packages revive is to use FemtoCleaner to removed deprecated syntax. Now…

---

## [Running Julia v1.0.4 code from Atom on OSX](https://discourse.julialang.org/t/running-julia-v1-0-4-code-from-atom-on-osx/27556)

<div class="topic-metadata">

**Author:** [@JdG](https://discourse.julialang.org/u/JdG)\
**Replies:** 7\
**Last updated:** [August 16, 2019, 9:57am UTC](https://discourse.julialang.org/t/running-julia-v1-0-4-code-from-atom-on-osx/27556 "2019-08-16T09:57:35Z")

</div>

After upgrading from version 0.6 to 1.0.4 I can’t get my code running from Atom anymore. I upgraded Julia-client to the latest version.

---

## [Pkg error in julia:latest Docker image](https://discourse.julialang.org/t/pkg-error-in-julia-latest-docker-image/27605)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 5\
**Last updated:** [August 16, 2019, 9:38am UTC](https://discourse.julialang.org/t/pkg-error-in-julia-latest-docker-image/27605 "2019-08-16T09:38:17Z")

</div>

I’m having a problem with the julia:latest docker image. Upon attempting to build upon it, I get: # output omitted Installed MbedTLS ───────────────────── v0.6.8 Installed IteratorInterfaceExtensions ─ v1.0.0 ERROR: t…

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

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