# General Usage

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

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

**Page:** 983

---

## [ANN: UnsafeArray.jl](https://discourse.julialang.org/t/ann-unsafearray-jl/10452)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 4\
**Last updated:** [April 20, 2018, 8:11pm UTC](https://discourse.julialang.org/t/ann-unsafearray-jl/10452 "2018-04-20T20:11:12Z")

</div>

Dear all, I’d like to present UnsafeArray.jl. It’s main function is to provide (heap-)allocation-free array views. It provides a (hopefully) safe alternative to ArrayViews.UnsafeArrayView, and integrates with Base.view(…

---

## [misinterpreting searchindex](https://discourse.julialang.org/t/misinterpreting-searchindex/10447)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 2\
**Last updated:** [April 20, 2018, 7:15pm UTC](https://discourse.julialang.org/t/misinterpreting-searchindex/10447 "2018-04-20T19:15:34Z")

</div>

Perhaps I am misinterpreting how searchindex() or search() works. The docs say, “The third argument optionally specifies a starting index.” Let’s see what I get: searchindex("Hello, World!", "o") 5 searchindex("Hello,…

---

## [Grid plot by factors with Dataframes and Plots](https://discourse.julialang.org/t/grid-plot-by-factors-with-dataframes-and-plots/10454)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 7\
**Last updated:** [April 20, 2018, 4:56pm UTC](https://discourse.julialang.org/t/grid-plot-by-factors-with-dataframes-and-plots/10454 "2018-04-20T16:56:49Z")

</div>

I have a Dataframe with two factors, an IV and a DV. I want to create a grid of plots based on the two factors using Plots.jl. Here is a minimum working example of the data format: using DataFrames df = DataFrame() df\[…

---

## [Where Statements](https://discourse.julialang.org/t/where-statements/10442)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 3\
**Last updated:** [April 20, 2018, 2:38pm UTC](https://discourse.julialang.org/t/where-statements/10442 "2018-04-20T14:38:36Z")

</div>

I would like to understand the difference between multiple where statements and single where statement. Can someone point me in the right direction or give me good answer? Here is an example: julia\> function foo(x::T…

---

## [Julia on Ubuntu Xenial](https://discourse.julialang.org/t/julia-on-ubuntu-xenial/10429)

<div class="topic-metadata">

**Author:** [@johnh](https://discourse.julialang.org/u/johnh)\
**Replies:** 13\
**Last updated:** [April 20, 2018, 1:29pm UTC](https://discourse.julialang.org/t/julia-on-ubuntu-xenial/10429 "2018-04-20T13:29:51Z")

</div>

I got a new Ubuntu Xenial (16.04) workstation at my new job. I absolutely know it is recommended to download Julia from julialang.org , however out of curiosity I used apt-get to install the distro supplied Julia. Vers…

---

## [Loading a shared library on Windows](https://discourse.julialang.org/t/loading-a-shared-library-on-windows/10346)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 7\
**Last updated:** [April 20, 2018, 3:05am UTC](https://discourse.julialang.org/t/loading-a-shared-library-on-windows/10346 "2018-04-20T03:05:40Z")

</div>

I built a shared library, according to the MSVC property manager it is a 32-bit DLL. Yet, when I do julia\> lib = Libdl.dlopen("C:\\\\Users\\\\PetrKrysl\\\\Documents\\\\Work-in-progress\\\\H2Lib-community\\\\build\\\\Library\\\\Release\\…

---

## [Multiprocessing in LAPACK is gone](https://discourse.julialang.org/t/multiprocessing-in-lapack-is-gone/10448)

<div class="topic-metadata">

**Author:** [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Replies:** 0\
**Last updated:** [April 20, 2018, 2:50am UTC](https://discourse.julialang.org/t/multiprocessing-in-lapack-is-gone/10448 "2018-04-20T02:50:07Z")

</div>

Hello everyone, I had built my own Julia excutable because I need to install CUDAdrv. But I was probably not aware of the multiprocessing options. Now when I call eigfact(), there is always only one core running, but on…

---

## [Producing plots in real time - "The applicable method may be too new"](https://discourse.julialang.org/t/producing-plots-in-real-time-the-applicable-method-may-be-too-new/10446)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 7\
**Last updated:** [April 19, 2018, 11:26pm UTC](https://discourse.julialang.org/t/producing-plots-in-real-time-the-applicable-method-may-be-too-new/10446 "2018-04-19T23:26:08Z")

</div>

I have existing code that does some complex calculations in “real time”, and I’ve written it so that I can customize its output with user-defined callback functions. This works well for text output or network interfaces,…

---

## [LaTeXStrings and Plots.jl Norm Symbol](https://discourse.julialang.org/t/latexstrings-and-plots-jl-norm-symbol/10441)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 1\
**Last updated:** [April 19, 2018, 8:22pm UTC](https://discourse.julialang.org/t/latexstrings-and-plots-jl-norm-symbol/10441 "2018-04-19T20:22:11Z")

</div>

If I try to use the norm symbol in a label on a figure (i.e., \\| x\\|), the double bars refuse to appear. This occurs with commands like: xlabel!(L"\\|x\\|") It shows up as |x|.

---

## [Outputting to console / SLURM log files in real time](https://discourse.julialang.org/t/outputting-to-console-slurm-log-files-in-real-time/10436)

<div class="topic-metadata">

**Author:** [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Replies:** 3\
**Last updated:** [April 19, 2018, 4:15pm UTC](https://discourse.julialang.org/t/outputting-to-console-slurm-log-files-in-real-time/10436 "2018-04-19T16:15:59Z")

</div>

I’m running julia scripts on a SLURM server in batch mode (julia my\_script.jl). SLURM creates output files with the output that julia is sending to the console, but I’m finding that while warnings are output in real time…

---

## [Invalid redefinition error for parametric type defined inside macro call](https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424)

<div class="topic-metadata">

**Author:** [@ntezak](https://discourse.julialang.org/u/ntezak)\
**Replies:** 1\
**Last updated:** [April 19, 2018, 2:03am UTC](https://discourse.julialang.org/t/invalid-redefinition-error-for-parametric-type-defined-inside-macro-call/10424 "2018-04-19T02:03:15Z")

</div>

Hi folks, been using Julia happily on and off since v0.2, here is a thing I keep stumbling over: julia\> macro passthru(ex) ex end @passthru (macro with 1 method) julia\> @passthru type MyType{T} …

---

## [Julia not using full CPU when running inside a GNU Screen session (edit: not a Julia isse](https://discourse.julialang.org/t/julia-not-using-full-cpu-when-running-inside-a-gnu-screen-session-edit-not-a-julia-isse/10430)

<div class="topic-metadata">

**Author:** [@Axel\_Gagge](https://discourse.julialang.org/u/Axel_Gagge)\
**Replies:** 3\
**Last updated:** [April 19, 2018, 1:00pm UTC](https://discourse.julialang.org/t/julia-not-using-full-cpu-when-running-inside-a-gnu-screen-session-edit-not-a-julia-isse/10430 "2018-04-19T13:00:48Z")

</div>

EDIT: the following is not a Julia issue, I notice exactly the same problem using Numpy. The following code: x=rand(10000,10000); x\*x shows ~800% CPU usage according to top (I have 8 cores). When running Julia within …

---

## [SOLVED: relative paths where filename arguments are expected](https://discourse.julialang.org/t/solved-relative-paths-where-filename-arguments-are-expected/10426)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 2\
**Last updated:** [April 19, 2018, 5:41am UTC](https://discourse.julialang.org/t/solved-relative-paths-where-filename-arguments-are-expected/10426 "2018-04-19T05:41:36Z")

</div>

Shouldn’t the following work as ways to reference files and directories relative to the current working directory: cd(“…/txt\_output”) isdir(“…/txt\_output”) open(“…/txt\_output/mytext.txt”, “r”) None of them do. Is th…

---

## [Way to treat function as symbol using boolean flag?](https://discourse.julialang.org/t/way-to-treat-function-as-symbol-using-boolean-flag/10384)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 8\
**Last updated:** [April 19, 2018, 1:07am UTC](https://discourse.julialang.org/t/way-to-treat-function-as-symbol-using-boolean-flag/10384 "2018-04-19T01:07:31Z")

</div>

Let’s say you have a bunch of coefficients, i.e. function K\_PC(cur\_blah::AbstractBlah) cur\_K = K\_law(cur\_blah) cur\_K \*= K\_G(cur\_blah) ^ 2 cur\_K \*= 1.273 cur\_K /= cur\_blah.eta\_T cur\_K end However, you’re us…

---

## [Help getting admonitions + pymdowns.details to work in docs](https://discourse.julialang.org/t/help-getting-admonitions-pymdowns-details-to-work-in-docs/10416)

<div class="topic-metadata">

**Author:** [@irislieuw](https://discourse.julialang.org/u/irislieuw)\
**Replies:** 2\
**Last updated:** [April 18, 2018, 10:57pm UTC](https://discourse.julialang.org/t/help-getting-admonitions-pymdowns-details-to-work-in-docs/10416 "2018-04-18T22:57:52Z")

</div>

Hi all, I’d like to use the pymdownx.details extension to create collapsible Admonition blocks in my julia docs. I’m currently using Julia 0.6 and Documenter.jl to generate the markdown files and am building docs with m…

---

## [Conversion?](https://discourse.julialang.org/t/conversion/10421)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 1\
**Last updated:** [April 18, 2018, 10:27pm UTC](https://discourse.julialang.org/t/conversion/10421 "2018-04-18T22:27:56Z")

</div>

Dear J experts: Trying to understand conversions and promotions. How would one set an autoconversion so that a Bool-eable type becomes Bool when Bool is requested. I.e., that the following would work? if (1) "ok" end…

---

## [Best way to import module variables to Main scope?](https://discourse.julialang.org/t/best-way-to-import-module-variables-to-main-scope/10383)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 5\
**Last updated:** [April 18, 2018, 8:42pm UTC](https://discourse.julialang.org/t/best-way-to-import-module-variables-to-main-scope/10383 "2018-04-18T20:42:18Z")

</div>

I run into this problem all the time. I want to develop a package where a bunch of pieces are hidden under the hood. I like testing along the way in jupyter, so constantly have to use \<Pkg\>.blah(blah, blah) Writing \<P…

---

## [SDE with matrix values, question on DifferentialEquations.jl](https://discourse.julialang.org/t/sde-with-matrix-values-question-on-differentialequations-jl/10412)

<div class="topic-metadata">

**Author:** [@benkj](https://discourse.julialang.org/u/benkj)\
**Replies:** 4\
**Last updated:** [April 18, 2018, 5:55pm UTC](https://discourse.julialang.org/t/sde-with-matrix-values-question-on-differentialequations-jl/10412 "2018-04-18T17:55:13Z")

</div>

I have the following SDE du = f(u,p,t)dt + sum\_i g\_i(u,p,t) dW\_i where du, f, and g\_i are all matrices, while W\_i are all independent Wiener processes. I have no problem in setting up the ODE when g\_i is zero, but I c…

---

## [\`read(STDIN, UInt32)\` doesn't seem to respond to the type argument correctly](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308)

<div class="topic-metadata">

**Author:** [@morrisonlevi](https://discourse.julialang.org/u/morrisonlevi)\
**Replies:** 3\
**Last updated:** [April 18, 2018, 5:42pm UTC](https://discourse.julialang.org/t/read-stdin-uint32-doesnt-seem-to-respond-to-the-type-argument-correctly/10308 "2018-04-18T17:42:36Z")

</div>

Today I spent an hour or so helping someone track down a type inference issue. The crux of it is that read(STDIN, UInt32) is inferring a return type of ANY. This seems odd as we are directly passing a type as a parameter…

---

## [Using many packages and including a file results in MethodError for AssertionError](https://discourse.julialang.org/t/using-many-packages-and-including-a-file-results-in-methoderror-for-assertionerror/10406)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 0\
**Last updated:** [April 18, 2018, 8:18am UTC](https://discourse.julialang.org/t/using-many-packages-and-including-a-file-results-in-methoderror-for-assertionerror/10406 "2018-04-18T08:18:20Z")

</div>

In the process of developing something I ended up adding more and more packages, resulting in this long list of using. Now I’ll obviously remove the ones I don’t need, but thought it’s still worth reporting this strange …

---

## [Efficient Disk Usage and JLD](https://discourse.julialang.org/t/efficient-disk-usage-and-jld/10399)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 5\
**Last updated:** [April 18, 2018, 6:06am UTC](https://discourse.julialang.org/t/efficient-disk-usage-and-jld/10399 "2018-04-18T06:06:10Z")

</div>

Suppose I generate the following two files using JLD X1=randn(5,10^4); X2 = \[randn(5) for i=1:10^4\]; @save "X1.jld" X1; @save "X2.jld" X2; Both data structures have the same amount of information, but X1.jld takes up 4…

---

## [Way to construct multi-key ImmutableDict](https://discourse.julialang.org/t/way-to-construct-multi-key-immutabledict/10294)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 13\
**Last updated:** [April 17, 2018, 11:48pm UTC](https://discourse.julialang.org/t/way-to-construct-multi-key-immutabledict/10294 "2018-04-17T23:48:53Z")

</div>

if you try to do, julia\> Base.ImmutableDict( :a =\> 1, :b =\> 2 ) you get, ERROR: MethodError: no method matching Base.ImmutableDict(::Pair{Symbol,Int64}, ::Pair{Symbol,Int64}) Closest candidate…

---

## [Expr malforming in Julia v 0.7](https://discourse.julialang.org/t/expr-malforming-in-julia-v-0-7/10393)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 4\
**Last updated:** [April 17, 2018, 9:03pm UTC](https://discourse.julialang.org/t/expr-malforming-in-julia-v-0-7/10393 "2018-04-17T21:03:27Z")

</div>

Hi fellows This is what happens julia\> Expr(:macrocall,Symbol("@m"),:(:x),:y) :(@m y) I was expecting :frowning:@m :x y) Is this a bug? Thanks

---

## [Standard patterns for arbitrary array constructors](https://discourse.julialang.org/t/standard-patterns-for-arbitrary-array-constructors/10389)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 6\
**Last updated:** [April 17, 2018, 5:47pm UTC](https://discourse.julialang.org/t/standard-patterns-for-arbitrary-array-constructors/10389 "2018-04-17T17:47:55Z")

</div>

I often find myself doing something like M = Matrix{Float64}(undef, m, n) for i ∈ 1:m, j ∈ 1:n # do some stuff which is too long for a list comprehension end it would be nice if I could do Matrix{Float64}(m,n) do …

---

## [How to swap index of a multi-dimensional array?](https://discourse.julialang.org/t/how-to-swap-index-of-a-multi-dimensional-array/10388)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [April 17, 2018, 1:41pm UTC](https://discourse.julialang.org/t/how-to-swap-index-of-a-multi-dimensional-array/10388 "2018-04-17T13:41:19Z")

</div>

I have a multi-dimensional array with shape (2, 3, 4, 5, 6), how can I swap dimensions in Julia? I want to swap to (2, 4, 3, 5, 6).

---

## [Evaluate Function Inside Quote](https://discourse.julialang.org/t/evaluate-function-inside-quote/10386)

<div class="topic-metadata">

**Author:** [@MLackner](https://discourse.julialang.org/u/MLackner)\
**Replies:** 2\
**Last updated:** [April 17, 2018, 1:35pm UTC](https://discourse.julialang.org/t/evaluate-function-inside-quote/10386 "2018-04-17T13:35:13Z")

</div>

Hi! I’ve got a seemingly trivial problem to tackle… Why does this work: julia\> function foo(x) f = quote function bar() a = $x println(a) end end eval(f) end foo (gen…

---

## [ClusterManagers package not connecting for PBS batch system](https://discourse.julialang.org/t/clustermanagers-package-not-connecting-for-pbs-batch-system/8879)

<div class="topic-metadata">

**Author:** [@jman87](https://discourse.julialang.org/u/jman87)\
**Replies:** 10\
**Last updated:** [April 17, 2018, 10:36am UTC](https://discourse.julialang.org/t/clustermanagers-package-not-connecting-for-pbs-batch-system/8879 "2018-04-17T10:36:56Z")

</div>

I am having issues getting the ClusterManagers package to work on an SGI cluster. I have referenced the following discussion heavily but to no avail: At this point, I have edited the ~/.julia/v0.6/ClusterManagers/src/…

---

## [Different parsing for the same expr in v06. and v07](https://discourse.julialang.org/t/different-parsing-for-the-same-expr-in-v06-and-v07/10379)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 0\
**Last updated:** [April 17, 2018, 12:19am UTC](https://discourse.julialang.org/t/different-parsing-for-the-same-expr-in-v06-and-v07/10379 "2018-04-17T00:19:30Z")

</div>

here is from v0.6 julia\> ex = :(begin Fun(x, Var(y)), if x == y end =\> true \_ =\> false end) quote # REPL\[8\], line 2: (Fun(x, Var(y)), if x == y # REPL\[8\], line 2: end) …

---

## [Test whether bounds checking is on?](https://discourse.julialang.org/t/test-whether-bounds-checking-is-on/10377)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 1\
**Last updated:** [April 16, 2018, 9:57pm UTC](https://discourse.julialang.org/t/test-whether-bounds-checking-is-on/10377 "2018-04-16T21:57:13Z")

</div>

dear j experts—I want to put a variety of asserts into my code, sort of like “programming by contract.” the cases in which I care about checking them are exactly the cases in which I like bounds checking; and when I wan…

---

## [Current\_module() vs @\_\_MODULE\_\_ / They are not equivalent](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 4\
**Last updated:** [April 16, 2018, 9:16pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373 "2018-04-16T21:16:20Z")

</div>

julia\> module XXX export foo,bar function foo(amod::Module = current\_module()) println(amod) end function bar(amod::Module = @\_\_MODULE\_\_…

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

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