# General Usage

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

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

**Page:** 352

---

## [Mutating versus non-mutating arrays for Zygote Gradient](https://discourse.julialang.org/t/mutating-versus-non-mutating-arrays-for-zygote-gradient/92095)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 6\
**Last updated:** [December 25, 2022, 2:57am UTC](https://discourse.julialang.org/t/mutating-versus-non-mutating-arrays-for-zygote-gradient/92095 "2022-12-25T02:57:09Z")

</div>

I created a custom Lux layer to evaluate a polynomial. Now, I have N point entering the layer, transformed, and input into a loss function. I created a loop to evaluate the polynomial since I do not understand broadcasti…

---

## [Declaring ForwardDiff tag directly with a DifferentialEquations integrator / nested function](https://discourse.julialang.org/t/declaring-forwarddiff-tag-directly-with-a-differentialequations-integrator-nested-function/83766)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 3\
**Last updated:** [December 24, 2022, 11:30pm UTC](https://discourse.julialang.org/t/declaring-forwarddiff-tag-directly-with-a-differentialequations-integrator-nested-function/83766 "2022-12-24T23:30:13Z")

</div>

This is a continuation of an original question of mine (Updating integrator parameter/initial condition with ForwardDiff.Dual types) to be more focused on the actual problem of defining an array/scalar for use with autom…

---

## [Building a custom Layer in Lux.jl](https://discourse.julialang.org/t/building-a-custom-layer-in-lux-jl/92091)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 10\
**Last updated:** [December 24, 2022, 11:03pm UTC](https://discourse.julialang.org/t/building-a-custom-layer-in-lux-jl/92091 "2022-12-24T23:03:25Z")

</div>

I am constructing a custom layer, and have an error: ERROR: MethodError: no method matching iterate(::Type{Vector{Float32}}) Closest candidates are: iterate(::Union{LinRange, StepRangeLen}) at range.jl:872 iterate(:…

---

## [Parametrized types](https://discourse.julialang.org/t/parametrized-types/92090)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 3\
**Last updated:** [December 24, 2022, 3:56pm UTC](https://discourse.julialang.org/t/parametrized-types/92090 "2022-12-24T15:56:07Z")

</div>

I am looking at the source code to Lux.jl layers, and see the following struct for the Dense layer: struct Dense{use\_bias, F1, F2, F3} \<: AbstractExplicitLayer activation::F1 in\_dims::Int out\_dims::Int i…

---

## [Dispatch on a set of value type parameters](https://discourse.julialang.org/t/dispatch-on-a-set-of-value-type-parameters/91864)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 7\
**Last updated:** [December 24, 2022, 3:21am UTC](https://discourse.julialang.org/t/dispatch-on-a-set-of-value-type-parameters/91864 "2022-12-24T03:21:47Z")

</div>

I have a type which has an Int value parameter, let’s represent the type like this: struct T{m} some\_fields end I want to define a method for a function f that takes a T value, but only if m is part of a certain fini…

---

## [Stack different color palettes in a single plot](https://discourse.julialang.org/t/stack-different-color-palettes-in-a-single-plot/92076)

<div class="topic-metadata">

**Author:** [@Jose\_Diaz](https://discourse.julialang.org/u/Jose_Diaz)\
**Replies:** 1\
**Last updated:** [December 24, 2022, 12:02pm UTC](https://discourse.julialang.org/t/stack-different-color-palettes-in-a-single-plot/92076 "2022-12-24T12:02:54Z")

</div>

Hello! Let’s say I have the following code. using Plots plots = palette.(\[:leonardo, :autumn\]) By doing that, I create a Vector{ColorPalette}, but actually I’d like to stack and display both color palettes (hopefully…

---

## [Multivariable piecewise functions: Julia-basics help](https://discourse.julialang.org/t/multivariable-piecewise-functions-julia-basics-help/92070)

<div class="topic-metadata">

**Author:** [@manya](https://discourse.julialang.org/u/manya)\
**Replies:** 2\
**Last updated:** [December 24, 2022, 1:35am UTC](https://discourse.julialang.org/t/multivariable-piecewise-functions-julia-basics-help/92070 "2022-12-24T01:35:35Z")

</div>

Hi, I was wondering how to create a piecewise function of two variables r(x,y) = \\begin{cases} f(x,y) & d(x,y)\\geq 0 \\\\ g(x,y) & d(x,y)\<0\\end{cases} and use it to plot the coordinate pair (x',y')= (m(x,y), n(x,y)) on…

---

## [AD Compatible Numerical Differentiation & Integration with Discrete Data](https://discourse.julialang.org/t/ad-compatible-numerical-differentiation-integration-with-discrete-data/92068)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 1\
**Last updated:** [December 24, 2022, 1:22am UTC](https://discourse.julialang.org/t/ad-compatible-numerical-differentiation-integration-with-discrete-data/92068 "2022-12-24T01:22:19Z")

</div>

Hello, I’m trying to calculate some numerical derivatives & integrals from discrete data inside of a loss function. This loss function must be compatible with auto-differentiation to find the minimum. I’ve tried the Num…

---

## [@generated functions aggressively disallowing lambdas (and accusations of impurity! how impious!)](https://discourse.julialang.org/t/generated-functions-aggressively-disallowing-lambdas-and-accusations-of-impurity-how-impious/92072)

<div class="topic-metadata">

**Author:** [@uniment](https://discourse.julialang.org/u/uniment)\
**Replies:** 0\
**Last updated:** [December 24, 2022, 1:10am UTC](https://discourse.julialang.org/t/generated-functions-aggressively-disallowing-lambdas-and-accusations-of-impurity-how-impious/92072 "2022-12-24T01:10:36Z")

</div>

This seems a bit aggressive: Code 1: julia\> @generated f(x) = :( map(i-\>i, x) ) f (generic function with 1 method) julia\> f((1,2,3)) ERROR: The function body AST defined by this @generated function is not pure. This l…

---

## [Very long stack trace](https://discourse.julialang.org/t/very-long-stack-trace/92025)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 15\
**Last updated:** [December 23, 2022, 11:01pm UTC](https://discourse.julialang.org/t/very-long-stack-trace/92025 "2022-12-23T23:01:11Z")

</div>

I am running a SciML type program called RUDE. The code generates an error, with a stack trace of almost 1000 lines long. I attach the trace herein. Perhaps somebody could give me sense of what the error is about? Perhap…

---

## [Missing source file for MultivariatePolynomials](https://discourse.julialang.org/t/missing-source-file-for-multivariatepolynomials/92064)

<div class="topic-metadata">

**Author:** [@bernardofpc](https://discourse.julialang.org/u/bernardofpc)\
**Replies:** 0\
**Last updated:** [December 23, 2022, 9:13pm UTC](https://discourse.julialang.org/t/missing-source-file-for-multivariatepolynomials/92064 "2022-12-23T21:13:38Z")

</div>

I tried to install DiffEqFlux on a machine which (unfortunately) was running out of disk space. The Pkg.add() command failed with “no space left on device”. I cleaned up, and tried again. It apparently succeeded, but …

---

## [How to save solution of differential equation as dataframe](https://discourse.julialang.org/t/how-to-save-solution-of-differential-equation-as-dataframe/92057)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 1\
**Last updated:** [December 23, 2022, 9:04pm UTC](https://discourse.julialang.org/t/how-to-save-solution-of-differential-equation-as-dataframe/92057 "2022-12-23T21:04:48Z")

</div>

Hello, I have generated a solution of a differential equation using DifferentialEquations. I saved the solution in the object soln. Is it possible to save it as a tab-delimited file (or csv) so I can open it again as a …

---

## [Reading video stream from IP camera](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782)

<div class="topic-metadata">

**Author:** [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)\
**Replies:** 3\
**Last updated:** [December 23, 2022, 6:41pm UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782 "2022-12-23T18:41:52Z")

</div>

I’m working on a project where I need to read an Internet video stream. I have the URL needed to connect to the IP camera. The camera administrator tells me that I can use either HTTP or RTSP (Real Time Streaming Protoco…

---

## [Custom array with padding through a view](https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914)

<div class="topic-metadata">

**Author:** [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Replies:** 5\
**Last updated:** [December 23, 2022, 10:27am UTC](https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914 "2022-12-23T10:27:50Z")

</div>

I would like to pad my vector/array for doing FFT stuff, specifically mirroring - and since my data is pretty big, would be great if there was no need for extra allocations. My thought was to have a custom array type, t…

---

## [NamedArray specifying only dimension names](https://discourse.julialang.org/t/namedarray-specifying-only-dimension-names/77895)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 3\
**Last updated:** [December 23, 2022, 6:16am UTC](https://discourse.julialang.org/t/namedarray-specifying-only-dimension-names/77895 "2022-12-23T06:16:28Z")

</div>

In NamedArrays, is it possible to specify ("Rows", "Cols") but leaving the row and column numbers as 1,2,…? julia\> NamedArray(\[1 3; 2 4\], ( OrderedDict("A"=\>1, "B"=\>2), OrderedDict("C"=\>1, "D"=\>2) ), ("Rows", "Cols") ) …

---

## [Compiling a Julia script into a single executable](https://discourse.julialang.org/t/compiling-a-julia-script-into-a-single-executable/92034)

<div class="topic-metadata">

**Author:** [@Dreycen\_Foiles](https://discourse.julialang.org/u/Dreycen_Foiles)\
**Replies:** 0\
**Last updated:** [December 23, 2022, 6:48am UTC](https://discourse.julialang.org/t/compiling-a-julia-script-into-a-single-executable/92034 "2022-12-23T06:48:41Z")

</div>

I’m trying to use PackageCompiler to compile a simple script of mine into a standalone application. Following the documentation on app creation, I created a folder consisting of all the compiled binaries. This is not ide…

---

## [Can't we create a macro named "?"](https://discourse.julialang.org/t/cant-we-create-a-macro-named/92027)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 2\
**Last updated:** [December 22, 2022, 11:41pm UTC](https://discourse.julialang.org/t/cant-we-create-a-macro-named/92027 "2022-12-22T23:41:47Z")

</div>

julia\> @? meca ┌ Error: Failed to revise C:\\Users\\joaqu\\.julia\\dev\\GMT\\src\\common\_options.jl │ exception = │ LoadError: "invalid identifier name \\"?\\"" But we have the broadcast macro @. (which I can’t find the def…

---

## [Code coverage in Base](https://discourse.julialang.org/t/code-coverage-in-base/76809)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 4\
**Last updated:** [December 22, 2022, 11:29pm UTC](https://discourse.julialang.org/t/code-coverage-in-base/76809 "2022-12-22T23:29:15Z")

</div>

Many Julia packages have nice code coverage views (e.g. Codecov). Is there a similar one for Base?

---

## [Error taking derivative of QuadratureProblem() with NullParameters()](https://discourse.julialang.org/t/error-taking-derivative-of-quadratureproblem-with-nullparameters/92026)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 2\
**Last updated:** [December 22, 2022, 11:24pm UTC](https://discourse.julialang.org/t/error-taking-derivative-of-quadratureproblem-with-nullparameters/92026 "2022-12-22T23:24:56Z")

</div>

Hello, I am trying to use Quadrature.jl to calculate the expected values of some random variables (code pasted below). This function works fine and it gives me the values I would expected; however, when I try and take t…

---

## [Solving the diffusion equation in Julia](https://discourse.julialang.org/t/solving-the-diffusion-equation-in-julia/28811)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 23\
**Last updated:** [December 22, 2022, 10:53pm UTC](https://discourse.julialang.org/t/solving-the-diffusion-equation-in-julia/28811 "2022-12-22T22:53:59Z")

</div>

I’m learning how to solve PDEs numerically. The code I wrote in Julia 1.2.0 is as follows: using PyCall so = pyimport("scipy.optimize") using PyPlot I = im h\_s = 0.1 h\_t = 0.02 T = 100.0 L\_x = 30.0 L\_y = 30.0 ddx(u…

---

## [Compiling Gtk UI app with PackageCompiler](https://discourse.julialang.org/t/compiling-gtk-ui-app-with-packagecompiler/92022)

<div class="topic-metadata">

**Author:** [@sschmidhuber](https://discourse.julialang.org/u/sschmidhuber)\
**Replies:** 0\
**Last updated:** [December 22, 2022, 9:00pm UTC](https://discourse.julialang.org/t/compiling-gtk-ui-app-with-packagecompiler/92022 "2022-12-22T21:00:44Z")

</div>

Hello all, I wrote a little desktop application with a Gtk frontend, it works fine in general, just the start up time is long. After that it works nicely. Also I would like to run it on machines without an Julia environ…

---

## [Effectively replace a key in a dictionary](https://discourse.julialang.org/t/effectively-replace-a-key-in-a-dictionary/92018)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 2\
**Last updated:** [December 22, 2022, 7:20pm UTC](https://discourse.julialang.org/t/effectively-replace-a-key-in-a-dictionary/92018 "2022-12-22T19:20:51Z")

</div>

Hello, please tell me a way to effectively replace a key in a dictionary, or a package that implements a data structure that allows you to do this, due to a fixed number of key-value pairs i have too many allocations, i…

---

## [Error when connecting to Pluto on localhost](https://discourse.julialang.org/t/error-when-connecting-to-pluto-on-localhost/88187)

<div class="topic-metadata">

**Author:** [@Soraen](https://discourse.julialang.org/u/Soraen)\
**Replies:** 6\
**Last updated:** [December 22, 2022, 7:03pm UTC](https://discourse.julialang.org/t/error-when-connecting-to-pluto-on-localhost/88187 "2022-12-22T19:03:04Z")

</div>

Hello all, I recently started using Julia and Pluto notebook, everything went well until I had to restart my MacBook Pro, and since then I’ve been unable to connect to Pluto on local host. When I run call Pluto.run(), i…

---

## [Convert data from txt file to matrix](https://discourse.julialang.org/t/convert-data-from-txt-file-to-matrix/91481)

<div class="topic-metadata">

**Author:** [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Replies:** 18\
**Last updated:** [December 22, 2022, 5:52pm UTC](https://discourse.julialang.org/t/convert-data-from-txt-file-to-matrix/91481 "2022-12-22T17:52:12Z")

</div>

Hello, I have txt file the following format It three column with numbers. How can i read data from file and convert him to matrix \[N1, N2, 1\] where N1 length first column, N2 length second column and 1 is the number t…

---

## [Fallback Constructor for All Subtypes](https://discourse.julialang.org/t/fallback-constructor-for-all-subtypes/92011)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 1\
**Last updated:** [December 22, 2022, 4:59pm UTC](https://discourse.julialang.org/t/fallback-constructor-for-all-subtypes/92011 "2022-12-22T16:59:02Z")

</div>

I have a series of structs that are all subtypes of the same abstract type. They can all be constructed with the same logic, but I’d like to have unique constructor names. abstract type AbstractThing end struct Thing1 \<…

---

## [ChatGPT weighs in on the Julia vs Python debate](https://discourse.julialang.org/t/chatgpt-weighs-in-on-the-julia-vs-python-debate/91986)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 1\
**Last updated:** [December 22, 2022, 3:29pm UTC](https://discourse.julialang.org/t/chatgpt-weighs-in-on-the-julia-vs-python-debate/91986 "2022-12-22T15:29:54Z")

</div>

---

## [Using parameters inside a function](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004)

<div class="topic-metadata">

**Author:** [@dgagnon](https://discourse.julialang.org/u/dgagnon)\
**Replies:** 4\
**Last updated:** [December 22, 2022, 2:51pm UTC](https://discourse.julialang.org/t/using-parameters-inside-a-function/92004 "2022-12-22T14:51:58Z")

</div>

Hello I want to use a function using parameters.jl. Inside REPL I simply type: julia\> called\_function(param1=4, param2=0) The function “called\_function” has other parameters but those have default values which are goo…

---

## [MeshViz/Makie is smoothing my colors](https://discourse.julialang.org/t/meshviz-makie-is-smoothing-my-colors/91993)

<div class="topic-metadata">

**Author:** [@\_stla](https://discourse.julialang.org/u/_stla)\
**Replies:** 3\
**Last updated:** [December 22, 2022, 11:23am UTC](https://discourse.julialang.org/t/meshviz-makie-is-smoothing-my-colors/91993 "2022-12-22T11:23:10Z")

</div>

Hello, I have a mesh of a torus, made with Meshes.jl. I assigned colors to the vertices in order to have a checkerboard texture: Nice but the mesh is not smooth, one can see the facets. I found that one can get the …

---

## [How to plot heat maps with grid lines in \`Plots.jl\` with \`GR\` as backend?](https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [December 22, 2022, 10:30am UTC](https://discourse.julialang.org/t/how-to-plot-heat-maps-with-grid-lines-in-plots-jl-with-gr-as-backend/91996 "2022-12-22T10:30:11Z")

</div>

For example, the following code will produce a heat map: using Plots heatmap(rand(4, 4)) How do I add the grid lines between each of the squares? The option grid = true does not work.

---

## [Maximal value - product of two lists](https://discourse.julialang.org/t/maximal-value-product-of-two-lists/91972)

<div class="topic-metadata">

**Author:** [@baprata](https://discourse.julialang.org/u/baprata)\
**Replies:** 6\
**Last updated:** [December 22, 2022, 10:41am UTC](https://discourse.julialang.org/t/maximal-value-product-of-two-lists/91972 "2022-12-22T10:41:33Z")

</div>

Concerning the following situation: max \\forall i { h\_i \* X\_{mij} } Is there a function to obtain the maximal value between the product of two lists?

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

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