# General Usage

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

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

**Page:** 560

---

## [DrWatson using tmpsave to save many files fails](https://discourse.julialang.org/t/drwatson-using-tmpsave-to-save-many-files-fails/66483)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 14\
**Last updated:** [August 18, 2021, 11:07am UTC](https://discourse.julialang.org/t/drwatson-using-tmpsave-to-save-many-files-fails/66483 "2021-08-18T11:07:21Z")

</div>

I am using DrWatson to run simulations on a cluster. I use this scheme to run many jobs - Real World Examples · DrWatson. The problem is that when I use too many parameters (which generate ~180 files), tmpsave fails. I …

---

## [How to specify the DPI while saving a Makie figure?](https://discourse.julialang.org/t/how-to-specify-the-dpi-while-saving-a-makie-figure/66588)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 1\
**Last updated:** [August 18, 2021, 9:31am UTC](https://discourse.julialang.org/t/how-to-specify-the-dpi-while-saving-a-makie-figure/66588 "2021-08-18T09:31:00Z")

</div>

For example, how can I obtain a figure with a physical size of (3.25 in x 2.4 in)?

---

## [Adding Julia itself to juliahub?](https://discourse.julialang.org/t/adding-julia-itself-to-juliahub/66582)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 4\
**Last updated:** [August 18, 2021, 8:15am UTC](https://discourse.julialang.org/t/adding-julia-itself-to-juliahub/66582 "2021-08-18T08:15:43Z")

</div>

I (re-)discovered juliahub to search also for help and code snippets. But then I wondered why the biggest package (Julia itself) seems not be included. Could the owner add it? - That would make a nice help interface. T…

---

## [How to read each line from a file then store the values to array elements?](https://discourse.julialang.org/t/how-to-read-each-line-from-a-file-then-store-the-values-to-array-elements/66585)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 5\
**Last updated:** [August 18, 2021, 7:20am UTC](https://discourse.julialang.org/t/how-to-read-each-line-from-a-file-then-store-the-values-to-array-elements/66585 "2021-08-18T07:20:17Z")

</div>

Sorry for another stupid question. I have a file called Yji.txt, contents is listed below, 3.29107948 3.01222513 1.81928273 1.73277408 1.01205782 3.79643512 3.12969360 2.72422926 1.99088313 1.3797150…

---

## [How to do flexible timing in Julia?](https://discourse.julialang.org/t/how-to-do-flexible-timing-in-julia/66577)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 3\
**Last updated:** [August 18, 2021, 12:49am UTC](https://discourse.julialang.org/t/how-to-do-flexible-timing-in-julia/66577 "2021-08-18T00:49:49Z")

</div>

Another stupid question, in Julia, how to do timing on various parts in the code and display them correspondingly? For example, a Fortran code like below, call cpu\_time(t0) blablabala call cpu\_time(t1) write(6,\*) 't1…

---

## [Julia Beginner (from Python): Numba outperforms Julia in rewrite. Any tips to improve performance?](https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414)

<div class="topic-metadata">

**Author:** [@rmeinl](https://discourse.julialang.org/u/rmeinl)\
**Replies:** 56\
**Last updated:** [August 18, 2021, 12:00am UTC](https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414 "2021-08-18T00:00:28Z")

</div>

Hey! I’m new to Julia (coming from Python) and was trying to benchmark Julia against a part of the apricot python package (submodular optimization). Unfortunately the Python version (using numba) is still a bit faster (1…

---

## [Entity Component System - A great way to understad the Julia philosophy](https://discourse.julialang.org/t/entity-component-system-a-great-way-to-understad-the-julia-philosophy/66574)

<div class="topic-metadata">

**Author:** [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)\
**Replies:** 0\
**Last updated:** [August 17, 2021, 10:54pm UTC](https://discourse.julialang.org/t/entity-component-system-a-great-way-to-understad-the-julia-philosophy/66574 "2021-08-17T22:54:52Z")

</div>

Hi folks! As you all know, people coming from an object oriented world may have a hard time getting into the Julia way of thinking about how to organize data and functions. Now, in game development a software pattern t…

---

## [Create static documentation with Documenter.jl](https://discourse.julialang.org/t/create-static-documentation-with-documenter-jl/66567)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 4\
**Last updated:** [August 17, 2021, 10:04pm UTC](https://discourse.julialang.org/t/create-static-documentation-with-documenter-jl/66567 "2021-08-17T22:04:15Z")

</div>

Hello, I am using Documenter.jl to write the documentation of a package. I would like to include tutorials with blocks of julia code and output figures. However, some of these tutorials can be quite long to run. Is it p…

---

## [22 seconds to 3 and now more: Let's fix all of the DifferentialEquations.jl + universe compile times!](https://discourse.julialang.org/t/22-seconds-to-3-and-now-more-lets-fix-all-of-the-differentialequations-jl-universe-compile-times/66313)

<div class="topic-metadata">

**Author:** [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Replies:** 6\
**Last updated:** [August 17, 2021, 9:18pm UTC](https://discourse.julialang.org/t/22-seconds-to-3-and-now-more-lets-fix-all-of-the-differentialequations-jl-universe-compile-times/66313 "2021-08-17T21:18:50Z")

</div>

These are the JuliaCon hackathon results for SciML compile time issues, with major help from @tim.holy (and more to be announced soon…). This is a repost of 22 seconds to 3 and now more: Let's fix all of the Differential…

---

## [Exception after package updates](https://discourse.julialang.org/t/exception-after-package-updates/66568)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 1\
**Last updated:** [August 17, 2021, 8:39pm UTC](https://discourse.julialang.org/t/exception-after-package-updates/66568 "2021-08-17T20:39:57Z")

</div>

After updating the packages used by my project I get the following exception: julia\> using RTSim julia\> init\_sim(5.0) ERROR: MethodError: no method matching residual!(::Vector{Float64}, ::StaticArrays.SizedVector{36, F…

---

## [IO write/read \<strlen\> \<string\>](https://discourse.julialang.org/t/io-write-read-strlen-string/66362)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 15\
**Last updated:** [August 17, 2021, 8:24pm UTC](https://discourse.julialang.org/t/io-write-read-strlen-string/66362 "2021-08-17T20:24:27Z")

</div>

With the suggestions below: # write number as type T function writenum(io, num, T) write(io, T(num)) end # read n numbers of type T function readnum(io, T, n) s = sizeof(T) f = zeros(UInt8, s\*n) readbyte…

---

## [DataFrames: where is categorical?](https://discourse.julialang.org/t/dataframes-where-is-categorical/66555)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [August 17, 2021, 3:27pm UTC](https://discourse.julialang.org/t/dataframes-where-is-categorical/66555 "2021-08-17T15:27:57Z")

</div>

This is confusing: categorical should be available in 1.2.2? (@v1.8) pkg\> st …

---

## [Improving function performance - Broadcasting vs Loops](https://discourse.julialang.org/t/improving-function-performance-broadcasting-vs-loops/66537)

<div class="topic-metadata">

**Author:** [@jpmorr](https://discourse.julialang.org/u/jpmorr)\
**Replies:** 14\
**Last updated:** [August 17, 2021, 1:02pm UTC](https://discourse.julialang.org/t/improving-function-performance-broadcasting-vs-loops/66537 "2021-08-17T13:02:57Z")

</div>

I’m slowly learning some of the tricks that can make julia code quicker. Coming from python I still find it strange to write a loop instead of some vectorised but it seems that sometimes that the loop is the quicker opti…

---

## [Color gradient by factor in StatsPlots](https://discourse.julialang.org/t/color-gradient-by-factor-in-statsplots/30704)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 9\
**Last updated:** [August 17, 2021, 1:02pm UTC](https://discourse.julialang.org/t/color-gradient-by-factor-in-statsplots/30704 "2021-08-17T13:02:08Z")

</div>

Hi all- I would like to use a gradient to color code lines based on values of a factor. In the example below, I would like the two groups of lines to have the same colors based on the slopes. How do I do that? using Da…

---

## [Parametered optional named arguments](https://discourse.julialang.org/t/parametered-optional-named-arguments/66541)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 3\
**Last updated:** [August 17, 2021, 11:36am UTC](https://discourse.julialang.org/t/parametered-optional-named-arguments/66541 "2021-08-17T11:36:18Z")

</div>

When I call the function function f(; field ::NTuple{Nfield,Symbol}, fieldscale ::NTuple= (),#NTuple{Nfield ,Float64}(1. for i =1: Nfield), afield ::NTuple{Nafield,Symbol}=(;), afieldscale…

---

## [BenchmarkGallery?](https://discourse.julialang.org/t/benchmarkgallery/66542)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 1\
**Last updated:** [August 17, 2021, 11:24am UTC](https://discourse.julialang.org/t/benchmarkgallery/66542 "2021-08-17T11:24:40Z")

</div>

I thought about collecting Julia code snippets and sort and assemble them into a public git repository. Does something like this already exist? I’m happy to start something, but before I do so, ideas would be very wel…

---

## [Object Detection in Julia](https://discourse.julialang.org/t/object-detection-in-julia/65115)

<div class="topic-metadata">

**Author:** [@ppkvm](https://discourse.julialang.org/u/ppkvm)\
**Replies:** 6\
**Last updated:** [August 17, 2021, 10:17am UTC](https://discourse.julialang.org/t/object-detection-in-julia/65115 "2021-08-17T10:17:35Z")

</div>

I would like to see examples of Object Detection using YOLO and SSD implemented in Julia. Has anyone tried this before?

---

## [Smarter, or at least less verbose, tab/auto completion.. using tools?](https://discourse.julialang.org/t/smarter-or-at-least-less-verbose-tab-auto-completion-using-tools/66529)

<div class="topic-metadata">

**Author:** [@eo1989](https://discourse.julialang.org/u/eo1989)\
**Replies:** 0\
**Last updated:** [August 17, 2021, 2:45am UTC](https://discourse.julialang.org/t/smarter-or-at-least-less-verbose-tab-auto-completion-using-tools/66529 "2021-08-17T02:45:56Z")

</div>

I use Julia REPL quite often and really enjoy the unicode completion a lot. That being said, Is it possible to incorporate FZF’s selection feature into tab completion? I understand OhMyREPL already uses fzf (or at least …

---

## [How to test \`jldoctest\` block for errors, but nothing else](https://discourse.julialang.org/t/how-to-test-jldoctest-block-for-errors-but-nothing-else/66491)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 3\
**Last updated:** [August 16, 2021, 10:10pm UTC](https://discourse.julialang.org/t/how-to-test-jldoctest-block-for-errors-but-nothing-else/66491 "2021-08-16T22:10:00Z")

</div>

I am making doctests for a package (Catalyst.jl) using Documenter. There are many blocks that returns a big mess of output (not displayed), which is stochastic or pseudo-stochastic. An example would be using DiffEqJump …

---

## [Why does julia use thousands of cpu-hours to compute 1+2?](https://discourse.julialang.org/t/why-does-julia-use-thousands-of-cpu-hours-to-compute-1-2/66041)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 10\
**Last updated:** [August 16, 2021, 9:03pm UTC](https://discourse.julialang.org/t/why-does-julia-use-thousands-of-cpu-hours-to-compute-1-2/66041 "2021-08-16T21:03:15Z")

</div>

I’m fairly new to julia, and not overly experienced with scaling to huge numbers of processes, so forgive me if I’m missing something obvious. Alright, to be honest, I actually used a couple thousand cpu-hours to run us…

---

## [Sorting strings containing numbers, so that "A2" \< "A10"?](https://discourse.julialang.org/t/sorting-strings-containing-numbers-so-that-a2-a10/5372)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 28\
**Last updated:** [August 16, 2021, 7:50pm UTC](https://discourse.julialang.org/t/sorting-strings-containing-numbers-so-that-a2-a10/5372 "2021-08-16T19:50:08Z")

</div>

I need to sort strings containing numbers. Is there a simple way to sort them, such that, for example, "A2" \< "A10"? That is, I want a lexicographic compare, such that numbers in the string are compared by value. I gues…

---

## [How to pre-allocate an Array of UnitRange (specifically a SharedArray of Tuple of UnitRange)?](https://discourse.julialang.org/t/how-to-pre-allocate-an-array-of-unitrange-specifically-a-sharedarray-of-tuple-of-unitrange/66506)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 1\
**Last updated:** [August 16, 2021, 7:33pm UTC](https://discourse.julialang.org/t/how-to-pre-allocate-an-array-of-unitrange-specifically-a-sharedarray-of-tuple-of-unitrange/66506 "2021-08-16T19:33:39Z")

</div>

Question Is there a shorter or better way to pre-allocate indsTup and inds as shown below? : indsTup = \[(1:2,1:2)\] for i in 1:10 push!(indsTup,(1:2,1:2)) end indsTup = SharedArray(indsTup) inds = \[1:2\] for i in 1:10 …

---

## [Memory allocation while using @views](https://discourse.julialang.org/t/memory-allocation-while-using-views/66482)

<div class="topic-metadata">

**Author:** [@aramgharibyan](https://discourse.julialang.org/u/aramgharibyan)\
**Replies:** 5\
**Last updated:** [August 16, 2021, 3:11pm UTC](https://discourse.julialang.org/t/memory-allocation-while-using-views/66482 "2021-08-16T15:11:39Z")

</div>

I found an issue while using @views, which may help others speed up their code. Let us consider this example of code. len = 5000 const arr1 = Array{Float64, 2}(undef, 10, len) const arr2 = Array{Float64, 2}(undef, 10, l…

---

## [Strange deadlock in 1.7.0-beta3 didn't happen in 1.5.x](https://discourse.julialang.org/t/strange-deadlock-in-1-7-0-beta3-didnt-happen-in-1-5-x/66462)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 10\
**Last updated:** [August 16, 2021, 6:38pm UTC](https://discourse.julialang.org/t/strange-deadlock-in-1-7-0-beta3-didnt-happen-in-1-5-x/66462 "2021-08-16T18:38:02Z")

</div>

I have an Agents.jl simulation that worked fine last summer… I’m back to looking at the code, and it’s deadlocking and sitting there using 0% of cpu. It’s a script that uses Threads.@spawn to run some threads each of wh…

---

## [@time and @benchmark give different results](https://discourse.julialang.org/t/time-and-benchmark-give-different-results/66374)

<div class="topic-metadata">

**Author:** [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Replies:** 6\
**Last updated:** [August 16, 2021, 5:18pm UTC](https://discourse.julialang.org/t/time-and-benchmark-give-different-results/66374 "2021-08-16T17:18:37Z")

</div>

\[Corrected: ms is 10^{-3} seconds and μs is 10^{-6}.\] I’m evaluating 2 algorithms for doing roughly the same thing, using @time and @benchmark. The ratio of times between the 2 timing methods differs by a factor of rou…

---

## [Multiple Conda Environments + PyCall.jl?](https://discourse.julialang.org/t/multiple-conda-environments-pycall-jl/61754)

<div class="topic-metadata">

**Author:** [@LodewijkBrand](https://discourse.julialang.org/u/LodewijkBrand)\
**Replies:** 2\
**Last updated:** [August 16, 2021, 4:36pm UTC](https://discourse.julialang.org/t/multiple-conda-environments-pycall-jl/61754 "2021-08-16T16:36:06Z")

</div>

I have been using PyCall.jl to wrap some algorithms written in Python to compare against a series of algorithms I’ve written in Julia. I’ve started adding additional algorithms one of which is implemented ~4 years ago a…

---

## [Dispatch on type only](https://discourse.julialang.org/t/dispatch-on-type-only/66498)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 4\
**Last updated:** [August 16, 2021, 4:17pm UTC](https://discourse.julialang.org/t/dispatch-on-type-only/66498 "2021-08-16T16:17:27Z")

</div>

Is it possible to dispatch on a type only, not having an instance with a type? This works: function choose(t::Float64) println("choosing t::Float64") end function choose(t::Tuple) println("choosing t::Tuple") e…

---

## [Help modeling attitude propagation using ModelingToolkit.jl](https://discourse.julialang.org/t/help-modeling-attitude-propagation-using-modelingtoolkit-jl/66398)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 2\
**Last updated:** [August 16, 2021, 2:03pm UTC](https://discourse.julialang.org/t/help-modeling-attitude-propagation-using-modelingtoolkit-jl/66398 "2021-08-16T14:03:57Z")

</div>

Hi! I am trying to model the attitude propagation with quaternions using ModelingToolkit.jl. I could make a very simple example as shown below: using ModelingToolkit using OrdinaryDiffEq using ReferenceFrameRotations u…

---

## [Data Collection Issue With Julia Agents](https://discourse.julialang.org/t/data-collection-issue-with-julia-agents/66458)

<div class="topic-metadata">

**Author:** [@bfried1](https://discourse.julialang.org/u/bfried1)\
**Replies:** 8\
**Last updated:** [August 16, 2021, 12:04pm UTC](https://discourse.julialang.org/t/data-collection-issue-with-julia-agents/66458 "2021-08-16T12:04:54Z")

</div>

mdata = \[:Social\] returns the same graph over and over without updating, I can’t seem to find the reason, any ideas?

---

## [Reshape into named tuple](https://discourse.julialang.org/t/reshape-into-named-tuple/66474)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 4\
**Last updated:** [August 16, 2021, 10:52am UTC](https://discourse.julialang.org/t/reshape-into-named-tuple/66474 "2021-08-16T10:52:18Z")

</div>

I have a vector with elements of possibly different types (but homogeneous) and the same length (\>1e8). Example: julia\> data 3-element Vector{Any}: \[0.7947257509914385, 0.938439282086563, 0.7825664679861779, 0.9622100…

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

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