# General Usage

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

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

**Page:** 766

---

## [Design and performance issues with function generator macro](https://discourse.julialang.org/t/design-and-performance-issues-with-function-generator-macro/37553)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 3\
**Last updated:** [April 14, 2020, 11:31am UTC](https://discourse.julialang.org/t/design-and-performance-issues-with-function-generator-macro/37553 "2020-04-14T11:31:37Z")

</div>

I am having some design and performance issues with a helper macro which creates (binary) parsers for structs. Let me add a bit of background in case of a totally wrong approach: I need to parse binary data and the stru…

---

## [Problem cloning registry in 1.3.1](https://discourse.julialang.org/t/problem-cloning-registry-in-1-3-1/33412)

<div class="topic-metadata">

**Author:** [@Paulo\_Jabardo](https://discourse.julialang.org/u/Paulo_Jabardo)\
**Replies:** 3\
**Last updated:** [April 14, 2020, 9:24am UTC](https://discourse.julialang.org/t/problem-cloning-registry-in-1-3-1/33412 "2020-04-14T09:24:09Z")

</div>

I am on Ubuntu 19.10 and using official Julia 1.3.1 binary tarballs. The problem is: (v1.3) pkg\> add IJulia Cloning default registries into \`~/.julia\` Cloning registry from "https://github.com/JuliaRegistries/Gen…

---

## [Curl certificate issue with Pkg3 on Mac](https://discourse.julialang.org/t/curl-certificate-issue-with-pkg3-on-mac/33299)

<div class="topic-metadata">

**Author:** [@kkmann](https://discourse.julialang.org/u/kkmann)\
**Replies:** 9\
**Last updated:** [April 14, 2020, 8:17am UTC](https://discourse.julialang.org/t/curl-certificate-issue-with-pkg3-on-mac/33299 "2020-04-14T08:17:28Z")

</div>

Hey, I am running into a problem with a FFMPEG dependency on Mac. (v1.3) pkg\> build FFMPEG returns ┌ Error: Error building \`FFMPEG\`: │ \[ Info: Downloading https://github.com/JuliaBinaryWrappers/Bzip2\_jll.jl/releases/…

---

## [How to write a Macro to define the multi-index symbols](https://discourse.julialang.org/t/how-to-write-a-macro-to-define-the-multi-index-symbols/37514)

<div class="topic-metadata">

**Author:** [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Replies:** 14\
**Last updated:** [April 14, 2020, 7:02am UTC](https://discourse.julialang.org/t/how-to-write-a-macro-to-define-the-multi-index-symbols/37514 "2020-04-14T07:02:24Z")

</div>

I write a Macro to define the symbols with one index as following macro varjs(x, j::Int64) vars=Expr(:block) for i = 1:j push!(vars.args, Expr(:(=), esc(Symbol("$x$i")), Expr(:quote,Symbol("$x$i")))) …

---

## [Unboxing while embedding Julia in C++?](https://discourse.julialang.org/t/unboxing-while-embedding-julia-in-c/37491)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [April 14, 2020, 5:31am UTC](https://discourse.julialang.org/t/unboxing-while-embedding-julia-in-c/37491 "2020-04-14T05:31:22Z")

</div>

Hello! So I am embedding some Julia code in C++, and this Julia code returns; 2×2 Array{Array{Int64,1},2}: \[2812, 2126, 74, 1469, 892, 1881, 1693, 318, 1337, 2805 … 2742, 1390, 1916, 2307, 1110, 6, 856, 2408, 2786, …

---

## [Getting at the parameters from each step of optimization](https://discourse.julialang.org/t/getting-at-the-parameters-from-each-step-of-optimization/37539)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 2\
**Last updated:** [April 14, 2020, 2:19am UTC](https://discourse.julialang.org/t/getting-at-the-parameters-from-each-step-of-optimization/37539 "2020-04-14T02:19:51Z")

</div>

Is there an easy way to access/pull the elements stored in the “extended” trace of the output of Optim.optimize()? I’d like to have a matrix, or an array of arrays, where the ith column (or row) is the ith set of parame…

---

## [Issues with For Loop - Appending New DataFrames](https://discourse.julialang.org/t/issues-with-for-loop-appending-new-dataframes/37534)

<div class="topic-metadata">

**Author:** [@aedunn12](https://discourse.julialang.org/u/aedunn12)\
**Replies:** 1\
**Last updated:** [April 13, 2020, 11:41pm UTC](https://discourse.julialang.org/t/issues-with-for-loop-appending-new-dataframes/37534 "2020-04-13T23:41:23Z")

</div>

Hello! I’m trying to run a pretty simple for loop. The premise is that I have a dataframe with 250 different subjects with time points over a number of different dates/times. The issue is that I need my my time to be seq…

---

## [ForwardDiff cannot assign ForwardDiff.Dual to input array](https://discourse.julialang.org/t/forwarddiff-cannot-assign-forwarddiff-dual-to-input-array/37522)

<div class="topic-metadata">

**Author:** [@Hudler](https://discourse.julialang.org/u/Hudler)\
**Replies:** 5\
**Last updated:** [April 13, 2020, 8:38pm UTC](https://discourse.julialang.org/t/forwarddiff-cannot-assign-forwarddiff-dual-to-input-array/37522 "2020-04-13T20:38:22Z")

</div>

Hi, I am trying to solve a following problem. I have an objective function that gets some initial parameters (init in the example) and metaparameter(s) (meta in example). The parameters are then updated w.r.t. metaparam…

---

## [Is changing an error message in a package a breaking change?](https://discourse.julialang.org/t/is-changing-an-error-message-in-a-package-a-breaking-change/37499)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 5\
**Last updated:** [April 13, 2020, 7:40pm UTC](https://discourse.julialang.org/t/is-changing-an-error-message-in-a-package-a-breaking-change/37499 "2020-04-13T19:40:46Z")

</div>

Let’s say that I have a module julia\> module a f(x::Int) = x \>= 0 ? √x : error("negative") end Main.a that I subsequently release as a package. Now an user writes a code that specifically relies on the er…

---

## [String and list](https://discourse.julialang.org/t/string-and-list/37464)

<div class="topic-metadata">

**Author:** [@Marques](https://discourse.julialang.org/u/Marques)\
**Replies:** 4\
**Last updated:** [April 13, 2020, 12:14pm UTC](https://discourse.julialang.org/t/string-and-list/37464 "2020-04-13T12:14:38Z")

</div>

Hi guys. I searched but I couldn’t find the answer. I would like to know how to invert the reading mode, for example in python if you have the phrase = “lua”, just make the phrase \[-1: -4: -1\], and the result would be au…

---

## [Verify a matrix is positive semi-definite](https://discourse.julialang.org/t/verify-a-matrix-is-positive-semi-definite/23329)

<div class="topic-metadata">

**Author:** [@Mr.Robot](https://discourse.julialang.org/u/Mr.Robot)\
**Replies:** 13\
**Last updated:** [April 13, 2020, 12:04pm UTC](https://discourse.julialang.org/t/verify-a-matrix-is-positive-semi-definite/23329 "2020-04-13T12:04:00Z")

</div>

I am trying to numerically verify that A symmetric matrix \\mathbf{A} is positive semidefinite if and only if it is a covariance matrix. Then I need to verify in both directions, i.e. Given a positive semidefinite m…

---

## [Huge sparse array construction](https://discourse.julialang.org/t/huge-sparse-array-construction/37459)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 9\
**Last updated:** [April 12, 2020, 11:25pm UTC](https://discourse.julialang.org/t/huge-sparse-array-construction/37459 "2020-04-12T23:25:49Z")

</div>

Hello, I have a huge sparse matrix (1 million x 1 million) which I am trying to efficiently construct. I am using the following code: D\_matrix = sparse(I, J, V) dropzeros!(D\_matrix,trim = true) Where I,J and V are ver…

---

## [The big difference in speed of remainder calculations](https://discourse.julialang.org/t/the-big-difference-in-speed-of-remainder-calculations/37401)

<div class="topic-metadata">

**Author:** [@likein12](https://discourse.julialang.org/u/likein12)\
**Replies:** 13\
**Last updated:** [April 13, 2020, 8:00am UTC](https://discourse.julialang.org/t/the-big-difference-in-speed-of-remainder-calculations/37401 "2020-04-13T08:00:58Z")

</div>

I found a curious behavior in Julia. When I ran the codes below, big difference in speed was observed. Code 1 function main() a = 0 p = 2^5 N = 100000000 for i in 1:N a %= p end println(a…

---

## [How to collect keyword arguments in a Dict?](https://discourse.julialang.org/t/how-to-collect-keyword-arguments-in-a-dict/6693)

<div class="topic-metadata">

**Author:** [@ksmet1977](https://discourse.julialang.org/u/ksmet1977)\
**Replies:** 9\
**Last updated:** [April 13, 2020, 8:04am UTC](https://discourse.julialang.org/t/how-to-collect-keyword-arguments-in-a-dict/6693 "2020-04-13T08:04:55Z")

</div>

How can I get the keyword arguments and their default values of a function in a dict in Julia? E.g: function foo(x; a = 1, b = 2, c= 3) # How do I get a dict of keyword arguments: Dict(a=\>1, b=\>2,c=3) ??, # so I ca…

---

## [Numerical Problems](https://discourse.julialang.org/t/numerical-problems/37364)

<div class="topic-metadata">

**Author:** [@Andres\_Gonzalez](https://discourse.julialang.org/u/Andres_Gonzalez)\
**Replies:** 12\
**Last updated:** [April 13, 2020, 4:29am UTC](https://discourse.julialang.org/t/numerical-problems/37364 "2020-04-13T04:29:42Z")

</div>

Hi all, I’m trying to write a simple code for an MCMC and I get into numerical errors when comparing two numbers in the metropolis step. The code for the metropolis step is if rand() \< exp( lokNew - logOld) oldPar = N…

---

## [How to access function documentation in a script](https://discourse.julialang.org/t/how-to-access-function-documentation-in-a-script/37466)

<div class="topic-metadata">

**Author:** [@jonathan-durbin](https://discourse.julialang.org/u/jonathan-durbin)\
**Replies:** 6\
**Last updated:** [April 12, 2020, 10:45pm UTC](https://discourse.julialang.org/t/how-to-access-function-documentation-in-a-script/37466 "2020-04-12T22:45:57Z")

</div>

Is there a way to access the documentation string associated with a function that is part of a module? Consider this example: module Test export f """ f(x) Return \`x\` squared. """ function f(x) return x^2 en…

---

## [Initializing Dictionary and where syntax](https://discourse.julialang.org/t/initializing-dictionary-and-where-syntax/37467)

<div class="topic-metadata">

**Author:** [@Holdmycoffee](https://discourse.julialang.org/u/Holdmycoffee)\
**Replies:** 1\
**Last updated:** [April 12, 2020, 9:47pm UTC](https://discourse.julialang.org/t/initializing-dictionary-and-where-syntax/37467 "2020-04-12T21:47:51Z")

</div>

Is there any difference between Dict{T where T\<: Real, Int64}() and Dict{Real, Int64}() ?

---

## [Branch in dispatch on values](https://discourse.julialang.org/t/branch-in-dispatch-on-values/37465)

<div class="topic-metadata">

**Author:** [@mforets](https://discourse.julialang.org/u/mforets)\
**Replies:** 2\
**Last updated:** [April 12, 2020, 9:37pm UTC](https://discourse.julialang.org/t/branch-in-dispatch-on-values/37465 "2020-04-12T21:37:08Z")

</div>

This has probably been discussed elsewhere, but I didn’t find it. Why do the runtimes of foo and bar functions below differ? Since w is constrained to be a boolean, I didn’t expect to see such a huge difference. Let fu…

---

## [Problems embedding Julia in C++](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 5\
**Last updated:** [April 12, 2020, 7:25pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455 "2020-04-12T19:25:37Z")

</div>

Hello! I am properly making a small mistake somewhere, but basically I am using CMake to try to include Julia capabilities in my cpp project. What I have in my CMakeLists.txt for that specific part of the project is: i…

---

## [PkgBenchmark.jl workflow](https://discourse.julialang.org/t/pkgbenchmark-jl-workflow/24472)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 7\
**Last updated:** [April 12, 2020, 4:48pm UTC](https://discourse.julialang.org/t/pkgbenchmark-jl-workflow/24472 "2020-04-12T16:48:26Z")

</div>

This is basically a revival of Benchmarking with PkgBenchmark.jl from two years ago. Benchmarking packages to detect regressions seems very important, but I don’t quite get how to use PkgBenchmark.jl effectively. In par…

---

## [Bug in Julia rational array inplace multiplication](https://discourse.julialang.org/t/bug-in-julia-rational-array-inplace-multiplication/37446)

<div class="topic-metadata">

**Author:** [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Replies:** 7\
**Last updated:** [April 12, 2020, 2:16pm UTC](https://discourse.julialang.org/t/bug-in-julia-rational-array-inplace-multiplication/37446 "2020-04-12T14:16:02Z")

</div>

On AMD64, julia\> x=\[1//1\];x.\*=1/5 1-element Array{Rational{Int64},1}: 3602879701896397//18014398509481984 but on i386 works correctly. See travis build for this repo for behavior on different platforms.

---

## [How to make Zygote not use its default @adjoint for transposition in my custom matrix representation](https://discourse.julialang.org/t/how-to-make-zygote-not-use-its-default-adjoint-for-transposition-in-my-custom-matrix-representation/37422)

<div class="topic-metadata">

**Author:** [@tlauli](https://discourse.julialang.org/u/tlauli)\
**Replies:** 3\
**Last updated:** [April 12, 2020, 2:20pm UTC](https://discourse.julialang.org/t/how-to-make-zygote-not-use-its-default-adjoint-for-transposition-in-my-custom-matrix-representation/37422 "2020-04-12T14:20:18Z")

</div>

Hello, #Minimal Working Example using Flux, Zygote struct MyMat{T} m::Matrix{T} n::Int end Flux.trainable(a::MyMat) = (a.m,) Matrix(a::MyMat) = a.m import Base:transpose #these two functions differ in name only fun…

---

## [Pi raised to negative integer powers produces a strange error message, and the literal\_pow obfuscation](https://discourse.julialang.org/t/pi-raised-to-negative-integer-powers-produces-a-strange-error-message-and-the-literal-pow-obfuscation/37434)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [April 12, 2020, 9:27am UTC](https://discourse.julialang.org/t/pi-raised-to-negative-integer-powers-produces-a-strange-error-message-and-the-literal-pow-obfuscation/37434 "2020-04-12T09:27:21Z")

</div>

I am trying to raise pi to negative integer powers, and end up with unexpected errors: julia\> pi^-2 # works 0.10132118364233779 julia\> n=2; pi^-n # doesn't work ERROR: DomainError with -2: Cannot raise an integer x to …

---

## [Transpose operator](https://discourse.julialang.org/t/transpose-operator/37393)

<div class="topic-metadata">

**Author:** [@Vage\_Karakhanyan](https://discourse.julialang.org/u/Vage_Karakhanyan)\
**Replies:** 11\
**Last updated:** [April 12, 2020, 7:48am UTC](https://discourse.julialang.org/t/transpose-operator/37393 "2020-04-12T07:48:42Z")

</div>

Hello everyone, I am trying to use a transpose operator over a vector in order to perform am element-wise addition. For example, I want to add a column vector a = \[a1;a2;a3\] to a row vector b = \[b1,b2\] I should get mat…

---

## [Trying not to overload Base.open](https://discourse.julialang.org/t/trying-not-to-overload-base-open/37432)

<div class="topic-metadata">

**Author:** [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Replies:** 4\
**Last updated:** [April 12, 2020, 5:46am UTC](https://discourse.julialang.org/t/trying-not-to-overload-base-open/37432 "2020-04-12T05:46:30Z")

</div>

I am trying to define a method open in my own module. I have no interest in overloading Base.open and it’s not imported in my module. However, Travis now complains with: ERROR: LoadError: error in method definition: fu…

---

## [Play a sound in Jupyter Notebook](https://discourse.julialang.org/t/play-a-sound-in-jupyter-notebook/15870)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 11\
**Last updated:** [April 12, 2020, 2:55am UTC](https://discourse.julialang.org/t/play-a-sound-in-jupyter-notebook/15870 "2020-04-12T02:55:41Z")

</div>

I want my Jupyter notebook to play a sound when a cell is done, what is the easiest way to do this? long\_running\_function() play\_sound()

---

## [ERROR "No module named sklearn" when using PyCall](https://discourse.julialang.org/t/error-no-module-named-sklearn-when-using-pycall/37427)

<div class="topic-metadata">

**Author:** [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Replies:** 6\
**Last updated:** [April 12, 2020, 2:19am UTC](https://discourse.julialang.org/t/error-no-module-named-sklearn-when-using-pycall/37427 "2020-04-12T02:19:25Z")

</div>

Hi, I’m trying to use PyCall for some function defined in python. However, it keeps returning the ERROR “No module named sklearn” when I import python package sklearn. I’m pretty sure that sklearn works well with python…

---

## [Using \`isnan()\` with missing values leads to hard to find bugs](https://discourse.julialang.org/t/using-isnan-with-missing-values-leads-to-hard-to-find-bugs/37399)

<div class="topic-metadata">

**Author:** [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Replies:** 6\
**Last updated:** [April 12, 2020, 1:35am UTC](https://discourse.julialang.org/t/using-isnan-with-missing-values-leads-to-hard-to-find-bugs/37399 "2020-04-12T01:35:53Z")

</div>

I found some curious behavior when using the isnan()function on a dataframe with missing values the other day. I was trying to replace NaN values with missing values in the dataframe. However, I found that when I encou…

---

## [Details of the ArrayAndChar broadcasting example](https://discourse.julialang.org/t/details-of-the-arrayandchar-broadcasting-example/37218)

<div class="topic-metadata">

**Author:** [@thisrod](https://discourse.julialang.org/u/thisrod)\
**Replies:** 6\
**Last updated:** [April 12, 2020, 1:16am UTC](https://discourse.julialang.org/t/details-of-the-arrayandchar-broadcasting-example/37218 "2020-04-12T01:16:51Z")

</div>

The Julia manual uses a type ArrayAndChar as its example of how to customise broadcasting. Following a suggestion from @mcabbott, I’m implementing this for real. I’m running into a bunch of complications that the manual…

---

## [Set Julia path in Juno](https://discourse.julialang.org/t/set-julia-path-in-juno/37417)

<div class="topic-metadata">

**Author:** [@alessandro\_di\_nola](https://discourse.julialang.org/u/alessandro_di_nola)\
**Replies:** 1\
**Last updated:** [April 11, 2020, 9:26pm UTC](https://discourse.julialang.org/t/set-julia-path-in-juno/37417 "2020-04-11T21:26:24Z")

</div>

Dear users, I have a problem regarding the installation of Julia and Atom-Juno. I followed the steps described in http://docs.junolab.org/stable/man/installation/index.html. Then I ran Julia but I got the following erro…

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

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