# General Usage

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

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

**Page:** 871

---

## [Show for vector type that defines matrix getindex](https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 2\
**Last updated:** [May 1, 2019, 12:28pm UTC](https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732 "2019-05-01T12:28:46Z")

</div>

I have a type that wraps a vector. I have defined two-argument getindex for vectors of this type, i.e., getindex(v::Vector{MyVec}, i::Int, j::Int) = v\[j\]\[i\]. This works well, but it messes up REPL display of one of thes…

---

## [Pkg checkout in Julia 1.0?](https://discourse.julialang.org/t/pkg-checkout-in-julia-1-0/13907)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 9\
**Last updated:** [May 1, 2019, 3:06am UTC](https://discourse.julialang.org/t/pkg-checkout-in-julia-1-0/13907 "2019-05-01T03:06:55Z")

</div>

how does one switch to/checkout and switch back/free from stable to the master with the new Pkg?

---

## [Interfaces, Julia organisations and XXBase packages](https://discourse.julialang.org/t/interfaces-julia-organisations-and-xxbase-packages/23683)

<div class="topic-metadata">

**Author:** [@Raf](https://discourse.julialang.org/u/Raf)\
**Replies:** 6\
**Last updated:** [May 1, 2019, 1:08am UTC](https://discourse.julialang.org/t/interfaces-julia-organisations-and-xxbase-packages/23683 "2019-05-01T01:08:59Z")

</div>

I’m researching the potential of software ecosystems for process modelling in the life-sciences. Its currently a wasteland of siloed frameworks and ancient Fortran repos… Coordination of component interfaces at the leve…

---

## [Ipopt objective vs getobjectivevalue() vs "Manual" objective](https://discourse.julialang.org/t/ipopt-objective-vs-getobjectivevalue-vs-manual-objective/23714)

<div class="topic-metadata">

**Author:** [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Replies:** 0\
**Last updated:** [April 30, 2019, 8:52pm UTC](https://discourse.julialang.org/t/ipopt-objective-vs-getobjectivevalue-vs-manual-objective/23714 "2019-04-30T20:52:38Z")

</div>

I am using Julia v1.0.2 with JuMP v0.18.5 and Ipopt v3.12.12. After solving my problem with juMP I want to estimate my objective to know how good is my solution (closer to 0 is better). The problem is that the objective…

---

## [Numerical issues causing wrong determinant values](https://discourse.julialang.org/t/numerical-issues-causing-wrong-determinant-values/23711)

<div class="topic-metadata">

**Author:** [@Mr.Robot](https://discourse.julialang.org/u/Mr.Robot)\
**Replies:** 3\
**Last updated:** [April 30, 2019, 8:14pm UTC](https://discourse.julialang.org/t/numerical-issues-causing-wrong-determinant-values/23711 "2019-04-30T20:14:46Z")

</div>

Problem I am practicing writing efficient Julia code that could (hopefully) comparable with the function provided in libraries in term of speed. Specifically, I am trying to write logpdf function, which returns the log p…

---

## [Package to validate X.509 certificates](https://discourse.julialang.org/t/package-to-validate-x-509-certificates/23549)

<div class="topic-metadata">

**Author:** [@sambitdash](https://discourse.julialang.org/u/sambitdash)\
**Replies:** 3\
**Last updated:** [April 30, 2019, 6:20pm UTC](https://discourse.julialang.org/t/package-to-validate-x-509-certificates/23549 "2019-04-30T18:20:43Z")

</div>

Hi All, I was looking for a Julia package that can validate X.509 certificates. Has anyone developed any for the same? Or the approach will be to query the underlying MBedSSL (armSSL) library directly? regards, Sambit …

---

## [Plotting with Plots.jl](https://discourse.julialang.org/t/plotting-with-plots-jl/23691)

<div class="topic-metadata">

**Author:** [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Replies:** 4\
**Last updated:** [April 30, 2019, 1:02pm UTC](https://discourse.julialang.org/t/plotting-with-plots-jl/23691 "2019-04-30T13:02:18Z")

</div>

How can I generate a two plots using Plots.jl and GR as the backend within the same window. I am using the following code from one of the book but plots appear in two separate windows. The book uses Pyplot.jl. using Plo…

---

## [Pkg instantiate fails](https://discourse.julialang.org/t/pkg-instantiate-fails/11709)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 8\
**Last updated:** [April 30, 2019, 9:37am UTC](https://discourse.julialang.org/t/pkg-instantiate-fails/11709 "2019-04-30T09:37:40Z")

</div>

Hi I copied a project.toml and a manifest.toml from one computer to another On my ‘new’ computer .julia\\registries is somehow empty. I get the error below. How can I fix that? Can I update or define a registry someho…

---

## [Extracing tuple types](https://discourse.julialang.org/t/extracing-tuple-types/23686)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 4\
**Last updated:** [April 30, 2019, 8:17am UTC](https://discourse.julialang.org/t/extracing-tuple-types/23686 "2019-04-30T08:17:10Z")

</div>

Given a tuple, how do I extract the type parameters information? It seems that I can do the following but I’m wondering if there’s a better way i.e. using a public API rather than accessing the types or parameters fiel…

---

## [Forcing users to implements all methods in an abstract interface](https://discourse.julialang.org/t/forcing-users-to-implements-all-methods-in-an-abstract-interface/23687)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 2\
**Last updated:** [April 30, 2019, 7:45am UTC](https://discourse.julialang.org/t/forcing-users-to-implements-all-methods-in-an-abstract-interface/23687 "2019-04-30T07:45:55Z")

</div>

Let us assume that we have an abstract type abstract type Person end and we want that the following queries are available to all Person types: sayhello(::Person)::String saybyebye(::Person)::String My current approac…

---

## [Statistics... cov(): Hermitian?](https://discourse.julialang.org/t/statistics-cov-hermitian/23621)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 14\
**Last updated:** [April 30, 2019, 7:30am UTC](https://discourse.julialang.org/t/statistics-cov-hermitian/23621 "2019-04-30T07:30:37Z")

</div>

I’m using the Statistics package with the cov() function to compute covariance of unscented mappings in sigma points (Unscented Kalman Filter). After a couple of iterations, the filter crashes with some message about pro…

---

## [Customize number of threads interactively](https://discourse.julialang.org/t/customize-number-of-threads-interactively/11574)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 8\
**Last updated:** [April 30, 2019, 6:54am UTC](https://discourse.julialang.org/t/customize-number-of-threads-interactively/11574 "2019-04-30T06:54:18Z")

</div>

The documentation says I can specify number of threads by using the JULIA\_NUM\_THREADS variable. Often, during testing, I need to experiment different values. Having to restart the REPL every time make it quite ineffici…

---

## [How to concatenate ranges?](https://discourse.julialang.org/t/how-to-concatenate-ranges/23673)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 2\
**Last updated:** [April 30, 2019, 6:21am UTC](https://discourse.julialang.org/t/how-to-concatenate-ranges/23673 "2019-04-30T06:21:42Z")

</div>

imagine you have some setup: linspace(a,b,n) = range(a,stop=b,length=n) n = 41 x\_raw = linspace(-1,+1,n) x\_vec = \[ linspace(x\_raw\[1:2\]...,3), linspace(x\_raw\[3\],x\_raw\[end-2\],n-4), linspace(x\_raw\[end-1:end\]...,3) …

---

## [Using metaprogramming to define a bunch of methods at once](https://discourse.julialang.org/t/using-metaprogramming-to-define-a-bunch-of-methods-at-once/23663)

<div class="topic-metadata">

**Author:** [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 7:36pm UTC](https://discourse.julialang.org/t/using-metaprogramming-to-define-a-bunch-of-methods-at-once/23663 "2019-04-29T19:36:24Z")

</div>

I’m trying to replicate the following trick that I found in SpecialFunctions.jl/src/bessel.jl: ## Bessel functions # besselj0, besselj1, bessely0, bessely1 for jy in ("j","y"), nu in (0,1) jynu = Expr(:quote, Symbo…

---

## [Avoiding very long output](https://discourse.julialang.org/t/avoiding-very-long-output/23658)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 7:29pm UTC](https://discourse.julialang.org/t/avoiding-very-long-output/23658 "2019-04-29T19:29:43Z")

</div>

Occasionally, for custom types, I forget to define a show method that respects limit. This can happen accidentally even with the best intentions, eg with unfortunate combinations of nested types. This can lead to very l…

---

## [Unable to Add Packages](https://discourse.julialang.org/t/unable-to-add-packages/23657)

<div class="topic-metadata">

**Author:** [@dburch](https://discourse.julialang.org/u/dburch)\
**Replies:** 3\
**Last updated:** [April 29, 2019, 5:10pm UTC](https://discourse.julialang.org/t/unable-to-add-packages/23657 "2019-04-29T17:10:20Z")

</div>

It seems like I cannot add packages. I am using Julia Pro v1.0.3. When I try to add a package, I get the following error: (v1.0) pkg\> add Plots Resolving package versions... ERROR: Unsatisfiable requirements detected f…

---

## [Problems creating Plots.jl recipes for custom types](https://discourse.julialang.org/t/problems-creating-plots-jl-recipes-for-custom-types/23654)

<div class="topic-metadata">

**Author:** [@srb](https://discourse.julialang.org/u/srb)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 4:16pm UTC](https://discourse.julialang.org/t/problems-creating-plots-jl-recipes-for-custom-types/23654 "2019-04-29T16:16:10Z")

</div>

I’m trying to implement plotting functions for my custom types as seen in Recipes · Plots. However, I cannot seem to make it work using custom parametric types. For example, take the following struct and recipe. struct…

---

## [Sum of float64 vector gives slightly incorrect answer](https://discourse.julialang.org/t/sum-of-float64-vector-gives-slightly-incorrect-answer/8577)

<div class="topic-metadata">

**Author:** [@GantZA](https://discourse.julialang.org/u/GantZA)\
**Replies:** 44\
**Last updated:** [April 29, 2019, 3:19pm UTC](https://discourse.julialang.org/t/sum-of-float64-vector-gives-slightly-incorrect-answer/8577 "2019-04-29T15:19:07Z")

</div>

I’ve noticed that when I run the following code a = \[0.00694 0.0023 -0.02064 0.01405\] sum(a) but instead of the expected answer of 0.00265 I get 0.0026500000000000013 Normally this wouldn’t be a problem but this is ha…

---

## [GPIO and robotics hints please](https://discourse.julialang.org/t/gpio-and-robotics-hints-please/23642)

<div class="topic-metadata">

**Author:** [@johnh](https://discourse.julialang.org/u/johnh)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 1:23pm UTC](https://discourse.julialang.org/t/gpio-and-robotics-hints-please/23642 "2019-04-29T13:23:27Z")

</div>

I have a Jetson Nano board, which is ARM architecture and can accept Respberry Pi peripherals. The SenseHat looks nifty Buy a Sense HAT – Raspberry Pi However the GPIO setup and drivers look extremely specific to the …

---

## [Find what has locked/held a file](https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278)

<div class="topic-metadata">

**Author:** [@Jeremy](https://discourse.julialang.org/u/Jeremy)\
**Replies:** 3\
**Last updated:** [April 29, 2019, 12:10pm UTC](https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278 "2019-04-29T12:10:18Z")

</div>

Is there a good way of finding out what has locked a file or what is holding it so that it can’t be deleted? In my code I unzip a few to a temporary folder, read the header lines with readline, and then read the bulk of…

---

## [Why summing a generator is slightly slower?](https://discourse.julialang.org/t/why-summing-a-generator-is-slightly-slower/23629)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 7\
**Last updated:** [April 29, 2019, 9:55am UTC](https://discourse.julialang.org/t/why-summing-a-generator-is-slightly-slower/23629 "2019-04-29T09:55:44Z")

</div>

Why is this: @btime (s = 0; for i = 1:10^6 s += i end; s) # 4.449 ns (0 allocations: 0 bytes) # 500000500000 significantly faster than this: @btime sum(i for i = 1:10^6) # 7.038 ns (0 allocations: 0 bytes) # 50000…

---

## [Non-allocating reduced broadcast?](https://discourse.julialang.org/t/non-allocating-reduced-broadcast/23634)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 4\
**Last updated:** [April 29, 2019, 8:57am UTC](https://discourse.julialang.org/t/non-allocating-reduced-broadcast/23634 "2019-04-29T08:57:48Z")

</div>

Suppose A and B are two long arrays of numbers of same length. Then sum(A .\* B) allocates the intermediary array A .\* B, and then sums it (the reduction). I know I can write this as a loop or using generators, but at th…

---

## [Is there something like broadcast\_mapreduce?](https://discourse.julialang.org/t/is-there-something-like-broadcast-mapreduce/6076)

<div class="topic-metadata">

**Author:** [@fabiangans](https://discourse.julialang.org/u/fabiangans)\
**Replies:** 10\
**Last updated:** [April 29, 2019, 8:49am UTC](https://discourse.julialang.org/t/is-there-something-like-broadcast-mapreduce/6076 "2019-04-29T08:49:03Z")

</div>

Assume I have 2 arrays x and y that can be broadcast to a common size. Is there any way to get a (zipped) iterator over the elements of both arrays as they would result from a broadcast operation? For example: x = rand(…

---

## [Is accessing the fields of a struct a good julia-style?](https://discourse.julialang.org/t/is-accessing-the-fields-of-a-struct-a-good-julia-style/23623)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 5\
**Last updated:** [April 29, 2019, 5:20am UTC](https://discourse.julialang.org/t/is-accessing-the-fields-of-a-struct-a-good-julia-style/23623 "2019-04-29T05:20:29Z")

</div>

I need to implement a struct that represents a vector of vectors (a.k.a. a ragged/jagged array) in compressed form: struct Foo{T} data::Vector{T} ptrs::Vector{Int} end where the field data contains the flatted valu…

---

## [Pmap for Threads?](https://discourse.julialang.org/t/pmap-for-threads/23631)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 1\
**Last updated:** [April 28, 2019, 10:13pm UTC](https://discourse.julialang.org/t/pmap-for-threads/23631 "2019-04-28T22:13:26Z")

</div>

Is there an equivalent function to pmap for Threads? I want to map a collection of parameters over a function and collect the results in an array. I could do this with Threads.@threads and a for loop, but that requires…

---

## [Iteration over OrdinalRange](https://discourse.julialang.org/t/iteration-over-ordinalrange/23569)

<div class="topic-metadata">

**Author:** [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Replies:** 3\
**Last updated:** [April 28, 2019, 8:43pm UTC](https://discourse.julialang.org/t/iteration-over-ordinalrange/23569 "2019-04-28T20:43:42Z")

</div>

Playing around with iterators I noticed that calling iterate(1:5, 1) yields in (2, 2) while iterate(collect(1:5), 1) yields in (1, 2) as I would expect it to. To the best of my knowledge, iterate is supposed to …

---

## [Sortperm slow test case and fix suggestion](https://discourse.julialang.org/t/sortperm-slow-test-case-and-fix-suggestion/23498)

<div class="topic-metadata">

**Author:** [@John\_Olsson](https://discourse.julialang.org/u/John_Olsson)\
**Replies:** 12\
**Last updated:** [April 28, 2019, 2:16pm UTC](https://discourse.julialang.org/t/sortperm-slow-test-case-and-fix-suggestion/23498 "2019-04-28T14:16:23Z")

</div>

is this a bug? a = vcat(zeros(Float32,1\_000\_000),ones(Float32,1\_000\_000)); @time sortperm(a,alg=QuickSort); 0.049065 seconds (8 allocations: 304 bytes) a = vcat(ones(Float32,1\_000\_000),zeros(Float32,1\_000\_000)); @time…

---

## [What's the general algorithm to draw a road network of a certain area?](https://discourse.julialang.org/t/whats-the-general-algorithm-to-draw-a-road-network-of-a-certain-area/20657)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 34\
**Last updated:** [April 28, 2019, 2:09pm UTC](https://discourse.julialang.org/t/whats-the-general-algorithm-to-draw-a-road-network-of-a-certain-area/20657 "2019-04-28T14:09:32Z")

</div>

Hi, this might be a naive question. But I would really appreciate it if someone can give me some hints. I was wondering, how do people usually plot the road network of a certain area in a map? Of course, certain coding f…

---

## [Dynamic distributed execution for data parallel tasks in Julia](https://discourse.julialang.org/t/dynamic-distributed-execution-for-data-parallel-tasks-in-julia/23596)

<div class="topic-metadata">

**Author:** [@Zecx](https://discourse.julialang.org/u/Zecx)\
**Replies:** 2\
**Last updated:** [April 28, 2019, 3:03am UTC](https://discourse.julialang.org/t/dynamic-distributed-execution-for-data-parallel-tasks-in-julia/23596 "2019-04-28T03:03:48Z")

</div>

I was assigned a homework. Task : Dynamic distributed execution for data parallel tasks in Julia. This project proposal is to implement a native Julia framework for distributed execution for general purpose data parall…

---

## [Benchmark tools breaks when using "Threads.@threads"?](https://discourse.julialang.org/t/benchmark-tools-breaks-when-using-threads-threads/23605)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 17\
**Last updated:** [April 27, 2019, 10:03pm UTC](https://discourse.julialang.org/t/benchmark-tools-breaks-when-using-threads-threads/23605 "2019-04-27T22:03:14Z")

</div>

Hey guys! I am trying to benchmark a function in a package I made. The package can be found here, https://github.com/AhmedSalih3d/PostSPH.jl, and the function inside of it I am testing is readVtkArray. When I run the fu…

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

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