# General Usage

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

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

**Page:** 815

---

## [Help writing macro which returns an eval expression](https://discourse.julialang.org/t/help-writing-macro-which-returns-an-eval-expression/31046)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 7\
**Last updated:** [November 13, 2019, 6:19pm UTC](https://discourse.julialang.org/t/help-writing-macro-which-returns-an-eval-expression/31046 "2019-11-13T18:19:03Z")

</div>

I have a macro which is expected to return a Core.eval expression, in the line of: macro foreach(f, arr) quote Core.eval(\_\_module\_\_, quote isempty($(esc(arr))) && return "" mapreduce(\*, $(esc(arr)…

---

## [Julia code with references (Latex style). Can I write a code and a paper in one file?](https://discourse.julialang.org/t/julia-code-with-references-latex-style-can-i-write-a-code-and-a-paper-in-one-file/31015)

<div class="topic-metadata">

**Author:** [@BMval](https://discourse.julialang.org/u/BMval)\
**Replies:** 3\
**Last updated:** [November 13, 2019, 5:06pm UTC](https://discourse.julialang.org/t/julia-code-with-references-latex-style-can-i-write-a-code-and-a-paper-in-one-file/31015 "2019-11-13T17:06:13Z")

</div>

Is it possible to include in the code file reference to papers or other code lines? So can I write code and include a latex command like \\citet \\eq and others. I would be helpful to comment code.

---

## [Why StaticArrays are not recommended for large Arrays?](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 2\
**Last updated:** [November 13, 2019, 3:46pm UTC](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041 "2019-11-13T15:46:21Z")

</div>

There is a warning that one should not use StaticArray for very large arrays: Note that in the current implementation, working with large StaticArray s puts a lot of stress on the compiler, and becomes slower than Ba…

---

## [Interpolate DateTime without InexactError](https://discourse.julialang.org/t/interpolate-datetime-without-inexacterror/31033)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 4\
**Last updated:** [November 13, 2019, 11:28am UTC](https://discourse.julialang.org/t/interpolate-datetime-without-inexacterror/31033 "2019-11-13T11:28:46Z")

</div>

Hello, I need to interpolate DateTime I have a function like function interpolate\_time(x1::Float64, t1::DateTime, x2::Float64, t2::DateTime, xI::Float64) return (xI - x1) / (x2 - x1) \* (t2 - t1) + t1 end interpol…

---

## [Reusing code in tests](https://discourse.julialang.org/t/reusing-code-in-tests/31035)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [November 13, 2019, 10:55am UTC](https://discourse.julialang.org/t/reusing-code-in-tests/31035 "2019-11-13T10:55:31Z")

</div>

I am wondering about how to organize test code that gets re-used, but not in a pattern that is regular for all cases. Eg consider the MWE using Test function dotests(xs) for x in xs @test isodd(x) end e…

---

## [Can't understand numerical errors on julia](https://discourse.julialang.org/t/cant-understand-numerical-errors-on-julia/31031)

<div class="topic-metadata">

**Author:** [@jgidi](https://discourse.julialang.org/u/jgidi)\
**Replies:** 2\
**Last updated:** [November 13, 2019, 8:15am UTC](https://discourse.julialang.org/t/cant-understand-numerical-errors-on-julia/31031 "2019-11-13T08:15:10Z")

</div>

Hello! First of all, I want to thank you all. This is the first time that I ask something here, but I always read you, and the community is great. I hope that, with enough experience, I can start answering things aswell …

---

## [Can I subtype "Type" ? If so how?](https://discourse.julialang.org/t/can-i-subtype-type-if-so-how/31017)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 3\
**Last updated:** [November 13, 2019, 7:38am UTC](https://discourse.julialang.org/t/can-i-subtype-type-if-so-how/31017 "2019-11-13T07:38:00Z")

</div>

Topic says it all. I would like to do something like: struct MySpecialType{T\<:Type} \<: Type{T} end

---

## [Profile.init time units](https://discourse.julialang.org/t/profile-init-time-units/30888)

<div class="topic-metadata">

**Author:** [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Replies:** 14\
**Last updated:** [November 13, 2019, 5:05am UTC](https://discourse.julialang.org/t/profile-init-time-units/30888 "2019-11-13T05:05:09Z")

</div>

The documentation says the time units for the delay in Profile.init are in seconds, but the results I’m getting seem more consistent with 100th of a second. What’s going on? Julia 1.2. Profile.init(10000000, 0.3) Prof…

---

## [Why can't I define a macro within a macro and call it?](https://discourse.julialang.org/t/why-cant-i-define-a-macro-within-a-macro-and-call-it/31025)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [November 13, 2019, 2:14am UTC](https://discourse.julialang.org/t/why-cant-i-define-a-macro-within-a-macro-and-call-it/31025 "2019-11-13T02:14:43Z")

</div>

macro mm(T) quote macro kk() :(println("A")) |\> esc end @kk end |\> esc end julia\> @macroexpand @mm Int ERROR: LoadError: Unde…

---

## [DifferentialEquations -- what goes wrong?](https://discourse.julialang.org/t/differentialequations-what-goes-wrong/30960)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 14\
**Last updated:** [November 13, 2019, 12:11am UTC](https://discourse.julialang.org/t/differentialequations-what-goes-wrong/30960 "2019-11-13T00:11:05Z")

</div>

I have solved a PDE successfully in OpenModelica, but I have problems with solving it in Julia. The Julia code seems to work for up to 8 slices (control volumes), but mysteriously collapses for 9 and more slices… I’m co…

---

## [Attach gdb to julia](https://discourse.julialang.org/t/attach-gdb-to-julia/31021)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 1\
**Last updated:** [November 13, 2019, 12:06am UTC](https://discourse.julialang.org/t/attach-gdb-to-julia/31021 "2019-11-13T00:06:16Z")

</div>

I’m trying to attach gdb (v8.3) to a debug build of julia v1.2, and I get Attaching to process 20122 \[New Thread 0x1803 of process 20122\] \[New Thread 0x1903 of process 20122\] \[New Thread 0x1a03 of process 20122\] \[New Th…

---

## [ProgressMeter and Threads.@Threads](https://discourse.julialang.org/t/progressmeter-and-threads-threads/30495)

<div class="topic-metadata">

**Author:** [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Replies:** 6\
**Last updated:** [November 12, 2019, 9:54pm UTC](https://discourse.julialang.org/t/progressmeter-and-threads-threads/30495 "2019-11-12T21:54:33Z")

</div>

Has there been any progress on this? I have tried using it in a manner similar the documentation (but for @threads) and couldn’t get this to work. I am currently using julia-1.2.0. A plain @showprogress 1 "Computing..."…

---

## [Why are there several independent folders inside of the package folder installed?](https://discourse.julialang.org/t/why-are-there-several-independent-folders-inside-of-the-package-folder-installed/31013)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 2\
**Last updated:** [November 12, 2019, 5:17pm UTC](https://discourse.julialang.org/t/why-are-there-several-independent-folders-inside-of-the-package-folder-installed/31013 "2019-11-12T17:17:21Z")

</div>

Hi, following this tutorial, OpenStreetMapX\_tutorial, I’m calculating the route between two given points using OSM data. The following is the code. using OpenStreetMapX md = get\_map\_data("s400.osm", only\_intersections …

---

## [Getting all set values of a sparse matrix](https://discourse.julialang.org/t/getting-all-set-values-of-a-sparse-matrix/31007)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 1\
**Last updated:** [November 12, 2019, 4:21pm UTC](https://discourse.julialang.org/t/getting-all-set-values-of-a-sparse-matrix/31007 "2019-11-12T16:21:28Z")

</div>

Using the sparse array example: julia\> using SparseArrays julia\> A = sparse(\[1, 2, 3\], \[1, 2, 3\], \[0, 2, 0\]) 3×3 SparseMatrixCSC{Int64,Int64} with 3 stored entries: \[1, 1\] = 0 \[2, 2\] = 2 \[3, 3\] = 0 How can…

---

## [Problem to install packages](https://discourse.julialang.org/t/problem-to-install-packages/30977)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 4\
**Last updated:** [November 12, 2019, 3:33pm UTC](https://discourse.julialang.org/t/problem-to-install-packages/30977 "2019-11-12T15:33:34Z")

</div>

Dear all, I just to install Julia in a new computer. When I run Pkg.add("JuMP") a error message appears: Updating registry at \`C:\\Users\\Usuário\\.juliapro\\JuliaPro\_v1.0.4.1\\registries\\JuliaPro\` Updating git-repo \`h…

---

## [Revise seems not triggered in Juno IDE](https://discourse.julialang.org/t/revise-seems-not-triggered-in-juno-ide/30479)

<div class="topic-metadata">

**Author:** [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Replies:** 4\
**Last updated:** [November 12, 2019, 3:27pm UTC](https://discourse.julialang.org/t/revise-seems-not-triggered-in-juno-ide/30479 "2019-11-12T15:27:17Z")

</div>

The other day I decided to come back to Juno for Julia IDE. I have julia-client 0.11.3, language-julia 0.19.1, uber-juno 0.3.0, all of which are the latest. It is no longer unresponsive or lagging. So far so good. Howe…

---

## [Facing issue in HTTP.jl Proxy support](https://discourse.julialang.org/t/facing-issue-in-http-jl-proxy-support/30995)

<div class="topic-metadata">

**Author:** [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Replies:** 8\
**Last updated:** [November 12, 2019, 3:25pm UTC](https://discourse.julialang.org/t/facing-issue-in-http-jl-proxy-support/30995 "2019-11-12T15:25:02Z")

</div>

First of all, I would like to thank everyone who helped me to overcome the obstacles I faced in learning this beautiful and powerful programming language. :slight\_smile: This time, the issue is regarding proxy in HTTP.g…

---

## [No constant expression elimination for e.g. '2^24-1'](https://discourse.julialang.org/t/no-constant-expression-elimination-for-e-g-2-24-1/30964)

<div class="topic-metadata">

**Author:** [@rryi](https://discourse.julialang.org/u/rryi)\
**Replies:** 7\
**Last updated:** [November 12, 2019, 11:26am UTC](https://discourse.julialang.org/t/no-constant-expression-elimination-for-e-g-2-24-1/30964 "2019-11-12T11:26:25Z")

</div>

I found differences in code generation for simple constant expressions: 1\<\<24-1 generates a constant, 2^24-1 generates a quite expensive C function call. Code example below. I did expect Julia to replace both expression…

---

## [Handling network plots with Julia](https://discourse.julialang.org/t/handling-network-plots-with-julia/30949)

<div class="topic-metadata">

**Author:** [@rad1um](https://discourse.julialang.org/u/rad1um)\
**Replies:** 0\
**Last updated:** [November 11, 2019, 12:02pm UTC](https://discourse.julialang.org/t/handling-network-plots-with-julia/30949 "2019-11-11T12:02:27Z")

</div>

Hello everyone, I currently have to plot a lot of networks for my master thesis. Since the common graph tools for networks in julia (e.g. lightgraph, gplot, graphrecipes,…) are far from being as mature as python’s netwo…

---

## [Coordinates transformation from SWEREF 99 to WGS84](https://discourse.julialang.org/t/coordinates-transformation-from-sweref-99-to-wgs84/30943)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 11\
**Last updated:** [November 12, 2019, 9:21am UTC](https://discourse.julialang.org/t/coordinates-transformation-from-sweref-99-to-wgs84/30943 "2019-11-12T09:21:03Z")

</div>

Hi, I have a bunch of coordinate points in SWEREF 99, and I’d like to transfer them into WGS84. I have searched some available libraries from the internet, only to find swift - Converting from coordinate system WGS84 to …

---

## [Performance of Dict](https://discourse.julialang.org/t/performance-of-dict/30993)

<div class="topic-metadata">

**Author:** [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Replies:** 1\
**Last updated:** [November 12, 2019, 9:17am UTC](https://discourse.julialang.org/t/performance-of-dict/30993 "2019-11-12T09:17:32Z")

</div>

Hi! I tend to use the Dict functionality of Julia pretty often to store information (e.g. attributes of various parameters that contain both strings and integers). But I’ve heard that Dict can slow down the performance…

---

## [Julia code generation - from DTD or XML Schema to Julia struct](https://discourse.julialang.org/t/julia-code-generation-from-dtd-or-xml-schema-to-julia-struct/30952)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 3\
**Last updated:** [November 12, 2019, 8:34am UTC](https://discourse.julialang.org/t/julia-code-generation-from-dtd-or-xml-schema-to-julia-struct/30952 "2019-11-12T08:34:11Z")

</div>

Hello, I have some XML data. Most of these data have a schema to describe them. Those schema is either a Document type definition (DTD) or an XML Schema (xsd)). I wonder if Julia have a similar tool than Java JAXB xj…

---

## [Quick question : generated functions and later defined functions](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 5\
**Last updated:** [November 12, 2019, 6:08am UTC](https://discourse.julialang.org/t/quick-question-generated-functions-and-later-defined-functions/30812 "2019-11-12T06:08:01Z")

</div>

Hi, Here,Metaprogramming · The Julia Language, it says " generated function cannot call any method that was not defined prior to the definition of the generated function itself." Is there a way to go beyond this? …

---

## [How to hack into type generation using UnionAlls?](https://discourse.julialang.org/t/how-to-hack-into-type-generation-using-unionalls/30976)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 4\
**Last updated:** [November 12, 2019, 3:05am UTC](https://discourse.julialang.org/t/how-to-hack-into-type-generation-using-unionalls/30976 "2019-11-12T03:05:19Z")

</div>

julia\> abstract type Atype{Q} end julia\> Atype{Int} Atype{Int64} However I want Atype{Int} to produce Union{Atype{Int64}, Atype{Number}, Atype{Signed}} So is there way that I can programmatically intervene in the gene…

---

## [GLM.jl DataFrame not defined error](https://discourse.julialang.org/t/glm-jl-dataframe-not-defined-error/29454)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 2\
**Last updated:** [November 11, 2019, 11:12pm UTC](https://discourse.julialang.org/t/glm-jl-dataframe-not-defined-error/29454 "2019-11-11T23:12:15Z")

</div>

I’m getting a DataFrame not defined error when attempting to use the interval keyword argument in the predict function from GLM.jl. MWE: using DataFrames, GLM data = DataFrame(X=\[1,2,3\], Y=\[2,4,7\]) ols = lm(@formula(Y…

---

## [How to add a package but only if it is not already there?](https://discourse.julialang.org/t/how-to-add-a-package-but-only-if-it-is-not-already-there/30674)

<div class="topic-metadata">

**Author:** [@andromodon](https://discourse.julialang.org/u/andromodon)\
**Replies:** 22\
**Last updated:** [November 11, 2019, 10:03pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-but-only-if-it-is-not-already-there/30674 "2019-11-11T22:03:35Z")

</div>

Hi. I’m learning Julia for the first time. I’'m looking for a way to say in my program “If you don’t already have this package, then get it, but if you do, then just use it”. The issue is that if I just put Pkg.add(“D…

---

## [Behavior of all() and any() on empty vectors](https://discourse.julialang.org/t/behavior-of-all-and-any-on-empty-vectors/30963)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 7\
**Last updated:** [November 11, 2019, 8:17pm UTC](https://discourse.julialang.org/t/behavior-of-all-and-any-on-empty-vectors/30963 "2019-11-11T20:17:14Z")

</div>

This caught me by surprise: julia\> any(x-\>true, \[\]) false julia\> all(x-\>true, \[\]) true julia\> any(x-\>false, \[\]) false julia\> all(x-\>false, \[\]) true This seems like a bug - I think that all should never be true when a…

---

## [Rules for constant elimination](https://discourse.julialang.org/t/rules-for-constant-elimination/6393)

<div class="topic-metadata">

**Author:** [@foobar\_lv](https://discourse.julialang.org/u/foobar_lv)\
**Replies:** 1\
**Last updated:** [October 11, 2017, 8:59pm UTC](https://discourse.julialang.org/t/rules-for-constant-elimination/6393 "2017-10-11T20:59:14Z")

</div>

Is there documentation for the rules for constant elimination? Or is there a well-documented/readable source file I could read? I recently ran into a rather severe performance gotcha in julia 0.6.0 (which is almost wort…

---

## [Default argument that's not executed unless needed?](https://discourse.julialang.org/t/default-argument-thats-not-executed-unless-needed/30957)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 2\
**Last updated:** [November 11, 2019, 3:25pm UTC](https://discourse.julialang.org/t/default-argument-thats-not-executed-unless-needed/30957 "2019-11-11T15:25:14Z")

</div>

I’m trying to write a script where one of the arguments can be a list of things, a file path, or have a default. I’m using ArgParse.jl, and when a user passes eg --parents \<stuff...\> to the commandline, I get an array st…

---

## [Imported ScikitLearn PyObj becomes NULL in a module](https://discourse.julialang.org/t/imported-scikitlearn-pyobj-becomes-null-in-a-module/30942)

<div class="topic-metadata">

**Author:** [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Replies:** 4\
**Last updated:** [November 11, 2019, 2:39pm UTC](https://discourse.julialang.org/t/imported-scikitlearn-pyobj-becomes-null-in-a-module/30942 "2019-11-11T14:39:43Z")

</div>

module TestMod using ScikitLearn: @sk\_import @sk\_import linear\_model: LogisticRegression println(LogisticRegression) export fun function fun() println(LogisticRegression) end end When the above TestMod is impor…

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

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