# General Usage

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

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

**Page:** 836

---

## [Error, parallel computing in a module](https://discourse.julialang.org/t/error-parallel-computing-in-a-module/28275)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 2\
**Last updated:** [September 3, 2019, 3:06am UTC](https://discourse.julialang.org/t/error-parallel-computing-in-a-module/28275 "2019-09-03T03:06:00Z")

</div>

I am creating a package which use parallel computing. I encountered some errors and not sure which place to put addprocs() and implement the parallel code. Please give some suggestions. The code is as follows. Repost: …

---

## [Using a (normalized) Histogram as a Distribution](https://discourse.julialang.org/t/using-a-normalized-histogram-as-a-distribution/27682)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 29\
**Last updated:** [September 3, 2019, 1:28am UTC](https://discourse.julialang.org/t/using-a-normalized-histogram-as-a-distribution/27682 "2019-09-03T01:28:44Z")

</div>

Do we have a wrapper somewhere that turns a StatsBase.Histogram into a Distributions.Distribution?

---

## [What happens in struct construction](https://discourse.julialang.org/t/what-happens-in-struct-construction/28305)

<div class="topic-metadata">

**Author:** [@jasonsun0310](https://discourse.julialang.org/u/jasonsun0310)\
**Replies:** 5\
**Last updated:** [September 2, 2019, 10:11pm UTC](https://discourse.julialang.org/t/what-happens-in-struct-construction/28305 "2019-09-02T22:11:23Z")

</div>

I wonder what is under the hood in the construction process of a struct. For example: struct A field::Dict member\_function function A(::Type{Int64}) return new(Dict(1 =\> "one"), nothing) end …

---

## [Keeping (AOT-compiling) runtime-generated functions](https://discourse.julialang.org/t/keeping-aot-compiling-runtime-generated-functions/27974)

<div class="topic-metadata">

**Author:** [@asprionj](https://discourse.julialang.org/u/asprionj)\
**Replies:** 4\
**Last updated:** [September 2, 2019, 9:37pm UTC](https://discourse.julialang.org/t/keeping-aot-compiling-runtime-generated-functions/27974 "2019-09-02T21:37:46Z")

</div>

I’m using code generation to generate efficient implementations of nested functions. That is, some functions are generated first and then used in another code-generated function. In a REPL-based workflow, this works fine…

---

## [DSL help with nested macros](https://discourse.julialang.org/t/dsl-help-with-nested-macros/28267)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 5\
**Last updated:** [September 2, 2019, 7:26pm UTC](https://discourse.julialang.org/t/dsl-help-with-nested-macros/28267 "2019-09-02T19:26:26Z")

</div>

Hi all. I’m learning how to implement DSL using macros and some help would be appreciated. In particular, I would like to create a DSL for L-System. The purpose of DSL is clean syntax. So here’s what I’m thinking in …

---

## [Chained comparisons on arrays allocating](https://discourse.julialang.org/t/chained-comparisons-on-arrays-allocating/28301)

<div class="topic-metadata">

**Author:** [@3d5g](https://discourse.julialang.org/u/3d5g)\
**Replies:** 2\
**Last updated:** [September 2, 2019, 7:21pm UTC](https://discourse.julialang.org/t/chained-comparisons-on-arrays-allocating/28301 "2019-09-02T19:21:04Z")

</div>

I consistently get heap allocations in groups of 3 of 4.33 KiB for each chain of comparisons: x = randn(Float64, (2,3)) y = similar(x) z @btime @. $y = -1 \<= $x \< 1 This prints “481.026 ns (3 allocations: 4.33 KiB)”. …

---

## [Is there a way to do unsafe type coercions?](https://discourse.julialang.org/t/is-there-a-way-to-do-unsafe-type-coercions/28281)

<div class="topic-metadata">

**Author:** [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Replies:** 14\
**Last updated:** [September 2, 2019, 7:00pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-do-unsafe-type-coercions/28281 "2019-09-02T19:00:46Z")

</div>

Let the compiler treat an object as a custom specified type. It’s unsafe but it’s necessary for this:

---

## [Type inference and abstract interpretation](https://discourse.julialang.org/t/type-inference-and-abstract-interpretation/28259)

<div class="topic-metadata">

**Author:** [@aml](https://discourse.julialang.org/u/aml)\
**Replies:** 3\
**Last updated:** [September 2, 2019, 5:59pm UTC](https://discourse.julialang.org/t/type-inference-and-abstract-interpretation/28259 "2019-09-02T17:59:03Z")

</div>

Hi, For pedagogical purposes, I wrote a Scheme interpreter in Julia, which I then updated to become a toy Julia interpreter written in Julia. So far, everything OK, without any relevant performance problems, despite bei…

---

## [Function declaration order?](https://discourse.julialang.org/t/function-declaration-order/28298)

<div class="topic-metadata">

**Author:** [@jasonsun0310](https://discourse.julialang.org/u/jasonsun0310)\
**Replies:** 8\
**Last updated:** [September 2, 2019, 5:55pm UTC](https://discourse.julialang.org/t/function-declaration-order/28298 "2019-09-02T17:55:13Z")

</div>

I am a bit confused about the function declaration order. For example, if I write following module: module A function callzeros() zeros(rand(5,5)) end function callzeros2() myzeros() end callzeros2() function …

---

## [SymPy does not precompile in v1.2?](https://discourse.julialang.org/t/sympy-does-not-precompile-in-v1-2/28257)

<div class="topic-metadata">

**Author:** [@drmartinrohde](https://discourse.julialang.org/u/drmartinrohde)\
**Replies:** 2\
**Last updated:** [September 2, 2019, 2:56pm UTC](https://discourse.julialang.org/t/sympy-does-not-precompile-in-v1-2/28257 "2019-09-02T14:56:27Z")

</div>

I am trying to use SymPy to do some symbolic manipulation in Julia. A simple code like using SymPy @vars x f(x) = e^x results in an error when precompiling: \[ Info: Precompiling SymPy \[24249f21-da20-56a4-8eb1-6a02cf…

---

## [Why does string(enum member value) not prepend the module name?](https://discourse.julialang.org/t/why-does-string-enum-member-value-not-prepend-the-module-name/15820)

<div class="topic-metadata">

**Author:** [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Replies:** 1\
**Last updated:** [September 2, 2019, 12:29pm UTC](https://discourse.julialang.org/t/why-does-string-enum-member-value-not-prepend-the-module-name/15820 "2019-09-02T12:29:38Z")

</div>

julia\> module Mod struct Struct end @enum Enum A B …

---

## [How to discover what functions can be called on a type](https://discourse.julialang.org/t/how-to-discover-what-functions-can-be-called-on-a-type/28236)

<div class="topic-metadata">

**Author:** [@jtf621](https://discourse.julialang.org/u/jtf621)\
**Replies:** 4\
**Last updated:** [September 1, 2019, 8:16pm UTC](https://discourse.julialang.org/t/how-to-discover-what-functions-can-be-called-on-a-type/28236 "2019-09-01T20:16:22Z")

</div>

What are the different ways using a Julia shell to discover what functions can be called on a type? I am learning Julia as an experienced Python programmer. In python, I would open ipython, instantiate a variable of th…

---

## [Any tips on finding about memory leaks please?](https://discourse.julialang.org/t/any-tips-on-finding-about-memory-leaks-please/13019)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 19\
**Last updated:** [September 1, 2019, 6:08pm UTC](https://discourse.julialang.org/t/any-tips-on-finding-about-memory-leaks-please/13019 "2019-09-01T18:08:59Z")

</div>

My code running in REPL causes memory usage (as shown in ‘top’) of julia to go up gradually. Calling gc() specifically doesn’y help much. Oftentimes, I have to restart julia. The code basically reads in a DataFrames v…

---

## [Logout on Mac when using PyPlot (v1.2)](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 9\
**Last updated:** [September 1, 2019, 6:01pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842 "2019-09-01T18:01:28Z")

</div>

Hi there, I just updated to v1.2 and run the code using PyPlot plot(\[i for i = 1:20\],\[i^2 for i = 1:20\]) And my Apple computer (Mojave, 2017) will log me out and close all my windows. Is there a crowd favorite plott…

---

## [What is the purpose of having both "nodes" and "vertices" in the package OpenStreetMapX?](https://discourse.julialang.org/t/what-is-the-purpose-of-having-both-nodes-and-vertices-in-the-package-openstreetmapx/28265)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 0\
**Last updated:** [September 1, 2019, 3:51pm UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-having-both-nodes-and-vertices-in-the-package-openstreetmapx/28265 "2019-09-01T15:51:39Z")

</div>

Hi. I hope this is not a naive question. I’m working on the OpenStreetMapX package lately and I do not quite understand the purpose of having both “nodes” and “vertices” in the package. Is it necessary? Any comments are …

---

## [Should I dispatch on singleton types or their instances?](https://discourse.julialang.org/t/should-i-dispatch-on-singleton-types-or-their-instances/28204)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 6\
**Last updated:** [September 1, 2019, 3:15pm UTC](https://discourse.julialang.org/t/should-i-dispatch-on-singleton-types-or-their-instances/28204 "2019-09-01T15:15:59Z")

</div>

When I am developing packages, I often come across the following problem. struct Step{T} end func(::Step{1}, x) = do something... func(::Step{2}, x) = do some different things... I am not sure should I use singleton t…

---

## [How to profile / analyse / optimise large Julia apps](https://discourse.julialang.org/t/how-to-profile-analyse-optimise-large-julia-apps/28258)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 7\
**Last updated:** [September 1, 2019, 1:21pm UTC](https://discourse.julialang.org/t/how-to-profile-analyse-optimise-large-julia-apps/28258 "2019-09-01T13:21:26Z")

</div>

What are the best practices for identifying performance bottlenecks in large Julia apps (with large function call stacks)? Genie apps are fairly complex, with a request → response cycle invoking easily over 100 Genie fun…

---

## [Anyone using Julia for drones (or other embedded)? Any forseen problems?](https://discourse.julialang.org/t/anyone-using-julia-for-drones-or-other-embedded-any-forseen-problems/18755)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 18\
**Last updated:** [September 1, 2019, 9:47am UTC](https://discourse.julialang.org/t/anyone-using-julia-for-drones-or-other-embedded-any-forseen-problems/18755 "2019-09-01T09:47:13Z")

</div>

\[I do know about the general garbage collection issue, that I’m not worried about; solved for robotics, see case studies at Julia Computing.\] Any hardware/OS combination a problem or has been proven to work, and I mostl…

---

## [Custom iterator, simple example](https://discourse.julialang.org/t/custom-iterator-simple-example/28212)

<div class="topic-metadata">

**Author:** [@Gus\_Hart](https://discourse.julialang.org/u/Gus_Hart)\
**Replies:** 6\
**Last updated:** [August 31, 2019, 10:24pm UTC](https://discourse.julialang.org/t/custom-iterator-simple-example/28212 "2019-08-31T22:24:30Z")

</div>

I implemented Donald Knuth’s “Algorithm M” for generating all numbers in a mixed-radix numbering system. I would like to turn this into an iterator so I could loop over all of them but without having them all in memory a…

---

## [How to activate a package in a script?](https://discourse.julialang.org/t/how-to-activate-a-package-in-a-script/28185)

<div class="topic-metadata">

**Author:** [@joefowler](https://discourse.julialang.org/u/joefowler)\
**Replies:** 20\
**Last updated:** [August 31, 2019, 3:42pm UTC](https://discourse.julialang.org/t/how-to-activate-a-package-in-a-script/28185 "2019-08-31T15:42:08Z")

</div>

I admit that the following problem might arise only because my team is mixing two concepts–Package and Application–in a single Project. Still, let me pose the problem: I have a package “Pope” that serves mainly as a lib…

---

## [What's actually inside precompiled Julia files?](https://discourse.julialang.org/t/whats-actually-inside-precompiled-julia-files/28234)

<div class="topic-metadata">

**Author:** [@ninjaaron](https://discourse.julialang.org/u/ninjaaron)\
**Replies:** 2\
**Last updated:** [August 31, 2019, 2:19pm UTC](https://discourse.julialang.org/t/whats-actually-inside-precompiled-julia-files/28234 "2019-08-31T14:19:13Z")

</div>

I’m talking about the files like those in the various subfolders of ~/.julia/compiled. Obviously machine code can’t really be compiled until all the all types are known–something that typically isn’t possible for entire…

---

## [Logging to console and file](https://discourse.julialang.org/t/logging-to-console-and-file/28101)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 8\
**Last updated:** [August 31, 2019, 12:59pm UTC](https://discourse.julialang.org/t/logging-to-console-and-file/28101 "2019-08-31T12:59:55Z")

</div>

I tried the example in the documentation a couple of times but I can’t get Julia to write to both console and file. The code in the documentation: # Load the logging module using Logging # Open a textfile for writing i…

---

## [Avoid temporary array creation for the argument of \`reduce\`](https://discourse.julialang.org/t/avoid-temporary-array-creation-for-the-argument-of-reduce/4464)

<div class="topic-metadata">

**Author:** [@fjarri](https://discourse.julialang.org/u/fjarri)\
**Replies:** 8\
**Last updated:** [August 31, 2019, 10:03am UTC](https://discourse.julialang.org/t/avoid-temporary-array-creation-for-the-argument-of-reduce/4464 "2019-08-31T10:03:23Z")

</div>

It is common to reduce (e.g. sum) the result of an array expression without needing the whole resulting array itself. In this case Julia will still create a temporary array to pass to the function, even if you managed to…

---

## [Clustering/Voronoi cell identification](https://discourse.julialang.org/t/clustering-voronoi-cell-identification/28211)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 1\
**Last updated:** [August 31, 2019, 12:33am UTC](https://discourse.julialang.org/t/clustering-voronoi-cell-identification/28211 "2019-08-31T00:33:57Z")

</div>

I’m thinking of the following problem. I have a set of points in the plane which have either been pre-selected or were obtained by a clustering method (i.e., K-means). I thus have an associated Voronoi partition of the…

---

## [DifferentialEquations and DAEProblem... strange error messages](https://discourse.julialang.org/t/differentialequations-and-daeproblem-strange-error-messages/28210)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 5\
**Last updated:** [August 31, 2019, 12:02am UTC](https://discourse.julialang.org/t/differentialequations-and-daeproblem-strange-error-messages/28210 "2019-08-31T00:02:27Z")

</div>

OK – I used the DAE solver a year ago without problems. Now, it doesn’t work for me: using Plots; pyplot(); using DifferentialEquations; using Sundials; If I run the example at DAE documentation, there are no problems …

---

## [UndefRefError: access to undefined reference, how to fix the following error?](https://discourse.julialang.org/t/undefreferror-access-to-undefined-reference-how-to-fix-the-following-error/28213)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 3\
**Last updated:** [August 30, 2019, 3:25pm UTC](https://discourse.julialang.org/t/undefreferror-access-to-undefined-reference-how-to-fix-the-following-error/28213 "2019-08-30T15:25:33Z")

</div>

I’m running some Julia code and the error message I get is as the following: UndefRefError: access to undefined reference in top-level scope at base/None in simulate! at do\_sim.jl:10 #simulate!#46 at so\_sim.jl:…

---

## [Generic way to create repeating tiled views?](https://discourse.julialang.org/t/generic-way-to-create-repeating-tiled-views/28207)

<div class="topic-metadata">

**Author:** [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Replies:** 1\
**Last updated:** [August 30, 2019, 12:23pm UTC](https://discourse.julialang.org/t/generic-way-to-create-repeating-tiled-views/28207 "2019-08-30T12:23:35Z")

</div>

LinearAlgebra implements Symmetric, which returns a mirrored view of the upper/lower triangle of a matrix. If I wanted to do something more simple and generic, is it possible using view() or manipulation of ::SubArray ? …

---

## [Creating an array of tuples (why doesn't filter work on a zip?)](https://discourse.julialang.org/t/creating-an-array-of-tuples-why-doesnt-filter-work-on-a-zip/28173)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 5\
**Last updated:** [August 30, 2019, 6:49am UTC](https://discourse.julialang.org/t/creating-an-array-of-tuples-why-doesnt-filter-work-on-a-zip/28173 "2019-08-30T06:49:59Z")

</div>

I’m pretty sure the answer is that a zip type, is not an Array, BitArray or AbstractArray and that’s what my problem is. I also read the definition for zip and it “runs multiple iterators”, also resultant type is not an…

---

## [Syntax highlighting and plotting problems with Jupyter Notebook](https://discourse.julialang.org/t/syntax-highlighting-and-plotting-problems-with-jupyter-notebook/28198)

<div class="topic-metadata">

**Author:** [@Volker](https://discourse.julialang.org/u/Volker)\
**Replies:** 0\
**Last updated:** [August 30, 2019, 6:37am UTC](https://discourse.julialang.org/t/syntax-highlighting-and-plotting-problems-with-jupyter-notebook/28198 "2019-08-30T06:37:50Z")

</div>

Hi, sometimes Jupyter Notebook loses the syntax highlighting for my Julia Notebooks. Addtionaly then I´m also unable to plot. I´m working on Julia 1.2.0, IJulia v1.20.0, WebIO v0.8.11 and Windows 10. I followed several …

---

## [Load Packages inside a function](https://discourse.julialang.org/t/load-packages-inside-a-function/28196)

<div class="topic-metadata">

**Author:** [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Replies:** 0\
**Last updated:** [August 30, 2019, 6:10am UTC](https://discourse.julialang.org/t/load-packages-inside-a-function/28196 "2019-08-30T06:10:28Z")

</div>

I tried to load a package inside a function and it did not work. Then I came across this post. https://stackoverflow.com/questions/47141374/load-a-package-within-a-function The post says that this can be done ’ @eval u…

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

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