# General Usage

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

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

**Page:** 992

---

## [Segmentation fault when using a package, but same code in REPL works fine](https://discourse.julialang.org/t/segmentation-fault-when-using-a-package-but-same-code-in-repl-works-fine/9557)

<div class="topic-metadata">

**Author:** [@safnuk](https://discourse.julialang.org/u/safnuk)\
**Replies:** 4\
**Last updated:** [March 7, 2018, 3:35am UTC](https://discourse.julialang.org/t/segmentation-fault-when-using-a-package-but-same-code-in-repl-works-fine/9557 "2018-03-07T03:35:46Z")

</div>

Hello everyone, I am relatively new to julia, and really not sure how to handle a problem with a package I am developing. When I call a function defined in it, I get a segmentation fault. However, if I paste the exact s…

---

## [How to add arrays using multithreading?](https://discourse.julialang.org/t/how-to-add-arrays-using-multithreading/9532)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 14\
**Last updated:** [March 6, 2018, 2:45pm UTC](https://discourse.julialang.org/t/how-to-add-arrays-using-multithreading/9532 "2018-03-06T14:45:21Z")

</div>

I have a prototype program looking like function calculate(i) # do something, maybe expensive return eye(2)\*rand() end s = zeros(2, 2) Thread.@thread for i in 1:100 s += calculate(i) end I understand thi…

---

## [Sparse instantiation from dense with simultaneous dropzeros](https://discourse.julialang.org/t/sparse-instantiation-from-dense-with-simultaneous-dropzeros/9520)

<div class="topic-metadata">

**Author:** [@crinders](https://discourse.julialang.org/u/crinders)\
**Replies:** 8\
**Last updated:** [March 6, 2018, 1:01pm UTC](https://discourse.julialang.org/t/sparse-instantiation-from-dense-with-simultaneous-dropzeros/9520 "2018-03-06T13:01:48Z")

</div>

I sometimes have the need to construct a sparse matrix from a dense matrix with a fair number of numerical zeros. Currently, I have to duplicate the matrix in as SparseMatrixCSC with sparse() and then drop the zeros with…

---

## [When will a function specialize on types?](https://discourse.julialang.org/t/when-will-a-function-specialize-on-types/9534)

<div class="topic-metadata">

**Author:** [@jamii](https://discourse.julialang.org/u/jamii)\
**Replies:** 1\
**Last updated:** [March 6, 2018, 12:50pm UTC](https://discourse.julialang.org/t/when-will-a-function-specialize-on-types/9534 "2018-03-06T12:50:57Z")

</div>

Is there any documentation on what type a function will specialize on? My mental model was that it only depended on the types of the arguments, not on the method signature, but I ran into this counter-example: julia\> @n…

---

## [Killing current julia and launching a new one programatically](https://discourse.julialang.org/t/killing-current-julia-and-launching-a-new-one-programatically/9516)

<div class="topic-metadata">

**Author:** [@huckl3b3rry87](https://discourse.julialang.org/u/huckl3b3rry87)\
**Replies:** 1\
**Last updated:** [March 6, 2018, 7:11am UTC](https://discourse.julialang.org/t/killing-current-julia-and-launching-a-new-one-programatically/9516 "2018-03-06T07:11:20Z")

</div>

I am running a bunch of different optimization problems and there is some sort of a memory leak detailed some here that causes julia to be Killed. Then when I restart it, I have no problem solving the problem that it was…

---

## [Use of squeeze function](https://discourse.julialang.org/t/use-of-squeeze-function/9500)

<div class="topic-metadata">

**Author:** [@Samudra](https://discourse.julialang.org/u/Samudra)\
**Replies:** 3\
**Last updated:** [March 6, 2018, 6:33am UTC](https://discourse.julialang.org/t/use-of-squeeze-function/9500 "2018-03-06T06:33:43Z")

</div>

Hi , I am trying to understand the way how squeeze function works, when I tried to do the following it gives me the error " squeezed dims must all be size 1" P = 0.1\*ones(Float64, 4, 9) for i=2:4 squeeze(P\[i,:\],1) …

---

## [Are calls to no-op functions passed as arguments always compiled away?](https://discourse.julialang.org/t/are-calls-to-no-op-functions-passed-as-arguments-always-compiled-away/9494)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 8\
**Last updated:** [March 6, 2018, 4:39am UTC](https://discourse.julialang.org/t/are-calls-to-no-op-functions-passed-as-arguments-always-compiled-away/9494 "2018-03-06T04:39:21Z")

</div>

I really like the current trend in Base of functions that take a function as their first argument, and have been adopting it for my own code. My question is: If I define the no-op function f(x) = x can I happily pass …

---

## [Travis OS X and gcc](https://discourse.julialang.org/t/travis-os-x-and-gcc/9525)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 2\
**Last updated:** [March 6, 2018, 12:02am UTC](https://discourse.julialang.org/t/travis-os-x-and-gcc/9525 "2018-03-06T00:02:27Z")

</div>

For the past little while all my OS X tests fail on travis, specifically the installation of gcc fails. I use this: before\_install: - if \[\[ $TRAVIS\_OS\_NAME == 'osx' \]\]; then brew update; fi - if \[\[ $TRAVIS\_OS\_NAME =…

---

## [Test Plots on Travis: GKS can't open display](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 11\
**Last updated:** [March 5, 2018, 10:16pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465 "2018-03-05T22:16:24Z")

</div>

I’m trying to test Plots on Travis and I get this: GKS: can't open display on "" Is your DISPLAY environment variable set correctly? Did you enable X11 and TCP forwarding? GKS: Open failed in routine OPEN\_WS G…

---

## [Automatic import of dependent packages](https://discourse.julialang.org/t/automatic-import-of-dependent-packages/9517)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 1\
**Last updated:** [March 5, 2018, 8:31pm UTC](https://discourse.julialang.org/t/automatic-import-of-dependent-packages/9517 "2018-03-05T20:31:20Z")

</div>

Suppose I develop a package named MyPkg. Also suppose the users of MyPkg must always use other packages PkgA and PkgB (e.g., a core function exported from MyPkg takes types defined in PkgA and PkgB). In that case, it w…

---

## [Maximum!(v, A) is slower than own implementation?](https://discourse.julialang.org/t/maximum-v-a-is-slower-than-own-implementation/9512)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 2\
**Last updated:** [March 5, 2018, 5:37pm UTC](https://discourse.julialang.org/t/maximum-v-a-is-slower-than-own-implementation/9512 "2018-03-05T17:37:23Z")

</div>

I noticed that maximum!(v, A) is slower than my following implementation, I couldn’t find its implementation in Base to check my self. function maximum2!(out,A) @inbounds for i = 1:length(out) out\[i\] = A\[i\] end …

---

## [To include types and functions or to use modules?](https://discourse.julialang.org/t/to-include-types-and-functions-or-to-use-modules/9502)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [March 5, 2018, 3:00pm UTC](https://discourse.julialang.org/t/to-include-types-and-functions-or-to-use-modules/9502 "2018-03-05T15:00:08Z")

</div>

Say I have a package that neatly separates into a few “units” (i.e. chunks of more or less independent code). The units do depend on some overarching constants and functions, as well as each other’s outputs (so unit 2 re…

---

## [Failure of PyPlot backend in Plots](https://discourse.julialang.org/t/failure-of-pyplot-backend-in-plots/9496)

<div class="topic-metadata">

**Author:** [@pegger0709](https://discourse.julialang.org/u/pegger0709)\
**Replies:** 2\
**Last updated:** [March 5, 2018, 5:52am UTC](https://discourse.julialang.org/t/failure-of-pyplot-backend-in-plots/9496 "2018-03-05T05:52:14Z")

</div>

Hello, I want to use the pyplot backend to make some 3D scatter plots using Plots; pyplot() and I get the following: sys:1: UserWarning: This call to matplotlib.use() has no effect because the backend has already be…

---

## [Strange behavior of arrays of UnionAll type](https://discourse.julialang.org/t/strange-behavior-of-arrays-of-unionall-type/9440)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 3\
**Last updated:** [March 5, 2018, 3:04am UTC](https://discourse.julialang.org/t/strange-behavior-of-arrays-of-unionall-type/9440 "2018-03-05T03:04:11Z")

</div>

Though I thought I understood UnionAll types pretty well by now, some behavior of them are still hard to understand. Consider the following example: julia\> struct MyType{N,S\<:NTuple{N}} t::S end MyTy…

---

## [Force interactive?](https://discourse.julialang.org/t/force-interactive/9479)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 7\
**Last updated:** [March 4, 2018, 9:29pm UTC](https://discourse.julialang.org/t/force-interactive/9479 "2018-03-04T21:29:15Z")

</div>

dear julia experts—Is it possible to to invoke julia in batch but still receive the output as if the session was interactive REPL? maybe this could be done by tricking the session into thinking it is interactive, even t…

---

## [Findfirst for Dicts with \`nothing\` keys](https://discourse.julialang.org/t/findfirst-for-dicts-with-nothing-keys/9432)

<div class="topic-metadata">

**Author:** [@Liso](https://discourse.julialang.org/u/Liso)\
**Replies:** 33\
**Last updated:** [March 4, 2018, 8:21pm UTC](https://discourse.julialang.org/t/findfirst-for-dicts-with-nothing-keys/9432 "2018-03-04T20:21:19Z")

</div>

Is there plan to fix this function? julia\> d=Dict(nothing=\>1) julia\> z = findfirst(x-\>x==1, d) # z === nothing ! julia\> d\[z\] # but nothing is correct key 1 julia\> z = findfirst(x-\>x==0, Dict(nothing=\>1)) # or coul…

---

## [Unexpected InexactError() while using DifferentialEquations.jl](https://discourse.julialang.org/t/unexpected-inexacterror-while-using-differentialequations-jl/9482)

<div class="topic-metadata">

**Author:** [@Marcus\_PS](https://discourse.julialang.org/u/Marcus_PS)\
**Replies:** 4\
**Last updated:** [March 4, 2018, 12:23pm UTC](https://discourse.julialang.org/t/unexpected-inexacterror-while-using-differentialequations-jl/9482 "2018-03-04T12:23:34Z")

</div>

Playing around with DifferentialEquations.jl, I ran into a simple corner case. The code corresponds to a trivial ODE, which is a modification of the following (that works just fine). function f(u,p,t) return p \* u …

---

## [Listing imported packages](https://discourse.julialang.org/t/listing-imported-packages/9464)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 4\
**Last updated:** [March 4, 2018, 4:28am UTC](https://discourse.julialang.org/t/listing-imported-packages/9464 "2018-03-04T04:28:02Z")

</div>

Are there any macros, functions, or any ways to show the list of packages imported by “using”? I cannot find a relevant function/macro at https://docs.julialang.org/en/stable/stdlib/pkg/.

---

## [Best approach for runtime dispatching inside a hot loop (heterogeneous tree structure)](https://discourse.julialang.org/t/best-approach-for-runtime-dispatching-inside-a-hot-loop-heterogeneous-tree-structure/9442)

<div class="topic-metadata">

**Author:** [@AleMorales](https://discourse.julialang.org/u/AleMorales)\
**Replies:** 18\
**Last updated:** [March 3, 2018, 10:46pm UTC](https://discourse.julialang.org/t/best-approach-for-runtime-dispatching-inside-a-hot-loop-heterogeneous-tree-structure/9442 "2018-03-03T22:46:17Z")

</div>

I am in the process of writing a ray tracing algorithm in Julia (not related to 3D rendering, but for physical simulations). The code is too complex and I have not been able to make a good MWE, but I will try to describe…

---

## [Build a DateTime from a Date and a Time](https://discourse.julialang.org/t/build-a-datetime-from-a-date-and-a-time/9437)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 4\
**Last updated:** [March 3, 2018, 10:22pm UTC](https://discourse.julialang.org/t/build-a-datetime-from-a-date-and-a-time/9437 "2018-03-03T22:22:07Z")

</div>

Hi all, I’d like to extend the DateTime constructor to accept DateTime(x::Date, y::Time). Can anyone think of anything more sensible than the following? DateTime(x::Date, y::Time) = DateTime(x) + Millisecond(Int(round(…

---

## [Invalid unicode variable](https://discourse.julialang.org/t/invalid-unicode-variable/9476)

<div class="topic-metadata">

**Author:** [@Robert\_Honig](https://discourse.julialang.org/u/Robert_Honig)\
**Replies:** 3\
**Last updated:** [March 3, 2018, 10:11pm UTC](https://discourse.julialang.org/t/invalid-unicode-variable/9476 "2018-03-03T22:11:44Z")

</div>

From what I’ve read, Julia supports unicode literals in symbol names. However, when trying to name a Type “∃Formula”, an error occurs: struct ∃Formula formula::String end ERROR: LoadError: syntax: invalid character …

---

## [Is there any package for creating multi-column output?](https://discourse.julialang.org/t/is-there-any-package-for-creating-multi-column-output/9441)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 1\
**Last updated:** [March 3, 2018, 9:00pm UTC](https://discourse.julialang.org/t/is-there-any-package-for-creating-multi-column-output/9441 "2018-03-03T21:00:40Z")

</div>

I’m trying to implement a show function that displays a list of strings. Because the strings are short and there are many of them, it isn’t making very good use of the screen. So I’m thinking about a text formatting fun…

---

## [Quick Longitudinal Access to arrays](https://discourse.julialang.org/t/quick-longitudinal-access-to-arrays/9280)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 33\
**Last updated:** [March 3, 2018, 5:58pm UTC](https://discourse.julialang.org/t/quick-longitudinal-access-to-arrays/9280 "2018-03-03T17:58:39Z")

</div>

I have an array Xvals, of type Array{Array{Float64,1},1} which corresponds to a time series for a system in dimension d. I’d like to quickly look at the different components, from a longitudinal point of view; in other …

---

## [Best debugging procedures equivalent for VS Debug / Release?](https://discourse.julialang.org/t/best-debugging-procedures-equivalent-for-vs-debug-release/8700)

<div class="topic-metadata">

**Author:** [@marosko89](https://discourse.julialang.org/u/marosko89)\
**Replies:** 0\
**Last updated:** [January 30, 2018, 8:44pm UTC](https://discourse.julialang.org/t/best-debugging-procedures-equivalent-for-vs-debug-release/8700 "2018-01-30T20:44:36Z")

</div>

I develop the package which I use as AOT compiled shared library. I would like to know if there is something new in this area for debugging production code. I found using const DEBUG = false with && here. Are there in Ju…

---

## [Mmap(io, Vector{Union{Missing,T}}, ...)](https://discourse.julialang.org/t/mmap-io-vector-union-missing-t/8863)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [March 3, 2018, 7:36am UTC](https://discourse.julialang.org/t/mmap-io-vector-union-missing-t/8863 "2018-03-03T07:36:12Z")

</div>

Is there a way I can mmap a vector of eltype Union{Missing, T} where isbits(T)? Clearly !isbits(Union{Missing, T}), but I thought this had a compact memory representation now. OK if it works only in v0.7. As a workarou…

---

## [How smart is the 0.7 compiler?](https://discourse.julialang.org/t/how-smart-is-the-0-7-compiler/9419)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 8\
**Last updated:** [March 3, 2018, 7:35am UTC](https://discourse.julialang.org/t/how-smart-is-the-0-7-compiler/9419 "2018-03-03T07:35:59Z")

</div>

From recent postings in this forum, I conclude that the 0.7 compiler has many new optimizations, and I would be interested if someone knowledgeable could explain their reach or else point to a PR in GitHub that describes…

---

## [Controlling both input and output of unix program?](https://discourse.julialang.org/t/controlling-both-input-and-output-of-unix-program/9471)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 0\
**Last updated:** [March 2, 2018, 11:41pm UTC](https://discourse.julialang.org/t/controlling-both-input-and-output-of-unix-program/9471 "2018-03-02T23:41:30Z")

</div>

dear julia experts—I want to start an external computer program, control the input to it, obtain back the output from it, and potentially time out when there is no answer coming (e.g., when I mistakenly wait for results,…

---

## [Overwriting functions in conditional statements](https://discourse.julialang.org/t/overwriting-functions-in-conditional-statements/9459)

<div class="topic-metadata">

**Author:** [@brossetti](https://discourse.julialang.org/u/brossetti)\
**Replies:** 2\
**Last updated:** [March 2, 2018, 4:37pm UTC](https://discourse.julialang.org/t/overwriting-functions-in-conditional-statements/9459 "2018-03-02T16:37:38Z")

</div>

I’m looking for some confirmation or correction about an interesting (to me) behavior I came across when defining functions inside conditional statements. Here’s a quick example: julia\> function test(x) if (x == …

---

## [Linking two values in either direction](https://discourse.julialang.org/t/linking-two-values-in-either-direction/9407)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 13\
**Last updated:** [March 2, 2018, 2:03pm UTC](https://discourse.julialang.org/t/linking-two-values-in-either-direction/9407 "2018-03-02T14:03:58Z")

</div>

Hi all, Is anyone aware of a type that can be used to link two values, in either direction? A trivial example would be if I wanted to link "a" to :z. I’d like to have some object obj such that obj("a") returns :z, and o…

---

## [FFTW warnings in Travis](https://discourse.julialang.org/t/fftw-warnings-in-travis/9448)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 1\
**Last updated:** [March 2, 2018, 12:47pm UTC](https://discourse.julialang.org/t/fftw-warnings-in-travis/9448 "2018-03-02T12:47:02Z")

</div>

These are only warnings, but I was wondering if anyone has a remedy for this, or should I just ignore it: WARNING: --output requested, but no modules defined during run WARNING: The call to compilecache failed to create…

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

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