# General Usage

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

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

**Page:** 503

---

## [Read binary Float128 data](https://discourse.julialang.org/t/read-binary-float128-data/73767)

<div class="topic-metadata">

**Author:** [@Mikel\_Antonana](https://discourse.julialang.org/u/Mikel_Antonana)\
**Replies:** 0\
**Last updated:** [December 29, 2021, 5:06pm UTC](https://discourse.julialang.org/t/read-binary-float128-data/73767 "2021-12-29T17:06:52Z")

</div>

We use our own C function to read Float128 binary data (Readbin code is below) which works correctly with Julia 1.4.2 and earlier versions. With later versions we get the following error: "julia: symbol lookup error…

---

## [Running Julia from JAVA? What is crazier?](https://discourse.julialang.org/t/running-julia-from-java-what-is-crazier/31662)

<div class="topic-metadata">

**Author:** [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Replies:** 39\
**Last updated:** [December 29, 2021, 7:35pm UTC](https://discourse.julialang.org/t/running-julia-from-java-what-is-crazier/31662 "2021-12-29T19:35:05Z")

</div>

Hey everyone, I’m exploring UI tools and integrating them with Julia. As part of this exercise I ended up making a nice UI in JAVAFX, now I need to hook it into Julia… So there’s two ways to go about this from what I un…

---

## [Does Cartesian Indexing work on single values?](https://discourse.julialang.org/t/does-cartesian-indexing-work-on-single-values/73744)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 13\
**Last updated:** [December 29, 2021, 7:15pm UTC](https://discourse.julialang.org/t/does-cartesian-indexing-work-on-single-values/73744 "2021-12-29T19:15:58Z")

</div>

My goal is to create a function to check if my data points are valid, i.e., not an NaN and not equal to -999. Here is the function I wrote: f(A) = \[idx for idx in CartesianIndices(A) if @inbounds (!isnan(A\[idx\]) && A\[i…

---

## [Differentiable vectorized piecewise function in Julia?](https://discourse.julialang.org/t/differentiable-vectorized-piecewise-function-in-julia/73766)

<div class="topic-metadata">

**Author:** [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Replies:** 6\
**Last updated:** [December 29, 2021, 5:47pm UTC](https://discourse.julialang.org/t/differentiable-vectorized-piecewise-function-in-julia/73766 "2021-12-29T17:47:57Z")

</div>

How could I define this function in Julia? f(x) = \\begin{cases} x^2 &\\text {x \< 2} \\\\ (x-2)(x-4) &\\text {otherwise}\\end{cases}

---

## [Polynomial plot clipped?](https://discourse.julialang.org/t/polynomial-plot-clipped/73747)

<div class="topic-metadata">

**Author:** [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Replies:** 5\
**Last updated:** [December 29, 2021, 5:30pm UTC](https://discourse.julialang.org/t/polynomial-plot-clipped/73747 "2021-12-29T17:30:19Z")

</div>

Curious, why does the plot of f get clipped around x=5.5? julia\> using Plots, Polynomials julia\> xdata = \[1.0, 3.5, 5.5, 7.0\] julia\> ydata = \[1.6884409261691142, 1.1095511387771335, 0.9753592108946215, 0.952227221687402…

---

## [Execution time test](https://discourse.julialang.org/t/execution-time-test/73753)

<div class="topic-metadata">

**Author:** [@XLVII](https://discourse.julialang.org/u/XLVII)\
**Replies:** 1\
**Last updated:** [December 29, 2021, 3:47pm UTC](https://discourse.julialang.org/t/execution-time-test/73753 "2021-12-29T15:47:33Z")

</div>

I have two function: Let’s say Funtion() Faster\_Function() their outputs are the same but their order is different, I want to test their speed and accuracy, how can I do this? I also need features such as writing out…

---

## [CUDA unexplainable SPEEDUP! Local memory?](https://discourse.julialang.org/t/cuda-unexplainable-speedup-local-memory/73754)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 4\
**Last updated:** [December 29, 2021, 3:35pm UTC](https://discourse.julialang.org/t/cuda-unexplainable-speedup-local-memory/73754 "2021-12-29T15:35:36Z")

</div>

Hey, I was trying to implement a kernel function when I faced with this incredible big difference: using BenchmarkTools using CUDA fast(v, nins,k,j,glay,glay2) = begin I = (blockIdx().x - 1) \* blockDim().x + threadIdx…

---

## [Not sure how to implement a python class in PyCall](https://discourse.julialang.org/t/not-sure-how-to-implement-a-python-class-in-pycall/73751)

<div class="topic-metadata">

**Author:** [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Replies:** 2\
**Last updated:** [December 29, 2021, 2:11pm UTC](https://discourse.julialang.org/t/not-sure-how-to-implement-a-python-class-in-pycall/73751 "2021-12-29T14:11:20Z")

</div>

I am trying to use PyCall to reuse a python script which has this code component. I have avoided using python’s oo class system and so I’m not too sure what is going on. from ib\_insync import \* ib = IB() ib.connect('n…

---

## [Documenter makedocs() failing to build locally](https://discourse.julialang.org/t/documenter-makedocs-failing-to-build-locally/73752)

<div class="topic-metadata">

**Author:** [@MattWillFlood](https://discourse.julialang.org/u/MattWillFlood)\
**Replies:** 0\
**Last updated:** [December 29, 2021, 1:20pm UTC](https://discourse.julialang.org/t/documenter-makedocs-failing-to-build-locally/73752 "2021-12-29T13:20:38Z")

</div>

Hi Guys :slightly\_smiling\_face: I’m trying to update the docs for a new package release, but makedocs() won’t build the HTML files locally. There is only a minor edit to the text in the new documentation and no change t…

---

## [Operator overloading of &&](https://discourse.julialang.org/t/operator-overloading-of/73735)

<div class="topic-metadata">

**Author:** [@atteson](https://discourse.julialang.org/u/atteson)\
**Replies:** 6\
**Last updated:** [December 29, 2021, 10:32am UTC](https://discourse.julialang.org/t/operator-overloading-of/73735 "2021-12-29T10:32:18Z")

</div>

As far as I can tell, there is no ability to overload &&. It doesn’t seem to be a function defined in Base as other operators are. I assume this is because it doesn’t behave the way other functions do in that it short …

---

## [Can't change python bin in PyCall](https://discourse.julialang.org/t/cant-change-python-bin-in-pycall/73736)

<div class="topic-metadata">

**Author:** [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Replies:** 2\
**Last updated:** [December 28, 2021, 11:16pm UTC](https://discourse.julialang.org/t/cant-change-python-bin-in-pycall/73736 "2021-12-28T23:16:23Z")

</div>

Hi all I am using Pluto and want to change PyCall python from conda to the one I use for a script I want to run that has a particular import that conda doesn’t have. I read the PyCall docs and “think” I am doing everyth…

---

## [JSON.print throws stack overflow error](https://discourse.julialang.org/t/json-print-throws-stack-overflow-error/73733)

<div class="topic-metadata">

**Author:** [@cocoa1231](https://discourse.julialang.org/u/cocoa1231)\
**Replies:** 0\
**Last updated:** [December 28, 2021, 11:01pm UTC](https://discourse.julialang.org/t/json-print-throws-stack-overflow-error/73733 "2021-12-28T23:01:11Z")

</div>

So I was trying to export the Plots.PyPlot.matplotlib.rcParams dictionary to a JSON file so I could use that configuration in my Python code (since the default plots made by Plots.jl are quite nice looking), so I wrote t…

---

## [Is Pmap \_both\_ distributed and threaded?](https://discourse.julialang.org/t/is-pmap-both-distributed-and-threaded/73717)

<div class="topic-metadata">

**Author:** [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)\
**Replies:** 4\
**Last updated:** [December 28, 2021, 9:18pm UTC](https://discourse.julialang.org/t/is-pmap-both-distributed-and-threaded/73717 "2021-12-28T21:18:24Z")

</div>

My typical cluster setup is 20-60 48-core AWS nodes If I use pmap() to distribute work across them, will the cluster workers also distribute their chunk of the map operation among their threads?

---

## [Apply macro to existing function](https://discourse.julialang.org/t/apply-macro-to-existing-function/73725)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 1\
**Last updated:** [December 28, 2021, 9:01pm UTC](https://discourse.julialang.org/t/apply-macro-to-existing-function/73725 "2021-12-28T21:01:35Z")

</div>

f(x) = x + 1 Given that function is already defined, is it possible to get the result of applying a macro to it? or is the AST not recoverable once the function is defined?

---

## [How to make norm(::AbstractVector) faster in my case?](https://discourse.julialang.org/t/how-to-make-norm-abstractvector-faster-in-my-case/73711)

<div class="topic-metadata">

**Author:** [@ziyiyin97](https://discourse.julialang.org/u/ziyiyin97)\
**Replies:** 14\
**Last updated:** [December 28, 2021, 8:36pm UTC](https://discourse.julialang.org/t/how-to-make-norm-abstractvector-faster-in-my-case/73711 "2021-12-28T20:36:07Z")

</div>

import Base.size import Base.IndexStyle import Base.getindex import Base.setindex! using LinearAlgebra using BenchmarkTools struct Dummy{T} \<: AbstractVector{T} coeffs::Vector{T} end ############### Base ########…

---

## [Saving SharedArrays](https://discourse.julialang.org/t/saving-sharedarrays/73723)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 2\
**Last updated:** [December 28, 2021, 8:22pm UTC](https://discourse.julialang.org/t/saving-sharedarrays/73723 "2021-12-28T20:22:53Z")

</div>

If I generate data as: using Distributed using SharedArrays using JLD2 n\_trials = 10^2; results = SharedArray{Float64}(n\_trials); @sync @distributed for i in 1:n\_trials results\[i\] = i; end jldsave("test.jld2"; res…

---

## [Acess an array using another array](https://discourse.julialang.org/t/acess-an-array-using-another-array/73714)

<div class="topic-metadata">

**Author:** [@Renan\_Rabelo](https://discourse.julialang.org/u/Renan_Rabelo)\
**Replies:** 3\
**Last updated:** [December 28, 2021, 6:25pm UTC](https://discourse.julialang.org/t/acess-an-array-using-another-array/73714 "2021-12-28T18:25:37Z")

</div>

I want to be able to acces a multi-dimentional array using another array. This is what happens if I try to do it: x = \[1,1,1\] y = zeros(Int64,(3,3,3)) # 3D array println(y\[x\]) # Prints \[0,0,0\] println(y\[1,1,1\]) # Prints…

---

## [Tuple and NamedTuple types](https://discourse.julialang.org/t/tuple-and-namedtuple-types/73701)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 6\
**Last updated:** [December 28, 2021, 4:24pm UTC](https://discourse.julialang.org/t/tuple-and-namedtuple-types/73701 "2021-12-28T16:24:16Z")

</div>

Dear all, I have some trouble to infer the types of Tuples and NamedTuples. Let’s start with a simple tuple. If each field in the tuple is of the same type, I can state the type of the tuple as follows (MWE): a = (:b, …

---

## [How to find a reviewer for StaticArrays?](https://discourse.julialang.org/t/how-to-find-a-reviewer-for-staticarrays/73709)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 0\
**Last updated:** [December 28, 2021, 4:00pm UTC](https://discourse.julialang.org/t/how-to-find-a-reviewer-for-staticarrays/73709 "2021-12-28T16:00:01Z")

</div>

How to find a reviewer for StaticArrays? Hello, I wrote a bug report (https://github.com/JuliaArrays/StaticArrays.jl/issues/981), which was approved, and patch was committed (https://github.com/JuliaArrays/StaticArray…

---

## [Is this a good way to export all variables inside of a function?](https://discourse.julialang.org/t/is-this-a-good-way-to-export-all-variables-inside-of-a-function/73699)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 4\
**Last updated:** [December 28, 2021, 2:25pm UTC](https://discourse.julialang.org/t/is-this-a-good-way-to-export-all-variables-inside-of-a-function/73699 "2021-12-28T14:25:28Z")

</div>

Hello! Not a question per se, more looking for some feedback I suppose. So by googling a bit, I came around and saw that it is possible to call a macro called Base.@locals, which if you use it inside of a function, you…

---

## [Is it normal that github actions hang?](https://discourse.julialang.org/t/is-it-normal-that-github-actions-hang/73653)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [December 28, 2021, 1:48pm UTC](https://discourse.julialang.org/t/is-it-normal-that-github-actions-hang/73653 "2021-12-28T13:48:57Z")

</div>

I started my first github package that uses github actions, it hangs often. Six of seven tasks are completed fast (within a few minutes), and the last task runs for more than 30 min and does not finish. Is that normal? …

---

## [Can I use a function variable name to generate a string to set it equal to?](https://discourse.julialang.org/t/can-i-use-a-function-variable-name-to-generate-a-string-to-set-it-equal-to/73659)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 13\
**Last updated:** [December 28, 2021, 11:20am UTC](https://discourse.julialang.org/t/can-i-use-a-function-variable-name-to-generate-a-string-to-set-it-equal-to/73659 "2021-12-28T11:20:47Z")

</div>

Pre-face: I know that this is properly not the smartest thing to do, if it is even possible. I want to learn and test something out. I was thinking if I could do something like this, imagine by using a macro: @var2str…

---

## [How to pass compile-time user settings to macro?](https://discourse.julialang.org/t/how-to-pass-compile-time-user-settings-to-macro/73607)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 8\
**Last updated:** [December 27, 2021, 7:36pm UTC](https://discourse.julialang.org/t/how-to-pass-compile-time-user-settings-to-macro/73607 "2021-12-27T19:36:45Z")

</div>

I have a module that develops a kernel using a macro based on settings that a user provides. I need those settings to be compile time available, otherwise the macro won’t work. In this current example, I do this with con…

---

## [Random julia v 1.7](https://discourse.julialang.org/t/random-julia-v-1-7/73444)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 10\
**Last updated:** [December 27, 2021, 5:25pm UTC](https://discourse.julialang.org/t/random-julia-v-1-7/73444 "2021-12-27T17:25:02Z")

</div>

How to change the default random generator? this works: rng=Random.MersenneTwister(1); rand(rng) however, i prefer to use rand() instead of rand(rng). is it possible? this does not work Random.seed!(Random.MersenneT…

---

## [Spot the error.. need help converting a c libturbojpeg example](https://discourse.julialang.org/t/spot-the-error-need-help-converting-a-c-libturbojpeg-example/32827)

<div class="topic-metadata">

**Author:** [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Replies:** 7\
**Last updated:** [December 27, 2021, 12:37pm UTC](https://discourse.julialang.org/t/spot-the-error-need-help-converting-a-c-libturbojpeg-example/32827 "2021-12-27T12:37:17Z")

</div>

I’m trying to wrap this c example of libturbojpeg compression, but while tjCompress2() doesn’t error, its supposed to write into jpegBuf and set jpegSize to the length of jpegBuf but currently both are unchanged. It seem…

---

## [Why I am getting TaskFailedException for package ParallelUtilities?](https://discourse.julialang.org/t/why-i-am-getting-taskfailedexception-for-package-parallelutilities/73556)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 4\
**Last updated:** [December 27, 2021, 5:11am UTC](https://discourse.julialang.org/t/why-i-am-getting-taskfailedexception-for-package-parallelutilities/73556 "2021-12-27T05:11:27Z")

</div>

I did not have much success using Threads.@threads to accelerate code execution. The code would sometimes run marginally faster and sometimes even slower. So now I am trying packages like ParallelUtilities that use the D…

---

## [Generator questions](https://discourse.julialang.org/t/generator-questions/73665)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 1\
**Last updated:** [December 27, 2021, 2:15am UTC](https://discourse.julialang.org/t/generator-questions/73665 "2021-12-27T02:15:38Z")

</div>

While poking around with the generator example below to try understanding the concept, some questions popped up: Why is the last equality false given that the generator was regenerated? With the command g.f(g.iter\[n\]),…

---

## [Block number conversion during bit operations](https://discourse.julialang.org/t/block-number-conversion-during-bit-operations/73640)

<div class="topic-metadata">

**Author:** [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Replies:** 1\
**Last updated:** [December 27, 2021, 2:15am UTC](https://discourse.julialang.org/t/block-number-conversion-during-bit-operations/73640 "2021-12-27T02:15:02Z")

</div>

Hello I am working on problem when I use UInt32 as a bitAttay of 32 entries - (I can not use Bitarray for some reasons) problem is that sometimes (once every couple hundred iterations) when I modify the first bit it lead…

---

## [Filtering keys out of named tuples](https://discourse.julialang.org/t/filtering-keys-out-of-named-tuples/73564)

<div class="topic-metadata">

**Author:** [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Replies:** 9\
**Last updated:** [December 26, 2021, 7:29pm UTC](https://discourse.julialang.org/t/filtering-keys-out-of-named-tuples/73564 "2021-12-26T19:29:05Z")

</div>

What’s the right way to filter a key out of a named tuple? Example: nt = (;a = 1, b = 2) filter(x-\>x\[1\] == :a,nt) # Errors filter(x-\>x\[1\] == :a,Base.Pairs(nt,keys(nt))) # Allocates an entire dictionary What’s the right…

---

## [A weird issue with Julia-1.7.1. on Ubuntu (GibbsSeaWater.jl package)](https://discourse.julialang.org/t/a-weird-issue-with-julia-1-7-1-on-ubuntu-gibbsseawater-jl-package/73632)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 6\
**Last updated:** [December 26, 2021, 5:33pm UTC](https://discourse.julialang.org/t/a-weird-issue-with-julia-1-7-1-on-ubuntu-gibbsseawater-jl-package/73632 "2021-12-26T17:33:21Z")

</div>

The bleow script runs perfectly fine on my Macbook Pro with Julia-1.7.1, but the same program does not run at all on Ubuntu (20.04) (Julia-1.7.1) and gives me the below error message. Not sure if it is due to Julia itsel…

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

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