# General Usage

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

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

**Page:** 686

---

## [Display of rational numbers in Jupyter notebook](https://discourse.julialang.org/t/display-of-rational-numbers-in-jupyter-notebook/49077)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 0\
**Last updated:** [October 26, 2020, 9:49pm UTC](https://discourse.julialang.org/t/display-of-rational-numbers-in-jupyter-notebook/49077 "2020-10-26T21:49:31Z")

</div>

When I run 1//2 in Jupyter notebook, the output is the raw LaTeX expression \\frac 1 2 which has not been rendered as a formula. Does anyone know how to force Jupyter to render the formula with MathJax or LaTeX? Other…

---

## [Very slow Plots performance and... no plot](https://discourse.julialang.org/t/very-slow-plots-performance-and-no-plot/49064)

<div class="topic-metadata">

**Author:** [@rnturn](https://discourse.julialang.org/u/rnturn)\
**Replies:** 8\
**Last updated:** [October 26, 2020, 9:44pm UTC](https://discourse.julialang.org/t/very-slow-plots-performance-and-no-plot/49064 "2020-10-26T21:44:53Z")

</div>

Environment: openSUSE 15.1, downloaded Julia 1.5.2 (tar.gz). I’m finding that using Plots (pun sort of intended) is really slow and when I use plot() in a script I get no output: #plottest using Dates t0 = now() using …

---

## [Global variables and threads](https://discourse.julialang.org/t/global-variables-and-threads/49068)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 8:12pm UTC](https://discourse.julialang.org/t/global-variables-and-threads/49068 "2020-10-26T20:12:40Z")

</div>

I have a function inside a module that I need to be thread-safe. The function looks like: function foo() for i=1:n sigma = (calculate stuff) end return sigma end Of course, the above code doesn’t wo…

---

## [Is this type piracy?](https://discourse.julialang.org/t/is-this-type-piracy/48894)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 3\
**Last updated:** [October 26, 2020, 7:09pm UTC](https://discourse.julialang.org/t/is-this-type-piracy/48894 "2020-10-26T19:09:26Z")

</div>

(::Type{T})(x::MyType) where T = dosomething(x) |\> T or perhaps just bad practice for some other reason? This is basically hijacking all single argument constructors to first dosomething with MyType. This seemed like a…

---

## [Large sum returns negative numbers in julia](https://discourse.julialang.org/t/large-sum-returns-negative-numbers-in-julia/49032)

<div class="topic-metadata">

**Author:** [@dashanan](https://discourse.julialang.org/u/dashanan)\
**Replies:** 5\
**Last updated:** [October 26, 2020, 6:55pm UTC](https://discourse.julialang.org/t/large-sum-returns-negative-numbers-in-julia/49032 "2020-10-26T18:55:22Z")

</div>

hello , i am trying to do a counter for some problem I am having, but while I was testing I see that Julia was returning negative numbers after some time, I have no idea why this is happening, now to check that, i ha…

---

## [Set Id of struct on construction](https://discourse.julialang.org/t/set-id-of-struct-on-construction/48977)

<div class="topic-metadata">

**Author:** [@cojua8](https://discourse.julialang.org/u/cojua8)\
**Replies:** 9\
**Last updated:** [October 26, 2020, 3:44pm UTC](https://discourse.julialang.org/t/set-id-of-struct-on-construction/48977 "2020-10-26T15:44:19Z")

</div>

Hi, I’m trying to implement a struct that must have an Id, which is set on construction, similar to C# static member So far, I have been able to do it like this: x = 0 struct A prop1 id A(prop1) = begin …

---

## [Base.precompile appears not to work](https://discourse.julialang.org/t/base-precompile-appears-not-to-work/49027)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 2:33pm UTC](https://discourse.julialang.org/t/base-precompile-appears-not-to-work/49027 "2020-10-26T14:33:01Z")

</div>

I found out about Base.precompile for compiling functions without running, so I tried it out. It doesn’t seem to work though when I put this in the REPL: \> using Plots \> precompile(plot, (typeof(rand(10)),) ) # returns…

---

## [Improving performance of network sampling/inference algorithm](https://discourse.julialang.org/t/improving-performance-of-network-sampling-inference-algorithm/45536)

<div class="topic-metadata">

**Author:** [@Adam\_Haber](https://discourse.julialang.org/u/Adam_Haber)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 12:12pm UTC](https://discourse.julialang.org/t/improving-performance-of-network-sampling-inference-algorithm/45536 "2020-10-26T12:12:25Z")

</div>

Hi, I’m trying to write a Julia package that does roughly what R’s ergm package does: fit, simulate and diagnose exponential-family models of networks. R’s ergm is an excellent and a very mature package, and I’m definit…

---

## [Timed loop](https://discourse.julialang.org/t/timed-loop/48802)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 9\
**Last updated:** [October 26, 2020, 11:46am UTC](https://discourse.julialang.org/t/timed-loop/48802 "2020-10-26T11:46:09Z")

</div>

I’m running a loop asynchronously. I’d like to have each iteration take at most max\_ns nanoseconds. Here’s what i have so far: function wait4it(t₀, max\_ns) t₁ = time\_ns() t = t₁ - t₀ if t \< max\_ns s …

---

## [Julia 1.5 + vscode runs very slow](https://discourse.julialang.org/t/julia-1-5-vscode-runs-very-slow/45483)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 3\
**Last updated:** [October 26, 2020, 10:21am UTC](https://discourse.julialang.org/t/julia-1-5-vscode-runs-very-slow/45483 "2020-10-26T10:21:32Z")

</div>

Running code in vscode using Julia 1.5 is very slow. Even when using Ctrl+F5 it seems that it is running as if it were debugging since at the end it prints in the terminal: Julia debuggee finished. Press ENTER to close …

---

## [Add row to 2D array in a loop](https://discourse.julialang.org/t/add-row-to-2d-array-in-a-loop/48993)

<div class="topic-metadata">

**Author:** [@mhex](https://discourse.julialang.org/u/mhex)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 9:50am UTC](https://discourse.julialang.org/t/add-row-to-2d-array-in-a-loop/48993 "2020-10-26T09:50:32Z")

</div>

Hi, my aim is to add a new row to a 2D array in a for-loop. If I execute A = Array{Int64}(undef, 0, 2) A = \[A; \[1 2\]\] A = \[A; \[2 3\]\] println(A) I receive \[1 2; 2 3\] that is correct. But if I run it in a for loop: …

---

## [Dropping missing values in dataframes](https://discourse.julialang.org/t/dropping-missing-values-in-dataframes/48967)

<div class="topic-metadata">

**Author:** [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Replies:** 14\
**Last updated:** [October 26, 2020, 9:13am UTC](https://discourse.julialang.org/t/dropping-missing-values-in-dataframes/48967 "2020-10-26T09:13:39Z")

</div>

The dataframe column’s describe shows: 5 age 29.6991 0.42 28.0 80.0 177 Union{Missing, Float64} I can get rid of the missing values with this: replace!(train\_df.age, missing =\> median(skipmissing(train\_df\[:age\]))); H…

---

## [Can unicode fraction symbols be used in equations](https://discourse.julialang.org/t/can-unicode-fraction-symbols-be-used-in-equations/49023)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 2\
**Last updated:** [October 26, 2020, 5:13am UTC](https://discourse.julialang.org/t/can-unicode-fraction-symbols-be-used-in-equations/49023 "2020-10-26T05:13:29Z")

</div>

I’d like to use ½ in equations e.g. X = 2 Y = ½X Is this possible? I just get error invalid character “½”

---

## [Only one legend for scenarios](https://discourse.julialang.org/t/only-one-legend-for-scenarios/48991)

<div class="topic-metadata">

**Author:** [@Arega\_Getaneh](https://discourse.julialang.org/u/Arega_Getaneh)\
**Replies:** 4\
**Last updated:** [October 25, 2020, 9:45pm UTC](https://discourse.julialang.org/t/only-one-legend-for-scenarios/48991 "2020-10-25T21:45:23Z")

</div>

I wanted to have only one legened for this scenario generated plot instead of 11 similar names over my plot. How can I do that? t= \[1; 2; 3; 4; 5; 6; 7;8; 9; 10; 11; 12\] y= rand(12,24) plot(t,y, color="blue", linewidth…

---

## [Legacy code on MacOS](https://discourse.julialang.org/t/legacy-code-on-macos/36580)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 3\
**Last updated:** [October 25, 2020, 8:21pm UTC](https://discourse.julialang.org/t/legacy-code-on-macos/36580 "2020-10-25T20:21:34Z")

</div>

Hi all, I need to run an old code written for Julia 0.6.\*. I have installed Julia 0.6.4 on my macbook, but it does not work properly. As soon as I try to install common packages I get the following error message: ERROR…

---

## [Zygote: CuArray only supports bits types](https://discourse.julialang.org/t/zygote-cuarray-only-supports-bits-types/48910)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.julialang.org/u/Jack)\
**Replies:** 6\
**Last updated:** [October 25, 2020, 6:35pm UTC](https://discourse.julialang.org/t/zygote-cuarray-only-supports-bits-types/48910 "2020-10-25T18:35:48Z")

</div>

Hi all, I encountered the ERROR: CuArray only supports bits types while doing gradient calculation. The calculation is a simple RNN that would pick the output sequence element based on sequence length in a batched tra…

---

## [Https://www.anaconda.com blocked](https://discourse.julialang.org/t/https-www-anaconda-com-blocked/48969)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 1\
**Last updated:** [October 25, 2020, 2:22pm UTC](https://discourse.julialang.org/t/https-www-anaconda-com-blocked/48969 "2020-10-25T14:22:48Z")

</div>

My current network has https://www.anaconda.com blocked. But I have managed to download, from main/win-64, the file matplotlib-base-3.3.2-py38hba9282a\_0.tar.bz2 Is there any way to activate it, from Julia, using the C…

---

## [Can structs have static fields?](https://discourse.julialang.org/t/can-structs-have-static-fields/48970)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 1\
**Last updated:** [October 25, 2020, 9:40am UTC](https://discourse.julialang.org/t/can-structs-have-static-fields/48970 "2020-10-25T09:40:46Z")

</div>

Does Julia have something similar to static class members in C++, whose values are shared across all objects of the class? If not, is there a good way to emulate it? I don’t want it to be a constant global variable, sinc…

---

## [Update Conda vs update Julia 1.5.2](https://discourse.julialang.org/t/update-conda-vs-update-julia-1-5-2/48926)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 2\
**Last updated:** [October 25, 2020, 6:38am UTC](https://discourse.julialang.org/t/update-conda-vs-update-julia-1-5-2/48926 "2020-10-25T06:38:47Z")

</div>

After successfully performing the Coda update: using Conda \[ Info: Precompiling Conda \[8f4d0f93-b110-5947-807f-2305c1781a2d\] julia\> Conda.ROOTENV "C:\\\\Users\\\\user\\\\.julia\\\\conda\\\\3" julia\> Conda.update() \[ Info: Runni…

---

## [Improving perfomance on nested loops](https://discourse.julialang.org/t/improving-perfomance-on-nested-loops/48864)

<div class="topic-metadata">

**Author:** [@k945](https://discourse.julialang.org/u/k945)\
**Replies:** 5\
**Last updated:** [October 25, 2020, 5:29am UTC](https://discourse.julialang.org/t/improving-perfomance-on-nested-loops/48864 "2020-10-25T05:29:00Z")

</div>

I am trying to improve the performance of script that I am converting from python. To my knowledge, I have: written a kernel function, preallocated my output and accessed memory in order. While I have improved the scrip…

---

## [Stuck on a NamedTuple problem](https://discourse.julialang.org/t/stuck-on-a-namedtuple-problem/48835)

<div class="topic-metadata">

**Author:** [@a5vzener](https://discourse.julialang.org/u/a5vzener)\
**Replies:** 9\
**Last updated:** [October 24, 2020, 11:34pm UTC](https://discourse.julialang.org/t/stuck-on-a-namedtuple-problem/48835 "2020-10-24T23:34:27Z")

</div>

I think a NamedTuple can do what I want but I can’t quite figure out the syntax. Can someone help me with this bit of runnable code? function nameparts(v) t = split(v,':') length(t) \< 2 ? (nothing,t\[1\]) : (t\[1\],…

---

## ["Traits" which may be defined on types or values?](https://discourse.julialang.org/t/traits-which-may-be-defined-on-types-or-values/48919)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 10\
**Last updated:** [October 24, 2020, 6:08pm UTC](https://discourse.julialang.org/t/traits-which-may-be-defined-on-types-or-values/48919 "2020-10-24T18:08:22Z")

</div>

I’m trying to learn about \[Holy\] traits for the first time. It seems that in the classic implementation, an object’s traitfulness depends only on that object’s type, not value. For example, maybe I want to classify certa…

---

## [Slow Deployment of Flux Mode](https://discourse.julialang.org/t/slow-deployment-of-flux-mode/48945)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 5\
**Last updated:** [October 24, 2020, 5:29pm UTC](https://discourse.julialang.org/t/slow-deployment-of-flux-mode/48945 "2020-10-24T17:29:10Z")

</div>

Hi. I have a trained Flux model which I wish to apply repeatedly using separate calls from an external program. Since Julia1.5 (and corresponding Flux version) every time the function is called, the line using Flux r…

---

## [Bug with \`@.\`](https://discourse.julialang.org/t/bug-with/48940)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 3\
**Last updated:** [October 24, 2020, 4:39pm UTC](https://discourse.julialang.org/t/bug-with/48940 "2020-10-24T16:39:10Z")

</div>

I think I’ve found a bug with the @. macro julia\> function foo(;x = 0, y = 8) return x end foo (generic function with 1 method) julia\> a = \[1, 2, 3\]; b = \[4, 5, 6\]; julia\> foo(; x = @. a \* b, y = b) ERRO…

---

## [Read numbers from stdin and display a realtime plot](https://discourse.julialang.org/t/read-numbers-from-stdin-and-display-a-realtime-plot/48943)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 0\
**Last updated:** [October 24, 2020, 4:05pm UTC](https://discourse.julialang.org/t/read-numbers-from-stdin-and-display-a-realtime-plot/48943 "2020-10-24T16:05:27Z")

</div>

I want to read streaming numbers from stdin, and create a plot from them (x being the line number and y the number itself) which updates itself as new data is available. What’s the best approach here? (I also don’t want…

---

## [Control flow of shell command Pipe()](https://discourse.julialang.org/t/control-flow-of-shell-command-pipe/48915)

<div class="topic-metadata">

**Author:** [@Donut\_Meepo](https://discourse.julialang.org/u/Donut_Meepo)\
**Replies:** 5\
**Last updated:** [October 24, 2020, 3:04pm UTC](https://discourse.julialang.org/t/control-flow-of-shell-command-pipe/48915 "2020-10-24T15:04:39Z")

</div>

Hi, I am trying to process a large amount of shell command output that I want to do it line by line. The following code is what I have right now. The while loop will not terminate. I could do that by checking process\_run…

---

## [Ccall performance](https://discourse.julialang.org/t/ccall-performance/48872)

<div class="topic-metadata">

**Author:** [@j\_tanu](https://discourse.julialang.org/u/j_tanu)\
**Replies:** 16\
**Last updated:** [October 24, 2020, 2:37pm UTC](https://discourse.julialang.org/t/ccall-performance/48872 "2020-10-24T14:37:25Z")

</div>

Hi, I am doing a matrix-matrix multiplication A(12870\*11440)\*B(11440\*11440) using mkl\_dgemm library. In c language, The whole calculation takes about 20 sec but if I call the mkl\_dgemm using Julia’s ccall it takes 42.27…

---

## [Symbol to variable in a macro](https://discourse.julialang.org/t/symbol-to-variable-in-a-macro/48924)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 6\
**Last updated:** [October 24, 2020, 1:49pm UTC](https://discourse.julialang.org/t/symbol-to-variable-in-a-macro/48924 "2020-10-24T13:49:23Z")

</div>

An easy question. I have asked it some time back and got a good answer, but cannot find back to it, not on Discourse, not in the manual, and not in my code… I want to write a macro to generate code like getfield(vari,…

---

## [Polar decomposition of a matrix](https://discourse.julialang.org/t/polar-decomposition-of-a-matrix/48830)

<div class="topic-metadata">

**Author:** [@danuzco](https://discourse.julialang.org/u/danuzco)\
**Replies:** 14\
**Last updated:** [October 24, 2020, 1:41pm UTC](https://discourse.julialang.org/t/polar-decomposition-of-a-matrix/48830 "2020-10-24T13:41:49Z")

</div>

I need to compute polar decomposition (PD) of matrices https://en.wikipedia.org/wiki/Polar\_decomposition. I tried to install this package https://github.com/weijianzhang/PolarFact.jl, but I’m getting this error: ERROR:…

---

## [Knet on powerpc64le platform?](https://discourse.julialang.org/t/knet-on-powerpc64le-platform/48149)

<div class="topic-metadata">

**Author:** [@jdad](https://discourse.julialang.org/u/jdad)\
**Replies:** 13\
**Last updated:** [October 24, 2020, 1:23pm UTC](https://discourse.julialang.org/t/knet-on-powerpc64le-platform/48149 "2020-10-24T13:23:28Z")

</div>

I am trying to use Knet on a supercomputer using powerpc64le nodes with NVidia TeslaV100 GPUs. But I am not able to compile it (so no use it, with or without GPU access). It seems the Knet version installed (1.4.2) wan…

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

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