# General Usage

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

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

**Page:** 624

---

## [Connect Subtree on a Tree LightGraphs](https://discourse.julialang.org/t/connect-subtree-on-a-tree-lightgraphs/57875)

<div class="topic-metadata">

**Author:** [@afazevedo](https://discourse.julialang.org/u/afazevedo)\
**Replies:** 1\
**Last updated:** [March 24, 2021, 5:29pm UTC](https://discourse.julialang.org/t/connect-subtree-on-a-tree-lightgraphs/57875 "2021-03-24T17:29:10Z")

</div>

Good afternoon everybody. In my work, i need to disconnect subtrees from my graph and connect elsewhere. My question is whether in the LightGraphs package, or in another package, is there an easy way to do this? In the…

---

## [Execution hangs indefinitely when trying to access QR factor](https://discourse.julialang.org/t/execution-hangs-indefinitely-when-trying-to-access-qr-factor/57881)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 0\
**Last updated:** [March 24, 2021, 5:10pm UTC](https://discourse.julialang.org/t/execution-hangs-indefinitely-when-trying-to-access-qr-factor/57881 "2021-03-24T17:10:54Z")

</div>

The Qr factorization of an NXL matrix does not produce a NXL orthogonal matrix Q but an NXN matrix. When I try to access the first L columns, the execution hangs indefinitely. using ArnoldiMethod; using LinearAlgebra; L…

---

## [Invoke different method for callable struct / How to emulate pythons \`super()\`](https://discourse.julialang.org/t/invoke-different-method-for-callable-struct-how-to-emulate-pythons-super/57869)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 4\
**Last updated:** [March 24, 2021, 5:01pm UTC](https://discourse.julialang.org/t/invoke-different-method-for-callable-struct-how-to-emulate-pythons-super/57869 "2021-03-24T17:01:46Z")

</div>

I have a parametric function as discussed here and now want to generate another such function type that logs its arguments while invoking the non-logging method for the computation. How do I use invoke to dispatch on the…

---

## [How to Put Sublists into Docstrings?](https://discourse.julialang.org/t/how-to-put-sublists-into-docstrings/57843)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 5\
**Last updated:** [March 24, 2021, 2:36pm UTC](https://discourse.julialang.org/t/how-to-put-sublists-into-docstrings/57843 "2021-03-24T14:36:41Z")

</div>

Hi all, I was reviewing a PR recently and was trying to correct a small error in their docstring. Here is the docstring: """ latex(text::LaTeXString, pos::Point, object::Symbol; valign::Symbol = :top, halign::Symbo…

---

## [How does a dictionary store structs?](https://discourse.julialang.org/t/how-does-a-dictionary-store-structs/57866)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 1\
**Last updated:** [March 24, 2021, 1:53pm UTC](https://discourse.julialang.org/t/how-does-a-dictionary-store-structs/57866 "2021-03-24T13:53:29Z")

</div>

Consider for a moment the following structs: abstract type AbstractTransport end struct Warp limit::Float32 end struct Galaxy \<:AbstractTransport name::String drive::Warp end struct Intrepid \<:AbstractTra…

---

## [How Do I Add a Colorbar to a Choropleth Map?](https://discourse.julialang.org/t/how-do-i-add-a-colorbar-to-a-choropleth-map/57814)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 5\
**Last updated:** [March 24, 2021, 1:47pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-colorbar-to-a-choropleth-map/57814 "2021-03-24T13:47:54Z")

</div>

Hi all, I have a choropleth plot that I have made using the following code snippet: choropleth = plot(states.geometry, axis = (\[\], false); fillcolor = permutedims(random\_values)) It comes out looking like this: How…

---

## [Does ForwardDiff work with Python functions?](https://discourse.julialang.org/t/does-forwarddiff-work-with-python-functions/57851)

<div class="topic-metadata">

**Author:** [@arif](https://discourse.julialang.org/u/arif)\
**Replies:** 1\
**Last updated:** [March 24, 2021, 10:29am UTC](https://discourse.julialang.org/t/does-forwarddiff-work-with-python-functions/57851 "2021-03-24T10:29:27Z")

</div>

Hi all, trying to use ForwardDiff on a Python function and getting errors. Here is a MWE using PyCall np = pyimport("numpy") function npsin(x) np.sin(x) end function dnpsin(x) ForwardDiff.derivative(npsin, x) …

---

## [PackageCompiler not compiles some statements](https://discourse.julialang.org/t/packagecompiler-not-compiles-some-statements/57803)

<div class="topic-metadata">

**Author:** [@Vangelis](https://discourse.julialang.org/u/Vangelis)\
**Replies:** 0\
**Last updated:** [March 23, 2021, 5:20pm UTC](https://discourse.julialang.org/t/packagecompiler-not-compiles-some-statements/57803 "2021-03-23T17:20:07Z")

</div>

Hi, I am trying to build a system image for the (simple) module below: module TestCatAF function myfunc(m1, m2) return cat(m1, m2, dims=(1,2)) end Base.@ccallable function call\_myfunc()::Cdouble M1 = …

---

## [Why does this ccall segfault?](https://discourse.julialang.org/t/why-does-this-ccall-segfault/57690)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 7\
**Last updated:** [March 24, 2021, 8:20am UTC](https://discourse.julialang.org/t/why-does-this-ccall-segfault/57690 "2021-03-24T08:20:31Z")

</div>

The following code segfaults for me: C = """ typedef struct CParticle { double charge; double E; double weight; } CParticle; void simulate(void (\*f)(CParticle x)) { CParticle cp; cp.charge = 0; …

---

## [Tutorial: How to benchmark and profile your code?](https://discourse.julialang.org/t/tutorial-how-to-benchmark-and-profile-your-code/57790)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 11\
**Last updated:** [March 24, 2021, 7:20am UTC](https://discourse.julialang.org/t/tutorial-how-to-benchmark-and-profile-your-code/57790 "2021-03-24T07:20:46Z")

</div>

Interested in benchmarking and profiling your code? My new blog post walks you through it from highlevel benchmarking to getting deeper with profiling tools. It’s quite high level so I avoided explaining the different …

---

## [\[PyCall\] Pre-installing a python package required by a Julia package](https://discourse.julialang.org/t/pycall-pre-installing-a-python-package-required-by-a-julia-package/3316)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 17\
**Last updated:** [March 23, 2021, 10:32pm UTC](https://discourse.julialang.org/t/pycall-pre-installing-a-python-package-required-by-a-julia-package/3316 "2021-03-23T22:32:10Z")

</div>

Hello, I’m developing OdsIO, a module that uses the Python ezodf (and, in turn, lxml) modules to import/export data from/to OpenDocument spreadsheets. How do I guarantee that ezodf and lxml are available to the user? O…

---

## [Why would these errors pop up?](https://discourse.julialang.org/t/why-would-these-errors-pop-up/57330)

<div class="topic-metadata">

**Author:** [@redlush](https://discourse.julialang.org/u/redlush)\
**Replies:** 2\
**Last updated:** [March 23, 2021, 7:37pm UTC](https://discourse.julialang.org/t/why-would-these-errors-pop-up/57330 "2021-03-23T19:37:52Z")

</div>

Hi all. I am new to Julia and not familiar on troubleshooting my code in this language. I have constructed a block matrix constructed of smaller block matrices - a diagonal one and then an off diagonal one. The construct…

---

## [Completely frustrated with compilation times](https://discourse.julialang.org/t/completely-frustrated-with-compilation-times/57733)

<div class="topic-metadata">

**Author:** [@andreasvarga](https://discourse.julialang.org/u/andreasvarga)\
**Replies:** 16\
**Last updated:** [March 23, 2021, 7:03pm UTC](https://discourse.julialang.org/t/completely-frustrated-with-compilation-times/57733 "2021-03-23T19:03:25Z")

</div>

I am working with Julia 1.5.3 on the development of a new package DescriptorSystems, which basically manipulates 5-tuples of matrices (which describe so called descriptor systems). Recently, I added a new object, which i…

---

## [Copy of postmortem for JuliaOptical](https://discourse.julialang.org/t/copy-of-postmortem-for-juliaoptical/57752)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 2\
**Last updated:** [March 23, 2021, 6:25pm UTC](https://discourse.julialang.org/t/copy-of-postmortem-for-juliaoptical/57752 "2021-03-23T18:25:12Z")

</div>

I ran across a JPL optics engineer’s explanation of why he’s giving up on his JuliaOptical project. I know there was a discussion about posting lists of gripes, but I don’t remember where that ended up and Jeff said in h…

---

## [Shuffle values and sample indices of a sparse matrix](https://discourse.julialang.org/t/shuffle-values-and-sample-indices-of-a-sparse-matrix/57677)

<div class="topic-metadata">

**Author:** [@eliassno](https://discourse.julialang.org/u/eliassno)\
**Replies:** 15\
**Last updated:** [March 23, 2021, 5:50pm UTC](https://discourse.julialang.org/t/shuffle-values-and-sample-indices-of-a-sparse-matrix/57677 "2021-03-23T17:50:24Z")

</div>

I need to shuffle entries in selected columns of a large, sparse matrix X with dimensions M x N . I have written a function that does this in-place, as I need to perform the shuffling repeatedly on the same data. functi…

---

## [Count words challenge](https://discourse.julialang.org/t/count-words-challenge/57221)

<div class="topic-metadata">

**Author:** [@alemelis](https://discourse.julialang.org/u/alemelis)\
**Replies:** 24\
**Last updated:** [March 23, 2021, 2:10pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221 "2021-03-23T14:10:06Z")

</div>

Hello! I’ve been reading this blog post today and decided to give it a try in Julia. In short, the idea is to benchmark different languages in counting words frequency for long text files. I’ve added what I believe is…

---

## [Which characters to avoid in file and path names](https://discourse.julialang.org/t/which-characters-to-avoid-in-file-and-path-names/57772)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [March 23, 2021, 1:29pm UTC](https://discourse.julialang.org/t/which-characters-to-avoid-in-file-and-path-names/57772 "2021-03-23T13:29:25Z")

</div>

The allowed set of characters within files and folders depends on the operating system. What would be “best practice” for the naming of files and folders in public Julia projects and packages?

---

## [Correct way to fetch results from distributed processes while also printing progress?](https://discourse.julialang.org/t/correct-way-to-fetch-results-from-distributed-processes-while-also-printing-progress/57779)

<div class="topic-metadata">

**Author:** [@rlrs](https://discourse.julialang.org/u/rlrs)\
**Replies:** 0\
**Last updated:** [March 23, 2021, 12:31pm UTC](https://discourse.julialang.org/t/correct-way-to-fetch-results-from-distributed-processes-while-also-printing-progress/57779 "2021-03-23T12:31:10Z")

</div>

This is my setup: I’m running a distributed computation where Futures return their own local results, and potential further (recursive) Futures that they have created. The initial Futures are stored in an array on the m…

---

## [Specify Julia enviroment in PyJulia?](https://discourse.julialang.org/t/specify-julia-enviroment-in-pyjulia/57776)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 0\
**Last updated:** [March 23, 2021, 10:52am UTC](https://discourse.julialang.org/t/specify-julia-enviroment-in-pyjulia/57776 "2021-03-23T10:52:37Z")

</div>

Hi! I am using PyJulia to link Python with Julia. In Python I am using a virtual enviroment (not Conda based) inside of Python in which I am calling PyJulia - this works completely fine. Inside of the virtual enviromen…

---

## [Why is the function of a callable object (Functor) allocating?](https://discourse.julialang.org/t/why-is-the-function-of-a-callable-object-functor-allocating/57773)

<div class="topic-metadata">

**Author:** [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Replies:** 1\
**Last updated:** [March 23, 2021, 8:21am UTC](https://discourse.julialang.org/t/why-is-the-function-of-a-callable-object-functor-allocating/57773 "2021-03-23T08:21:10Z")

</div>

I’m experimenting with functors. I noticed that when I pass an array to the functor, that it is allocating memory even if it should be possible without memory allocation. Here is a simplified version: struct Foo end (:…

---

## [Multithreaded random: different behaviour in Julia \>= 1.5 (not just different stream)](https://discourse.julialang.org/t/multithreaded-random-different-behaviour-in-julia-1-5-not-just-different-stream/57291)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 6\
**Last updated:** [March 23, 2021, 7:20am UTC](https://discourse.julialang.org/t/multithreaded-random-different-behaviour-in-julia-1-5-not-just-different-stream/57291 "2021-03-23T07:20:45Z")

</div>

Hi, I just realised that my solution below for multithreaded random number generators works only in Julia \>= 1.5. In particular the test of “CASE A” fails, i.e. the two repetitions issue the same number. Is there a way…

---

## [Link back to main repo on each page in Documenter.jl](https://discourse.julialang.org/t/link-back-to-main-repo-on-each-page-in-documenter-jl/57444)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 6\
**Last updated:** [March 23, 2021, 6:32am UTC](https://discourse.julialang.org/t/link-back-to-main-repo-on-each-page-in-documenter-jl/57444 "2021-03-23T06:32:56Z")

</div>

I am sure this has been asked before, but I was not able to find it here or in the Documenter issues: Is there a way to include a link back to the main repository on each page of Documenter.jl? I know that there’s the E…

---

## [First example of Makie failed?](https://discourse.julialang.org/t/first-example-of-makie-failed/54926)

<div class="topic-metadata">

**Author:** [@Carsten](https://discourse.julialang.org/u/Carsten)\
**Replies:** 8\
**Last updated:** [March 23, 2021, 6:17am UTC](https://discourse.julialang.org/t/first-example-of-makie-failed/54926 "2021-03-23T06:17:11Z")

</div>

I running the first example of the documentation of Makie using GLMakie using AbstractPlotting AbstractPlotting.inline!(true) points = \[Point2f0(cos(t), sin(t)) for t in LinRange(0, 2pi, 20)\]; colors = 1:20; figure, axi…

---

## [Is there an implementation of Trefethen's contour integrals for evaluating \[1 - exp(-x)\] / x as x-\>0?](https://discourse.julialang.org/t/is-there-an-implementation-of-trefethens-contour-integrals-for-evaluating-1-exp-x-x-as-x-0/57680)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 15\
**Last updated:** [March 23, 2021, 5:07am UTC](https://discourse.julialang.org/t/is-there-an-implementation-of-trefethens-contour-integrals-for-evaluating-1-exp-x-x-as-x-0/57680 "2021-03-23T05:07:16Z")

</div>

This kind of evaluation frequently occurs in numerical analysis, and I believe there should be an implementation in Julia. If so, I am happy to use it rather than re-invent the wheel:) Thanks!

---

## [Experiments with VectorizationBase](https://discourse.julialang.org/t/experiments-with-vectorizationbase/57475)

<div class="topic-metadata">

**Author:** [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Replies:** 6\
**Last updated:** [March 23, 2021, 3:17am UTC](https://discourse.julialang.org/t/experiments-with-vectorizationbase/57475 "2021-03-23T03:17:12Z")

</div>

I’ve been trying out VectorizationBase for some low-level SIMD coding. This has worked but I suspect there may be better ways to go about it or at least I need some pointers for how to adapt to some recent changes in thi…

---

## [When developing a package, how do you access files in the package directory structure?](https://discourse.julialang.org/t/when-developing-a-package-how-do-you-access-files-in-the-package-directory-structure/57750)

<div class="topic-metadata">

**Author:** [@3ArnjN](https://discourse.julialang.org/u/3ArnjN)\
**Replies:** 3\
**Last updated:** [March 23, 2021, 12:18am UTC](https://discourse.julialang.org/t/when-developing-a-package-how-do-you-access-files-in-the-package-directory-structure/57750 "2021-03-23T00:18:53Z")

</div>

I am working on a package that’s supposed to download and use files in the data directory inside the package directory structure. Originally, I was using ./data as a path of the data directory. That worked fine for me a…

---

## [Error in Agent pos attribute Prisoner’s Dilemma Agents](https://discourse.julialang.org/t/error-in-agent-pos-attribute-prisoner-s-dilemma-agents/57655)

<div class="topic-metadata">

**Author:** [@Ola\_Megahed](https://discourse.julialang.org/u/Ola_Megahed)\
**Replies:** 2\
**Last updated:** [March 22, 2021, 11:59pm UTC](https://discourse.julialang.org/t/error-in-agent-pos-attribute-prisoner-s-dilemma-agents/57655 "2021-03-22T23:59:18Z")

</div>

I am trying to duplicate the demographic Prisoner’s Dilemma by Epstein. I am having a code problem related to moving the agent according to my below function. basically I canot get the attribute position. function movem…

---

## [Foreach for macros?](https://discourse.julialang.org/t/foreach-for-macros/57678)

<div class="topic-metadata">

**Author:** [@turquoise](https://discourse.julialang.org/u/turquoise)\
**Replies:** 9\
**Last updated:** [March 22, 2021, 11:16pm UTC](https://discourse.julialang.org/t/foreach-for-macros/57678 "2021-03-22T23:16:59Z")

</div>

I am trying to define a foreach macro that works with macros. That is: @foreach @amacro expr1 expr2 ... Should give @amacro(expr1) @amacro(expr2) ... I couldn’t make this work even with a single expr input. I defin…

---

## ["Zipped" loops in test sets: a bad design pattern?](https://discourse.julialang.org/t/zipped-loops-in-test-sets-a-bad-design-pattern/57685)

<div class="topic-metadata">

**Author:** [@Jollywatt](https://discourse.julialang.org/u/Jollywatt)\
**Replies:** 8\
**Last updated:** [March 22, 2021, 9:41pm UTC](https://discourse.julialang.org/t/zipped-loops-in-test-sets-a-bad-design-pattern/57685 "2021-03-22T21:41:47Z")

</div>

I’m (ab)using Julia’s testing interface to verify mathematical propositions for many randomly generated samples. I find myself using the following pattern a lot: @testset "definitions" begin for x in rand(N) ... @t…

---

## [Using anonymous Functions to avoid type dispatch](https://discourse.julialang.org/t/using-anonymous-functions-to-avoid-type-dispatch/57749)

<div class="topic-metadata">

**Author:** [@nben](https://discourse.julialang.org/u/nben)\
**Replies:** 0\
**Last updated:** [March 22, 2021, 8:52pm UTC](https://discourse.julialang.org/t/using-anonymous-functions-to-avoid-type-dispatch/57749 "2021-03-22T20:52:10Z")

</div>

This question is about the merits of a methods of avoiding type dispatch in some low-level functions. I’ve included the context below; though the question itself can probably be understood and answered without the contex…

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

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