# General Usage

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

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

**Page:** 623

---

## [Ad-hoc equality test for struct after definition](https://discourse.julialang.org/t/ad-hoc-equality-test-for-struct-after-definition/4615)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 13\
**Last updated:** [March 26, 2021, 5:59pm UTC](https://discourse.julialang.org/t/ad-hoc-equality-test-for-struct-after-definition/4615 "2021-03-26T17:59:06Z")

</div>

I am trying to streamline some unit tests. Most of them work by generating a value and comparing it to a known value. I want something like ==, but I only want to define it in the tests, not the package source, since equ…

---

## [Optimizing semiclassical simulation for a lattice system](https://discourse.julialang.org/t/optimizing-semiclassical-simulation-for-a-lattice-system/58014)

<div class="topic-metadata">

**Author:** [@Joh11](https://discourse.julialang.org/u/Joh11)\
**Replies:** 7\
**Last updated:** [March 26, 2021, 4:55pm UTC](https://discourse.julialang.org/t/optimizing-semiclassical-simulation-for-a-lattice-system/58014 "2021-03-26T16:55:13Z")

</div>

Hi everyone, I am currently working on implementing an implementation of semiclassical Monte Carlo for a lattice system (https://github.com/Joh11/semiclassical-monte-carlo). I would like to make my code faster. The bot…

---

## [Symbolics.jl - solve\_for not defined](https://discourse.julialang.org/t/symbolics-jl-solve-for-not-defined/57292)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 3\
**Last updated:** [March 26, 2021, 3:43pm UTC](https://discourse.julialang.org/t/symbolics-jl-solve-for-not-defined/57292 "2021-03-26T15:43:35Z")

</div>

When I tried to use Symbolics.jl to sovle a simple equation, I ran into the error saying that solve\_for was not defined. Below you can see the package status and a screenshot from the docs. Am I wrong, or is something no…

---

## [Missing ascii/unicode](https://discourse.julialang.org/t/missing-ascii-unicode/57990)

<div class="topic-metadata">

**Author:** [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Replies:** 6\
**Last updated:** [March 26, 2021, 1:55pm UTC](https://discourse.julialang.org/t/missing-ascii-unicode/57990 "2021-03-26T13:55:17Z")

</div>

When I run for i in 1:3000 print(Char(i)) end many of the characters appeared as question marks. I understand that this is most likely an windows OS problem, but just wondering if anyone have encountered this issue be…

---

## [Help me understand unintuitive behavior of array comparison](https://discourse.julialang.org/t/help-me-understand-unintuitive-behavior-of-array-comparison/57946)

<div class="topic-metadata">

**Author:** [@levasco](https://discourse.julialang.org/u/levasco)\
**Replies:** 8\
**Last updated:** [March 26, 2021, 1:00pm UTC](https://discourse.julialang.org/t/help-me-understand-unintuitive-behavior-of-array-comparison/57946 "2021-03-26T13:00:16Z")

</div>

julia\> minimum(\[\[1,1e10,1e10\],\[2,0,0\]\]) 3-element Array{Float64,1}: 1.0 1.0e10 1.0e10 I would expect this to return either the same as min.() or a MethodError, but instead only the first elements are compared. Simila…

---

## [Always show exception type in stack trace?](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010)

<div class="topic-metadata">

**Author:** [@tpgillam](https://discourse.julialang.org/u/tpgillam)\
**Replies:** 0\
**Last updated:** [March 26, 2021, 11:57am UTC](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010 "2021-03-26T11:57:14Z")

</div>

I observe that stack traces in Julia do not necessarily show the type of the exception that is thrown. For example: julia\> throw(DomainError("moo")) ERROR: DomainError with moo: ...snip... includes “DomainError” in the…

---

## [DataFrames/CSV: how to read vectors from \*.csv?](https://discourse.julialang.org/t/dataframes-csv-how-to-read-vectors-from-csv/57883)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 9\
**Last updated:** [March 26, 2021, 10:09am UTC](https://discourse.julialang.org/t/dataframes-csv-how-to-read-vectors-from-csv/57883 "2021-03-26T10:09:00Z")

</div>

Dear folks, unfortunately, I fail to read vectors from a \*.csv file. Here is an MWE: using CSV, DataFrames df = DataFrame( A=\[\[1,2,3\], \[4,5,6\]\] ) file = "my\_test.csv" CSV.write(file, df, delim=';') new\_df = DataFrame…

---

## [Tuple as argument for size(AbstractArray)](https://discourse.julialang.org/t/tuple-as-argument-for-size-abstractarray/57533)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 36\
**Last updated:** [March 26, 2021, 7:52am UTC](https://discourse.julialang.org/t/tuple-as-argument-for-size-abstractarray/57533 "2021-03-26T07:52:06Z")

</div>

It would be great to have an alternative way of calling size with a tuple of dimensions. Is there a specific reason that this does not exist in Base? The function could look like function size(x::AbstractArray{T},dim:…

---

## [ProfileView not loading MacOS](https://discourse.julialang.org/t/profileview-not-loading-macos/57970)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 5\
**Last updated:** [March 26, 2021, 6:40am UTC](https://discourse.julialang.org/t/profileview-not-loading-macos/57970 "2021-03-26T06:40:35Z")

</div>

Unfortunately, I can’t seem to get the ProfileView.view() GUI to load on MacOS. I didn’t have any problems adding or precompiling the package. Profile works. The GUI window pops up, but it stays completely blank and I ge…

---

## [Solarized Dark theme with 1.6.0](https://discourse.julialang.org/t/solarized-dark-theme-with-1-6-0/57941)

<div class="topic-metadata">

**Author:** [@theogf](https://discourse.julialang.org/u/theogf)\
**Replies:** 8\
**Last updated:** [March 25, 2021, 8:59pm UTC](https://discourse.julialang.org/t/solarized-dark-theme-with-1-6-0/57941 "2021-03-25T20:59:42Z")

</div>

If you noticed like me that some messages are invisible during precompilation with 1.6 when using the Solarized Dark theme in Linux you need to change some of the colors. @dave.f.kleinschmidt proposed the following chan…

---

## [Differentiate expressions involving LinearMap](https://discourse.julialang.org/t/differentiate-expressions-involving-linearmap/57945)

<div class="topic-metadata">

**Author:** [@mpf01](https://discourse.julialang.org/u/mpf01)\
**Replies:** 3\
**Last updated:** [March 25, 2021, 7:53pm UTC](https://discourse.julialang.org/t/differentiate-expressions-involving-linearmap/57945 "2021-03-25T19:53:42Z")

</div>

Is it possible, perhaps by defining an appropriate pullback, to differentiate expressions that involve a LinearMap object? Here’s a small example: using Zygote, LinearMaps m, n = 2, 3; r = ones(m); x = ones(n) A = Line…

---

## [Calling a macro within a macro](https://discourse.julialang.org/t/calling-a-macro-within-a-macro/57766)

<div class="topic-metadata">

**Author:** [@turquoise](https://discourse.julialang.org/u/turquoise)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 6:40pm UTC](https://discourse.julialang.org/t/calling-a-macro-within-a-macro/57766 "2021-03-25T18:40:40Z")

</div>

I have defined a macro called @m.trial which simply escapes its argument and feeds into the @identity macro. The @identity macro is defined as (not escaped at the moment intentionally): macro identity(x) x end @m.t…

---

## [Rewriting dplyr code which uses a function of columns in Julia -style using DataFrames.jl](https://discourse.julialang.org/t/rewriting-dplyr-code-which-uses-a-function-of-columns-in-julia-style-using-dataframes-jl/57939)

<div class="topic-metadata">

**Author:** [@Adam\_Fleischhacker](https://discourse.julialang.org/u/Adam_Fleischhacker)\
**Replies:** 5\
**Last updated:** [March 25, 2021, 5:49pm UTC](https://discourse.julialang.org/t/rewriting-dplyr-code-which-uses-a-function-of-columns-in-julia-style-using-dataframes-jl/57939 "2021-03-25T17:49:14Z")

</div>

I am migrating my brain towards thinking in Julia-esque style. Yet, I am not sure how to approach this problem where I want to create a third column of a data frame that is a function of the other two. I prefer intuiti…

---

## [Mean of Period](https://discourse.julialang.org/t/mean-of-period/57951)

<div class="topic-metadata">

**Author:** [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 5:05pm UTC](https://discourse.julialang.org/t/mean-of-period/57951 "2021-03-25T17:05:56Z")

</div>

So reading the documentation, if you take a difference of DateTime you get an Period outputs (year, minute etc) and these are supposed to behave like integers. But if I would like the average period time (ex mean(\[Second…

---

## [Broadcasting to all fields of a struct](https://discourse.julialang.org/t/broadcasting-to-all-fields-of-a-struct/57924)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 13\
**Last updated:** [March 25, 2021, 2:48pm UTC](https://discourse.julialang.org/t/broadcasting-to-all-fields-of-a-struct/57924 "2021-03-25T14:48:43Z")

</div>

I have a data structure, nesting AbstractArrays and Structs, where all the elements (leaves of my datatree) are, for example Float64, and I wish to transform them all into Float32, by rebuilding the data structure. I wr…

---

## [Symbolics and substitution?](https://discourse.julialang.org/t/symbolics-and-substitution/57460)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 20\
**Last updated:** [March 25, 2021, 2:35pm UTC](https://discourse.julialang.org/t/symbolics-and-substitution/57460 "2021-03-25T14:35:08Z")

</div>

I’m trying to use Symbolics.jl to fit a polynomial to some data points (\\ldots,(x\_j,y\_j),\\ldots) by Lagrange interpolation, then take the derivative of the polynomial, and substitute some relationships between the data p…

---

## [Computing ~Z-transform~ residues in Julia](https://discourse.julialang.org/t/computing-z-transform-residues-in-julia/57446)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 8\
**Last updated:** [March 25, 2021, 2:17pm UTC](https://discourse.julialang.org/t/computing-z-transform-residues-in-julia/57446 "2021-03-25T14:17:29Z")

</div>

Hey Are there any libraries that compute the Z transform and it’s inverse, implemented in julia? I know of ControlSystems.jl for continous systems - can it’s features be applied to discrete systems as well? Is there any…

---

## [How can I run only a newly add line of code?](https://discourse.julialang.org/t/how-can-i-run-only-a-newly-add-line-of-code/57918)

<div class="topic-metadata">

**Author:** [@Zerosum](https://discourse.julialang.org/u/Zerosum)\
**Replies:** 3\
**Last updated:** [March 25, 2021, 11:01am UTC](https://discourse.julialang.org/t/how-can-i-run-only-a-newly-add-line-of-code/57918 "2021-03-25T11:01:11Z")

</div>

Hi, I am not sure about the keywords that I should look for on this problem. Suppose my codes can be separated into two parts. The first part is generating a very huge Markov transition matrix and finding a solution o…

---

## [Nsight compute from CUDA.jl and source annotation](https://discourse.julialang.org/t/nsight-compute-from-cuda-jl-and-source-annotation/57855)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 3\
**Last updated:** [March 25, 2021, 7:28am UTC](https://discourse.julialang.org/t/nsight-compute-from-cuda-jl-and-source-annotation/57855 "2021-03-25T07:28:48Z")

</div>

Hi, I try to build a training session on GPU programming (including kernel programming) and I want to use Julia and CUDA.jl as a development environment. Profiling is an essential tool for GPGPU and I think that profili…

---

## [How to understand Flux.functor?](https://discourse.julialang.org/t/how-to-understand-flux-functor/57906)

<div class="topic-metadata">

**Author:** [@pilgrimygy](https://discourse.julialang.org/u/pilgrimygy)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 5:51am UTC](https://discourse.julialang.org/t/how-to-understand-flux-functor/57906 "2021-03-25T05:51:33Z")

</div>

Dear Community, I got a question about functor usage in Flux.jl. When I read the DQN code in ReinforcementLearningZoo, I confused the usage of the functor: Flux.functor(x::DQNLearner) = (Q = x.approximator, Qₜ = x.targe…

---

## [\`$ julia -p n\` can't use Project.toml?](https://discourse.julialang.org/t/julia-p-n-cant-use-project-toml/57907)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 5:17am UTC](https://discourse.julialang.org/t/julia-p-n-cant-use-project-toml/57907 "2021-03-25T05:17:19Z")

</div>

Basic script: me@pc:/tmp/testenv$ less /tmp/testproj/test.jl using Optim,DataFrames DataFrame(rand(3,3)) Project has all deps: me@pc:/tmp/testenv$ less /tmp/testproj/Project.toml ./Project.toml me@pc:/tmp/testen…

---

## [Error using ControlSystems' lsim](https://discourse.julialang.org/t/error-using-controlsystems-lsim/57898)

<div class="topic-metadata">

**Author:** [@cjdakin](https://discourse.julialang.org/u/cjdakin)\
**Replies:** 1\
**Last updated:** [March 25, 2021, 4:59am UTC](https://discourse.julialang.org/t/error-using-controlsystems-lsim/57898 "2021-03-25T04:59:05Z")

</div>

Newbie to the ControlSystems toolbox trying to simulate the output of a control signal being passed through a transfer function but am having trouble solving an error that is arising. Is it due to a coding error or the t…

---

## [Static array over 1,024 elements is slow to compile?](https://discourse.julialang.org/t/static-array-over-1-024-elements-is-slow-to-compile/57764)

<div class="topic-metadata">

**Author:** [@jdh62043](https://discourse.julialang.org/u/jdh62043)\
**Replies:** 11\
**Last updated:** [March 25, 2021, 3:54am UTC](https://discourse.julialang.org/t/static-array-over-1-024-elements-is-slow-to-compile/57764 "2021-03-25T03:54:15Z")

</div>

I am trying to improve the compilation time of using the StaticArrays package in my use case. Currently, I have made a fork of the package and changed how broadcasting works to generate rolled-up loops instead of its pre…

---

## [Pkg REPL mode bug in 1.6.0-rc2](https://discourse.julialang.org/t/pkg-repl-mode-bug-in-1-6-0-rc2/57261)

<div class="topic-metadata">

**Author:** [@braydenware](https://discourse.julialang.org/u/braydenware)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 1:45am UTC](https://discourse.julialang.org/t/pkg-repl-mode-bug-in-1-6-0-rc2/57261 "2021-03-25T01:45:15Z")

</div>

There seems to be a bug in parsing the strings in Pkg. It only happens in a weird subset of cases: specifically, only on 1.6.0, only when using ssh rather than http to clone, and only when trying to add a specific packag…

---

## [How to use ArgParse with Distributed (error calling from inside main)?](https://discourse.julialang.org/t/how-to-use-argparse-with-distributed-error-calling-from-inside-main/57902)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 1\
**Last updated:** [March 25, 2021, 12:57am UTC](https://discourse.julialang.org/t/how-to-use-argparse-with-distributed-error-calling-from-inside-main/57902 "2021-03-25T00:57:15Z")

</div>

For some reason I can’t get a basic example of this working: File: testargs.jl # example 1: minimal options/arguments, auto-generated help/version using ArgParse function main(args) s = ArgParseSettings("Run deco…

---

## [Manual dispatch over a constant type set](https://discourse.julialang.org/t/manual-dispatch-over-a-constant-type-set/57811)

<div class="topic-metadata">

**Author:** [@RGon](https://discourse.julialang.org/u/RGon)\
**Replies:** 5\
**Last updated:** [March 24, 2021, 10:01pm UTC](https://discourse.julialang.org/t/manual-dispatch-over-a-constant-type-set/57811 "2021-03-24T22:01:09Z")

</div>

I’m trying to run a simulation that has many different thermodynamic methods depending on the substance type (usually phase), and it’s nice to be able to easily choose what method to use. Long story short, I need to be a…

---

## [How to lock variables in @threads](https://discourse.julialang.org/t/how-to-lock-variables-in-threads/57697)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 11\
**Last updated:** [March 24, 2021, 8:56pm UTC](https://discourse.julialang.org/t/how-to-lock-variables-in-threads/57697 "2021-03-24T20:56:03Z")

</div>

I am running a multithreaded parameter tuning for some ML algorithms. I can avoid allocation in the input using CartesianIndices (thanks, stevengj !) but how can I avoid allocation in the output ? I would likely need to…

---

## [Random number flow independent from the number of threads](https://discourse.julialang.org/t/random-number-flow-independent-from-the-number-of-threads/57850)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [March 24, 2021, 8:50pm UTC](https://discourse.julialang.org/t/random-number-flow-independent-from-the-number-of-threads/57850 "2021-03-24T20:50:20Z")

</div>

I am still trying to arrive to a workflow where I can set some multithreaded experiment random or fixed given some input depending of the needs. The code above works for a given (fixed) number of threads, but if I let c…

---

## [Pkg add - action at a distance](https://discourse.julialang.org/t/pkg-add-action-at-a-distance/57886)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [March 24, 2021, 8:48pm UTC](https://discourse.julialang.org/t/pkg-add-action-at-a-distance/57886 "2021-03-24T20:48:17Z")

</div>

I did: (@v1.6) pkg\> add BPFnative \[..\] \[856f044c\] ↓ MKL\_jll v2021.1.1+1 ⇒ v2020.2.254+0 \[da04e1cc\] ↑ MPI v0.16.1 ⇒ v0.17.1 and even with it, I think, installed before to the same version, I got lots of upgrades for…

---

## [EzXML node question](https://discourse.julialang.org/t/ezxml-node-question/57277)

<div class="topic-metadata">

**Author:** [@matianhe3](https://discourse.julialang.org/u/matianhe3)\
**Replies:** 2\
**Last updated:** [March 24, 2021, 6:36pm UTC](https://discourse.julialang.org/t/ezxml-node-question/57277 "2021-03-24T18:36:24Z")

</div>

file = readxml("f0dc19ff.xml") nums = findall("//TT", file) for num in nums counter = findall("//contour", num)) println(length(counter)) \<TT\>\<contour\>\</contour\>\</TT\> \<TT\>\<contour\>\</contour\>\</…

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

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