# General Usage

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

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

**Page:** 798

---

## [Technical questions about forking packages](https://discourse.julialang.org/t/technical-questions-about-forking-packages/33297)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [January 14, 2020, 6:23am UTC](https://discourse.julialang.org/t/technical-questions-about-forking-packages/33297 "2020-01-14T06:23:50Z")

</div>

Forking packages has been surprisingly rare in the Julia ecosystem, so I could not find any guidelines or examples on it. I am wondering about the following: I am assuming that the fork needs a new UUID, and while tec…

---

## [How to differentiate on ODEProblem (built from other problem) w.r.t. its parameters](https://discourse.julialang.org/t/how-to-differentiate-on-odeproblem-built-from-other-problem-w-r-t-its-parameters/33321)

<div class="topic-metadata">

**Author:** [@Antomek](https://discourse.julialang.org/u/Antomek)\
**Replies:** 1\
**Last updated:** [January 14, 2020, 5:11am UTC](https://discourse.julialang.org/t/how-to-differentiate-on-odeproblem-built-from-other-problem-w-r-t-its-parameters/33321 "2020-01-14T05:11:04Z")

</div>

Hi everyone, The basic issue is: differentiating (using ForwardDiff.jl) an ODEProblem from DifferentialEquations.jl with respect to parameters, where the ODEProblem is built from another ODEProblem. My problem arises i…

---

## [How to let PyCall print out results in a Jupyter Notebook](https://discourse.julialang.org/t/how-to-let-pycall-print-out-results-in-a-jupyter-notebook/33330)

<div class="topic-metadata">

**Author:** [@Tianzhu\_Xiong](https://discourse.julialang.org/u/Tianzhu_Xiong)\
**Replies:** 0\
**Last updated:** [January 14, 2020, 4:43am UTC](https://discourse.julialang.org/t/how-to-let-pycall-print-out-results-in-a-jupyter-notebook/33330 "2020-01-14T04:43:49Z")

</div>

I noticed that if we ask julia to execute the following code in a Jupyter Notebook: using PyCall py""" print('Hello World') """ Nothing is shown in the notebook, but if you execute the same code in a regular Julia cons…

---

## [Is it possible to get the fieldnames of a struct inside a macro?](https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 18\
**Last updated:** [January 14, 2020, 3:00am UTC](https://discourse.julialang.org/t/is-it-possible-to-get-the-fieldnames-of-a-struct-inside-a-macro/33314 "2020-01-14T03:00:53Z")

</div>

Hi all, I was wondering if it is possible to expand or get fieldnames of a DataType inside a macro. My instinct says it is not possible, but maybe someone knows a trick or something… struct DummyStruct a b end # r…

---

## [Programmatic retrieval of const documentation](https://discourse.julialang.org/t/programmatic-retrieval-of-const-documentation/33308)

<div class="topic-metadata">

**Author:** [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Replies:** 7\
**Last updated:** [January 14, 2020, 1:13am UTC](https://discourse.julialang.org/t/programmatic-retrieval-of-const-documentation/33308 "2020-01-14T01:13:13Z")

</div>

How do I programmatically get the documentation for a documented constant? module MyMod """ This is MyAlias """ const MyAlias = Val{:Alias} end using .MyMod Docs.doc(MyMod.MyAlias) .... “…” just gives the documen…

---

## [Julia 1.3 Package Manager Problem](https://discourse.julialang.org/t/julia-1-3-package-manager-problem/33318)

<div class="topic-metadata">

**Author:** [@David\_Hoffman](https://discourse.julialang.org/u/David_Hoffman)\
**Replies:** 2\
**Last updated:** [January 13, 2020, 10:36pm UTC](https://discourse.julialang.org/t/julia-1-3-package-manager-problem/33318 "2020-01-13T22:36:41Z")

</div>

I am creating a RungeKutta.jl for personal use (and as a learning exercise). I have been working on if off and on for a while, and have been using Git and the package manager for some time. I recently added some unit tes…

---

## [Even after PackageCompile, the binary still runs slower than in REPL](https://discourse.julialang.org/t/even-after-packagecompile-the-binary-still-runs-slower-than-in-repl/33165)

<div class="topic-metadata">

**Author:** [@cuchxq](https://discourse.julialang.org/u/cuchxq)\
**Replies:** 11\
**Last updated:** [January 13, 2020, 4:35pm UTC](https://discourse.julialang.org/t/even-after-packagecompile-the-binary-still-runs-slower-than-in-repl/33165 "2020-01-13T16:35:23Z")

</div>

I am trying to find a way to finally deploy the program I have written in Julia. And having a binary seems to be the way to go, since I don’t expect the user to have Julia installed. So I use PackageCompiler.jl. I compi…

---

## [My startup for revise juno](https://discourse.julialang.org/t/my-startup-for-revise-juno/33288)

<div class="topic-metadata">

**Author:** [@mactuan12](https://discourse.julialang.org/u/mactuan12)\
**Replies:** 1\
**Last updated:** [January 13, 2020, 6:44am UTC](https://discourse.julialang.org/t/my-startup-for-revise-juno/33288 "2020-01-13T06:44:02Z")

</div>

So with the new Debugger integration into Juno there’s a lot more incentive to have Revise loaded within a Juno session, but I ran into some issues where loading Revise in my startup.jl was problematic because Atom was…

---

## [What is the best way to use a module inside a function](https://discourse.julialang.org/t/what-is-the-best-way-to-use-a-module-inside-a-function/33285)

<div class="topic-metadata">

**Author:** [@asavasci](https://discourse.julialang.org/u/asavasci)\
**Replies:** 3\
**Last updated:** [January 13, 2020, 5:19am UTC](https://discourse.julialang.org/t/what-is-the-best-way-to-use-a-module-inside-a-function/33285 "2020-01-13T05:19:31Z")

</div>

I am not able to use the function syntax below function f() using DataFrames return Dataframe(x=\[1,2\],y=\[3,4\]) end gives syntax: "using" expression not at top level error message, I searched the error m…

---

## [Delete\_function?](https://discourse.julialang.org/t/delete-function/33278)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 3\
**Last updated:** [January 12, 2020, 9:59pm UTC](https://discourse.julialang.org/t/delete-function/33278 "2020-01-12T21:59:49Z")

</div>

Is there an extension of Base.delete\_method that deletes all registered methods belonging to a function?

---

## [Error, install ZMQ, Julia1.3.1](https://discourse.julialang.org/t/error-install-zmq-julia1-3-1/33188)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 1\
**Last updated:** [January 12, 2020, 9:50pm UTC](https://discourse.julialang.org/t/error-install-zmq-julia1-3-1/33188 "2020-01-12T21:50:34Z")

</div>

I got the following error while installing ZMQ.jl. Could anyone help? System information. Julia Version 1.3.1 Commit 2d5741174c (2019-12-30 21:36 UTC) Platform Info: OS: Windows (x86\_64-w64-mingw32) CPU: Intel(R) C…

---

## [Why doesn't this type substitution work?](https://discourse.julialang.org/t/why-doesnt-this-type-substitution-work/33273)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [January 12, 2020, 7:26pm UTC](https://discourse.julialang.org/t/why-doesnt-this-type-substitution-work/33273 "2020-01-12T19:26:39Z")

</div>

abstract type MM{T,U,V} end function f(args...) typename = (vtypedecl{T, U, V} = MM{T, U, CV} where CV \<: V) typename{args...} end julia\> f(Int,Number,Float64) ERROR: UndefVarError: V not defined …

---

## [Is it possible to define a type that takes a variable number of type parameters](https://discourse.julialang.org/t/is-it-possible-to-define-a-type-that-takes-a-variable-number-of-type-parameters/33264)

<div class="topic-metadata">

**Author:** [@jkroso](https://discourse.julialang.org/u/jkroso)\
**Replies:** 2\
**Last updated:** [January 12, 2020, 6:39pm UTC](https://discourse.julialang.org/t/is-it-possible-to-define-a-type-that-takes-a-variable-number-of-type-parameters/33264 "2020-01-12T18:39:48Z")

</div>

AFAIK there are two types in Julia that can take a variable number of type parameters: Union and Tuple but they both seem to be defined in C. Are there any implemented in Julia or can it not be done?

---

## [DIfferentialEquations with the driving function defined on a fixed grid](https://discourse.julialang.org/t/differentialequations-with-the-driving-function-defined-on-a-fixed-grid/33160)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 2\
**Last updated:** [January 12, 2020, 7:05am UTC](https://discourse.julialang.org/t/differentialequations-with-the-driving-function-defined-on-a-fixed-grid/33160 "2020-01-12T07:05:52Z")

</div>

Hello, I want to use DifferentialEquations.jl to solve a differential equation whose driving function is defined on a fixed grid. One of thе solutions would be to pass the grid and the driving function arrays as paramet…

---

## [Printing 10x10 matrix on Jupyter Notebook](https://discourse.julialang.org/t/printing-10x10-matrix-on-jupyter-notebook/33258)

<div class="topic-metadata">

**Author:** [@Dervis](https://discourse.julialang.org/u/Dervis)\
**Replies:** 2\
**Last updated:** [January 12, 2020, 4:53am UTC](https://discourse.julialang.org/t/printing-10x10-matrix-on-jupyter-notebook/33258 "2020-01-12T04:53:37Z")

</div>

Hello, Anoyone knows how to plot 10x10 large matrix on jupyter notebook without missing any values in it? My solution matrix, “sol”, is 10x10x2 matrix. I would like to print it as two 10x10 matrices. When I do “println…

---

## [Is there a difference between these 2 pieces of code?](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [January 12, 2020, 3:46am UTC](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255 "2020-01-12T03:46:55Z")

</div>

struct MM abstract type TT end export TT MM() = new() end vs abstract type TT end export TT struct MM end Thanks?

---

## [Better syntax for collecting into array including both end points](https://discourse.julialang.org/t/better-syntax-for-collecting-into-array-including-both-end-points/33246)

<div class="topic-metadata">

**Author:** [@ArchieCall](https://discourse.julialang.org/u/ArchieCall)\
**Replies:** 6\
**Last updated:** [January 12, 2020, 2:27am UTC](https://discourse.julialang.org/t/better-syntax-for-collecting-into-array-including-both-end-points/33246 "2020-01-12T02:27:58Z")

</div>

The following code shows two ways of collecting data into an array. MyArray0 may not include YrEnd depending on YrStep. MyArray1 always includes YrEnd regardless of YrStep. Question, is there a better or more elegant …

---

## [Substitute the value of a variable intro the string](https://discourse.julialang.org/t/substitute-the-value-of-a-variable-intro-the-string/33254)

<div class="topic-metadata">

**Author:** [@BMval](https://discourse.julialang.org/u/BMval)\
**Replies:** 4\
**Last updated:** [January 12, 2020, 2:13am UTC](https://discourse.julialang.org/t/substitute-the-value-of-a-variable-intro-the-string/33254 "2020-01-12T02:13:26Z")

</div>

I have a variable: X I have a text: " … $X…" from a text file. What I can do, to substitute the value of variable X into the text? I know how it can be done directly in the code: text = " bla bla bla $x … ", But if th…

---

## [Inconsistency in TypeError message?](https://discourse.julialang.org/t/inconsistency-in-typeerror-message/33256)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 0\
**Last updated:** [January 12, 2020, 1:05am UTC](https://discourse.julialang.org/t/inconsistency-in-typeerror-message/33256 "2020-01-12T01:05:53Z")

</div>

I like the second error because it’s clear to me that which keyword argument was passed with wrong type… julia\> function foo(a, b; x::Bool = true, y::String = "abc") println("hello") x ? a + b : y …

---

## [How to optimize the following code?](https://discourse.julialang.org/t/how-to-optimize-the-following-code/33209)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 7\
**Last updated:** [January 11, 2020, 11:55pm UTC](https://discourse.julialang.org/t/how-to-optimize-the-following-code/33209 "2020-01-11T23:55:35Z")

</div>

I recently watched this video which ended in a comparison between Python+Numba vs Julia (starting around 1h:06m): The author used multithreading to run the same function 10\_000 times and concluded that Juli…

---

## [How to speed up \`Statistics.median\` along a given dimension?](https://discourse.julialang.org/t/how-to-speed-up-statistics-median-along-a-given-dimension/33220)

<div class="topic-metadata">

**Author:** [@bensetterholm](https://discourse.julialang.org/u/bensetterholm)\
**Replies:** 9\
**Last updated:** [January 11, 2020, 9:06pm UTC](https://discourse.julialang.org/t/how-to-speed-up-statistics-median-along-a-given-dimension/33220 "2020-01-11T21:06:51Z")

</div>

I am in the process of translating a Python function into Julia. I was expecting the latter to be faster than the former, but to my surprise the Python function outperformed my Julia version each time. Using the Profil…

---

## [Noob question: JuliaWebAPI - does not accept keyword arguments](https://discourse.julialang.org/t/noob-question-juliawebapi-does-not-accept-keyword-arguments/33228)

<div class="topic-metadata">

**Author:** [@digeratus](https://discourse.julialang.org/u/digeratus)\
**Replies:** 7\
**Last updated:** [January 11, 2020, 7:53pm UTC](https://discourse.julialang.org/t/noob-question-juliawebapi-does-not-accept-keyword-arguments/33228 "2020-01-11T19:53:36Z")

</div>

Hello Julia Community!!! Can’t tell you how much I’m enjoying Julia’s core concepts and implementation. I’m hoping this becomes my main language. Ok, so I created a little prototype using JuliaWebAPI and its GitHub doc…

---

## [Given S = Set{Vector{Int}}, how do I get a reference to the original object in S?](https://discourse.julialang.org/t/given-s-set-vector-int-how-do-i-get-a-reference-to-the-original-object-in-s/33241)

<div class="topic-metadata">

**Author:** [@rrhiemstra](https://discourse.julialang.org/u/rrhiemstra)\
**Replies:** 8\
**Last updated:** [January 11, 2020, 5:54pm UTC](https://discourse.julialang.org/t/given-s-set-vector-int-how-do-i-get-a-reference-to-the-original-object-in-s/33241 "2020-01-11T17:54:14Z")

</div>

Given a set S = Set{Vector{Int}}(s\_1,…,s\_n) and a vector v such that v == s\_k but not v===s\_k, how do I return the original object s\_k from S?

---

## [Huge performance drop using @spawn](https://discourse.julialang.org/t/huge-performance-drop-using-spawn/33242)

<div class="topic-metadata">

**Author:** [@wizebt](https://discourse.julialang.org/u/wizebt)\
**Replies:** 3\
**Last updated:** [January 11, 2020, 5:27pm UTC](https://discourse.julialang.org/t/huge-performance-drop-using-spawn/33242 "2020-01-11T17:27:13Z")

</div>

Using Jeff’s article https://julialang.org/blog/2019/07/multithreading using julia\> VERSION v"1.3.1" I simply tried the first example with JULIA\_NUM\_THREADS=4 on a 12 core machine with 64GB RAM import Base.Threads.@…

---

## [Output type of binary operations involving StaticArrays](https://discourse.julialang.org/t/output-type-of-binary-operations-involving-staticarrays/33187)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 11\
**Last updated:** [January 11, 2020, 10:38am UTC](https://discourse.julialang.org/t/output-type-of-binary-operations-involving-staticarrays/33187 "2020-01-11T10:38:21Z")

</div>

binary operations on a StaticArray and Array give outputs with quite-inconsistent types. For example, intuitively SVector .+ Vector should give a SVector rather than a Vector? julia\> using StaticArrays julia\> typeof(SV…

---

## [Capturing where-clause using MacroTools](https://discourse.julialang.org/t/capturing-where-clause-using-macrotools/33223)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 3\
**Last updated:** [January 11, 2020, 2:29am UTC](https://discourse.julialang.org/t/capturing-where-clause-using-macrotools/33223 "2020-01-11T02:29:48Z")

</div>

Hi there! I wonder if anyone can help me with this… I would like to write a macro that takes a function definition and modifies it to do something at the beginning and at the end. So I cooked up this MWE but I got stuc…

---

## [For loop Performance](https://discourse.julialang.org/t/for-loop-performance/33214)

<div class="topic-metadata">

**Author:** [@sam1988](https://discourse.julialang.org/u/sam1988)\
**Replies:** 8\
**Last updated:** [January 11, 2020, 12:16am UTC](https://discourse.julialang.org/t/for-loop-performance/33214 "2020-01-11T00:16:33Z")

</div>

Can somebody help me in speeding up following function function mean\_loop(p::AbstractArray,q::AbstractArray) a = p; a1 = q; z=0.0; for i in 1:length(a1) s=0.0; @inbounds s= mean(a .\> a1\[i\]); z+= s; s=0.0 end r…

---

## [Ray traversing voxelized cube](https://discourse.julialang.org/t/ray-traversing-voxelized-cube/33065)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 4\
**Last updated:** [January 10, 2020, 8:04pm UTC](https://discourse.julialang.org/t/ray-traversing-voxelized-cube/33065 "2020-01-10T20:04:44Z")

</div>

I have a ray, that traverses a voxelized cube. I want to know, which voxels are traversed by the ray and which are not. Here is a picture in 2d: Is there some julia package that can help?

---

## [Performance Tips for Combinatorial Problem](https://discourse.julialang.org/t/performance-tips-for-combinatorial-problem/32208)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 16\
**Last updated:** [January 10, 2020, 5:50pm UTC](https://discourse.julialang.org/t/performance-tips-for-combinatorial-problem/32208 "2020-01-10T17:50:43Z")

</div>

Hello! I have a combinatorial discrete choice problem that I solve by Backward Induction. The problem seems to be intensive in both memory and computation time and I would be super happy to improve it on any of these two…

---

## [Type instability of getfield()](https://discourse.julialang.org/t/type-instability-of-getfield/33205)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 5\
**Last updated:** [January 10, 2020, 5:10pm UTC](https://discourse.julialang.org/t/type-instability-of-getfield/33205 "2020-01-10T17:10:17Z")

</div>

See the following example julia\> struct Bar{T\<:Real} x::T end julia\> struct Foo{T \<: Real} bars::Array{Bar{T},1} end julia\> foo = Foo(fill(Bar(rand()),2)) Foo{Float64}(Bar{Float64}\[Bar{Floa…

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

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