# General Usage

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

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

**Page:** 567

---

## [Error with parallel sparse array building](https://discourse.julialang.org/t/error-with-parallel-sparse-array-building/65833)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 0\
**Last updated:** [August 4, 2021, 5:46pm UTC](https://discourse.julialang.org/t/error-with-parallel-sparse-array-building/65833 "2021-08-04T17:46:54Z")

</div>

I know that the recommended way to @thread build array is to split the work based on nthreads() and then join the array later. (What I said is the same as the macro @threads.) Nevertheless, in the below each thread shoul…

---

## [Can't reproduce package environment](https://discourse.julialang.org/t/cant-reproduce-package-environment/65830)

<div class="topic-metadata">

**Author:** [@LinasBa](https://discourse.julialang.org/u/LinasBa)\
**Replies:** 1\
**Last updated:** [August 4, 2021, 6:36pm UTC](https://discourse.julialang.org/t/cant-reproduce-package-environment/65830 "2021-08-04T18:36:56Z")

</div>

Hello, I am trying to install private package on new device, but dependencies doesn’t work. Here are steps I took: git clone dev MyPackage using MyPackage In package Project.Toml there is specified dependency: Color…

---

## [How to create structs with fields that are reserved Julia keywords](https://discourse.julialang.org/t/how-to-create-structs-with-fields-that-are-reserved-julia-keywords/65784)

<div class="topic-metadata">

**Author:** [@orso](https://discourse.julialang.org/u/orso)\
**Replies:** 4\
**Last updated:** [August 4, 2021, 4:34pm UTC](https://discourse.julialang.org/t/how-to-create-structs-with-fields-that-are-reserved-julia-keywords/65784 "2021-08-04T16:34:16Z")

</div>

I do not seem to be able to create structs that have reserved Julia keywords as fields Essentials · The Julia Language For example: struct test local::Float64 end will throw a syntax: malformed expression error B…

---

## [Warning: Atom.jl: unrecognised message \`cacheCompletions\`](https://discourse.julialang.org/t/warning-atom-jl-unrecognised-message-cachecompletions/35908)

<div class="topic-metadata">

**Author:** [@Kavitha](https://discourse.julialang.org/u/Kavitha)\
**Replies:** 7\
**Last updated:** [August 4, 2021, 4:08pm UTC](https://discourse.julialang.org/t/warning-atom-jl-unrecognised-message-cachecompletions/35908 "2021-08-04T16:08:40Z")

</div>

Hi, When I start Julia in Atom, I get the following warning. ‘julia-client’ and all the packages are up to date. I just updated it earlier today. After the update, I tried to run an example from the repo, but I couldn…

---

## [JuliaPro - package installation issues](https://discourse.julialang.org/t/juliapro-package-installation-issues/65807)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 12\
**Last updated:** [August 4, 2021, 3:25pm UTC](https://discourse.julialang.org/t/juliapro-package-installation-issues/65807 "2021-08-04T15:25:31Z")

</div>

Why can’t I install MLJ.j? This is my error: (@JuliaPro\_v1.5.1-1) pkg\> add MLJ Updating registry at C:\\Users\\dell\\.julia\\registries\\JuliaComputingRegistry ERROR: The following package names could not be resolved: M…

---

## [How to convert a string to UInt8?](https://discourse.julialang.org/t/how-to-convert-a-string-to-uint8/65811)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 5\
**Last updated:** [August 4, 2021, 1:59pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-to-uint8/65811 "2021-08-04T13:59:45Z")

</div>

This does not work: reinterpret(UInt8, "Ab") UInt8.("Ab")

---

## [Convert a 3D Array to 2D array of vectors](https://discourse.julialang.org/t/convert-a-3d-array-to-2d-array-of-vectors/65755)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 7\
**Last updated:** [August 4, 2021, 1:34pm UTC](https://discourse.julialang.org/t/convert-a-3d-array-to-2d-array-of-vectors/65755 "2021-08-04T13:34:45Z")

</div>

Hi, I have a 3D array (X::Array{Int8, 3}, size N x K x 2). How can I convert it to a Matrix (size N x K) of Vector such that new X will be X\[i, j\] = X\[i, j, :\] with very little new memory allocation. Thanks, Vishnu Ra…

---

## [Question about possibility prediction](https://discourse.julialang.org/t/question-about-possibility-prediction/65809)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 0\
**Last updated:** [August 4, 2021, 1:24pm UTC](https://discourse.julialang.org/t/question-about-possibility-prediction/65809 "2021-08-04T13:24:49Z")

</div>

I am studying the probabilistic prediction of time series data of power system. Is there any Pkg in Julia that can realize the multidimensional probabilistic prediction problem? thanks!!!

---

## [How to timeout in a function call](https://discourse.julialang.org/t/how-to-timeout-in-a-function-call/65763)

<div class="topic-metadata">

**Author:** [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Replies:** 1\
**Last updated:** [August 4, 2021, 11:50am UTC](https://discourse.julialang.org/t/how-to-timeout-in-a-function-call/65763 "2021-08-04T11:50:24Z")

</div>

I am currently downloading some data from a remote server, however the connection may not always be stable and therefore the data loading might hang. Therefore, I would like break the connection and restart it after a c…

---

## [Why \`lock\` does NOT work for full channel?](https://discourse.julialang.org/t/why-lock-does-not-work-for-full-channel/65710)

<div class="topic-metadata">

**Author:** [@zwtechnb](https://discourse.julialang.org/u/zwtechnb)\
**Replies:** 10\
**Last updated:** [August 4, 2021, 11:14am UTC](https://discourse.julialang.org/t/why-lock-does-not-work-for-full-channel/65710 "2021-08-04T11:14:01Z")

</div>

I am wondering why lock function does NOT work for full channel? For example: function showme(n, m) c = Channel(m) t1 = @async begin sleep(3) for \_ in 1:n put!(c, 0) slee…

---

## [GLIBCXX missing when compiling julia 1.6.2](https://discourse.julialang.org/t/glibcxx-missing-when-compiling-julia-1-6-2/65733)

<div class="topic-metadata">

**Author:** [@albheim](https://discourse.julialang.org/u/albheim)\
**Replies:** 3\
**Last updated:** [August 4, 2021, 10:47am UTC](https://discourse.julialang.org/t/glibcxx-missing-when-compiling-julia-1-6-2/65733 "2021-08-04T10:47:39Z")

</div>

I have been compiling Julia without any problems over the last few years, and suddenly it is not working anymore. I just upgraded my fedora version so I assume it is connected to that, but I don’t really understand how. …

---

## [Function arguments with multiple names](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 2\
**Last updated:** [August 4, 2021, 9:30am UTC](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787 "2021-08-04T09:30:12Z")

</div>

I’d like to use a function with multiple data sources that have slightly different parameter names. Is there something like function f(; end\_date {alternates: endDate, eDate, EndDt }, start\_date="1Jan2020" ) wher…

---

## [How to define an array whose elements are manually defined type?](https://discourse.julialang.org/t/how-to-define-an-array-whose-elements-are-manually-defined-type/65776)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 6\
**Last updated:** [August 4, 2021, 9:19am UTC](https://discourse.julialang.org/t/how-to-define-an-array-whose-elements-are-manually-defined-type/65776 "2021-08-04T09:19:50Z")

</div>

I have a manually defined type, or called struct in Julia, mutable struct Mean\_covar mu::Array{Float64,2} sigma::Array{Float64,2} w::Float64 end Now I want to define an const array but its content can chan…

---

## [Juliapackages.com and juliaobserver.com broken?](https://discourse.julialang.org/t/juliapackages-com-and-juliaobserver-com-broken/64578)

<div class="topic-metadata">

**Author:** [@murrayE](https://discourse.julialang.org/u/murrayE)\
**Replies:** 6\
**Last updated:** [August 4, 2021, 1:19am UTC](https://discourse.julialang.org/t/juliapackages-com-and-juliaobserver-com-broken/64578 "2021-08-04T01:19:41Z")

</div>

Both those sites seem to be down. Trying to visit juliapackages.com gives an Application Error. Trying to visit juliaobserver.com gives a “Whoops…Something went wrong.”

---

## [Calling functions with named tuples by element name](https://discourse.julialang.org/t/calling-functions-with-named-tuples-by-element-name/65469)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 7\
**Last updated:** [July 30, 2021, 2:22pm UTC](https://discourse.julialang.org/t/calling-functions-with-named-tuples-by-element-name/65469 "2021-07-30T14:22:43Z")

</div>

Allowing functions to read named tuple elements by name is a wonderful feature of 1.7. Thank you :slight\_smile: I can now write: a,b,c,d = 1:4 f( (;a,b) = (a=0,b=0) ) = a - b f((;c,d,b,a)) #result -1 f() …

---

## [Log scale in histogram](https://discourse.julialang.org/t/log-scale-in-histogram/65723)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 5\
**Last updated:** [August 3, 2021, 11:26pm UTC](https://discourse.julialang.org/t/log-scale-in-histogram/65723 "2021-08-03T23:26:13Z")

</div>

I don’t mind specifying my histogram bins manually in order to get a log scale, but it appears to break the viewport in Plots.jl: using Plots x = rand(1000) b = 10.0 .^ (-5:0) histogram(x, bins=b) And setting the x-a…

---

## [Pkg.build() vs Pkg.add() with julia -e](https://discourse.julialang.org/t/pkg-build-vs-pkg-add-with-julia-e/65762)

<div class="topic-metadata">

**Author:** [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 10:54pm UTC](https://discourse.julialang.org/t/pkg-build-vs-pkg-add-with-julia-e/65762 "2021-08-03T22:54:28Z")

</div>

When constructing command-lines to start he Julia REPL, I’m noticing some folks using Pkg.build("PyCall) rather than Pkg.add("PyCall"). The command-line I want to build is to allow many Julia environments, particularl…

---

## [Structures containing a function field](https://discourse.julialang.org/t/structures-containing-a-function-field/65696)

<div class="topic-metadata">

**Author:** [@aaraujo71](https://discourse.julialang.org/u/aaraujo71)\
**Replies:** 12\
**Last updated:** [August 3, 2021, 5:50pm UTC](https://discourse.julialang.org/t/structures-containing-a-function-field/65696 "2021-08-03T17:50:46Z")

</div>

I would like to include a function as part of a Julia object (struct). However, when I, for example, execute using BenchmarkTools func(x) = 2\*x^2 struct Test k :: Float64 V :: Array{Float64, 1} fn :: Funct…

---

## [Stipple error in PlotOptions](https://discourse.julialang.org/t/stipple-error-in-plotoptions/65757)

<div class="topic-metadata">

**Author:** [@Rafael\_Brus](https://discourse.julialang.org/u/Rafael_Brus)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 5:49pm UTC](https://discourse.julialang.org/t/stipple-error-in-plotoptions/65757 "2021-08-03T17:49:20Z")

</div>

I am trying to get the German credit demo for STipple running. The “Credits by age” graph is not showing correctly I noticed that the problem is with the xaxis\_max option: const bar\_plot\_opts = PlotOptions(xaxis\_tick\_…

---

## [What is the fastest way to turn a 3D array into a vector of 2D arrays?](https://discourse.julialang.org/t/what-is-the-fastest-way-to-turn-a-3d-array-into-a-vector-of-2d-arrays/65729)

<div class="topic-metadata">

**Author:** [@erwanlecarpentier](https://discourse.julialang.org/u/erwanlecarpentier)\
**Replies:** 13\
**Last updated:** [August 3, 2021, 2:56pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-way-to-turn-a-3d-array-into-a-vector-of-2d-arrays/65729 "2021-08-03T14:56:36Z")

</div>

Hi, I wonder what would be the fastest way to turn a 3D array into a vector of 2D arrays. Specifically: the input is an array of size size(inp) = (a, b, c) and I want as output a vector (typeof(out) = Array{Array{UInt8,…

---

## [How to perform explicit array broadcasting like np.broadcast\_to/torch.expand in Julia?](https://discourse.julialang.org/t/how-to-perform-explicit-array-broadcasting-like-np-broadcast-to-torch-expand-in-julia/65559)

<div class="topic-metadata">

**Author:** [@oscarknagg](https://discourse.julialang.org/u/oscarknagg)\
**Replies:** 11\
**Last updated:** [August 3, 2021, 1:27pm UTC](https://discourse.julialang.org/t/how-to-perform-explicit-array-broadcasting-like-np-broadcast-to-torch-expand-in-julia/65559 "2021-08-03T13:27:22Z")

</div>

Hi all. In Pytorch/numpy you can perform broadcasting with fine-grained and explicit control. To see what I mean here is a numpy example of what I mean. import numpy as np a = np.array(\[\[0,0\], \[0,1\], \[0, 1\]\]) b = np.ar…

---

## [Deserialization error (StackOverflow) crashes Julia and can not be caught](https://discourse.julialang.org/t/deserialization-error-stackoverflow-crashes-julia-and-can-not-be-caught/65748)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 1:26pm UTC](https://discourse.julialang.org/t/deserialization-error-stackoverflow-crashes-julia-and-can-not-be-caught/65748 "2021-08-03T13:26:28Z")

</div>

I have the following function which retrieves the content of a cache stored as a serialized Julia object: """ fromcache(key::Any, expiration::Int; dir::String = "") :: Union{Nothing,Any} Retrieves from cache the ob…

---

## [Turning the target function for M-H into a distribution](https://discourse.julialang.org/t/turning-the-target-function-for-m-h-into-a-distribution/65747)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 1:01pm UTC](https://discourse.julialang.org/t/turning-the-target-function-for-m-h-into-a-distribution/65747 "2021-08-03T13:01:35Z")

</div>

I have a target function that I want to transform into a distribution in order to use Turing, let’s suppose that the target function is written on this form: logtarget(x::Vector)= log(prod(x))^2 how can I turn it into …

---

## [Turing MethodError with reversediff but not with forwarddiff](https://discourse.julialang.org/t/turing-methoderror-with-reversediff-but-not-with-forwarddiff/65633)

<div class="topic-metadata">

**Author:** [@fkrauer](https://discourse.julialang.org/u/fkrauer)\
**Replies:** 2\
**Last updated:** [August 3, 2021, 12:31pm UTC](https://discourse.julialang.org/t/turing-methoderror-with-reversediff-but-not-with-forwarddiff/65633 "2021-08-03T12:31:41Z")

</div>

Hi everyone I have a small ODE model, which runs fine (albeit slow) with Turing forwarddiff AD. However, I cannot get it to run with reversediff (and neither with Zygote). It throws a MethodError (see below). Is this so…

---

## [Milliseconds and JSON3](https://discourse.julialang.org/t/milliseconds-and-json3/65743)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [August 3, 2021, 12:12pm UTC](https://discourse.julialang.org/t/milliseconds-and-json3/65743 "2021-08-03T12:12:12Z")

</div>

Hi all :slight\_smile: I want to do a round trip. Converting Milliseconds to JSON and back. But I can’t get it to work. Only one way works. The code below is my example. julia\> using JSON3 julia\> using StructTypes jul…

---

## [Implementing the builder pattern for types with UnionAll fields, idiomatic or not](https://discourse.julialang.org/t/implementing-the-builder-pattern-for-types-with-unionall-fields-idiomatic-or-not/65735)

<div class="topic-metadata">

**Author:** [@SeSodesa](https://discourse.julialang.org/u/SeSodesa)\
**Replies:** 3\
**Last updated:** [August 3, 2021, 11:15am UTC](https://discourse.julialang.org/t/implementing-the-builder-pattern-for-types-with-unionall-fields-idiomatic-or-not/65735 "2021-08-03T11:15:27Z")

</div>

My issue is essentially this: I have a type I would like to instantiate at some point with a validity check in an inner constructor, but before that I need to collect the data needed to actually build the type. I figured…

---

## [Julia output without escape sequences?](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 10\
**Last updated:** [August 3, 2021, 11:09am UTC](https://discourse.julialang.org/t/julia-output-without-escape-sequences/65515 "2021-08-03T11:09:28Z")

</div>

I am trying to make Julia work with an expect-like program. I do not want to adapt that program but have access to its source code. The program assumes that (in this case) the julia REPL gives the answer plus a followin…

---

## [When using bits as type parameters they are regarded a subtype of Any](https://discourse.julialang.org/t/when-using-bits-as-type-parameters-they-are-regarded-a-subtype-of-any/65724)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 3\
**Last updated:** [August 3, 2021, 9:33am UTC](https://discourse.julialang.org/t/when-using-bits-as-type-parameters-they-are-regarded-a-subtype-of-any/65724 "2021-08-03T09:33:05Z")

</div>

Hi all, using julia 1.6.1 there is currently an inconsistency when using bits (i.e. anything which is a bit-type) as type-parameters and when comparing bits directly with types. julia\> f(::Type{Tuple{T1}}) where T1 \<: …

---

## [Matrix multiplied by inverse matrix does not reproduce identity matrix](https://discourse.julialang.org/t/matrix-multiplied-by-inverse-matrix-does-not-reproduce-identity-matrix/65706)

<div class="topic-metadata">

**Author:** [@mengxiaoliu](https://discourse.julialang.org/u/mengxiaoliu)\
**Replies:** 4\
**Last updated:** [August 3, 2021, 9:12am UTC](https://discourse.julialang.org/t/matrix-multiplied-by-inverse-matrix-does-not-reproduce-identity-matrix/65706 "2021-08-03T09:12:47Z")

</div>

Hello, I found that multiplying a matrix by its inverse does not yield an identity matrix. Please see below a MWE: matrix = \[5.93419 4.8067; 4.8067 5.93419\] invmatrix = inv(matrix) matrix\*invmatrix The last line gener…

---

## [Question ) Mathematical equivalence, but different results of fixed point?](https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628)

<div class="topic-metadata">

**Author:** [@Zerosum](https://discourse.julialang.org/u/Zerosum)\
**Replies:** 1\
**Last updated:** [August 3, 2021, 8:53am UTC](https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628 "2021-08-03T08:53:36Z")

</div>

I am working on my own project, and I proved the following recursive equation has a unique fixed point (due to the Banach Fixed Point Theorem). Here is the equation with simplified notations. I couldn’t find any option…

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

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