# General Usage

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

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

**Page:** 923

---

## [Slider in Julia with Luxor](https://discourse.julialang.org/t/slider-in-julia-with-luxor/17079)

<div class="topic-metadata">

**Author:** [@microlifecc](https://discourse.julialang.org/u/microlifecc)\
**Replies:** 4\
**Last updated:** [November 3, 2018, 5:37pm UTC](https://discourse.julialang.org/t/slider-in-julia-with-luxor/17079 "2018-11-03T17:37:17Z")

</div>

Hi! I am trying to implement elementary graphics stuffs in Julia, like displaying a circle whose size would change based on the value set by the user on a slider. My code: using Luxor, Interact; @png begin s = sli…

---

## [Arithmetics on Array of Arrays](https://discourse.julialang.org/t/arithmetics-on-array-of-arrays/17115)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 12\
**Last updated:** [November 3, 2018, 5:22pm UTC](https://discourse.julialang.org/t/arithmetics-on-array-of-arrays/17115 "2018-11-03T17:22:07Z")

</div>

I have an array of vectors, represented as static arrays (SArray), and want to perform arithmetic operations like addition (vec + vec), scaling (vec \* vec) and so on. Obvious ways I tried turn out to behave very unintuit…

---

## [Passing Parameter Values using a dictionary](https://discourse.julialang.org/t/passing-parameter-values-using-a-dictionary/17117)

<div class="topic-metadata">

**Author:** [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Replies:** 1\
**Last updated:** [November 3, 2018, 3:41pm UTC](https://discourse.julialang.org/t/passing-parameter-values-using-a-dictionary/17117 "2018-11-03T15:41:04Z")

</div>

I am trying to use a DecisionTree classifer and have specified the parameter value using a dicitonary. See below. An error is thrown when i try to do that # build a classifier dtclf = DecisionTree.DecisionTreeClassifie…

---

## [UndefVarError on loop iterator in while loop](https://discourse.julialang.org/t/undefvarerror-on-loop-iterator-in-while-loop/14747)

<div class="topic-metadata">

**Author:** [@Joseph\_Fletcher](https://discourse.julialang.org/u/Joseph_Fletcher)\
**Replies:** 3\
**Last updated:** [November 3, 2018, 1:28pm UTC](https://discourse.julialang.org/t/undefvarerror-on-loop-iterator-in-while-loop/14747 "2018-11-03T13:28:42Z")

</div>

When I try to run this code I copied from a tutorial, I get an error. t = 0 while t\<5 println(t) t+=1 # t = t + 1 end LoadError: UndefVarError: n not defined Did I do something wrong while setting up Julia?

---

## [Redefining x - y = 0](https://discourse.julialang.org/t/redefining-x-y-0/17015)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 18\
**Last updated:** [November 3, 2018, 8:02am UTC](https://discourse.julialang.org/t/redefining-x-y-0/17015 "2018-11-03T08:02:01Z")

</div>

I just realized you can do this in Julia: x - y = 0 subsequently breaking the minus sign. I had a bug in my code where I wrote - instead of \_ with the intention of defining a variable, and broke - instead. It was a bit…

---

## [Function to get docs of a package to open in a browser window?](https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 12\
**Last updated:** [November 3, 2018, 12:43am UTC](https://discourse.julialang.org/t/function-to-get-docs-of-a-package-to-open-in-a-browser-window/17090 "2018-11-03T00:43:39Z")

</div>

Is there a function docs that will open up the documentation of a package in a new browser window? docs(DataFrames) Goes here It would maybe be a nice feature. Given that so many packages have their Docs as part of th…

---

## [Julia v0.6: loaded JLD file does not show full contents](https://discourse.julialang.org/t/julia-v0-6-loaded-jld-file-does-not-show-full-contents/17108)

<div class="topic-metadata">

**Author:** [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Replies:** 5\
**Last updated:** [November 2, 2018, 11:43pm UTC](https://discourse.julialang.org/t/julia-v0-6-loaded-jld-file-does-not-show-full-contents/17108 "2018-11-02T23:43:23Z")

</div>

(Still) new to julia so bear with me. I have a file Pkg.jld that was saved with package versions from a julia v0.6 installation. I have the correct JLD installed but when I execute load("\<path\>/Pkgs.jld")\["data"\] the…

---

## [Surface Plots](https://discourse.julialang.org/t/surface-plots/7161)

<div class="topic-metadata">

**Author:** [@Romero\_Azzalini](https://discourse.julialang.org/u/Romero_Azzalini)\
**Replies:** 7\
**Last updated:** [November 2, 2018, 9:15pm UTC](https://discourse.julialang.org/t/surface-plots/7161 "2018-11-02T21:15:29Z")

</div>

Hi, has anybody an idea how to make such surface plots I have stored the data in files (one format is x-y-z component). But I have also the format (600x600 grid with the entry of every point in the grid). For the lat…

---

## [Pkg REPL mode: filter status list](https://discourse.julialang.org/t/pkg-repl-mode-filter-status-list/17087)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 3\
**Last updated:** [November 2, 2018, 8:20pm UTC](https://discourse.julialang.org/t/pkg-repl-mode-filter-status-list/17087 "2018-11-02T20:20:08Z")

</div>

If I switch to pkg repl mode (\]) is there a way to filter the status list of added packages? For example, I might want to know which version of package X I’m using in this environment but the status list is really long. …

---

## [Compile-time vs run-time actions](https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035)

<div class="topic-metadata">

**Author:** [@Vic](https://discourse.julialang.org/u/Vic)\
**Replies:** 7\
**Last updated:** [November 2, 2018, 7:15pm UTC](https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035 "2018-11-02T19:15:52Z")

</div>

I would like to make a high-level summary about compile-time vs run-time , based on the end part of this too long thread , that I think will help other (beginner) users too, and also ask a question. While in Julia, due…

---

## [Eval() vs @eval](https://discourse.julialang.org/t/eval-vs-eval/17091)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 7\
**Last updated:** [November 2, 2018, 5:39pm UTC](https://discourse.julialang.org/t/eval-vs-eval/17091 "2018-11-02T17:39:11Z")

</div>

I expected that the two forms would yield identical results. But to my surprise: julia\> @eval :x :x julia\> eval(:x) ERROR: UndefVarError: x not defined Stacktrace: \[1\] top-level scope \[2\] eval at ./boot.jl:319 \[inlin…

---

## [How to let two modules use part of each other?](https://discourse.julialang.org/t/how-to-let-two-modules-use-part-of-each-other/17075)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 2\
**Last updated:** [November 2, 2018, 4:57pm UTC](https://discourse.julialang.org/t/how-to-let-two-modules-use-part-of-each-other/17075 "2018-11-02T16:57:25Z")

</div>

For instance: module moduleA using moduleB export StructA mutable struct StructA i::Int SB::StructB end end module moduleB # import moduleA.StructA using moduleA: StructA export StructB export func mutable st…

---

## [Slow static compilation, large binaries (SnoopCompile/PackageCompiler)](https://discourse.julialang.org/t/slow-static-compilation-large-binaries-snoopcompile-packagecompiler/16450)

<div class="topic-metadata">

**Author:** [@dhazeghi](https://discourse.julialang.org/u/dhazeghi)\
**Replies:** 1\
**Last updated:** [November 2, 2018, 4:16pm UTC](https://discourse.julialang.org/t/slow-static-compilation-large-binaries-snoopcompile-packagecompiler/16450 "2018-11-02T16:16:23Z")

</div>

We’re using PackageCompiler (on Julia 0.6.3) to generate binaries for a couple of tools that we will be deploying. Even though the package we’re building is pretty modest (a few hundred lines of code, dependencies on 3 …

---

## [Add BinDeps dependency to the build in julia v1](https://discourse.julialang.org/t/add-bindeps-dependency-to-the-build-in-julia-v1/17086)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [November 2, 2018, 12:20pm UTC](https://discourse.julialang.org/t/add-bindeps-dependency-to-the-build-in-julia-v1/17086 "2018-11-02T12:20:22Z")

</div>

tl;dr: In the build step of one of my packages I need to make use of BinDeps, but I get an error that the BinDeps package isn’t found in current path. I have this file structure: MyPackage ├── deps │ ├── build.jl # w…

---

## [Inconsistent behavior of getindex method with LinearIndices](https://discourse.julialang.org/t/inconsistent-behavior-of-getindex-method-with-linearindices/17041)

<div class="topic-metadata">

**Author:** [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Replies:** 4\
**Last updated:** [November 2, 2018, 7:18am UTC](https://discourse.julialang.org/t/inconsistent-behavior-of-getindex-method-with-linearindices/17041 "2018-11-02T07:18:46Z")

</div>

Currently we have two getindex methods with LinearIndices here function getindex(iter::LinearIndices, i::Int) @\_inline\_meta @boundscheck checkbounds(iter, i) i end function getindex(iter::LinearIndices, i::A…

---

## [Overwriting Methods](https://discourse.julialang.org/t/overwriting-methods/17078)

<div class="topic-metadata">

**Author:** [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Replies:** 2\
**Last updated:** [November 2, 2018, 1:29am UTC](https://discourse.julialang.org/t/overwriting-methods/17078 "2018-11-02T01:29:13Z")

</div>

Is there a way to tell when you are overwriting a method? For example: The following code exists: f(x::Int) = 0 And then this exists somewhere later: f(x::Int) = 1 Is there a way to make the second line of code err…

---

## [V0.6 vs v1.0: keyword memory allocation example](https://discourse.julialang.org/t/v0-6-vs-v1-0-keyword-memory-allocation-example/17061)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 3\
**Last updated:** [November 2, 2018, 12:51am UTC](https://discourse.julialang.org/t/v0-6-vs-v1-0-keyword-memory-allocation-example/17061 "2018-11-02T00:51:17Z")

</div>

The docs suggest preallocating arrays for performance in the following way: function xinc!(ret::AbstractVector{T}, x::T) where T ret\[1\] = x ret\[2\] = x+1 ret\[3\] = x+2 nothing end function loopinc\_preallo…

---

## [JuMP - with\_optimizer method not working](https://discourse.julialang.org/t/jump-with-optimizer-method-not-working/17055)

<div class="topic-metadata">

**Author:** [@Altaf\_Sultanji](https://discourse.julialang.org/u/Altaf_Sultanji)\
**Replies:** 2\
**Last updated:** [November 1, 2018, 10:01pm UTC](https://discourse.julialang.org/t/jump-with-optimizer-method-not-working/17055 "2018-11-01T22:01:12Z")

</div>

Trying to run this very basic code as is from JuMP / examples in side Jupyter Notebook, but getting this “UndefVarError: with\_optimizer not defined” error. Any idea what is missing or going wrong ? using JuMP, GLPK, Lin…

---

## [Function chaining with |\> and filter function](https://discourse.julialang.org/t/function-chaining-with-and-filter-function/17060)

<div class="topic-metadata">

**Author:** [@sirex](https://discourse.julialang.org/u/sirex)\
**Replies:** 5\
**Last updated:** [November 1, 2018, 9:24pm UTC](https://discourse.julialang.org/t/function-chaining-with-and-filter-function/17060 "2018-11-01T21:24:08Z")

</div>

How can I call filter(isodd) using function chaining |\>? This does not work: julia\> 1:9 |\> filter(isodd) ERROR: MethodError: no method matching filter(::typeof(isodd)) Closest candidates are: filter(::Any, ::Array{T,…

---

## [Doubt about nested functions and scopes](https://discourse.julialang.org/t/doubt-about-nested-functions-and-scopes/17058)

<div class="topic-metadata">

**Author:** [@gcalderone](https://discourse.julialang.org/u/gcalderone)\
**Replies:** 2\
**Last updated:** [November 1, 2018, 6:49pm UTC](https://discourse.julialang.org/t/doubt-about-nested-functions-and-scopes/17058 "2018-11-01T18:49:22Z")

</div>

I need a sortperm! function which returns the number of comparisons actually performed to sort an array. I thought I could do this by intercepting and counting the calls to isless. After a few trials I identified two p…

---

## [MPI.jl status and import error](https://discourse.julialang.org/t/mpi-jl-status-and-import-error/16990)

<div class="topic-metadata">

**Author:** [@tims](https://discourse.julialang.org/u/tims)\
**Replies:** 4\
**Last updated:** [November 1, 2018, 4:39pm UTC](https://discourse.julialang.org/t/mpi-jl-status-and-import-error/16990 "2018-11-01T16:39:55Z")

</div>

Is MPI.jl supported for Julia 0.6.4 ? I get the following precompile error: mpirun -n 1 julia hello.jl WARNING: deprecated syntax “bitstype 64 CComm” at /share/apps/Julia/julia-903644385b/share/julia/site/v0.6/MPI/src…

---

## [Splatting arguments causes ~30x slow down](https://discourse.julialang.org/t/splatting-arguments-causes-30x-slow-down/16964)

<div class="topic-metadata">

**Author:** [@cnliao](https://discourse.julialang.org/u/cnliao)\
**Replies:** 10\
**Last updated:** [November 1, 2018, 3:56pm UTC](https://discourse.julialang.org/t/splatting-arguments-causes-30x-slow-down/16964 "2018-11-01T15:56:49Z")

</div>

I found the performance characteristic not intuitive when trying to splatting arguments into function calls. On Julia v1.0.1 Ubuntu 16.04 I get the following benchmark and numbers: using BenchmarkTools function k1(x1, …

---

## [@testset scoping](https://discourse.julialang.org/t/testset-scoping/17025)

<div class="topic-metadata">

**Author:** [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Replies:** 4\
**Last updated:** [November 1, 2018, 3:13pm UTC](https://discourse.julialang.org/t/testset-scoping/17025 "2018-11-01T15:13:50Z")

</div>

Hi, I’m belatedly getting around to updating some private packages to 0.7 (and then to 1.0). I ran into some instances of implicit globals in the package tests and I’ve mostly gotten rid of them and gotten my head round…

---

## [Comparing Python, Julia, and C++](https://discourse.julialang.org/t/comparing-python-julia-and-c/17019)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 21\
**Last updated:** [November 1, 2018, 1:07pm UTC](https://discourse.julialang.org/t/comparing-python-julia-and-c/17019 "2018-11-01T13:07:53Z")

</div>

I am going to present Julia at the next ADASS (http://adass2018.astro.umd.edu/), and I would like to show its ability to fuse broadcasted operations like .+ and .\*. I have found some weird results, so I would like to as…

---

## [RandomizedSearchCV : specify scoring metrics other than default](https://discourse.julialang.org/t/randomizedsearchcv-specify-scoring-metrics-other-than-default/16994)

<div class="topic-metadata">

**Author:** [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Replies:** 3\
**Last updated:** [November 1, 2018, 8:05am UTC](https://discourse.julialang.org/t/randomizedsearchcv-specify-scoring-metrics-other-than-default/16994 "2018-11-01T08:05:46Z")

</div>

I am using RandomizedsearchCV to fine tune hyperparameters. I think the default scoring is based on “accuracy”. However I wish to specify a different scoring function such as “recall”. I have been able to use it succe…

---

## [Type definition](https://discourse.julialang.org/t/type-definition/17027)

<div class="topic-metadata">

**Author:** [@jackf](https://discourse.julialang.org/u/jackf)\
**Replies:** 3\
**Last updated:** [November 1, 2018, 12:54am UTC](https://discourse.julialang.org/t/type-definition/17027 "2018-11-01T00:54:43Z")

</div>

I’m trying to express a type where the field container types are all identical, but their element type varies. I have tried a few things but can’t crack it: julia\> struct MyType1{V \<: AbstractVector} a::V{Int6…

---

## [Square root array using composition function](https://discourse.julialang.org/t/square-root-array-using-composition-function/17014)

<div class="topic-metadata">

**Author:** [@dribeiro142](https://discourse.julialang.org/u/dribeiro142)\
**Replies:** 7\
**Last updated:** [October 31, 2018, 10:08pm UTC](https://discourse.julialang.org/t/square-root-array-using-composition-function/17014 "2018-10-31T22:08:36Z")

</div>

I want to make this function: sum(sqrt.(rand(20))) using function composition, I tried this forms, but none works. (sum ∘ sqrt.)(rand(10)) (sum ∘ sqrt)(rand(10)) (sum .∘ sqrt)(rand(10)) (sum ∘ sqrt)(.rand(10)) How…

---

## [Accuracy of floats saved with writedlm](https://discourse.julialang.org/t/accuracy-of-floats-saved-with-writedlm/17026)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 5\
**Last updated:** [October 31, 2018, 8:25pm UTC](https://discourse.julialang.org/t/accuracy-of-floats-saved-with-writedlm/17026 "2018-10-31T20:25:23Z")

</div>

Following the discussion on More control over writedlm formatting I understood that the tool to save numeric matrices was wrtiedlm. I have a bunch of small Matrix{Float64}s (some times just 1x2, sometimes ~500x3, never m…

---

## [Question about internal representation of Union{Missing, Float64}](https://discourse.julialang.org/t/question-about-internal-representation-of-union-missing-float64/17000)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 2\
**Last updated:** [October 31, 2018, 3:46pm UTC](https://discourse.julialang.org/t/question-about-internal-representation-of-union-missing-float64/17000 "2018-10-31T15:46:17Z")

</div>

I am trying to understand the internals of the datatype Union{Missing, Float64}. From what I understand, this type encodes the presence of elements in the array by means of a hidden Array{UInt8}, which flags which elemen…

---

## [Avoiding allocations from views: copyto! between arrays of different shape](https://discourse.julialang.org/t/avoiding-allocations-from-views-copyto-between-arrays-of-different-shape/16980)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 14\
**Last updated:** [October 31, 2018, 3:28pm UTC](https://discourse.julialang.org/t/avoiding-allocations-from-views-copyto-between-arrays-of-different-shape/16980 "2018-10-31T15:28:21Z")

</div>

Say I have an n x m Matrix, and an n-length Vector that I want to copy to, say, column 2 of my matrix. My first try was to do copyto! using CartesianIndices. m = rand(3,3) v = rand(3) copyto!(m, CartesianIndices((1:3, 2…

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

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