# General Usage

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

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

**Page:** 896

---

## [Cfunction in runtest](https://discourse.julialang.org/t/cfunction-in-runtest/20445)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 8\
**Last updated:** [February 7, 2019, 7:19am UTC](https://discourse.julialang.org/t/cfunction-in-runtest/20445 "2019-02-07T07:19:37Z")

</div>

I’m trying to port some older package (unregistered) to 1.0. Strange is, the functionality works on REPL, but breaks with sig11 when run in runtests. https://github.com/lobingera/CairoScript.jl/tree/v10prep …

---

## [How do I get the expected return type of a polymorphic function at compile time?](https://discourse.julialang.org/t/how-do-i-get-the-expected-return-type-of-a-polymorphic-function-at-compile-time/20182)

<div class="topic-metadata">

**Author:** [@jlumpe](https://discourse.julialang.org/u/jlumpe)\
**Replies:** 15\
**Last updated:** [February 7, 2019, 6:58am UTC](https://discourse.julialang.org/t/how-do-i-get-the-expected-return-type-of-a-polymorphic-function-at-compile-time/20182 "2019-02-07T06:58:23Z")

</div>

I find myself frequently running into this problem - I have a function f that returns a vector, and a function g that pre-allocates an array and uses f to fill it column by column. In the event that f raises an exception…

---

## [Equivalent of Ref in a @. — $Ref?](https://discourse.julialang.org/t/equivalent-of-ref-in-a-ref/20478)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [February 7, 2019, 6:20am UTC](https://discourse.julialang.org/t/equivalent-of-ref-in-a-ref/20478 "2019-02-07T06:20:31Z")

</div>

If I want to simplify a broadcasted call full of .s with @., what is the recommended way of ensuring that certain values are treated as scalars? Eg should I replace Ref with $Ref? MWE: # setup a, b = 1, 2 cs = collect(1…

---

## [Puzzling inference with inhomogeneous tuples](https://discourse.julialang.org/t/puzzling-inference-with-inhomogeneous-tuples/20498)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 12\
**Last updated:** [February 6, 2019, 4:16pm UTC](https://discourse.julialang.org/t/puzzling-inference-with-inhomogeneous-tuples/20498 "2019-02-06T16:16:20Z")

</div>

Consider this reduced example: f(term, sets...) = (sets..., zero(term)), zero(term) g(sets, term, terms...) = g(\_g(sets, term), terms...) g(sets) = sets function \_g(sets, term) newsets, newset = f(term, sets...) …

---

## [Flux: user defined layer problem](https://discourse.julialang.org/t/flux-user-defined-layer-problem/20455)

<div class="topic-metadata">

**Author:** [@fastwave](https://discourse.julialang.org/u/fastwave)\
**Replies:** 5\
**Last updated:** [February 6, 2019, 4:09pm UTC](https://discourse.julialang.org/t/flux-user-defined-layer-problem/20455 "2019-02-06T16:09:42Z")

</div>

I am trying to define a layer that is a polynomial in Flux. The definition seems to work, but any training with it diverges. It is also impossible to calculate the Jacobian of this polynomial function using Flux, which s…

---

## [Figures not appearing using Makie](https://discourse.julialang.org/t/figures-not-appearing-using-makie/20502)

<div class="topic-metadata">

**Author:** [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Replies:** 2\
**Last updated:** [February 6, 2019, 4:07pm UTC](https://discourse.julialang.org/t/figures-not-appearing-using-makie/20502 "2019-02-06T16:07:51Z")

</div>

Hello everyone, I just installed Makie and the recommended associated packages. I cannot, however get to work a very simple example. I haven’t found anything on discourse that could help me. Maybe I missed something. …

---

## [Word wrap function?](https://discourse.julialang.org/t/word-wrap-function/20438)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 10\
**Last updated:** [February 6, 2019, 3:44pm UTC](https://discourse.julialang.org/t/word-wrap-function/20438 "2019-02-06T15:44:40Z")

</div>

I need a word-wrap function that takes an input string and returns a similar string with some of the spaces replaced by newlines such that no line in the returned string exceeds a threshold length. My current version is …

---

## [Automatically installing dependencies problem](https://discourse.julialang.org/t/automatically-installing-dependencies-problem/20105)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 12\
**Last updated:** [February 6, 2019, 2:24pm UTC](https://discourse.julialang.org/t/automatically-installing-dependencies-problem/20105 "2019-02-06T14:24:18Z")

</div>

Hi! I have an unregistered package that includes a REQUIRE file with some dependencies as StatsBase, JSON, etc. It works fine, the problem is when I install my package in another machine by using pkg\> add https://gith…

---

## [Hard to acess JuliaBox](https://discourse.julialang.org/t/hard-to-acess-juliabox/20382)

<div class="topic-metadata">

**Author:** [@liliya1ageeva](https://discourse.julialang.org/u/liliya1ageeva)\
**Replies:** 1\
**Last updated:** [February 6, 2019, 12:46pm UTC](https://discourse.julialang.org/t/hard-to-acess-juliabox/20382 "2019-02-06T12:46:13Z")

</div>

When I try to access JuliaBox, this problem is appearing: RSA key with id c0dc9e5be2e620e7de8ddbec8b18f12b2d90c264 not found

---

## [Task switch not allowed from inside staged nor pure functions](https://discourse.julialang.org/t/task-switch-not-allowed-from-inside-staged-nor-pure-functions/20488)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 9\
**Last updated:** [February 6, 2019, 10:12am UTC](https://discourse.julialang.org/t/task-switch-not-allowed-from-inside-staged-nor-pure-functions/20488 "2019-02-06T10:12:06Z")

</div>

Recently I encountered the following error while developing my experimental Grassmann.jl package The following error only occurs if I run the commands at once using ; on one line julia\> using Grassmann; mixedbasis"2" \[…

---

## [Allocations when pushing to SVector in a loop](https://discourse.julialang.org/t/allocations-when-pushing-to-svector-in-a-loop/20472)

<div class="topic-metadata">

**Author:** [@rjww](https://discourse.julialang.org/u/rjww)\
**Replies:** 4\
**Last updated:** [February 6, 2019, 4:54am UTC](https://discourse.julialang.org/t/allocations-when-pushing-to-svector-in-a-loop/20472 "2019-02-06T04:54:32Z")

</div>

I’m trying to use SVectors from StaticArrays.jl to minimise allocations in a piece of code, but seeing some weird behaviour (and extra allocations) in a specific use case. If I call the following function function foo()…

---

## [Efficiently compute X\[sub,:\]\*X\[sub,:\]'](https://discourse.julialang.org/t/efficiently-compute-x-sub-x-sub/20480)

<div class="topic-metadata">

**Author:** [@maximerischard](https://discourse.julialang.org/u/maximerischard)\
**Replies:** 1\
**Last updated:** [February 5, 2019, 6:30pm UTC](https://discourse.julialang.org/t/efficiently-compute-x-sub-x-sub/20480 "2019-02-05T18:30:30Z")

</div>

X is a matrix and sub is a subset of columns. I’m trying to find the most efficient way to compute X’X for the submatrix. What I find is that first allocating X\[sub,:\] is significantly faster than using view(X,sub,:), bu…

---

## [Elegantly create Dicts of parameters](https://discourse.julialang.org/t/elegantly-create-dicts-of-parameters/20471)

<div class="topic-metadata">

**Author:** [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)\
**Replies:** 3\
**Last updated:** [February 5, 2019, 2:59pm UTC](https://discourse.julialang.org/t/elegantly-create-dicts-of-parameters/20471 "2019-02-05T14:59:46Z")

</div>

Hey there, I’m trying to write a script that creates dictionaries with simulation parameters. I need these to eventually call pmap(job\_function, parameter\_dicts) where each worker gets its own parameter set and does …

---

## [A\_mul\_B! overwrites elements in an array](https://discourse.julialang.org/t/a-mul-b-overwrites-elements-in-an-array/20421)

<div class="topic-metadata">

**Author:** [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Replies:** 4\
**Last updated:** [February 5, 2019, 7:48am UTC](https://discourse.julialang.org/t/a-mul-b-overwrites-elements-in-an-array/20421 "2019-02-05T07:48:19Z")

</div>

I am using DifferentialEquations and I have following preallocated arrays of the type Array{Array{Float64,2},1}: lay1mul = fill(zeros(n,n),g+1); views = fill(zeros(n,n),g+1); Then, in the derivative function I am filli…

---

## [Is there a way to get keyword argument names of a method?](https://discourse.julialang.org/t/is-there-a-way-to-get-keyword-argument-names-of-a-method/20454)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [February 5, 2019, 1:15am UTC](https://discourse.julialang.org/t/is-there-a-way-to-get-keyword-argument-names-of-a-method/20454 "2019-02-05T01:15:32Z")

</div>

I’m looking for a function which would work in the following way: f(x; y) = () get\_kwarg\_names(first(methods(f))) # would return \[:y\] FWIW, getting the positional argument names could look like, get\_arg\_names(m::Meth…

---

## [Download files from websites using HTTP.jl, Gumbo.jl and Cascadia.jl](https://discourse.julialang.org/t/download-files-from-websites-using-http-jl-gumbo-jl-and-cascadia-jl/20442)

<div class="topic-metadata">

**Author:** [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Replies:** 0\
**Last updated:** [February 4, 2019, 6:41pm UTC](https://discourse.julialang.org/t/download-files-from-websites-using-http-jl-gumbo-jl-and-cascadia-jl/20442 "2019-02-04T18:41:44Z")

</div>

Hello I’m trying to download files from different URLs. In this application, every website has a link called “Formulário de Referência”. Given these two websites sites = \["http://www.dynamo.com.br/pt/empresa/dig" …

---

## [How do I write a macro for evaluating polynomial derivatives?](https://discourse.julialang.org/t/how-do-i-write-a-macro-for-evaluating-polynomial-derivatives/20410)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 13\
**Last updated:** [February 4, 2019, 3:42pm UTC](https://discourse.julialang.org/t/how-do-i-write-a-macro-for-evaluating-polynomial-derivatives/20410 "2019-02-04T15:42:53Z")

</div>

I am working with splines, and I would like to evaluate polynomials along with their derivatives using all sorts of nice tricks like @evalpoly and @SArray. The function below gives an idea. It does not look great, though…

---

## [Suggestion - GUI to change directory](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391)

<div class="topic-metadata">

**Author:** [@johnh](https://discourse.julialang.org/u/johnh)\
**Replies:** 13\
**Last updated:** [February 4, 2019, 3:42pm UTC](https://discourse.julialang.org/t/suggestion-gui-to-change-directory/20391 "2019-02-04T15:42:08Z")

</div>

I find that in the REPL I start by cd(“directory where the data is”) constantly, and this irritates me. By that I mean repeated cd() calls till I get to the directory with the correct data file. Yes, I know I could set …

---

## [\[Coverage.jl\] Submit CI Coverage results to different repo](https://discourse.julialang.org/t/coverage-jl-submit-ci-coverage-results-to-different-repo/20420)

<div class="topic-metadata">

**Author:** [@PieterjanRobbe](https://discourse.julialang.org/u/PieterjanRobbe)\
**Replies:** 2\
**Last updated:** [February 4, 2019, 11:59am UTC](https://discourse.julialang.org/t/coverage-jl-submit-ci-coverage-results-to-different-repo/20420 "2019-02-04T11:59:04Z")

</div>

Suppose I have a package called Main.jl and a separate package TestMain.jl that uses Main.jl. Both are on Github and have Travis CI activated. Is there a way to submit the coverage results from Main, obtained by testing T…

---

## [Inner function overhead](https://discourse.julialang.org/t/inner-function-overhead/20394)

<div class="topic-metadata">

**Author:** [@ShnitzelKiller](https://discourse.julialang.org/u/ShnitzelKiller)\
**Replies:** 2\
**Last updated:** [February 3, 2019, 9:57pm UTC](https://discourse.julialang.org/t/inner-function-overhead/20394 "2019-02-03T21:57:53Z")

</div>

I have found that using a small nested function to handle repeated code has resulted in unwanted allocations. I tried to simplify the below function: function compute\_distance(grid::Matrix{T}, I::CartesianIndex{2}, Ifir…

---

## [On macro hygiene](https://discourse.julialang.org/t/on-macro-hygiene/20406)

<div class="topic-metadata">

**Author:** [@kim366](https://discourse.julialang.org/u/kim366)\
**Replies:** 2\
**Last updated:** [February 3, 2019, 7:24pm UTC](https://discourse.julialang.org/t/on-macro-hygiene/20406 "2019-02-03T19:24:59Z")

</div>

So I have this macro: macro partial(call) Expr(:function, :((rest...,)), Expr(:call, call.args..., :(rest...))) end for partial function application. timestwo = @partial \*(2) timestwo(5) # 10; works fine rest = 7 #…

---

## [Help to create tests for apparently an untestable package](https://discourse.julialang.org/t/help-to-create-tests-for-apparently-an-untestable-package/20386)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 8\
**Last updated:** [February 3, 2019, 6:34pm UTC](https://discourse.julialang.org/t/help-to-create-tests-for-apparently-an-untestable-package/20386 "2019-02-03T18:34:21Z")

</div>

Hi guys! As I mentioned before, I am creating a package to built TUIs using Ncurses. My problem is: how can I develop tests? It seems that it is not possible since all the things needs interactions with the user and rea…

---

## [Memory allocation of keyword arguments](https://discourse.julialang.org/t/memory-allocation-of-keyword-arguments/20389)

<div class="topic-metadata">

**Author:** [@srikar\_sastry](https://discourse.julialang.org/u/srikar_sastry)\
**Replies:** 5\
**Last updated:** [February 3, 2019, 1:52pm UTC](https://discourse.julialang.org/t/memory-allocation-of-keyword-arguments/20389 "2019-02-03T13:52:45Z")

</div>

Hello, I was looking into keyword function arguments. I tried using @time to check the memory allocation for the function, and found that one single keyword argument of type Bool adds half an MB of memory. Is that expec…

---

## [Assigning an array to a view](https://discourse.julialang.org/t/assigning-an-array-to-a-view/20381)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 12\
**Last updated:** [February 3, 2019, 1:37pm UTC](https://discourse.julialang.org/t/assigning-an-array-to-a-view/20381 "2019-02-03T13:37:52Z")

</div>

I am trying to use views to write generic code that can work either with a single vector as an input, operating over numbers, or taking a matrix and operating over vectors (columns of the matrix). Since this is a pretty …

---

## [Preventing broadcast fusing](https://discourse.julialang.org/t/preventing-broadcast-fusing/20372)

<div class="topic-metadata">

**Author:** [@pengwyn](https://discourse.julialang.org/u/pengwyn)\
**Replies:** 17\
**Last updated:** [February 3, 2019, 12:17pm UTC](https://discourse.julialang.org/t/preventing-broadcast-fusing/20372 "2019-02-03T12:17:17Z")

</div>

I have found in a particular function of mine that it is fastest to perform a calculation in 4 steps. I can logically write this down as one line of code, but the fusing syntax of broadcasting ends up being too greedy an…

---

## [Matrix versus matrix transpose](https://discourse.julialang.org/t/matrix-versus-matrix-transpose/8460)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 9\
**Last updated:** [February 3, 2019, 6:57am UTC](https://discourse.julialang.org/t/matrix-versus-matrix-transpose/8460 "2019-02-03T06:57:08Z")

</div>

I’m a bit confused: how is the matrix transpose expected to work? Let’s say I form a transpose: julia\> a = rand(3,3) 3×3 Array{Float64,2}: 0.138434 0.0714774 0.570142 0.169383 0.0834496 0.1411 0.704381 0.070336…

---

## [malloc/segmentation error with ccall](https://discourse.julialang.org/t/malloc-segmentation-error-with-ccall/17653)

<div class="topic-metadata">

**Author:** [@g001234](https://discourse.julialang.org/u/g001234)\
**Replies:** 1\
**Last updated:** [December 23, 2018, 4:08pm UTC](https://discourse.julialang.org/t/malloc-segmentation-error-with-ccall/17653 "2018-12-23T16:08:28Z")

</div>

I have interchangeably two errors (either malloc error or segmentation fault) when using ccall to call a C function. The C function is from the CPLEX C callable library: CPXLIBAPI int CPXPUBLIC CPXcallbackpostheurso…

---

## [Macro in macro with](https://discourse.julialang.org/t/macro-in-macro-with/20378)

<div class="topic-metadata">

**Author:** [@anj](https://discourse.julialang.org/u/anj)\
**Replies:** 4\
**Last updated:** [February 2, 2019, 4:12pm UTC](https://discourse.julialang.org/t/macro-in-macro-with/20378 "2019-02-02T16:12:06Z")

</div>

I have a macro (say m1) which might or might not be defined, depending if user included a file or not. To tackle the problem I am trying to create m2 which calls m1 if module x it is defined in is loaded. Then m1 and mo…

---

## [Reading binary data from raw PCM files](https://discourse.julialang.org/t/reading-binary-data-from-raw-pcm-files/20313)

<div class="topic-metadata">

**Author:** [@srikar\_sastry](https://discourse.julialang.org/u/srikar_sastry)\
**Replies:** 12\
**Last updated:** [February 2, 2019, 5:46am UTC](https://discourse.julialang.org/t/reading-binary-data-from-raw-pcm-files/20313 "2019-02-02T05:46:07Z")

</div>

Hello, I’m new to Julia and trying to figure out a way to read raw PCM samples of audio. When encoded in WAV, I can use the wavread function from the WAV package. But, when the file is simply raw PCM without encoder/dec…

---

## [round() and signif() aren't working](https://discourse.julialang.org/t/round-and-signif-arent-working/20343)

<div class="topic-metadata">

**Author:** [@kirboone](https://discourse.julialang.org/u/kirboone)\
**Replies:** 3\
**Last updated:** [February 2, 2019, 4:49am UTC](https://discourse.julialang.org/t/round-and-signif-arent-working/20343 "2019-02-02T04:49:31Z")

</div>

Hi, I’m new to Julia. I’m trying to use the round() command so that an == condition works properly (don’t need 60 decimal points). For example: round(pi, 3) returns: ERROR: MethodError: no method matching round(::Irra…

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

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