# General Usage

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

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

**Page:** 434

---

## [Allocation with Subset of Matrix and Views](https://discourse.julialang.org/t/allocation-with-subset-of-matrix-and-views/82998)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 2\
**Last updated:** [June 20, 2022, 4:04pm UTC](https://discourse.julialang.org/t/allocation-with-subset-of-matrix-and-views/82998 "2022-06-20T16:04:31Z")

</div>

Hello, I’m wondering if anyone can help me understand the following. I want to replace a subset of matrix A with matrix B. I understand this can be done efficiently using for loops or copyto!. I am specifically interest…

---

## [Slices: should they default to views?](https://discourse.julialang.org/t/slices-should-they-default-to-views/83023)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 11\
**Last updated:** [June 20, 2022, 3:27pm UTC](https://discourse.julialang.org/t/slices-should-they-default-to-views/83023 "2022-06-20T15:27:23Z")

</div>

I wonder what is more common, slicing a matrix to create a copy of the entries, or to create a view? If we desire the latter, we have to do @views. But if the latter is the more common use, wouldn’t it be nice to dispens…

---

## [How to multiply tuples and how to change a format of summation?](https://discourse.julialang.org/t/how-to-multiply-tuples-and-how-to-change-a-format-of-summation/82928)

<div class="topic-metadata">

**Author:** [@Kevin\_12](https://discourse.julialang.org/u/Kevin_12)\
**Replies:** 2\
**Last updated:** [June 20, 2022, 3:03pm UTC](https://discourse.julialang.org/t/how-to-multiply-tuples-and-how-to-change-a-format-of-summation/82928 "2022-06-20T15:03:24Z")

</div>

If you have a set A = \[ (1,4,7), (2,5,3), (5,4,9), (2,8,7), (8,6,7), (2,3,5) \] .Is it possible to derive: #1 another set A' such that A' = 1.2\*A each element of A' is the scaled version of A #2 define a variable …

---

## [Failed to plot](https://discourse.julialang.org/t/failed-to-plot/83002)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 2\
**Last updated:** [June 20, 2022, 2:38pm UTC](https://discourse.julialang.org/t/failed-to-plot/83002 "2022-06-20T14:38:55Z")

</div>

I have added the PLots.jl But when I use it to plot.It shows me such wrong. using Plots plot(\[1,2,3\]) ERROR: LoadError: UndefVarError: plot not defined Stacktrace: \[1\] top-level scope at untitled-752712825fa0b1fb343e…

---

## [Evaluate variable-length input array RNN in Julia Flux](https://discourse.julialang.org/t/evaluate-variable-length-input-array-rnn-in-julia-flux/82475)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 4\
**Last updated:** [June 20, 2022, 1:19pm UTC](https://discourse.julialang.org/t/evaluate-variable-length-input-array-rnn-in-julia-flux/82475 "2022-06-20T13:19:59Z")

</div>

How to create a vector of a matrice for variable sequence length data to evaluate untrained RNN? Following the idea developed in these \[link1, link2\] it is possible to carry out the evaluation for a vector; using Flux …

---

## [Julia precompilation limits or are there really any?](https://discourse.julialang.org/t/julia-precompilation-limits-or-are-there-really-any/55224)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 20\
**Last updated:** [June 20, 2022, 1:19pm UTC](https://discourse.julialang.org/t/julia-precompilation-limits-or-are-there-really-any/55224 "2022-06-20T13:19:17Z")

</div>

Hey, I tried to read every details on this topic but I still can’t be sure about what is the limiting factor at reaching “nocompilation” speed. (Under no compilation speed I mean the speed when you second time run the a…

---

## [Overcoming performance hit of accessing struct field](https://discourse.julialang.org/t/overcoming-performance-hit-of-accessing-struct-field/82911)

<div class="topic-metadata">

**Author:** [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Replies:** 11\
**Last updated:** [June 20, 2022, 12:18pm UTC](https://discourse.julialang.org/t/overcoming-performance-hit-of-accessing-struct-field/82911 "2022-06-20T12:18:31Z")

</div>

Hi all, I’m working on a simulator for a Monte Carlo simulation of a spin ising model. I was working with a custom struct holding a few arrays and dicts. As an example, one of the arrays holds 512^2 Int8’s, which repres…

---

## [How to print markdown in the terminal](https://discourse.julialang.org/t/how-to-print-markdown-in-the-terminal/82397)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 14\
**Last updated:** [June 20, 2022, 11:24am UTC](https://discourse.julialang.org/t/how-to-print-markdown-in-the-terminal/82397 "2022-06-20T11:24:50Z")

</div>

I want to print styled markdown with colors and etc (the same way the REPL prints docs), instead of the raw text. So far i wasn’t able to figure out, i was thinking something like: show(stdout, MIME"text/markdown", some…

---

## [How to get within r2 and t value from FixedEffectModels?](https://discourse.julialang.org/t/how-to-get-within-r2-and-t-value-from-fixedeffectmodels/83055)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 0\
**Last updated:** [June 20, 2022, 10:04am UTC](https://discourse.julialang.org/t/how-to-get-within-r2-and-t-value-from-fixedeffectmodels/83055 "2022-06-20T10:04:40Z")

</div>

Dear all, how to get within\_r2 and t value? julia\> using DataFrames, DataFramesMeta, FixedEffectModels julia\> df = dataset("plm", "GrunFeld"); julia\> fe1 = reg(df, @formula(Inv ~ Value + Capital + fe(Firm))) …

---

## [Default v.s. inner constructor changes dispatch?](https://discourse.julialang.org/t/default-v-s-inner-constructor-changes-dispatch/83036)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 6\
**Last updated:** [June 20, 2022, 6:53am UTC](https://discourse.julialang.org/t/default-v-s-inner-constructor-changes-dispatch/83036 "2022-06-20T06:53:55Z")

</div>

I’m running into an inconsistency between default and inner constructors and have tried to construct an MWE below. Consider code version a) struct MyType{V} x::V y::Int64 end MyType{V}(x::V, y::Real) where …

---

## [Does anybody use the syntax \`a \<operator\> b = ...\` to define new methods for operators?](https://discourse.julialang.org/t/does-anybody-use-the-syntax-a-operator-b-to-define-new-methods-for-operators/83034)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 8\
**Last updated:** [June 20, 2022, 4:09am UTC](https://discourse.julialang.org/t/does-anybody-use-the-syntax-a-operator-b-to-define-new-methods-for-operators/83034 "2022-06-20T04:09:28Z")

</div>

I know that the julia docs mentions that operators are just regular functions that have a special syntax, so the expressions a \<operator\> b and \<operator\>(a, b) are equivalent. What i did not realized, is that we can use…

---

## [Massive performance penalty for Float16 compared to Float32](https://discourse.julialang.org/t/massive-performance-penalty-for-float16-compared-to-float32/6864)

<div class="topic-metadata">

**Author:** [@zenon](https://discourse.julialang.org/u/zenon)\
**Replies:** 17\
**Last updated:** [June 20, 2022, 1:15am UTC](https://discourse.julialang.org/t/massive-performance-penalty-for-float16-compared-to-float32/6864 "2022-06-20T01:15:29Z")

</div>

Hello, I just do the Coursera lectures about Deep Leanring by Andrew Ng, and want to implement what I learned in Julia (lecture is in Python), so I can check my understanding. So there is a small neural net, and it take…

---

## [Interactive/Animated graphics a-la scratch.mit.edu?](https://discourse.julialang.org/t/interactive-animated-graphics-a-la-scratch-mit-edu/40772)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 13\
**Last updated:** [June 20, 2022, 12:12am UTC](https://discourse.julialang.org/t/interactive-animated-graphics-a-la-scratch-mit-edu/40772 "2022-06-20T00:12:52Z")

</div>

Suppose someone wanted to teach computer programming concepts using Julia through interactive graphical animations a-la scratch? Are there any packages that let you open a window and draw objects/move them around/animate…

---

## [Handling SIGTERM in Julia](https://discourse.julialang.org/t/handling-sigterm-in-julia/32231)

<div class="topic-metadata">

**Author:** [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Replies:** 9\
**Last updated:** [June 19, 2022, 11:47pm UTC](https://discourse.julialang.org/t/handling-sigterm-in-julia/32231 "2022-06-19T23:47:21Z")

</div>

Hi, from researching a bit I learned that handling unix signals has been tricky in Julia for a while. Our queuing systems send signals to programs to indicate they should come to an end; and I’d like to do stuff like sto…

---

## [Can macros also be precompiled?](https://discourse.julialang.org/t/can-macros-also-be-precompiled/83032)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 4\
**Last updated:** [June 19, 2022, 10:56pm UTC](https://discourse.julialang.org/t/can-macros-also-be-precompiled/83032 "2022-06-19T22:56:49Z")

</div>

I know that on working on a package, is common to create a precompile.jl file that calls precompile for various methods and the types they may accept as arguments, but i was thinking that the same thing could be done for…

---

## [For a sequence of n values, that produces an expected value curve, overlay the distribution associated with each value horizontally](https://discourse.julialang.org/t/for-a-sequence-of-n-values-that-produces-an-expected-value-curve-overlay-the-distribution-associated-with-each-value-horizontally/83027)

<div class="topic-metadata">

**Author:** [@Ryan\_Vogt1](https://discourse.julialang.org/u/Ryan_Vogt1)\
**Replies:** 0\
**Last updated:** [June 19, 2022, 7:04pm UTC](https://discourse.julialang.org/t/for-a-sequence-of-n-values-that-produces-an-expected-value-curve-overlay-the-distribution-associated-with-each-value-horizontally/83027 "2022-06-19T19:04:45Z")

</div>

Howdy, so I have a small code which for a value n produces the mean value from a list of samples, and produces the domain (x\_n) and range values (y\_n) of a kernel density estimate for given n value. I was curious if it i…

---

## [Confused about NamedTuple implementation](https://discourse.julialang.org/t/confused-about-namedtuple-implementation/83007)

<div class="topic-metadata">

**Author:** [@dodoplus](https://discourse.julialang.org/u/dodoplus)\
**Replies:** 2\
**Last updated:** [June 19, 2022, 5:59pm UTC](https://discourse.julialang.org/t/confused-about-namedtuple-implementation/83007 "2022-06-19T17:59:14Z")

</div>

Hi, I wanted to understand how NamedTuples work, so I’ve asked: @which NamedTuple((:a=\>1,)) # NamedTuple(itr) in Base at namedtuple.jl:122 which is apparently this line: NamedTuple(itr) = (; itr...) Also, we have th…

---

## [DataDrivenDiffEq package - Choosing the Basis](https://discourse.julialang.org/t/datadrivendiffeq-package-choosing-the-basis/82389)

<div class="topic-metadata">

**Author:** [@ccccc](https://discourse.julialang.org/u/ccccc)\
**Replies:** 7\
**Last updated:** [June 19, 2022, 1:35pm UTC](https://discourse.julialang.org/t/datadrivendiffeq-package-choosing-the-basis/82389 "2022-06-19T13:35:18Z")

</div>

I’m trying to use the package DataDrivenDiffEq.jl, and I’ve worked through many of the examples. My problem is that I’m not sure how to choose a basis for any given problem (or the algorithm). I wondered if anyone has an…

---

## [How do I find the size of a Matrix object?](https://discourse.julialang.org/t/how-do-i-find-the-size-of-a-matrix-object/82999)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 6\
**Last updated:** [June 19, 2022, 8:20am UTC](https://discourse.julialang.org/t/how-do-i-find-the-size-of-a-matrix-object/82999 "2022-06-19T08:20:46Z")

</div>

I found the code below on the web, it is quite standard. It looks like it worked at some point in the past. It does not work today in my system (Windows 11 Pro, Julia 7.3). Does anyone know why and how do I find the dime…

---

## [Convert Int to base64](https://discourse.julialang.org/t/convert-int-to-base64/82980)

<div class="topic-metadata">

**Author:** [@AlanAylmer](https://discourse.julialang.org/u/AlanAylmer)\
**Replies:** 2\
**Last updated:** [June 19, 2022, 7:45am UTC](https://discourse.julialang.org/t/convert-int-to-base64/82980 "2022-06-19T07:45:17Z")

</div>

Hello. I want to convert any Int in a range 0:63 to its base64 equivalent. The function f(i) would be: f(i::Int64) =\> 0 =\> A 1 =\> B 32 =\> g 63=\> / If there are choices I prefer low RAM and human readability. (Edi…

---

## [Fill option in dataframe unstack not recognized](https://discourse.julialang.org/t/fill-option-in-dataframe-unstack-not-recognized/82994)

<div class="topic-metadata">

**Author:** [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Replies:** 2\
**Last updated:** [June 19, 2022, 6:50am UTC](https://discourse.julialang.org/t/fill-option-in-dataframe-unstack-not-recognized/82994 "2022-06-19T06:50:02Z")

</div>

I’m trying to unstack a dataframe with missing values filled in as 0. I followed exactly the example in the online documentation, but that example fails with the same error that I see in my code. The following is copie…

---

## [Comparing Julia functions](https://discourse.julialang.org/t/comparing-julia-functions/82990)

<div class="topic-metadata">

**Author:** [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Replies:** 2\
**Last updated:** [June 19, 2022, 4:45am UTC](https://discourse.julialang.org/t/comparing-julia-functions/82990 "2022-06-19T04:45:18Z")

</div>

Is there a way to view the lower level code of a Julia function? I want to confirm whether the two functions are equivalent. For example: function modify1(a,b) return a+b end function modify2(a,b) return (a+b)\*…

---

## [Code in unexecuted if statement causes slowdown in other function](https://discourse.julialang.org/t/code-in-unexecuted-if-statement-causes-slowdown-in-other-function/82983)

<div class="topic-metadata">

**Author:** [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Replies:** 1\
**Last updated:** [June 19, 2022, 3:02am UTC](https://discourse.julialang.org/t/code-in-unexecuted-if-statement-causes-slowdown-in-other-function/82983 "2022-06-19T03:02:48Z")

</div>

I’m making a Monte Carlo simulation program. The object my simulation is working on is a graph, which I represent by struct mutable struct IsingGraph state::Vector{Int8} adj::Vector{Vector{Int32}} ... eprops…

---

## [Problem with SuiteSparse: memory duplication?](https://discourse.julialang.org/t/problem-with-suitesparse-memory-duplication/78977)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [June 19, 2022, 12:10am UTC](https://discourse.julialang.org/t/problem-with-suitesparse-memory-duplication/78977 "2022-06-19T00:10:10Z")

</div>

From my reading of the SuiteSparse: In order to use one of the direct solvers, the CSC sparse matrix is converted to an internal type, Sparse. Unfortunately, at that point the memory used for the matrix is duplicated bec…

---

## [TypeError in Julia/Turing when sampling for a forced differential equation](https://discourse.julialang.org/t/typeerror-in-julia-turing-when-sampling-for-a-forced-differential-equation/82937)

<div class="topic-metadata">

**Author:** [@Duo\_Chan](https://discourse.julialang.org/u/Duo_Chan)\
**Replies:** 6\
**Last updated:** [June 18, 2022, 9:50pm UTC](https://discourse.julialang.org/t/typeerror-in-julia-turing-when-sampling-for-a-forced-differential-equation/82937 "2022-06-18T21:50:03Z")

</div>

Hi I am new to Julia and Turing and am trying to fit a forced 0-D box ODE to data, but I get type error when doing sampling. The tutorial (Bayesian Estimation of Differential Equations) gives an example for unforced LV…

---

## [Initialize the julia runtime more than once within C++](https://discourse.julialang.org/t/initialize-the-julia-runtime-more-than-once-within-c/82892)

<div class="topic-metadata">

**Author:** [@MarioSouto](https://discourse.julialang.org/u/MarioSouto)\
**Replies:** 5\
**Last updated:** [June 18, 2022, 7:49pm UTC](https://discourse.julialang.org/t/initialize-the-julia-runtime-more-than-once-within-c/82892 "2022-06-18T19:49:34Z")

</div>

I’m trying to create a micro service in C++ that calls julia at each new request. In the first call it works just fine but it crashes with a signal (11): Segmentation fault at the second call. I’ve tried initializing the…

---

## [Unpack named tuples (does anyone know how to do it?)](https://discourse.julialang.org/t/unpack-named-tuples-does-anyone-know-how-to-do-it/32456)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 10\
**Last updated:** [June 18, 2022, 5:38pm UTC](https://discourse.julialang.org/t/unpack-named-tuples-does-anyone-know-how-to-do-it/32456 "2022-06-18T17:38:15Z")

</div>

Hi all, I just wanted to know if it is possible to unpack named tuples in the following context. I know that Parameters.jl addresses some related issues, but I have not been able to figure out if it can handle the follo…

---

## [A default representation for Expr](https://discourse.julialang.org/t/a-default-representation-for-expr/82956)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 3\
**Last updated:** [June 18, 2022, 3:15pm UTC](https://discourse.julialang.org/t/a-default-representation-for-expr/82956 "2022-06-18T15:15:21Z")

</div>

Say I have two equivalent expressions: julia\> ex1 = :(a + b\*c + 1) :(a + b \* c + 1) julia\> ex2 = :(1 + a + c\*b) :(1 + a + c \* b) Is there a way to naively rearrange each of these to some default representation, so tha…

---

## [There should be a guide for compat-block writing](https://discourse.julialang.org/t/there-should-be-a-guide-for-compat-block-writing/82963)

<div class="topic-metadata">

**Author:** [@Rratic](https://discourse.julialang.org/u/Rratic)\
**Replies:** 9\
**Last updated:** [June 18, 2022, 12:22pm UTC](https://discourse.julialang.org/t/there-should-be-a-guide-for-compat-block-writing/82963 "2022-06-18T12:22:18Z")

</div>

This afternoon (time zone: east 8), I noticed several topics in JuliaCN, all asking about package using problems. I looked at the github repos and noticed that, although packages vary in (science) fields, they aren’t abl…

---

## [How to simply get the array struct's element array](https://discourse.julialang.org/t/how-to-simply-get-the-array-structs-element-array/82965)

<div class="topic-metadata">

**Author:** [@cepheid](https://discourse.julialang.org/u/cepheid)\
**Replies:** 2\
**Last updated:** [June 18, 2022, 12:48pm UTC](https://discourse.julialang.org/t/how-to-simply-get-the-array-structs-element-array/82965 "2022-06-18T12:48:05Z")

</div>

For example: mutable struct Coords x::Float64 y::Float64 z::Float64 end n = 10 v = Vector{Coords}(undef, n) for i = 1:n v\[i\] = Coords(rand(), rand(), rand()) end I want to get ar…

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

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