# General Usage

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

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

**Page:** 989

---

## [@time vs @btime](https://discourse.julialang.org/t/time-vs-btime/9879)

<div class="topic-metadata">

**Author:** [@leoc](https://discourse.julialang.org/u/leoc)\
**Replies:** 5\
**Last updated:** [March 22, 2018, 12:10pm UTC](https://discourse.julialang.org/t/time-vs-btime/9879 "2018-03-22T12:10:31Z")

</div>

Hi all, I know that @btime is better than builtin @time because latest compute some overhead. But in my scenario most of my code is computed only once, and I have to take into account this overhead. Also forcing @btime …

---

## [Why does Julia's \`isbits()\` require not only pointer-freeness but immutability?](https://discourse.julialang.org/t/why-does-julias-isbits-require-not-only-pointer-freeness-but-immutability/9805)

<div class="topic-metadata">

**Author:** [@yatra9](https://discourse.julialang.org/u/yatra9)\
**Replies:** 6\
**Last updated:** [March 21, 2018, 10:39pm UTC](https://discourse.julialang.org/t/why-does-julias-isbits-require-not-only-pointer-freeness-but-immutability/9805 "2018-03-21T22:39:48Z")

</div>

Although I’m not a native English speaker, the word “isbits” implies pointer-freeness only, i.e. copyable with “memcpy” like POD in c++, dosen’t it? Aside from wording, why there is no trait that only indicates pointer-…

---

## [How to get URL of current Jupyter notebook?](https://discourse.julialang.org/t/how-to-get-url-of-current-jupyter-notebook/9851)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 4\
**Last updated:** [March 21, 2018, 9:52pm UTC](https://discourse.julialang.org/t/how-to-get-url-of-current-jupyter-notebook/9851 "2018-03-21T21:52:22Z")

</div>

Let’s say you’re inside a jupyter notebook. How do you find the URL of the current page? This should be equivalent to if you just did the following in the javascript console: window.location.href // this assumes y…

---

## [Buggy array of array](https://discourse.julialang.org/t/buggy-array-of-array/9867)

<div class="topic-metadata">

**Author:** [@leoll2](https://discourse.julialang.org/u/leoll2)\
**Replies:** 3\
**Last updated:** [March 21, 2018, 9:23pm UTC](https://discourse.julialang.org/t/buggy-array-of-array/9867 "2018-03-21T21:23:41Z")

</div>

I’ve spent many hours trying to figure out why this code misbehaves. First, let’s explain this code (which is an excerpt of my real code, just enough to reproduce the issue). I’ve a custom type named MyScalar, which is …

---

## [Requesting idle workers to speed up unbalanced processes with pmap](https://discourse.julialang.org/t/requesting-idle-workers-to-speed-up-unbalanced-processes-with-pmap/9838)

<div class="topic-metadata">

**Author:** [@bchiem](https://discourse.julialang.org/u/bchiem)\
**Replies:** 9\
**Last updated:** [March 21, 2018, 8:12pm UTC](https://discourse.julialang.org/t/requesting-idle-workers-to-speed-up-unbalanced-processes-with-pmap/9838 "2018-03-21T20:12:38Z")

</div>

Dear Julia users, I am currently coding an algorithm that performs the same task on several pieces of a dataset in parallel using pmap, and then gathers the results in a SharedArray. Due to the exploratory nature of the…

---

## [Generator for formal language (a|b)\*](https://discourse.julialang.org/t/generator-for-formal-language-a-b/9861)

<div class="topic-metadata">

**Author:** [@rapus95](https://discourse.julialang.org/u/rapus95)\
**Replies:** 1\
**Last updated:** [March 21, 2018, 5:23pm UTC](https://discourse.julialang.org/t/generator-for-formal-language-a-b/9861 "2018-03-21T17:23:31Z")

</div>

What’s the easiest way to construct a generator that (lazily) returns all words in (a|b)\* ordered by its length?

---

## [Inverse of cumsum/cumsum!?](https://discourse.julialang.org/t/inverse-of-cumsum-cumsum/9828)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 6\
**Last updated:** [March 21, 2018, 1:44am UTC](https://discourse.julialang.org/t/inverse-of-cumsum-cumsum/9828 "2018-03-21T01:44:36Z")

</div>

Is there an inverse operation for cumsum (resp. cumsum!)? It’s not diff, exactly, because diff’s output is one element shorter (and so there can’t be a diff!, either).

---

## [Can't figure out why these allocations are happening](https://discourse.julialang.org/t/cant-figure-out-why-these-allocations-are-happening/9850)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 4\
**Last updated:** [March 21, 2018, 12:18am UTC](https://discourse.julialang.org/t/cant-figure-out-why-these-allocations-are-happening/9850 "2018-03-21T00:18:46Z")

</div>

I can’t figure out why allocations are happening when that should simply destructively update zsum. Here’s the relevant portions of the allocated trace: 0 i = j 0 while i \<= nsync 185614…

---

## [How to use custom indices](https://discourse.julialang.org/t/how-to-use-custom-indices/9848)

<div class="topic-metadata">

**Author:** [@leoll2](https://discourse.julialang.org/u/leoll2)\
**Replies:** 4\
**Last updated:** [March 20, 2018, 11:32pm UTC](https://discourse.julialang.org/t/how-to-use-custom-indices/9848 "2018-03-20T23:32:14Z")

</div>

Hello everyone, I’m having a hard time figuring out how to implement arrays with custom indices. I’ve read all the existing documentation out there, but it’s often poor and lacking of information, especially examples. …

---

## [Julia is running only with root user and for other users throwing error "could not load library sys.so"](https://discourse.julialang.org/t/julia-is-running-only-with-root-user-and-for-other-users-throwing-error-could-not-load-library-sys-so/9744)

<div class="topic-metadata">

**Author:** [@Kaleem\_M](https://discourse.julialang.org/u/Kaleem_M)\
**Replies:** 12\
**Last updated:** [March 20, 2018, 8:24pm UTC](https://discourse.julialang.org/t/julia-is-running-only-with-root-user-and-for-other-users-throwing-error-could-not-load-library-sys-so/9744 "2018-03-20T20:24:19Z")

</div>

Hi All, Julia is working with root user only and not working with other users. It is throwing the following error message. Please advise OS: ubuntu 16.04 Julia: 0.6.2.2 ERROR: could not load library “/julia/JuliaPr…

---

## [Compatibility of Dict{String, Any} with Dict{String, String}](https://discourse.julialang.org/t/compatibility-of-dict-string-any-with-dict-string-string/9841)

<div class="topic-metadata">

**Author:** [@aliddell](https://discourse.julialang.org/u/aliddell)\
**Replies:** 3\
**Last updated:** [March 20, 2018, 5:01pm UTC](https://discourse.julialang.org/t/compatibility-of-dict-string-any-with-dict-string-string/9841 "2018-03-20T17:01:13Z")

</div>

Hi all. I’m trying to pass an argument of type Dict{String, String} to a function with signature Dict{String, Any}, e.g., function foo(x::Dict{String, Any}) x end When I invoke it like so: foo(Dict("bar"=\>"baz")) …

---

## [Problem using PyCall with import not defined](https://discourse.julialang.org/t/problem-using-pycall-with-import-not-defined/9816)

<div class="topic-metadata">

**Author:** [@dompas](https://discourse.julialang.org/u/dompas)\
**Replies:** 7\
**Last updated:** [March 20, 2018, 2:32pm UTC](https://discourse.julialang.org/t/problem-using-pycall-with-import-not-defined/9816 "2018-03-20T14:32:12Z")

</div>

I am running a test code for a larger code that I am working on and this is the code: function addWorkersCluster() if length(procs()) == 1 println("Adding cluster") machines = \[\] cluster = \[102,104,105,106…

---

## [\`run(cmd)\` does not use my shell](https://discourse.julialang.org/t/run-cmd-does-not-use-my-shell/9833)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 2\
**Last updated:** [March 20, 2018, 11:21am UTC](https://discourse.julialang.org/t/run-cmd-does-not-use-my-shell/9833 "2018-03-20T11:21:20Z")

</div>

I’m struggling to call a python script from julia. I am using https://github.com/pyenv/pyenv for multiple python versions, but for that to work my shell needs to be /bin/zsh and it needs to use my login shell (i.e. it ne…

---

## [Have a time issue, need advises on my parallel code](https://discourse.julialang.org/t/have-a-time-issue-need-advises-on-my-parallel-code/9686)

<div class="topic-metadata">

**Author:** [@ersoacc](https://discourse.julialang.org/u/ersoacc)\
**Replies:** 10\
**Last updated:** [March 20, 2018, 7:50am UTC](https://discourse.julialang.org/t/have-a-time-issue-need-advises-on-my-parallel-code/9686 "2018-03-20T07:50:35Z")

</div>

Hello everyone. I am working on a computation fluid dynamics code which needs to solve some subdomains parallel defined in function ASPINS1Sub. To do this, I wrote the code given below which consists of many if stateme…

---

## [Correct calling order for modules and pmap?](https://discourse.julialang.org/t/correct-calling-order-for-modules-and-pmap/9824)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 6\
**Last updated:** [March 20, 2018, 3:04am UTC](https://discourse.julialang.org/t/correct-calling-order-for-modules-and-pmap/9824 "2018-03-20T03:04:11Z")

</div>

I have a module , my\_module.jl, which includes functions that I would like to use with pmap. Currently, I have tried to execute this like: addprocs(4) include("my\_module.jl") @everywhere function pmap\_f(x) return …

---

## [First steps to programming](https://discourse.julialang.org/t/first-steps-to-programming/9436)

<div class="topic-metadata">

**Author:** [@Imane\_Agnaou](https://discourse.julialang.org/u/Imane_Agnaou)\
**Replies:** 14\
**Last updated:** [March 20, 2018, 12:24am UTC](https://discourse.julialang.org/t/first-steps-to-programming/9436 "2018-03-20T00:24:24Z")

</div>

function \[y1,y2\]=Croisement(ch1,ch2) %ch1 chromosome 1; %ch2 chromosome 2; nVar=numel(ch1); c=randi(\[1 nVar-1\]); y1=\[ch1(1:c) ch2(c+1:end)\] y2=\[ch2(1:c) ch1(c+1:end)\] end please how can i write this code by julia ( now …

---

## [Julia-client / juno problems after update to 0.6.10](https://discourse.julialang.org/t/julia-client-juno-problems-after-update-to-0-6-10/9767)

<div class="topic-metadata">

**Author:** [@brenhinkeller](https://discourse.julialang.org/u/brenhinkeller)\
**Replies:** 9\
**Last updated:** [March 20, 2018, 12:13am UTC](https://discourse.julialang.org/t/julia-client-juno-problems-after-update-to-0-6-10/9767 "2018-03-20T00:13:52Z")

</div>

I’m running in to some problems that seem to be associated with the Atom package julia-client that (as far as I understand) provides most of the functionality of Juno. After updating julia-client to v0.6.10 and restartin…

---

## [Operations on missing values](https://discourse.julialang.org/t/operations-on-missing-values/9785)

<div class="topic-metadata">

**Author:** [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Replies:** 8\
**Last updated:** [March 19, 2018, 11:28pm UTC](https://discourse.julialang.org/t/operations-on-missing-values/9785 "2018-03-19T23:28:47Z")

</div>

In Julia 0.7 what is the consensus about the best practice for handling missing arguments in combination with functions that do not accept missing values by design? What I mean is that currently we have for example: ju…

---

## [Using pmap with ForwardDiff](https://discourse.julialang.org/t/using-pmap-with-forwarddiff/9821)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 1\
**Last updated:** [March 19, 2018, 7:57pm UTC](https://discourse.julialang.org/t/using-pmap-with-forwarddiff/9821 "2018-03-19T19:57:18Z")

</div>

I’m trying to run the following code: println(workers()) @everywhere using ForwardDiff @everywhere function V(r) return 0.5 \* ((r\[1\]^2-1)^2) end @everywhere gradV = r-\> ForwardDiff.gradient(V, r); xx = 0:0.1:1;…

---

## [Calling an external mpi executable from julia](https://discourse.julialang.org/t/calling-an-external-mpi-executable-from-julia/9815)

<div class="topic-metadata">

**Author:** [@woutersj](https://discourse.julialang.org/u/woutersj)\
**Replies:** 5\
**Last updated:** [March 19, 2018, 7:21pm UTC](https://discourse.julialang.org/t/calling-an-external-mpi-executable-from-julia/9815 "2018-03-19T19:21:02Z")

</div>

I want to call an MPI exectable from Julia in a Jupyter notebook. Doing cmd = Cmd(\`mpiexec -np 4 name\_of\_executable\`) run(cmd) creates 4 processes, but they all use 25% cpu on one core. Is there a way to have it run 1…

---

## [Creating multi-module projects (preparing for Pkg3)](https://discourse.julialang.org/t/creating-multi-module-projects-preparing-for-pkg3/9808)

<div class="topic-metadata">

**Author:** [@jmert](https://discourse.julialang.org/u/jmert)\
**Replies:** 8\
**Last updated:** [March 19, 2018, 7:12pm UTC](https://discourse.julialang.org/t/creating-multi-module-projects-preparing-for-pkg3/9808 "2018-03-19T19:12:27Z")

</div>

I’m having a hard time understanding how to “properly” lay out semi-shared code among a series of mini-projects, especially in the context of preparing for Julia v0.7/Pkg3. (I’m just starting the project, so with v0.7 im…

---

## [Understanding generated assembly for simple loop](https://discourse.julialang.org/t/understanding-generated-assembly-for-simple-loop/9698)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 14\
**Last updated:** [March 19, 2018, 6:37pm UTC](https://discourse.julialang.org/t/understanding-generated-assembly-for-simple-loop/9698 "2018-03-19T18:37:18Z")

</div>

I am trying to understand how simple julia functions are converted into assembly. In this case, I am interested in summing the integer serie up to some argument: function foo(n) res = zero(n) …

---

## [Difficulty with converting a macro to use multiple parameters](https://discourse.julialang.org/t/difficulty-with-converting-a-macro-to-use-multiple-parameters/9810)

<div class="topic-metadata">

**Author:** [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Replies:** 2\
**Last updated:** [March 19, 2018, 2:19pm UTC](https://discourse.julialang.org/t/difficulty-with-converting-a-macro-to-use-multiple-parameters/9810 "2018-03-19T14:19:49Z")

</div>

I have a simple macro like this: macro logit(signal) :(subscribe!(a -\>@error(@sprintf("Debug %s: ", $(string(signal))), a), $(esc(signal)))) end using MicroLogging using ReactiveBasics as = Signal(0) @logit as p…

---

## [Using DataFrames: ~ 10 seconds](https://discourse.julialang.org/t/using-dataframes-10-seconds/9526)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 24\
**Last updated:** [March 19, 2018, 1:38pm UTC](https://discourse.julialang.org/t/using-dataframes-10-seconds/9526 "2018-03-19T13:38:47Z")

</div>

I AM NOT COMPLAINING. I AM MERELY WONDERING. I have seen a couple of messages about slow package adding/compiling/using times. Why is ‘using DataFrames’ so slow? (i.e., not the first time when using it, so presumabl…

---

## [Nested pmap() functions don not work as I expect](https://discourse.julialang.org/t/nested-pmap-functions-don-not-work-as-i-expect/9789)

<div class="topic-metadata">

**Author:** [@ersoacc](https://discourse.julialang.org/u/ersoacc)\
**Replies:** 3\
**Last updated:** [March 19, 2018, 12:36pm UTC](https://discourse.julialang.org/t/nested-pmap-functions-don-not-work-as-i-expect/9789 "2018-03-19T12:36:45Z")

</div>

Hello everyone. I am using pmap function to calculate and sum a function with different arguments such as: function gparal(nsubs) Gs = pmap(i -\> ASPINS1Sub(i, ...), 1:nsubs) return sum(G…

---

## [Custom distribution for DistributedArrays](https://discourse.julialang.org/t/custom-distribution-for-distributedarrays/9806)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 0\
**Last updated:** [March 19, 2018, 12:08pm UTC](https://discourse.julialang.org/t/custom-distribution-for-distributedarrays/9806 "2018-03-19T12:08:10Z")

</div>

Hi to everybody, I am going to port an old code by mine to Julia. Since this code uses MPI, I figured out I could use DistributedArrays.jl. My code implements a calculation on a very large arrays (~1 TB) and uses MPI to…

---

## [Array performance Julia 0.6 vs 0.5](https://discourse.julialang.org/t/array-performance-julia-0-6-vs-0-5/9796)

<div class="topic-metadata">

**Author:** [@leoc](https://discourse.julialang.org/u/leoc)\
**Replies:** 11\
**Last updated:** [March 19, 2018, 7:54am UTC](https://discourse.julialang.org/t/array-performance-julia-0-6-vs-0-5/9796 "2018-03-19T07:54:48Z")

</div>

Hello, a simple test return strange results … I’ve placed in a file speed05vs06.jl following code: function speedtest() a = \[1:10...\] b = 2\*a + 1 @show a @show b if (VERSION \< v"0.6.0") @time v = (a .\< 7) & (…

---

## [@sync @async with non-loop counter](https://discourse.julialang.org/t/sync-async-with-non-loop-counter/9801)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 0\
**Last updated:** [March 18, 2018, 10:40pm UTC](https://discourse.julialang.org/t/sync-async-with-non-loop-counter/9801 "2018-03-18T22:40:39Z")

</div>

function paralleloop( f::Function, NC::Int=4 ) z = SharedArray{Float64}( NC ) k=0 @sync for i=1:NC k+=1 # z\[k\]= f( k ) # works # @async z\[i\]= f( i ) # works @async z\[…

---

## [Why array slices can't be passed to a function by reference?](https://discourse.julialang.org/t/why-array-slices-cant-be-passed-to-a-function-by-reference/9792)

<div class="topic-metadata">

**Author:** [@vpetukhov](https://discourse.julialang.org/u/vpetukhov)\
**Replies:** 4\
**Last updated:** [March 18, 2018, 6:53pm UTC](https://discourse.julialang.org/t/why-array-slices-cant-be-passed-to-a-function-by-reference/9792 "2018-03-18T18:53:46Z")

</div>

Imagine we have an array and we want to change it inside a function: function set\_ones!(x) x\[:,:\] .= 1 end arr = zeros(5) set\_ones!(arr) println(arr) It works just as expected. Result: \[1.0, 1.0, 1.0, 1.0, 1.0\] B…

---

## [Is there way to run julia in jupyter notebook without leaving terminal?](https://discourse.julialang.org/t/is-there-way-to-run-julia-in-jupyter-notebook-without-leaving-terminal/9782)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 0\
**Last updated:** [March 18, 2018, 5:26am UTC](https://discourse.julialang.org/t/is-there-way-to-run-julia-in-jupyter-notebook-without-leaving-terminal/9782 "2018-03-18T05:26:11Z")

</div>

Let’s say you were making a binder and wanted to build WebIO prior to having the docker box sent to the user. Is there a way to make a jupyter notebook with this tailored initialization routine: cd(Pkg.dir("WebIO", "as…

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

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