# General Usage

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

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

**Page:** 472

---

## [Improving type inference for \`x\` where \`Meta.isexpr(x, ...)\`](https://discourse.julialang.org/t/improving-type-inference-for-x-where-meta-isexpr-x/77993)

<div class="topic-metadata">

**Author:** [@rikh](https://discourse.julialang.org/u/rikh)\
**Replies:** 4\
**Last updated:** [March 18, 2022, 6:56am UTC](https://discourse.julialang.org/t/improving-type-inference-for-x-where-meta-isexpr-x/77993 "2022-03-18T06:56:12Z")

</div>

Type inference struggles a bit with the following: julia\> a = :(x = y = 1); julia\> a.args\[2\] :(y = 1) julia\> function f(a::Expr) ex = a.args\[2\] if Meta.isexpr(ex, :(=)) return ex …

---

## [Inconsistent number of decimal places when printing sum(x, dims=1)](https://discourse.julialang.org/t/inconsistent-number-of-decimal-places-when-printing-sum-x-dims-1/78054)

<div class="topic-metadata">

**Author:** [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)\
**Replies:** 5\
**Last updated:** [March 18, 2022, 2:22am UTC](https://discourse.julialang.org/t/inconsistent-number-of-decimal-places-when-printing-sum-x-dims-1/78054 "2022-03-18T02:22:06Z")

</div>

For a while, I just couldn’t understand what was going on here: julia\> x = \[ 7136.52 0.00 7136.52; 6047.88 62.74 6110.62; 2374.32 26.19 2400.51; 2374.32 78.57 2452.89\]; julia\> sum(x, dims=1) 1×3 Matrix{Float64}: 1793…

---

## [ERROR: LoadError: Failed to precompile](https://discourse.julialang.org/t/error-loaderror-failed-to-precompile/78043)

<div class="topic-metadata">

**Author:** [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Replies:** 4\
**Last updated:** [March 18, 2022, 1:55am UTC](https://discourse.julialang.org/t/error-loaderror-failed-to-precompile/78043 "2022-03-18T01:55:55Z")

</div>

Attempting to instantiate an old environment I get a number of packages that fail with the error in the subject. The trace information that is printed out doesn’t offer any clue I can understand about the actual source …

---

## [Read every other line into a variable from a text file](https://discourse.julialang.org/t/read-every-other-line-into-a-variable-from-a-text-file/78052)

<div class="topic-metadata">

**Author:** [@Jdbeck66](https://discourse.julialang.org/u/Jdbeck66)\
**Replies:** 2\
**Last updated:** [March 17, 2022, 9:57pm UTC](https://discourse.julialang.org/t/read-every-other-line-into-a-variable-from-a-text-file/78052 "2022-03-17T21:57:53Z")

</div>

I’d like to read every other (or every third, fourth,…) line from a text file into a variable. function readtext(file) lines = String\[\] for line ∈ eachline(file) push!(lines, line::String) end r…

---

## [ERROR: IOError: when generating exe file](https://discourse.julialang.org/t/error-ioerror-when-generating-exe-file/71287)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 3\
**Last updated:** [November 11, 2021, 10:45am UTC](https://discourse.julialang.org/t/error-ioerror-when-generating-exe-file/71287 "2021-11-11T10:45:39Z")

</div>

@Gnimuc Could you please help in this? I am trying to generate exe file for my codes (which organized as below): inside /scr.folderpackage.jl, I wrote the below module folderpackage Base.@ccallable function julia\_…

---

## [How to store data where columns are added/updated separately?](https://discourse.julialang.org/t/how-to-store-data-where-columns-are-added-updated-separately/78051)

<div class="topic-metadata">

**Author:** [@Satvik](https://discourse.julialang.org/u/Satvik)\
**Replies:** 0\
**Last updated:** [March 17, 2022, 9:38pm UTC](https://discourse.julialang.org/t/how-to-store-data-where-columns-are-added-updated-separately/78051 "2022-03-17T21:38:50Z")

</div>

I have data with columns that can get added or updated at different times. For example, my data might all start at 2021-01-01, have some baseline columns like temperature and humidity that get updated every minute, and s…

---

## [Accessing the field of \`Pair\` seems to be type-unstable](https://discourse.julialang.org/t/accessing-the-field-of-pair-seems-to-be-type-unstable/78045)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 3\
**Last updated:** [March 17, 2022, 6:30pm UTC](https://discourse.julialang.org/t/accessing-the-field-of-pair-seems-to-be-type-unstable/78045 "2022-03-17T18:30:29Z")

</div>

MWE (Julia v1.6 & v1.7): julia\> p1 = Pair(:a, 2) :a =\> 2 julia\> @code\_warntype p1.first Variables #self#::Core.Const(getproperty) x::Pair{Symbol, Int64} f::Symbol Body::Union{Int64, Symbol} 1 ─ %1 = Base.getfiel…

---

## [@inbounds not working?](https://discourse.julialang.org/t/inbounds-not-working/78033)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 6:07pm UTC](https://discourse.julialang.org/t/inbounds-not-working/78033 "2022-03-17T18:07:38Z")

</div>

Simply tried the following: a=\[0.5\] @inbounds b=a\[2\] yielding surprisingly BoundsError: attempt to access 1-element Vector{Float64} at index \[2\] Stacktrace: \[1\] getindex(A::Vector{Float64}, i1::Int64) @ Base .\\ar…

---

## [Using Interact in a Jupyter Notebook through Binder](https://discourse.julialang.org/t/using-interact-in-a-jupyter-notebook-through-binder/78028)

<div class="topic-metadata">

**Author:** [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Replies:** 3\
**Last updated:** [March 17, 2022, 2:48pm UTC](https://discourse.julialang.org/t/using-interact-in-a-jupyter-notebook-through-binder/78028 "2022-03-17T14:48:39Z")

</div>

Hello, I would like to ask if somebody knows how to make a Jupyter Notebook with slide bars in Julia work using Binder. Locally, in my machine, after installing the necessary dependencies in the project I am able to mak…

---

## [PrettyTables linebreak in title](https://discourse.julialang.org/t/prettytables-linebreak-in-title/78017)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 2:28pm UTC](https://discourse.julialang.org/t/prettytables-linebreak-in-title/78017 "2022-03-17T14:28:16Z")

</div>

How do I make linebreaks in the header of a pretty\_table? Here is a MEW of my attempt: julia\> using PrettyTables julia\> pretty\_table(linebreaks=true, body\_hlines = \[1, 2, 3\], header = (\[" " …

---

## [Restore session in VSCode: ERROR: LoadError: IOError: connect: connection refused (ECONNREFUSED)](https://discourse.julialang.org/t/restore-session-in-vscode-error-loaderror-ioerror-connect-connection-refused-econnrefused/78022)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 3\
**Last updated:** [March 17, 2022, 1:41pm UTC](https://discourse.julialang.org/t/restore-session-in-vscode-error-loaderror-ioerror-connect-connection-refused-econnrefused/78022 "2022-03-17T13:41:39Z")

</div>

In one computer, when I restart VScode, I’m getting this error in the Julia session: julia\> Session contents restored from 3/17/2022 at 9:30:27 AM ERROR: LoadError: IOError: connect: connection refused (ECONNREFUSE…

---

## [ERROR: LoadError: IOError: open("..)](https://discourse.julialang.org/t/error-loaderror-ioerror-open/77884)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 1:23pm UTC](https://discourse.julialang.org/t/error-loaderror-ioerror-open/77884 "2022-03-17T13:23:12Z")

</div>

I am trying to generating executable. So, I created Net module inside .Net/src/Net.jl. However, when I run packagecompiler (below), it gives an error. How can I solve the problem? module Net using NativeFileDialog…

---

## [Get the number of rows updated in SQLite?](https://discourse.julialang.org/t/get-the-number-of-rows-updated-in-sqlite/78023)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 0\
**Last updated:** [March 17, 2022, 12:58pm UTC](https://discourse.julialang.org/t/get-the-number-of-rows-updated-in-sqlite/78023 "2022-03-17T12:58:20Z")

</div>

In other languages I’ve used, after running update SQL, it returns the number of rows updated. However, when I run DBInterface.execute("update Test set val='green' where id=1"), it seems to return nothing. Is there a way…

---

## [1 + 'a' = 'b'](https://discourse.julialang.org/t/1-a-b/77947)

<div class="topic-metadata">

**Author:** [@Jerry](https://discourse.julialang.org/u/Jerry)\
**Replies:** 81\
**Last updated:** [March 17, 2022, 11:48am UTC](https://discourse.julialang.org/t/1-a-b/77947 "2022-03-17T11:48:39Z")

</div>

julia\> 1 + 'a' 'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase) This is ridiculous. How is this not an error? There should be—and maybe there is—an increment function for characters. I know this aggressive beh…

---

## [How to get the state of a dynamic system during integration?](https://discourse.julialang.org/t/how-to-get-the-state-of-a-dynamic-system-during-integration/78016)

<div class="topic-metadata">

**Author:** [@egor](https://discourse.julialang.org/u/egor)\
**Replies:** 15\
**Last updated:** [March 17, 2022, 11:04am UTC](https://discourse.julialang.org/t/how-to-get-the-state-of-a-dynamic-system-during-integration/78016 "2022-03-17T11:04:44Z")

</div>

Hello everyone, I am calculating Lyapunov exponents for my system using lyapunovspectrum from DynamicalSystems. Can I somehow get the state of the system during integration? For another system, I wrote this code: check …

---

## [How to get a quick description of a vector/matrix like \`pd.DataFrame.describe\`](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 6\
**Last updated:** [March 17, 2022, 10:57am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013 "2022-03-17T10:57:08Z")

</div>

When in python pandas I find pd.DataFrame.describe a helpful tool to get some quick insight about my DataFrame, particularly when using large DataFrames in the REPL. It works as follows, from the linked docs: \>\>\> s = pd…

---

## [Why is Julia's graphics system so slow?](https://discourse.julialang.org/t/why-is-julias-graphics-system-so-slow/68750)

<div class="topic-metadata">

**Author:** [@aachener](https://discourse.julialang.org/u/aachener)\
**Replies:** 32\
**Last updated:** [March 17, 2022, 8:59am UTC](https://discourse.julialang.org/t/why-is-julias-graphics-system-so-slow/68750 "2022-03-17T08:59:14Z")

</div>

Hi, all, I am relatively new to Julia, and am using Julia 1.6.2 as well as newest Plots.jl, pyplot.jl and Gadfly.jl. I am programming Julia using vs code extension. I find that drawing charts and plots in Julia is par…

---

## [How to deal with inconsistent objects due to mutation](https://discourse.julialang.org/t/how-to-deal-with-inconsistent-objects-due-to-mutation/77960)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 19\
**Last updated:** [March 17, 2022, 7:58am UTC](https://discourse.julialang.org/t/how-to-deal-with-inconsistent-objects-due-to-mutation/77960 "2022-03-17T07:58:42Z")

</div>

This is a bit of a basic philosophical question about type and API design. I would love the input of more experienced coders, since I suspect I might be approaching my problem wrong. I have a type in essence similar to: …

---

## [Why is this numerical scheme so much faster when using \`collect()\` than a for loop?](https://discourse.julialang.org/t/why-is-this-numerical-scheme-so-much-faster-when-using-collect-than-a-for-loop/77949)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 2:34am UTC](https://discourse.julialang.org/t/why-is-this-numerical-scheme-so-much-faster-when-using-collect-than-a-for-loop/77949 "2022-03-17T02:34:38Z")

</div>

Consider a toy algorithm that finds the maximum of a vector, then removes it and alters the other entries of the vector in a way that depends on whether they are located at a lower or higher index. In the code below, wh…

---

## [JET.jl reports error for every \`println\`](https://discourse.julialang.org/t/jet-jl-reports-error-for-every-println/77991)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [March 17, 2022, 12:30am UTC](https://discourse.julialang.org/t/jet-jl-reports-error-for-every-println/77991 "2022-03-17T00:30:21Z")

</div>

JET.jl reports run-time dispatch errors for every println, even if the println line in question is not reached. Is that desired? (it makes harder to check for errors in any package that prints information optionally for …

---

## [How to get system state during event handling?](https://discourse.julialang.org/t/how-to-get-system-state-during-event-handling/77994)

<div class="topic-metadata">

**Author:** [@egor](https://discourse.julialang.org/u/egor)\
**Replies:** 1\
**Last updated:** [March 16, 2022, 10:17pm UTC](https://discourse.julialang.org/t/how-to-get-system-state-during-event-handling/77994 "2022-03-16T22:17:17Z")

</div>

Hello everyone, I’m going through an example from the documentation about event handling during dynamic system integration. using DifferentialEquations function f(du,u,p,t) du\[1\] = -u\[1\] end u0 = \[10.0\] const V = 1 …

---

## [Condition to use or not to use threaded for loop](https://discourse.julialang.org/t/condition-to-use-or-not-to-use-threaded-for-loop/77935)

<div class="topic-metadata">

**Author:** [@JesperMartinsson](https://discourse.julialang.org/u/JesperMartinsson)\
**Replies:** 4\
**Last updated:** [March 16, 2022, 10:04pm UTC](https://discourse.julialang.org/t/condition-to-use-or-not-to-use-threaded-for-loop/77935 "2022-03-16T22:04:57Z")

</div>

I have a function with a for-loop that I like to turn multi- or single-threaded by a separate argument. For example: function foo(cond) if cond @inbounds Threads.@threads for n = 1:N # computatio…

---

## [Very large arrays](https://discourse.julialang.org/t/very-large-arrays/77942)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 5\
**Last updated:** [March 16, 2022, 5:18pm UTC](https://discourse.julialang.org/t/very-large-arrays/77942 "2022-03-16T17:18:51Z")

</div>

Does Julia support AbstractArrays larger than typemax(Int)? (e.g. sparse arrays or arrays larger than 2^31 on a 32-bit Julia install) Is code in Base allowed to assume that an AbstractArray has length no more than typem…

---

## [\`unique(Vector{CustomStruct})\` requires method for hash | Bug or misleading documentation?](https://discourse.julialang.org/t/unique-vector-customstruct-requires-method-for-hash-bug-or-misleading-documentation/77974)

<div class="topic-metadata">

**Author:** [@aaronpeikert](https://discourse.julialang.org/u/aaronpeikert)\
**Replies:** 6\
**Last updated:** [March 16, 2022, 5:02pm UTC](https://discourse.julialang.org/t/unique-vector-customstruct-requires-method-for-hash-bug-or-misleading-documentation/77974 "2022-03-16T17:02:02Z")

</div>

I was surprised to see that it is not enough to implement isequal to get unique for free, though the documentation seems to suggest it: https://docs.julialang.org/en/v1/base/collections/#Base.unique Return an array co…

---

## [How to convert CartesianIndex{N} values to Int64](https://discourse.julialang.org/t/how-to-convert-cartesianindex-n-values-to-int64/15074)

<div class="topic-metadata">

**Author:** [@Tomoyuki\_Kosaka](https://discourse.julialang.org/u/Tomoyuki_Kosaka)\
**Replies:** 18\
**Last updated:** [March 16, 2022, 4:13pm UTC](https://discourse.julialang.org/t/how-to-convert-cartesianindex-n-values-to-int64/15074 "2022-03-16T16:13:36Z")

</div>

I’m using Clustering Pkg and function fuzzy\_cmean, and try to assign the cluster number to each data. If I use findmax(FuzzyCMeansResult.weights, dims=2) will give us (value, CartesianIndex(2)). Then, I cannot find out…

---

## [CxxWrap.jl, why these code report error?](https://discourse.julialang.org/t/cxxwrap-jl-why-these-code-report-error/77984)

<div class="topic-metadata">

**Author:** [@Brian1](https://discourse.julialang.org/u/Brian1)\
**Replies:** 0\
**Last updated:** [March 16, 2022, 4:11pm UTC](https://discourse.julialang.org/t/cxxwrap-jl-why-these-code-report-error/77984 "2022-03-16T16:11:01Z")

</div>

I’m using CxxWrap. My setup: Julia: 1.7.2 CxxWrap: 0.12.0 when I do this, there come error: the error: the dependency is Can anyone can tell me why this error happened?

---

## [Destructuring object into DataFrame](https://discourse.julialang.org/t/destructuring-object-into-dataframe/77964)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 6\
**Last updated:** [March 16, 2022, 3:44pm UTC](https://discourse.julialang.org/t/destructuring-object-into-dataframe/77964 "2022-03-16T15:44:20Z")

</div>

Hi all, I have an array of objects that I would like to convert to a DataFrame. Each object has some arrays and some individual values. I would like to destructure the arrays into individual rows and columns and repeat …

---

## [Why does my hash function return a different value to the built in hash function?](https://discourse.julialang.org/t/why-does-my-hash-function-return-a-different-value-to-the-built-in-hash-function/77973)

<div class="topic-metadata">

**Author:** [@Jon\_Barker](https://discourse.julialang.org/u/Jon_Barker)\
**Replies:** 7\
**Last updated:** [March 16, 2022, 2:33pm UTC](https://discourse.julialang.org/t/why-does-my-hash-function-return-a-different-value-to-the-built-in-hash-function/77973 "2022-03-16T14:33:41Z")

</div>

I copied the hash function code from here: And ran it under J1.7 but I get different results. Why?

---

## [Some registries failed to update!?](https://discourse.julialang.org/t/some-registries-failed-to-update/77969)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 0\
**Last updated:** [March 16, 2022, 1:08pm UTC](https://discourse.julialang.org/t/some-registries-failed-to-update/77969 "2022-03-16T13:08:17Z")

</div>

When performing the command (@v1.7) pkg\>up, I receive the following alert: Error: Some registries failed to update: from the following list: (@v1.7) pkg\> st Status C:\\Users\\Hermesr\\.julia\\environments\\v1.7\\Project.to…

---

## [Assigning a color to each variable](https://discourse.julialang.org/t/assigning-a-color-to-each-variable/77967)

<div class="topic-metadata">

**Author:** [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Replies:** 0\
**Last updated:** [March 16, 2022, 12:56pm UTC](https://discourse.julialang.org/t/assigning-a-color-to-each-variable/77967 "2022-03-16T12:56:06Z")

</div>

Hi, I was wondering if there was a way of automatically assigning a color to each bar when doing a bar plot (Plots.bar), something similar to color=:variable in Gadfly. My data looks like this: Var1 Var2 Var3 1 …

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

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