# General Usage

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

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

**Page:** 490

---

## [Returning Arrays from Functions - Recommended Approach?](https://discourse.julialang.org/t/returning-arrays-from-functions-recommended-approach/75448)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 3\
**Last updated:** [January 30, 2022, 10:38pm UTC](https://discourse.julialang.org/t/returning-arrays-from-functions-recommended-approach/75448 "2022-01-30T22:38:03Z")

</div>

I have been working through an exercise of reviewing and re-reviewing some code I have that solves a one-dimensional system of coupled ODEs using finite differences (just as a toy problem to get better with Julia). I hav…

---

## [What is \`N\` in \`Array{T,N}\`?](https://discourse.julialang.org/t/what-is-n-in-array-t-n/75476)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [January 30, 2022, 9:58pm UTC](https://discourse.julialang.org/t/what-is-n-in-array-t-n/75476 "2022-01-30T21:58:00Z")

</div>

As in the title, what is N in Array{T,N} ? When dealing with parametric types, the doc shows the parameter being a Type, but here it is an integer. The doc actually says: " it can be any type at all (or a value of any …

---

## [Defining a type that mirrors a built-in container](https://discourse.julialang.org/t/defining-a-type-that-mirrors-a-built-in-container/75472)

<div class="topic-metadata">

**Author:** [@rpmuller](https://discourse.julialang.org/u/rpmuller)\
**Replies:** 4\
**Last updated:** [January 30, 2022, 9:14pm UTC](https://discourse.julialang.org/t/defining-a-type-that-mirrors-a-built-in-container/75472 "2022-01-30T21:14:33Z")

</div>

I’d like to define a type that mirrors a built-in type. Normally when I want to do this, I just define a struct with a member l that has the type I want: struct mylist1 l::Array{Int32} end and then define some meth…

---

## [Array dimensions don't match](https://discourse.julialang.org/t/array-dimensions-dont-match/75442)

<div class="topic-metadata">

**Author:** [@chunquan](https://discourse.julialang.org/u/chunquan)\
**Replies:** 2\
**Last updated:** [January 30, 2022, 8:22pm UTC](https://discourse.julialang.org/t/array-dimensions-dont-match/75442 "2022-01-30T20:22:05Z")

</div>

Hello, I used x, y =MNIST.testdata() and then did this “x = (x .- mean(x,dims = 2)) / std(x .- mean(x,dims = 2))” And I get 282810000 Array{Float64, 3}. But actually I need an Array 784\*10000, which means this shoul…

---

## [GLM - inconsistency with R on ISLR dataset?](https://discourse.julialang.org/t/glm-inconsistency-with-r-on-islr-dataset/75427)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 2\
**Last updated:** [January 30, 2022, 5:31pm UTC](https://discourse.julialang.org/t/glm-inconsistency-with-r-on-islr-dataset/75427 "2022-01-30T17:31:11Z")

</div>

I am teaching a class using the (well-known) book Intro to Statistical Learning in R (ISLR). For the Lab example in Chapter 3, there is an example using polynomial regression in GLM. According to documentation, the wa…

---

## [Understanding btime](https://discourse.julialang.org/t/understanding-btime/75468)

<div class="topic-metadata">

**Author:** [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Replies:** 1\
**Last updated:** [January 30, 2022, 2:50pm UTC](https://discourse.julialang.org/t/understanding-btime/75468 "2022-01-30T14:50:19Z")

</div>

I’ve implemented insertion sort and merge sort and I’m trying to run a benchmark between the two using @btime from BenchmarkTools input = rand(1:1000, 1000000) println("Insertion sort on random array of size ", length(i…

---

## [Plots, DataFrames, composite x-axis](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458)

<div class="topic-metadata">

**Author:** [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Replies:** 3\
**Last updated:** [January 30, 2022, 10:45am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458 "2022-01-30T10:45:37Z")

</div>

Hello I would like to create a plot similar to this shown below. It would be based on a dataframe and I would like to use Plots. The x axis data would come from two columns. Like a country-code and a date, as shown. …

---

## [A question on creating an array](https://discourse.julialang.org/t/a-question-on-creating-an-array/75439)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [January 30, 2022, 12:37am UTC](https://discourse.julialang.org/t/a-question-on-creating-an-array/75439 "2022-01-30T00:37:21Z")

</div>

I have a matrix X1 with the size of 360 \* 180. My goal is to create an array X2 with 100 layers, and each layer will have a matrix identical to X1, so that my final array X2 will have a size of 360 \* 180 \* 100. How do …

---

## [Providing artifacts/libraries for unsupported platforms (e.g. Apple Silicon)](https://discourse.julialang.org/t/providing-artifacts-libraries-for-unsupported-platforms-e-g-apple-silicon/75411)

<div class="topic-metadata">

**Author:** [@Hawkes](https://discourse.julialang.org/u/Hawkes)\
**Replies:** 5\
**Last updated:** [January 29, 2022, 9:32pm UTC](https://discourse.julialang.org/t/providing-artifacts-libraries-for-unsupported-platforms-e-g-apple-silicon/75411 "2022-01-29T21:32:07Z")

</div>

Hi, as I have recently switched to a MBP with Apple M1 I have experienced some issues with packages relying on Artifacts/JLL packages which do not yet include a wrapper in their JLL package. In particular I have encoun…

---

## [More threads, slower code, even if not spawning them](https://discourse.julialang.org/t/more-threads-slower-code-even-if-not-spawning-them/75242)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 19\
**Last updated:** [January 29, 2022, 9:16pm UTC](https://discourse.julialang.org/t/more-threads-slower-code-even-if-not-spawning-them/75242 "2022-01-29T21:16:37Z")

</div>

Maybe I don’t understand how @spawn works, but here is what I am observing: When executing a parallel task with it, I observe that the performance is significantly worse if I have more threads available (i. e. starting j…

---

## [Counting all same path in a JSON](https://discourse.julialang.org/t/counting-all-same-path-in-a-json/75433)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 0\
**Last updated:** [January 29, 2022, 8:50pm UTC](https://discourse.julialang.org/t/counting-all-same-path-in-a-json/75433 "2022-01-29T20:50:07Z")

</div>

Hi All, I am curios if someone was solving a following problem. In JsonGrinder.jl, I need to store leafs of JSONs of the same type (same path) to the same continuous array, such that when I pass it to Neural Network, B…

---

## [Gtk. How do I create a submenu?](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418)

<div class="topic-metadata">

**Author:** [@johntrinder](https://discourse.julialang.org/u/johntrinder)\
**Replies:** 2\
**Last updated:** [January 29, 2022, 7:31pm UTC](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418 "2022-01-29T19:31:48Z")

</div>

I’m still a beginner at Gtk GUI interface package. I’ve googled a lot, but I can’t find any code snippets for how to create a submenu in Julia. Could someone please advise.

---

## [Create a user-type set](https://discourse.julialang.org/t/create-a-user-type-set/75420)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 2\
**Last updated:** [January 29, 2022, 6:31pm UTC](https://discourse.julialang.org/t/create-a-user-type-set/75420 "2022-01-29T18:31:41Z")

</div>

hellow, how to create a user type set? # i do mutable struct UserType id::Int end Base.:(==)(a::UserType, b::UserType) = a.id == b.id set = Set((UserType(1), UserType(2),)) UserType(1) == UserType(1) # -\> true # bu…

---

## [Is Julia a good choice for Data Engineering?](https://discourse.julialang.org/t/is-julia-a-good-choice-for-data-engineering/38629)

<div class="topic-metadata">

**Author:** [@rwatts3](https://discourse.julialang.org/u/rwatts3)\
**Replies:** 11\
**Last updated:** [January 29, 2022, 12:41pm UTC](https://discourse.julialang.org/t/is-julia-a-good-choice-for-data-engineering/38629 "2022-01-29T12:41:58Z")

</div>

My apologies for the generic question. Unfortunately after searching around I haven’t been able to find a direct answer. I would like to know the communities opinion on using Julia for Data Engineering tasks. You know…

---

## [Higher precision leads to incorrect results?](https://discourse.julialang.org/t/higher-precision-leads-to-incorrect-results/75248)

<div class="topic-metadata">

**Author:** [@chrisoffner](https://discourse.julialang.org/u/chrisoffner)\
**Replies:** 19\
**Last updated:** [January 28, 2022, 7:32pm UTC](https://discourse.julialang.org/t/higher-precision-leads-to-incorrect-results/75248 "2022-01-28T19:32:55Z")

</div>

I’m working through Arthur & Vassilvitskii’s \\Omega(n^2) lower bound proof for the iterative closest point (ICP) algorithm in \\mathbb{R} (Theorem 3.4 in the paper) and thought it’d be neat to visualize their construction…

---

## [Conversion of CxxWrap.StdLib.StdVectorAllocated{UInt8} to Julian Vector{UInt8} faster](https://discourse.julialang.org/t/conversion-of-cxxwrap-stdlib-stdvectorallocated-uint8-to-julian-vector-uint8-faster/75351)

<div class="topic-metadata">

**Author:** [@Ashwani\_Rathee](https://discourse.julialang.org/u/Ashwani_Rathee)\
**Replies:** 8\
**Last updated:** [January 29, 2022, 6:21am UTC](https://discourse.julialang.org/t/conversion-of-cxxwrap-stdlib-stdvectorallocated-uint8-to-julian-vector-uint8-faster/75351 "2022-01-29T06:21:02Z")

</div>

Hey guys, issue I am facing is the conversion of the arrays and the efficiency of the conversion julia\> res = screenshot\_rgb() # image of size 1920\*1080 with 4 bytes per pixel returned 8294400-element CxxWrap.StdLib.Std…

---

## [Do views interfere with thread synchronization?](https://discourse.julialang.org/t/do-views-interfere-with-thread-synchronization/75379)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 7\
**Last updated:** [January 28, 2022, 10:17pm UTC](https://discourse.julialang.org/t/do-views-interfere-with-thread-synchronization/75379 "2022-01-28T22:17:59Z")

</div>

I have this code which attempts compute a matrix-vector product using submatrices. tasks = \[\]; for th in 1:length(tbs) tb = tbs\[th\] push!(tasks, Threads.@spawn begin mul!(tb.result, tb.k…

---

## [\[GUI\] \[Gtk.jl\] UI freezing when signal\_connect used](https://discourse.julialang.org/t/gui-gtk-jl-ui-freezing-when-signal-connect-used/75156)

<div class="topic-metadata">

**Author:** [@kodintent](https://discourse.julialang.org/u/kodintent)\
**Replies:** 6\
**Last updated:** [January 28, 2022, 6:46pm UTC](https://discourse.julialang.org/t/gui-gtk-jl-ui-freezing-when-signal-connect-used/75156 "2022-01-28T18:46:47Z")

</div>

Hi. Im investigating Gtk.jl for GUI apps - specifically, multithreading with progress updates in the GUI. I wish to have a single window that can be used to select params, then also display progress. I can update a pr…

---

## [Split inconsistency?](https://discourse.julialang.org/t/split-inconsistency/75380)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 5\
**Last updated:** [January 28, 2022, 6:31pm UTC](https://discourse.julialang.org/t/split-inconsistency/75380 "2022-01-28T18:31:37Z")

</div>

julia\> split(" aa bb") 2-element Vector{SubString{String}}: "aa" "bb" julia\> split(" aa bb", ' ') 3-element Vector{SubString{String}}: "" "aa" "bb" julia\> split(" aa bb", " ") 3-element Vector{SubString{String}}: …

---

## [@everywhere effect region / distributed calculation](https://discourse.julialang.org/t/everywhere-effect-region-distributed-calculation/75359)

<div class="topic-metadata">

**Author:** [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Replies:** 0\
**Last updated:** [January 28, 2022, 1:30pm UTC](https://discourse.julialang.org/t/everywhere-effect-region-distributed-calculation/75359 "2022-01-28T13:30:09Z")

</div>

Hi, I have a problem with distributed calculation, here is a small example can reflect my question @everywhere begin function f(x, b) return x^2 + sum(b) end end @everywhere using Distributed, SharedArr…

---

## [A question about my Gurobi](https://discourse.julialang.org/t/a-question-about-my-gurobi/75369)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [January 28, 2022, 5:28pm UTC](https://discourse.julialang.org/t/a-question-about-my-gurobi/75369 "2022-01-28T17:28:38Z")

</div>

Why can’t my Gurobi install?? (@v1.6) pkg\> build Gurobi Building Gurobi → C:\\Users\\dell\\.julia\\scratchspaces\\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\\0c39671e531549c2969bdf0c0513d03a07f9ffd8\\build.log ERROR: Error buildin…

---

## [Julia 1.7 says it can switch the thread your task is on. How often does that happen, and how can it be disabled?](https://discourse.julialang.org/t/julia-1-7-says-it-can-switch-the-thread-your-task-is-on-how-often-does-that-happen-and-how-can-it-be-disabled/75373)

<div class="topic-metadata">

**Author:** [@heyx3](https://discourse.julialang.org/u/heyx3)\
**Replies:** 6\
**Last updated:** [January 28, 2022, 5:01pm UTC](https://discourse.julialang.org/t/julia-1-7-says-it-can-switch-the-thread-your-task-is-on-how-often-does-that-happen-and-how-can-it-be-disabled/75373 "2022-01-28T17:01:19Z")

</div>

According to the release notes: Tasks can now migrate among threads when they are re-scheduled. Previously, a Task would always run on whichever thread executed it first Does this mean that the thread I’m running on …

---

## [Using local sourcecode](https://discourse.julialang.org/t/using-local-sourcecode/75368)

<div class="topic-metadata">

**Author:** [@volkerkarle](https://discourse.julialang.org/u/volkerkarle)\
**Replies:** 1\
**Last updated:** [January 28, 2022, 4:15pm UTC](https://discourse.julialang.org/t/using-local-sourcecode/75368 "2022-01-28T16:15:59Z")

</div>

Hi folks, Following this guide I have some source-code which is sitting in some folder /path/…/example/MyNiceUtils.jl and loaded it with push!(LOAD\_PATH,"/path/.../example/") using MyNiceUtils So somehow this not wor…

---

## [Advices on convergence issues Turing](https://discourse.julialang.org/t/advices-on-convergence-issues-turing/74862)

<div class="topic-metadata">

**Author:** [@99dB](https://discourse.julialang.org/u/99dB)\
**Replies:** 12\
**Last updated:** [January 28, 2022, 2:03pm UTC](https://discourse.julialang.org/t/advices-on-convergence-issues-turing/74862 "2022-01-28T14:03:48Z")

</div>

Hi all, I am estimating ~10 ODE parameters using some data with Turing. While I ran the sampling for quite a long time (~ 10.000 steps) for 10 chains, I got some convergence issues. After analyzing the posteriors, I re…

---

## [Passing a Julia function to a Python function](https://discourse.julialang.org/t/passing-a-julia-function-to-a-python-function/73985)

<div class="topic-metadata">

**Author:** [@krzysztofpostek](https://discourse.julialang.org/u/krzysztofpostek)\
**Replies:** 5\
**Last updated:** [January 28, 2022, 11:11am UTC](https://discourse.julialang.org/t/passing-a-julia-function-to-a-python-function/73985 "2022-01-28T11:11:20Z")

</div>

Hi there, I want to use a GPyOpt Python package for Bayesian Optimization to find the minimum value of a function which is written in Julia. For that end, I try to use the PyCall.jl and to call the function as function…

---

## [Call python packages from Julia](https://discourse.julialang.org/t/call-python-packages-from-julia/75324)

<div class="topic-metadata">

**Author:** [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Replies:** 3\
**Last updated:** [January 28, 2022, 11:03am UTC](https://discourse.julialang.org/t/call-python-packages-from-julia/75324 "2022-01-28T11:03:26Z")

</div>

Hi, with the help of PyCall.jl, I can easily run a script of python, but if I want to replace the function defined in python with the function defined in julia, it reminds me cannot find the sub-function, can anybody hel…

---

## [How to convert the binary form of a float to an integer, and vice versa?](https://discourse.julialang.org/t/how-to-convert-the-binary-form-of-a-float-to-an-integer-and-vice-versa/70083)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 17\
**Last updated:** [January 28, 2022, 9:29am UTC](https://discourse.julialang.org/t/how-to-convert-the-binary-form-of-a-float-to-an-integer-and-vice-versa/70083 "2022-01-28T09:29:00Z")

</div>

I am trying to implement the “fast inverse square root” algorithm in Julia: function rsqrt(x::Float32) xₛ = x int32 = reinterpret(UInt32, xₛ) int32 = 0x5f3759df - int32 \>\> 1 xₛ = reinterpret(Float32, int…

---

## [Julia program obfuscation for commercial code](https://discourse.julialang.org/t/julia-program-obfuscation-for-commercial-code/75174)

<div class="topic-metadata">

**Author:** [@maharvey](https://discourse.julialang.org/u/maharvey)\
**Replies:** 19\
**Last updated:** [January 28, 2022, 9:45am UTC](https://discourse.julialang.org/t/julia-program-obfuscation-for-commercial-code/75174 "2022-01-28T09:45:24Z")

</div>

Hi there, I thought I rather not revive the 2 year old thread here on the topic. I just wanted to share the solution which works for us. In our case, the julia code is called from a C/C++ program, so the simplest way I …

---

## [Redirect\_stdout fails to restore ccall prints](https://discourse.julialang.org/t/redirect-stdout-fails-to-restore-ccall-prints/75262)

<div class="topic-metadata">

**Author:** [@Codzilla](https://discourse.julialang.org/u/Codzilla)\
**Replies:** 9\
**Last updated:** [January 28, 2022, 8:16am UTC](https://discourse.julialang.org/t/redirect-stdout-fails-to-restore-ccall-prints/75262 "2022-01-28T08:16:51Z")

</div>

There is probably something that I don’t understand with redirect\_stdout but if I try using it and returning to the normal stdout it doesn’t work for ccall outputs. (using IJulia and Jupyter notebook with Julia Version 1…

---

## [Check Julia Application is 32- or 64-bit](https://discourse.julialang.org/t/check-julia-application-is-32-or-64-bit/75341)

<div class="topic-metadata">

**Author:** [@ThummeTo](https://discourse.julialang.org/u/ThummeTo)\
**Replies:** 2\
**Last updated:** [January 28, 2022, 7:36am UTC](https://discourse.julialang.org/t/check-julia-application-is-32-or-64-bit/75341 "2022-01-28T07:36:19Z")

</div>

Hello everyone, I think there is a pretty easy solution, but I don’t find it on Discourse.JuliaLang or Google: I want to check, if the Julia application that currently runs, is Julia 32- or 64-bit. Important: I need t…

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

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