# General Usage

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

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

**Page:** 512

---

## [How to define a Python class in a module with PyCall?](https://discourse.julialang.org/t/how-to-define-a-python-class-in-a-module-with-pycall/72634)

<div class="topic-metadata">

**Author:** [@nxtruong](https://discourse.julialang.org/u/nxtruong)\
**Replies:** 1\
**Last updated:** [December 6, 2021, 7:22am UTC](https://discourse.julialang.org/t/how-to-define-a-python-class-in-a-module-with-pycall/72634 "2021-12-06T07:22:50Z")

</div>

I want to write a Julia module in which I define a Python class using PyCall. Using an example in the README of PyCall, a MWE: module parent using PyCall const pypoly = PyNULL() function \_\_init\_\_() copy!(pypoly, py…

---

## [Massive crash](https://discourse.julialang.org/t/massive-crash/72552)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 6\
**Last updated:** [December 5, 2021, 9:23pm UTC](https://discourse.julialang.org/t/massive-crash/72552 "2021-12-05T21:23:29Z")

</div>

This is very hard to figure out. I’ll try the debugger to find the exact line that crashes. Most of the code works, but there is new code that is run based on one input parameter, so I at least know what code file causes…

---

## [Cannot import function in Pluto](https://discourse.julialang.org/t/cannot-import-function-in-pluto/72608)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 3\
**Last updated:** [December 5, 2021, 8:17pm UTC](https://discourse.julialang.org/t/cannot-import-function-in-pluto/72608 "2021-12-05T20:17:23Z")

</div>

Hi all, I recieve an error indicating multiple function definitions when I import a function and define a method. The attached image shows a simple example. Am I doing something incorrectly? Version Julia 1.7 Plut…

---

## [Save figure with transparent background color in Plots.jl](https://discourse.julialang.org/t/save-figure-with-transparent-background-color-in-plots-jl/18808)

<div class="topic-metadata">

**Author:** [@Shunsuke-Hori](https://discourse.julialang.org/u/Shunsuke-Hori)\
**Replies:** 19\
**Last updated:** [December 5, 2021, 4:40pm UTC](https://discourse.julialang.org/t/save-figure-with-transparent-background-color-in-plots-jl/18808 "2021-12-05T16:40:24Z")

</div>

Is there a way to save a figure with transparent background color in Plots.jl? pyplot can do that by transparent=True.

---

## [JuMP.jl and DifferentialEquation.jl benchmarks on M1 Max Julia 1.7.0 x89 vs ARM. (spoiler: ARM is 1.5-2x faster)](https://discourse.julialang.org/t/jump-jl-and-differentialequation-jl-benchmarks-on-m1-max-julia-1-7-0-x89-vs-arm-spoiler-arm-is-1-5-2x-faster/72496)

<div class="topic-metadata">

**Author:** [@DenisTitov](https://discourse.julialang.org/u/DenisTitov)\
**Replies:** 12\
**Last updated:** [December 5, 2021, 4:11pm UTC](https://discourse.julialang.org/t/jump-jl-and-differentialequation-jl-benchmarks-on-m1-max-julia-1-7-0-x89-vs-arm-spoiler-arm-is-1-5-2x-faster/72496 "2021-12-05T16:11:19Z")

</div>

This is just FYI for fun in case people are interested. I compared JuMP, DiffEq and simple sort() on M1 Max MacBook using official binaries of Julia 1.7.0 with either Native ARM or x86 with Rosetta2. Native ARM version…

---

## [Question on the behavior of dot notation](https://discourse.julialang.org/t/question-on-the-behavior-of-dot-notation/72603)

<div class="topic-metadata">

**Author:** [@yucho147](https://discourse.julialang.org/u/yucho147)\
**Replies:** 2\
**Last updated:** [December 5, 2021, 10:33am UTC](https://discourse.julialang.org/t/question-on-the-behavior-of-dot-notation/72603 "2021-12-05T10:33:23Z")

</div>

As the title suggests, I have a question about the behavior of dot notation. Background I am implementing the conjugate gradient method. I am trying to speed up the vector processing by using dot notation. The problem …

---

## [Laplacian of shallow Flux neural network with complex weights](https://discourse.julialang.org/t/laplacian-of-shallow-flux-neural-network-with-complex-weights/72600)

<div class="topic-metadata">

**Author:** [@Matematija](https://discourse.julialang.org/u/Matematija)\
**Replies:** 0\
**Last updated:** [December 5, 2021, 4:14am UTC](https://discourse.julialang.org/t/laplacian-of-shallow-flux-neural-network-with-complex-weights/72600 "2021-12-05T04:14:06Z")

</div>

Hi all, I am trying to use Julia’s AD ecosystem to calculate what the title says - a Laplacian (trace of Hessian matrix) of a shallow (1 layer) Flux neural net. There are two twists to the story: I need all of the we…

---

## [Removed dev Pkg before free (1.6 and 1.7)](https://discourse.julialang.org/t/removed-dev-pkg-before-free-1-6-and-1-7/72428)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 5\
**Last updated:** [December 4, 2021, 7:32pm UTC](https://discourse.julialang.org/t/removed-dev-pkg-before-free-1-6-and-1-7/72428 "2021-12-04T19:32:13Z")

</div>

I added a package and then dev’ed it and then removed it before freeing it. Now I am getting an error that I can’t fix. I removed the registries directory and also downloaded julia 1.7 and started fresh, but I get the fo…

---

## [Github-action-benchmark with Julia support](https://discourse.julialang.org/t/github-action-benchmark-with-julia-support/72589)

<div class="topic-metadata">

**Author:** [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Replies:** 0\
**Last updated:** [December 4, 2021, 7:52pm UTC](https://discourse.julialang.org/t/github-action-benchmark-with-julia-support/72589 "2021-12-04T19:52:31Z")

</div>

Recently I added the Julia support to an interesting github action: https://github.com/benchmark-action/github-action-benchmark Hope it might be useful to some other package developers. You can find how to enable the wo…

---

## [IJulia notebook, local Pkg activate, julia-1.7.0 FAILures](https://discourse.julialang.org/t/ijulia-notebook-local-pkg-activate-julia-1-7-0-failures/72588)

<div class="topic-metadata">

**Author:** [@proudindiv](https://discourse.julialang.org/u/proudindiv)\
**Replies:** 3\
**Last updated:** [December 4, 2021, 7:40pm UTC](https://discourse.julialang.org/t/ijulia-notebook-local-pkg-activate-julia-1-7-0-failures/72588 "2021-12-04T19:40:21Z")

</div>

Julia-1.7.0 works fine in command-line REPL after getting Pkgs installed and recompiled, but has lots of various failures when precompiling some packages with the exact same code in IJulia notebooks: (I’ve deleted and r…

---

## [Why is the intersection of a polyhedra with itself not equal to itself?](https://discourse.julialang.org/t/why-is-the-intersection-of-a-polyhedra-with-itself-not-equal-to-itself/72585)

<div class="topic-metadata">

**Author:** [@XLVII](https://discourse.julialang.org/u/XLVII)\
**Replies:** 7\
**Last updated:** [December 4, 2021, 7:38pm UTC](https://discourse.julialang.org/t/why-is-the-intersection-of-a-polyhedra-with-itself-not-equal-to-itself/72585 "2021-12-04T19:38:42Z")

</div>

using Polyhedra import CDDLib lib = CDDLib.Library() P = polyhedron(vrep(Acolums,Is),lib) #(lines=Acolums , rays = Is) println(intersect(P,P) == P ) # it should be true but it gives false How can it be made to ret…

---

## [Embedding Julia in Julia](https://discourse.julialang.org/t/embedding-julia-in-julia/72586)

<div class="topic-metadata">

**Author:** [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)\
**Replies:** 4\
**Last updated:** [December 4, 2021, 6:07pm UTC](https://discourse.julialang.org/t/embedding-julia-in-julia/72586 "2021-12-04T18:07:09Z")

</div>

Suppose you were writing a GUI tool for Julia, in Julia. For instance if you were making an IDE or notebook-type interface with a Qt or Vulkan-based GUI. In order to execute Julia code that the user wants you to run with…

---

## [Sparse matrix assembly with bad timings](https://discourse.julialang.org/t/sparse-matrix-assembly-with-bad-timings/72584)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 2\
**Last updated:** [December 4, 2021, 5:52pm UTC](https://discourse.julialang.org/t/sparse-matrix-assembly-with-bad-timings/72584 "2021-12-04T17:52:43Z")

</div>

Hi, I took the 2016 codes from Julia iFEM 2: Optimizing Stiffness Matrix Assembly and made some cosmetic changes to run them with Julia 1.7. Chris’ old timings were: tic; assemblingstandard(node,elem); toc; tic; assem…

---

## [Derivative in Symbolics.jl becomes zero?](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 2\
**Last updated:** [December 4, 2021, 2:47pm UTC](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491 "2021-12-04T14:47:28Z")

</div>

Hi! I am playing around with Julia 1.7.0. I am using this piece of code: using Symbolics @variables x z1(x) = x z2 = x Dx = Differential(x) expand\_derivatives(Dx(z1)) #Gives 0 expand\_derivatives(Dx(z2)) #Gi…

---

## [Force keyword argument input with keyword name for a function](https://discourse.julialang.org/t/force-keyword-argument-input-with-keyword-name-for-a-function/72575)

<div class="topic-metadata">

**Author:** [@AtsushiSakai](https://discourse.julialang.org/u/AtsushiSakai)\
**Replies:** 1\
**Last updated:** [December 4, 2021, 1:26pm UTC](https://discourse.julialang.org/t/force-keyword-argument-input-with-keyword-name-for-a-function/72575 "2021-12-04T13:26:01Z")

</div>

In python, we can force keyword argument input with keyword name for a function using “\*” like: In \[3\]: def f(a, b, c=0, d=1): ...: pass ...: In \[4\]: f(1, 2, 3, 4) In \[5\]: f(1, 2, c=3, d=4) In \[6\]: def f(a,…

---

## [Plot @layout adjust width of grid](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527)

<div class="topic-metadata">

**Author:** [@evolbio](https://discourse.julialang.org/u/evolbio)\
**Replies:** 5\
**Last updated:** [December 4, 2021, 11:33am UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527 "2021-12-04T11:33:27Z")

</div>

My goal is a layout like: @layout \[grid(4,2) \[b; c{0.166h}; d{0.166h}; e{0.166h}\]\] which is a 4 x 2 grid on the left and a stack of 4 plots on the right. However, I want the left 4 x 2 grid to be 1/3 of the total width…

---

## [Forward- and reverse-mode AD comparisons with JAX](https://discourse.julialang.org/t/forward-and-reverse-mode-ad-comparisons-with-jax/72379)

<div class="topic-metadata">

**Author:** [@wil-j-wil](https://discourse.julialang.org/u/wil-j-wil)\
**Replies:** 7\
**Last updated:** [December 4, 2021, 11:16am UTC](https://discourse.julialang.org/t/forward-and-reverse-mode-ad-comparisons-with-jax/72379 "2021-12-04T11:16:53Z")

</div>

I have been attempting to compute the gradients of a covariance function (kernel) in Julia. I was initially using Zygote, incorrectly since forward-mode is much better suited to my task. However this resulted in some int…

---

## [Segfaults on Julia 1.7 Apple M1](https://discourse.julialang.org/t/segfaults-on-julia-1-7-apple-m1/72566)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 2\
**Last updated:** [December 4, 2021, 10:43am UTC](https://discourse.julialang.org/t/segfaults-on-julia-1-7-apple-m1/72566 "2021-12-04T10:43:22Z")

</div>

Julia 1.7 is extremely unstable for me, to the point of being unusable. Getting segfaults in some apps about 50% of the times. It’s been like that since pre-release days but I hoped the issue would go away in the final r…

---

## [GPU Compilation Error: KernelError: kernel returns a value of type \`Union{}\`](https://discourse.julialang.org/t/gpu-compilation-error-kernelerror-kernel-returns-a-value-of-type-union/72539)

<div class="topic-metadata">

**Author:** [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Replies:** 3\
**Last updated:** [December 4, 2021, 8:33am UTC](https://discourse.julialang.org/t/gpu-compilation-error-kernelerror-kernel-returns-a-value-of-type-union/72539 "2021-12-04T08:33:50Z")

</div>

Hi, To familiarize myself with the syntax of CUDA.jl, I’m implement basic programs from scratch. I wrote a version of Matrix Multiplication that uses shared memory but it’s not compiling. function MatMulGPU!(A\_d::Abstr…

---

## [Count occurrences of columns in a 2d array (using countmap)](https://discourse.julialang.org/t/count-occurrences-of-columns-in-a-2d-array-using-countmap/44023)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 13\
**Last updated:** [December 3, 2021, 11:37pm UTC](https://discourse.julialang.org/t/count-occurrences-of-columns-in-a-2d-array-using-countmap/44023 "2021-12-03T23:37:29Z")

</div>

I have a 2d BitArray and I want to count the number of distinct columns in that array. And I want to do it fast. I guess that countmap (of StatsBase) is the most efficient way for such operations. However it only works…

---

## [I need help with my Macros (newbie question)](https://discourse.julialang.org/t/i-need-help-with-my-macros-newbie-question/72549)

<div class="topic-metadata">

**Author:** [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Replies:** 2\
**Last updated:** [December 3, 2021, 10:40pm UTC](https://discourse.julialang.org/t/i-need-help-with-my-macros-newbie-question/72549 "2021-12-03T22:40:52Z")

</div>

I’m trying to enter the Metaprogramming world, and I decided to convert some functions into a macro. I have one function get\_return, that depending on one parameter , call two other functions. One that returns a sum, an…

---

## [Juliaup and 1.7](https://discourse.julialang.org/t/juliaup-and-1-7/72374)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 13\
**Last updated:** [December 3, 2021, 8:13pm UTC](https://discourse.julialang.org/t/juliaup-and-1-7/72374 "2021-12-03T20:13:52Z")

</div>

So 1.7 is released, yay! I went to update my Julia version, only to find: C:\\Users\\densb\>juliaup update release C:\\Users\\densb\>juliaup st Installed Julia channels (default marked with \*): lts \* release C:\\User…

---

## [Stop the running code in vscode](https://discourse.julialang.org/t/stop-the-running-code-in-vscode/72458)

<div class="topic-metadata">

**Author:** [@FH96](https://discourse.julialang.org/u/FH96)\
**Replies:** 0\
**Last updated:** [December 2, 2021, 3:11pm UTC](https://discourse.julialang.org/t/stop-the-running-code-in-vscode/72458 "2021-12-02T15:11:30Z")

</div>

How can I stop a running code in vscode? Alt+K didn’t work

---

## [How could communication with the PortAudio callback work? Maybe 1.7's atomics?](https://discourse.julialang.org/t/how-could-communication-with-the-portaudio-callback-work-maybe-1-7s-atomics/72537)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 0\
**Last updated:** [December 3, 2021, 6:58pm UTC](https://discourse.julialang.org/t/how-could-communication-with-the-portaudio-callback-work-maybe-1-7s-atomics/72537 "2021-12-03T18:58:59Z")

</div>

I would like to play around with PortAudio.jl. My goal is to create some simple functions like sine, saw, or triangle wave generators, maybe some basic filters or delays, and then adjust parameters using a simple GUI or …

---

## [Read+write on serial port mixes input and output](https://discourse.julialang.org/t/read-write-on-serial-port-mixes-input-and-output/55486)

<div class="topic-metadata">

**Author:** [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Replies:** 7\
**Last updated:** [December 3, 2021, 6:35pm UTC](https://discourse.julialang.org/t/read-write-on-serial-port-mixes-input-and-output/55486 "2021-12-03T18:35:46Z")

</div>

Hi, I apologize for not posting a working example, but I haven’t figured out how to make it. The problem is, I have an fpga hooked up to the usb on my Ubuntu-box. The ftdi-driver makes it look like an uart, a serial po…

---

## [Juliacall cant use a package that builds fine outside juliacall \<random file path ending in "artifacts"\>/libgobject-2.0.so: undefined symbol: g\_uri\_ref](https://discourse.julialang.org/t/juliacall-cant-use-a-package-that-builds-fine-outside-juliacall-random-file-path-ending-in-artifacts-libgobject-2-0-so-undefined-symbol-g-uri-ref/68289)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 10\
**Last updated:** [December 3, 2021, 6:09pm UTC](https://discourse.julialang.org/t/juliacall-cant-use-a-package-that-builds-fine-outside-juliacall-random-file-path-ending-in-artifacts-libgobject-2-0-so-undefined-symbol-g-uri-ref/68289 "2021-12-03T18:09:22Z")

</div>

This code has been working without issue on hpc (also using JuliaCall) but when I tried to call it locally I get this error (also julia 1.6.0 to match the cluster environment, even though I have 1.6.1) this : Note that …

---

## [Developed Package Dependencies](https://discourse.julialang.org/t/developed-package-dependencies/72528)

<div class="topic-metadata">

**Author:** [@dkzwart](https://discourse.julialang.org/u/dkzwart)\
**Replies:** 1\
**Last updated:** [December 3, 2021, 4:21pm UTC](https://discourse.julialang.org/t/developed-package-dependencies/72528 "2021-12-03T16:21:10Z")

</div>

I have a warning that a dev package is not in the dependencies of another dev package that I am using. In order to use this dev package, it loads it from the dependencies of another package. Any idea how to get rid of th…

---

## [Draw two distinct random integers from \`1:n\`](https://discourse.julialang.org/t/draw-two-distinct-random-integers-from-1-n/72289)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 24\
**Last updated:** [December 3, 2021, 2:09pm UTC](https://discourse.julialang.org/t/draw-two-distinct-random-integers-from-1-n/72289 "2021-12-03T14:09:47Z")

</div>

I’m looking for a fast and elegant way to repeatedly draw two distinct random integers from the range 1:n. A naive baseline: julia\> function draw(n, iter) …

---

## [Documentation of internals](https://discourse.julialang.org/t/documentation-of-internals/72523)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 0\
**Last updated:** [December 3, 2021, 1:37pm UTC](https://discourse.julialang.org/t/documentation-of-internals/72523 "2021-12-03T13:37:47Z")

</div>

Having the ? keyword to access documentation is very practical, but that exposes the documentation to the user, thus it may be risky for internal functions not having a stable interface. Because of that, I was modifying …

---

## [Assign name to operator with ternary operator](https://discourse.julialang.org/t/assign-name-to-operator-with-ternary-operator/72518)

<div class="topic-metadata">

**Author:** [@cbrnr](https://discourse.julialang.org/u/cbrnr)\
**Replies:** 3\
**Last updated:** [December 3, 2021, 12:45pm UTC](https://discourse.julialang.org/t/assign-name-to-operator-with-ternary-operator/72518 "2021-12-03T12:45:44Z")

</div>

I want to use different comparisons (either \>= or \<) based on some condition. I thought I’d just define a name f pointing to the corresponding operation, which works with the following code: if true f = \>= else …

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

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