# General Usage

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

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

**Page:** 921

---

## [Best way to shuffle elements in a vector of vectors](https://discourse.julialang.org/t/best-way-to-shuffle-elements-in-a-vector-of-vectors/17357)

<div class="topic-metadata">

**Author:** [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Replies:** 11\
**Last updated:** [November 9, 2018, 11:35pm UTC](https://discourse.julialang.org/t/best-way-to-shuffle-elements-in-a-vector-of-vectors/17357 "2018-11-09T23:35:59Z")

</div>

I have some code that needs to shuffle up the elements of a vector of vectors the way I have this coded feels terrible and I was hoping some advice could come on how to make this better. The key is that the data is store…

---

## [TypeVar becomes lost to method implementation?](https://discourse.julialang.org/t/typevar-becomes-lost-to-method-implementation/17364)

<div class="topic-metadata">

**Author:** [@ajkeller34](https://discourse.julialang.org/u/ajkeller34)\
**Replies:** 1\
**Last updated:** [November 9, 2018, 9:16pm UTC](https://discourse.julialang.org/t/typevar-becomes-lost-to-method-implementation/17364 "2018-11-09T21:16:24Z")

</div>

I’m trying to understand the following behavior. In short, it seems like in some circumstances a TypeVar can become lost to the method implementation. Is this a bug, or some limitation I’m unaware of with defining method…

---

## [Functions as fields of mutable struct in if-elseif environment](https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342)

<div class="topic-metadata">

**Author:** [@Faber](https://discourse.julialang.org/u/Faber)\
**Replies:** 3\
**Last updated:** [November 9, 2018, 5:37pm UTC](https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342 "2018-11-09T17:37:31Z")

</div>

Hi, so I’m trying to do define functions as fields of a mutable struct based on input parameters. The general structure of which has the following form module TestModule mutable struct TestStruct F function …

---

## [Seeking documentation on C calling Julia API](https://discourse.julialang.org/t/seeking-documentation-on-c-calling-julia-api/17348)

<div class="topic-metadata">

**Author:** [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Replies:** 5\
**Last updated:** [November 9, 2018, 5:00pm UTC](https://discourse.julialang.org/t/seeking-documentation-on-c-calling-julia-api/17348 "2018-11-09T17:00:44Z")

</div>

Hello, I am still trying to call Julia from C++ Here is my Julia module TestF f(x::Int32)::Int32 = x + 3 end Following these directions \[Embedding Julia · The Julia Language\](http://Manual \>\> Embedding Julia) \[Redir…

---

## [Julia-0.7-RC2: Eval from module Base to](https://discourse.julialang.org/t/julia-0-7-rc2-eval-from-module-base-to/12892)

<div class="topic-metadata">

**Author:** [@goedman](https://discourse.julialang.org/u/goedman)\
**Replies:** 2\
**Last updated:** [November 9, 2018, 4:27pm UTC](https://discourse.julialang.org/t/julia-0-7-rc2-eval-from-module-base-to/12892 "2018-11-09T16:27:26Z")

</div>

Below message occurs (CmdStan replaced by another package name) when testing packages on Julia-0.7-RC2. Is this just a warning or am I doing something wrong? WARNING: eval from module Base to CmdStan: Expr(:-\>, :x, …

---

## [Stdin/stdout 10x slower than file open](https://discourse.julialang.org/t/stdin-stdout-10x-slower-than-file-open/17233)

<div class="topic-metadata">

**Author:** [@peter.derijk](https://discourse.julialang.org/u/peter.derijk)\
**Replies:** 13\
**Last updated:** [November 9, 2018, 12:31pm UTC](https://discourse.julialang.org/t/stdin-stdout-10x-slower-than-file-open/17233 "2018-11-09T12:31:35Z")

</div>

I came across a curious problem writing some code converting files. It turned out to be slower than a previously used scripting language, and not approaching (expected) C speed at all. I could get it to approximate C spe…

---

## [Incomplete Gamma with Complex input](https://discourse.julialang.org/t/incomplete-gamma-with-complex-input/17281)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 5\
**Last updated:** [November 9, 2018, 10:14am UTC](https://discourse.julialang.org/t/incomplete-gamma-with-complex-input/17281 "2018-11-09T10:14:07Z")

</div>

Does julia 1.0 have any implementation of incomplete gamma that takes complex values? The GSL version takes reals only.

---

## [ERROR: BoundsError: attempt to access "fc6"](https://discourse.julialang.org/t/error-boundserror-attempt-to-access-fc6/17333)

<div class="topic-metadata">

**Author:** [@lannisite110](https://discourse.julialang.org/u/lannisite110)\
**Replies:** 0\
**Last updated:** [November 9, 2018, 3:37am UTC](https://discourse.julialang.org/t/error-boundserror-attempt-to-access-fc6/17333 "2018-11-09T03:37:58Z")

</div>

when i read the trained parameter of vgg16, there occurs some problem. julia\> function getWeights(file) layers=get(file,"layers","") meta=get(file,"meta","") weights=Dict() we…

---

## [An algorithm](https://discourse.julialang.org/t/an-algorithm/17298)

<div class="topic-metadata">

**Author:** [@lannisite110](https://discourse.julialang.org/u/lannisite110)\
**Replies:** 4\
**Last updated:** [November 9, 2018, 12:53am UTC](https://discourse.julialang.org/t/an-algorithm/17298 "2018-11-09T00:53:57Z")

</div>

this is a VGG3D algorithm used for RGB-D object recognition, but the version is old. There are many difference for the new julia version. I think that will help julia with some improvement also. https://github.com/saman…

---

## [Wrapping a C lib, question on the safety of convert that uses unsafe\_convert to retrieve a pointer](https://discourse.julialang.org/t/wrapping-a-c-lib-question-on-the-safety-of-convert-that-uses-unsafe-convert-to-retrieve-a-pointer/16981)

<div class="topic-metadata">

**Author:** [@musm](https://discourse.julialang.org/u/musm)\
**Replies:** 13\
**Last updated:** [November 9, 2018, 12:18am UTC](https://discourse.julialang.org/t/wrapping-a-c-lib-question-on-the-safety-of-convert-that-uses-unsafe-convert-to-retrieve-a-pointer/16981 "2018-11-09T00:18:38Z")

</div>

The following pseudo-code represents a reduced example of a library I am wrapping. The code actually works well, however I think that there are exceptional cases where it is potentially unsafe (see comments below w…

---

## [Plot line segments (e.g. n-th roots on unit circle ) in polar projection](https://discourse.julialang.org/t/plot-line-segments-e-g-n-th-roots-on-unit-circle-in-polar-projection/17322)

<div class="topic-metadata">

**Author:** [@haigenw](https://discourse.julialang.org/u/haigenw)\
**Replies:** 4\
**Last updated:** [November 8, 2018, 10:41pm UTC](https://discourse.julialang.org/t/plot-line-segments-e-g-n-th-roots-on-unit-circle-in-polar-projection/17322 "2018-11-08T22:41:21Z")

</div>

Question: How to plot n-th roots on the unit circle in polar projection in Julia? Is this the intended/natural way to do it, or is there any better/lighter-weight way than the following? How to plot “π/6” instead …

---

## [Passing Keyword Arguments to Expr Object with :call](https://discourse.julialang.org/t/passing-keyword-arguments-to-expr-object-with-call/17315)

<div class="topic-metadata">

**Author:** [@elperkerson62](https://discourse.julialang.org/u/elperkerson62)\
**Replies:** 2\
**Last updated:** [November 8, 2018, 10:20pm UTC](https://discourse.julialang.org/t/passing-keyword-arguments-to-expr-object-with-call/17315 "2018-11-08T22:20:45Z")

</div>

I have a function f that has many different versions (e.g. f\_A, f\_B, f\_C, …), “subversions” (e.g. f\_Aa, f\_Ab, …, f\_Ba, f\_Bb, …), “subsubversions” (e.g. f\_Aaa, …), and so forth. Each of these takes a large number of param…

---

## [Passing expression stored in variable into a macro](https://discourse.julialang.org/t/passing-expression-stored-in-variable-into-a-macro/17311)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 3\
**Last updated:** [November 8, 2018, 7:44pm UTC](https://discourse.julialang.org/t/passing-expression-stored-in-variable-into-a-macro/17311 "2018-11-08T19:44:30Z")

</div>

At some point in my program I create expressions (and store them inside variable (which is inside a struct)). At some later point I wish to do some light manipulations of these expressions and execute the resulting code.…

---

## [Date(Y::AbstractArray{\<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH) in v1.0](https://discourse.julialang.org/t/date-y-abstractarray-abstractstring-f-abstractstring-locale-locale-english-in-v1-0/17317)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 1\
**Last updated:** [November 8, 2018, 6:56pm UTC](https://discourse.julialang.org/t/date-y-abstractarray-abstractstring-f-abstractstring-locale-locale-english-in-v1-0/17317 "2018-11-08T18:56:41Z")

</div>

I’m trying to port some code from v0.6 to v1.0 and I don’t know how to get it right. I have d: d = \["$(rand(2000:2020))-$(rand(1:12))-$(rand(1:28))" for \_ in 1:100\] And then in v0.7 julia\> Date(d, "yyyy-mm-dd", local…

---

## [Pairwise distance using matrix or Vector{SVector}: The first is faster!](https://discourse.julialang.org/t/pairwise-distance-using-matrix-or-vector-svector-the-first-is-faster/17312)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 4\
**Last updated:** [November 8, 2018, 5:55pm UTC](https://discourse.julialang.org/t/pairwise-distance-using-matrix-or-vector-svector-the-first-is-faster/17312 "2018-11-08T17:55:11Z")

</div>

I am facing a really unexpected result, that is that the pairwise distance computation using a matrix is actually faster than a vector of static vectors, for small dimensions. here is my simple setup: using Distances, S…

---

## [Largest float \`z\` such that \`z\*y \<= x\`](https://discourse.julialang.org/t/largest-float-z-such-that-z-y-x/17262)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 14\
**Last updated:** [November 8, 2018, 4:46pm UTC](https://discourse.julialang.org/t/largest-float-z-such-that-z-y-x/17262 "2018-11-08T16:46:29Z")

</div>

Given floating-point numbers x,y, is there a way to obtain the largest floating point number z such that z \* y \<= x? Hopefully in a single operation. I tried z = prevfloat(y/x), but I’m not 100% sure this works in every …

---

## [Inlining behavior: constant prop. fails, I need help in understanding "why"](https://discourse.julialang.org/t/inlining-behavior-constant-prop-fails-i-need-help-in-understanding-why/17134)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 9\
**Last updated:** [November 8, 2018, 4:20pm UTC](https://discourse.julialang.org/t/inlining-behavior-constant-prop-fails-i-need-help-in-understanding-why/17134 "2018-11-08T16:20:40Z")

</div>

MWE: using StaticArrays, BenchmarkTools struct DelayEmbedding{D} delays::SVector{D, Int} end @inline DelayEmbedding(D::Int) = DelayEmbedding(Val{D}()) @inline function DelayEmbedding(::Val{D}) where {D} idxs = …

---

## [Inconsistent Base method overwrite behaviour](https://discourse.julialang.org/t/inconsistent-base-method-overwrite-behaviour/15367)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 5\
**Last updated:** [November 8, 2018, 3:18pm UTC](https://discourse.julialang.org/t/inconsistent-base-method-overwrite-behaviour/15367 "2018-11-08T15:18:35Z")

</div>

This doesn’t look right to me – looks like methods in Base are not automatically loaded until something triggers that, leading to inconsistent behaviour. \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.o…

---

## [Package 'Profile' in Julia 1.0.1 Can not be installed](https://discourse.julialang.org/t/package-profile-in-julia-1-0-1-can-not-be-installed/17257)

<div class="topic-metadata">

**Author:** [@Mannaperuma](https://discourse.julialang.org/u/Mannaperuma)\
**Replies:** 3\
**Last updated:** [November 8, 2018, 2:45pm UTC](https://discourse.julialang.org/t/package-profile-in-julia-1-0-1-can-not-be-installed/17257 "2018-11-08T14:45:15Z")

</div>

I’m trying to install Package “profile”, it gives some errors. How I can solve this, please? julia\> import Pkg; julia\> Pkg.add(“profile”) ERROR: The following package names could not be resolved: profile (not found…

---

## [Is constructing an array on the fly on this line costing me a lot of memory?](https://discourse.julialang.org/t/is-constructing-an-array-on-the-fly-on-this-line-costing-me-a-lot-of-memory/17276)

<div class="topic-metadata">

**Author:** [@SZJX](https://discourse.julialang.org/u/SZJX)\
**Replies:** 9\
**Last updated:** [November 8, 2018, 1:54pm UTC](https://discourse.julialang.org/t/is-constructing-an-array-on-the-fly-on-this-line-costing-me-a-lot-of-memory/17276 "2018-11-08T13:54:58Z")

</div>

One of my functions takes an array of String as an argument. According to my benchmarking results it apparently incurs very high memory usage, sometimes even the highest throughout my whole program under certain conditio…

---

## [include and eval for baremodule](https://discourse.julialang.org/t/include-and-eval-for-baremodule/17245)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [November 8, 2018, 1:31pm UTC](https://discourse.julialang.org/t/include-and-eval-for-baremodule/17245 "2018-11-08T13:31:20Z")

</div>

what is the preferred way to define include and eval in baremodule? I just stumbled upon this and was suprised, that the documentation does not say anything about how to restore this functionality. I just wanted to use …

---

## [When I import Gtk library my code became immaediately slower](https://discourse.julialang.org/t/when-i-import-gtk-library-my-code-became-immaediately-slower/17301)

<div class="topic-metadata">

**Author:** [@dsHitman](https://discourse.julialang.org/u/dsHitman)\
**Replies:** 2\
**Last updated:** [November 8, 2018, 10:42am UTC](https://discourse.julialang.org/t/when-i-import-gtk-library-my-code-became-immaediately-slower/17301 "2018-11-08T10:42:12Z")

</div>

Hi, I have created a GUI whit Gtk, but it was so slowly. To make a test I have import the Gtk library (using Gtk) in a code, without using it, and the code immediately went slower. Anyone have an idea on why?

---

## [Large size of plot files generated using Plots.jl with GR backend](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261)

<div class="topic-metadata">

**Author:** [@Tbl](https://discourse.julialang.org/u/Tbl)\
**Replies:** 10\
**Last updated:** [November 8, 2018, 9:12am UTC](https://discourse.julialang.org/t/large-size-of-plot-files-generated-using-plots-jl-with-gr-backend/17261 "2018-11-08T09:12:11Z")

</div>

The sizes of the plot files generated by GR are sometimes ridiculously large. Changing dpi does not help significantly. After some experimenting, it seems it is caused by LaTeX text. For example gr() xi = 0:0.1:10 pl…

---

## [Odd counts from code coverage on 0.7/1.0](https://discourse.julialang.org/t/odd-counts-from-code-coverage-on-0-7-1-0/13398)

<div class="topic-metadata">

**Author:** [@alee](https://discourse.julialang.org/u/alee)\
**Replies:** 3\
**Last updated:** [November 8, 2018, 8:16am UTC](https://discourse.julialang.org/t/odd-counts-from-code-coverage-on-0-7-1-0/13398 "2018-11-08T08:16:14Z")

</div>

Probably not very important, but code coverage is giving slightly odd results on 1.0 (and 0.7) in comparison to 0.6. Does anyone know why? Consider function foo(array::Vector{Float64}) v = 0.0 for i in 1:length(arra…

---

## [Compile and forw functions](https://discourse.julialang.org/t/compile-and-forw-functions/17284)

<div class="topic-metadata">

**Author:** [@lannisite110](https://discourse.julialang.org/u/lannisite110)\
**Replies:** 0\
**Last updated:** [November 8, 2018, 12:47am UTC](https://discourse.julialang.org/t/compile-and-forw-functions/17284 "2018-11-08T00:47:50Z")

</div>

this function is vgg function vggmodel(x0;weights=0) x1 = cbf(x0; w = map(Float32,weights\["w1\_1"\]), b = reshape(map(Float32,weights\["b1\_1"\]) ,1,1,size(weights\["b1\_1"\],1),1), out=64) x2 = cbf(x1; w = map(Float32,wei…

---

## [How to reload a module in Julia 1](https://discourse.julialang.org/t/how-to-reload-a-module-in-julia-1/17192)

<div class="topic-metadata">

**Author:** [@ig-or](https://discourse.julialang.org/u/ig-or)\
**Replies:** 2\
**Last updated:** [November 7, 2018, 11:45pm UTC](https://discourse.julialang.org/t/how-to-reload-a-module-in-julia-1/17192 "2018-11-07T23:45:23Z")

</div>

Hello! Do I have to reload julia if I just need to make a small change inside a module? What is the correct way to handle this? For example, I created a big module mtest. julia\> using mtest \[ Info: Precompiling mtest …

---

## [Solving system of differential equations with complex variables leads to Type errors](https://discourse.julialang.org/t/solving-system-of-differential-equations-with-complex-variables-leads-to-type-errors/17269)

<div class="topic-metadata">

**Author:** [@EmadMasroor](https://discourse.julialang.org/u/EmadMasroor)\
**Replies:** 2\
**Last updated:** [November 7, 2018, 10:28pm UTC](https://discourse.julialang.org/t/solving-system-of-differential-equations-with-complex-variables-leads-to-type-errors/17269 "2018-11-07T22:28:37Z")

</div>

I am trying to solve a set of coupled ODEs where the solution variable is a complex array. When I run the following code, I get an error which says: LoadError: InexactError: Int64(Int64, 1731//50000) The Stacktrace sar…

---

## [Use unreleased packages with Travis](https://discourse.julialang.org/t/use-unreleased-packages-with-travis/17277)

<div class="topic-metadata">

**Author:** [@tpoisot](https://discourse.julialang.org/u/tpoisot)\
**Replies:** 2\
**Last updated:** [November 7, 2018, 9:18pm UTC](https://discourse.julialang.org/t/use-unreleased-packages-with-travis/17277 "2018-11-07T21:18:48Z")

</div>

We’re working on a series of packages, with one core package and a series of companions adding some functionalities. The core package is not currently released, but we would like to use it for testing of the other packag…

---

## [Interpolate: BoundsError thrown in the interior](https://discourse.julialang.org/t/interpolate-boundserror-thrown-in-the-interior/17252)

<div class="topic-metadata">

**Author:** [@axelle](https://discourse.julialang.org/u/axelle)\
**Replies:** 2\
**Last updated:** [November 7, 2018, 7:42pm UTC](https://discourse.julialang.org/t/interpolate-boundserror-thrown-in-the-interior/17252 "2018-11-07T19:42:45Z")

</div>

Hi, I am using version 1.0.0. When using Interpolations, I am thrown a BoundsError for an evaluation inside the domain of the grid. I saw there were some already opened issues such as #244) #245 but I could not see the…

---

## [Why is LinearIndices hardcoded to use Int?](https://discourse.julialang.org/t/why-is-linearindices-hardcoded-to-use-int/17235)

<div class="topic-metadata">

**Author:** [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Replies:** 8\
**Last updated:** [November 7, 2018, 6:10pm UTC](https://discourse.julialang.org/t/why-is-linearindices-hardcoded-to-use-int/17235 "2018-11-07T18:10:14Z")

</div>

Hi, The LinearIndices type is defined in Base at line 382 of indices.jl as struct LinearIndices{N,R\<:NTuple{N,AbstractUnitRange{Int}}} \<: AbstractArray{Int,N} indices::R end I’m wondering why it’s defined to hold …

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

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