# General Usage

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

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

**Page:** 841

---

## [Easy saving of Dict{Tuple,Number} to JSON?](https://discourse.julialang.org/t/easy-saving-of-dict-tuple-number-to-json/27607)

<div class="topic-metadata">

**Author:** [@gobs](https://discourse.julialang.org/u/gobs)\
**Replies:** 0\
**Last updated:** [August 16, 2019, 9:30am UTC](https://discourse.julialang.org/t/easy-saving-of-dict-tuple-number-to-json/27607 "2019-08-16T09:30:44Z")

</div>

Hello, I was wondering if there was an easy way to save a Dict{Tuple,Number} (see example below) to JSON. d = Dict((1,:A) =\> 1, (1,:B) =\> 2, (2,:A) =\> 3, (2,:B) =\> 4) I think JSON3 or LazyJSON might be what I’m lookin…

---

## [Any rational behind Symbol("true") != :true?](https://discourse.julialang.org/t/any-rational-behind-symbol-true-true/27597)

<div class="topic-metadata">

**Author:** [@o314](https://discourse.julialang.org/u/o314)\
**Replies:** 8\
**Last updated:** [August 16, 2019, 1:22am UTC](https://discourse.julialang.org/t/any-rational-behind-symbol-true-true/27597 "2019-08-16T01:22:20Z")

</div>

It seems strange to me that using Test @test Symbol("true") != :true Since @test Symbol("foo") == :foo @test Symbol("bar") == :bar @test Symbol("baz") == :baz # ... Suppose we have a function that generate a symbol f…

---

## [More basic Revise usage with module](https://discourse.julialang.org/t/more-basic-revise-usage-with-module/27517)

<div class="topic-metadata">

**Author:** [@pearlzli](https://discourse.julialang.org/u/pearlzli)\
**Replies:** 9\
**Last updated:** [August 15, 2019, 5:15pm UTC](https://discourse.julialang.org/t/more-basic-revise-usage-with-module/27517 "2019-08-15T17:15:53Z")

</div>

Hello, I’m having trouble getting Revise to track changes to my module. I have using Revise in my startup.jl, and I’ve checked that it is indeed being loaded on startup. I then try: (v1.1) pkg\> generate MyPackage Genera…

---

## [Strange behavior of Pkg's version resolver](https://discourse.julialang.org/t/strange-behavior-of-pkgs-version-resolver/27588)

<div class="topic-metadata">

**Author:** [@s-broda](https://discourse.julialang.org/u/s-broda)\
**Replies:** 2\
**Last updated:** [August 15, 2019, 5:11pm UTC](https://discourse.julialang.org/t/strange-behavior-of-pkgs-version-resolver/27588 "2019-08-15T17:11:17Z")

</div>

I have the following Project.toml in https://github.com/s-broda/ARCHModels.jl name = "ARCHModels" uuid = "6d3278bc-c23a-5105-85e5-0d57d2bf684f" authors = \["Simon Broda \<simon.broda@uzh.ch\>"\] version = "0.4.0" \[deps\] Da…

---

## [Thread-local storage initialization](https://discourse.julialang.org/t/thread-local-storage-initialization/27579)

<div class="topic-metadata">

**Author:** [@Reimer](https://discourse.julialang.org/u/Reimer)\
**Replies:** 2\
**Last updated:** [August 15, 2019, 1:57pm UTC](https://discourse.julialang.org/t/thread-local-storage-initialization/27579 "2019-08-15T13:57:26Z")

</div>

I have a problem with a couple (possibly three) C/C++ modules that I interface with Julia. Namely, these modules rely on thread-local state that needs to be initialized with thread-specific state before any code is calle…

---

## [Parametric Types](https://discourse.julialang.org/t/parametric-types/27580)

<div class="topic-metadata">

**Author:** [@mischmi](https://discourse.julialang.org/u/mischmi)\
**Replies:** 2\
**Last updated:** [August 15, 2019, 11:53am UTC](https://discourse.julialang.org/t/parametric-types/27580 "2019-08-15T11:53:09Z")

</div>

Hi there, I have a quick question regarding types. This is my code: struct SomeStruct{L} v::Vector{Int64} function SomeStruct{L}() where L::Integer new( zeros( Int64, L ) ) end end If I want to compile it, I g…

---

## [Translating Fortran to Julia](https://discourse.julialang.org/t/translating-fortran-to-julia/27518)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 7\
**Last updated:** [August 15, 2019, 10:22am UTC](https://discourse.julialang.org/t/translating-fortran-to-julia/27518 "2019-08-15T10:22:48Z")

</div>

I’m translating some old Fortran code to Julia. It’s pretty straightforward, but I only picked up Fortran to be able to translate this project. I see at some points things like c OPENING FILES FOR OUTPUT WRITING …

---

## [Loop over multi-dimensional array optimization](https://discourse.julialang.org/t/loop-over-multi-dimensional-array-optimization/27539)

<div class="topic-metadata">

**Author:** [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Replies:** 9\
**Last updated:** [August 15, 2019, 9:29am UTC](https://discourse.julialang.org/t/loop-over-multi-dimensional-array-optimization/27539 "2019-08-15T09:29:51Z")

</div>

Hi, I encountered a performance bottleneck for array operations. I tried two versions: dot fusion and explicit loop. To my surprise, not only does dot fusion take less time, it also takes less memory, which contradicts …

---

## [Native (oversimplified) Julia gemm implementation](https://discourse.julialang.org/t/native-oversimplified-julia-gemm-implementation/27530)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 6\
**Last updated:** [August 15, 2019, 7:58am UTC](https://discourse.julialang.org/t/native-oversimplified-julia-gemm-implementation/27530 "2019-08-15T07:58:55Z")

</div>

Hi Julians, In the context of a Julia lecture preparation, I have implemented the following (over)simplfied mygemm matrix-matrix product implementation (150 lines): mygemm.jlusing BenchmarkTools using LinearAlgebra usi…

---

## [Selective deconstruction of NamedTuples to local variables?](https://discourse.julialang.org/t/selective-deconstruction-of-namedtuples-to-local-variables/27545)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 2\
**Last updated:** [August 15, 2019, 7:42am UTC](https://discourse.julialang.org/t/selective-deconstruction-of-namedtuples-to-local-variables/27545 "2019-08-15T07:42:24Z")

</div>

Do we have something like nt = (a = 1, b = 2, c = 3, d = 4, e = 5) @some\_macro a, c, d = nt resulting in the creation of local variables a = nt.a c = nt.c d = nt.d somewhere? NamedTuple deconstruction that extracts v…

---

## [How to optimize ForwardDiff.jacobian for large system of equations?](https://discourse.julialang.org/t/how-to-optimize-forwarddiff-jacobian-for-large-system-of-equations/27546)

<div class="topic-metadata">

**Author:** [@josimar](https://discourse.julialang.org/u/josimar)\
**Replies:** 4\
**Last updated:** [August 15, 2019, 12:10am UTC](https://discourse.julialang.org/t/how-to-optimize-forwarddiff-jacobian-for-large-system-of-equations/27546 "2019-08-15T00:10:48Z")

</div>

Hi, I am trying to use ForwardDiff to compute the jacobian of a system of equations that I anticipate will be very large. Below is a very simplified working code that illustrate what I am trying to do. When I run the c…

---

## [How to convert \_\_source\_\_.file to string?](https://discourse.julialang.org/t/how-to-convert-source-file-to-string/27533)

<div class="topic-metadata">

**Author:** [@epogrebnyak](https://discourse.julialang.org/u/epogrebnyak)\
**Replies:** 13\
**Last updated:** [August 14, 2019, 11:33pm UTC](https://discourse.julialang.org/t/how-to-convert-source-file-to-string/27533 "2019-08-14T23:33:06Z")

</div>

I’m trying to extract filename as string from \_\_source\_\_.file. When running code below everything works, typeof(g) is String and it contains path filename. macro file1() return QuoteNode(\_\_source\_\_.file) end f = @fil…

---

## [How to log all output in console to file?](https://discourse.julialang.org/t/how-to-log-all-output-in-console-to-file/27557)

<div class="topic-metadata">

**Author:** [@wenqi\_kou](https://discourse.julialang.org/u/wenqi_kou)\
**Replies:** 1\
**Last updated:** [August 14, 2019, 8:59pm UTC](https://discourse.julialang.org/t/how-to-log-all-output-in-console-to-file/27557 "2019-08-14T20:59:07Z")

</div>

I want to log all outputs in console into a file, including all records automatically generates at run time. For example, when I use Mosek to solve some problems, I need these data logged in the output file. These data …

---

## [Best way to convert a NTuple to a Set](https://discourse.julialang.org/t/best-way-to-convert-a-ntuple-to-a-set/27532)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [August 14, 2019, 8:48pm UTC](https://discourse.julialang.org/t/best-way-to-convert-a-ntuple-to-a-set/27532 "2019-08-14T20:48:51Z")

</div>

I did: julia\> ntup = (1, 2, 3, 4, 5, 6), NTuple{6, Int} julia\> Set(ntup) Set(Any\[(1, 2, 3, 4, 5, 6), NTuple{6,Int64}\]) But I want to get a set of Int64. How can I achieve that?

---

## [Problems with executable compilation using PackageCompiler.jl](https://discourse.julialang.org/t/problems-with-executable-compilation-using-packagecompiler-jl/25892)

<div class="topic-metadata">

**Author:** [@vitreo12](https://discourse.julialang.org/u/vitreo12)\
**Replies:** 14\
**Last updated:** [August 14, 2019, 3:19pm UTC](https://discourse.julialang.org/t/problems-with-executable-compilation-using-packagecompiler-jl/25892 "2019-08-14T15:19:23Z")

</div>

Hello everyone, I was trying to build some julia code into command line applications with PackageCompiler.jl, but I have noticed that, still, they do rely on compiling the functions, or parts of it, on first call. As a…

---

## [Equivalent of setting "receive timeout" value on ZMQ socket](https://discourse.julialang.org/t/equivalent-of-setting-receive-timeout-value-on-zmq-socket/27552)

<div class="topic-metadata">

**Author:** [@Josiah\_Slack](https://discourse.julialang.org/u/Josiah_Slack)\
**Replies:** 0\
**Last updated:** [August 14, 2019, 8:15pm UTC](https://discourse.julialang.org/t/equivalent-of-setting-receive-timeout-value-on-zmq-socket/27552 "2019-08-14T20:15:53Z")

</div>

I’m wondering if there’s an idiomatic way of setting a timeout for recv(socket)?

---

## [Relative performance discrepancy across cpus even with --cpu-target set](https://discourse.julialang.org/t/relative-performance-discrepancy-across-cpus-even-with-cpu-target-set/27503)

<div class="topic-metadata">

**Author:** [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Replies:** 5\
**Last updated:** [August 14, 2019, 8:02pm UTC](https://discourse.julialang.org/t/relative-performance-discrepancy-across-cpus-even-with-cpu-target-set/27503 "2019-08-14T20:02:11Z")

</div>

I’ve been trying to optimize the benchmarks game’s julia programs again, and I’m running into a problem I don’t really know how to work around. The gist is that between two implementations, one is significantly faster…

---

## [Dataframe map function drops empty results](https://discourse.julialang.org/t/dataframe-map-function-drops-empty-results/27505)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 2\
**Last updated:** [August 14, 2019, 4:03pm UTC](https://discourse.julialang.org/t/dataframe-map-function-drops-empty-results/27505 "2019-08-14T16:03:59Z")

</div>

Which is the result i wanted, but not the result i expected. The result I expect in my example below is a group with an empty dataframe for each of the odd values from column a. p.s. documentation does not indicate wh…

---

## [Function calls in global scope, benchmarking, etc](https://discourse.julialang.org/t/function-calls-in-global-scope-benchmarking-etc/27513)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 6\
**Last updated:** [August 14, 2019, 3:10pm UTC](https://discourse.julialang.org/t/function-calls-in-global-scope-benchmarking-etc/27513 "2019-08-14T15:10:18Z")

</div>

I recently asked a Stack Overflow question about interpolating into benchmarking expressions. But I still have some lingering confusion about the impact on performance of passing global variables as arguments to function…

---

## [Redefining constants in functions, confusing behavior](https://discourse.julialang.org/t/redefining-constants-in-functions-confusing-behavior/27538)

<div class="topic-metadata">

**Author:** [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Replies:** 3\
**Last updated:** [August 14, 2019, 2:59pm UTC](https://discourse.julialang.org/t/redefining-constants-in-functions-confusing-behavior/27538 "2019-08-14T14:59:16Z")

</div>

Hello all, I know that redefining constants is discouraged and is only allowed as a convenience. However, I found this confusing: julia\> const x1=0;const x2=0; julia\> function f1() global x1+=1 i-\>i+x1 …

---

## [Overload write?](https://discourse.julialang.org/t/overload-write/27528)

<div class="topic-metadata">

**Author:** [@stephancb](https://discourse.julialang.org/u/stephancb)\
**Replies:** 1\
**Last updated:** [August 14, 2019, 2:44pm UTC](https://discourse.julialang.org/t/overload-write/27528 "2019-08-14T14:44:39Z")

</div>

write(io::IO, x) …

---

## [Top level vs global scope](https://discourse.julialang.org/t/top-level-vs-global-scope/27516)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 4\
**Last updated:** [August 14, 2019, 2:23am UTC](https://discourse.julialang.org/t/top-level-vs-global-scope/27516 "2019-08-14T02:23:35Z")

</div>

The Julia docs contain the terms “top level” and “global scope”. Is the relation between the two this: "top level" === "global scope" or this: "top level" ≈ "global scope" or something else entirely?

---

## [Wrong dictionary key type does not give type error](https://discourse.julialang.org/t/wrong-dictionary-key-type-does-not-give-type-error/27515)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 5\
**Last updated:** [August 14, 2019, 12:35pm UTC](https://discourse.julialang.org/t/wrong-dictionary-key-type-does-not-give-type-error/27515 "2019-08-14T12:35:36Z")

</div>

Shouldn’t the example give a type error instead of key not found error ?? julia\> d=Dict{Tuple{Int,Int}, Int}() Dict{Tuple{Int64,Int64},Int64} with 0 entries julia\> d\[(1,1)\] = 5 5 julia\> d\[(1,1)\] 5 julia\> d\[1\] ERROR: …

---

## [Documentation of keyword arguments confuses me](https://discourse.julialang.org/t/documentation-of-keyword-arguments-confuses-me/27524)

<div class="topic-metadata">

**Author:** [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Replies:** 1\
**Last updated:** [August 14, 2019, 9:53am UTC](https://discourse.julialang.org/t/documentation-of-keyword-arguments-confuses-me/27524 "2019-08-14T09:53:41Z")

</div>

I was trying to pass keyword arguments from function-to-function and encountered the following: julia\> function foo(x;y=10, kwargs...) println(x,y) end foo (generic function with 1 method) julia\> …

---

## [Human-readable externalization for multi-dimensional arrays](https://discourse.julialang.org/t/human-readable-externalization-for-multi-dimensional-arrays/27214)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 23\
**Last updated:** [August 13, 2019, 3:53pm UTC](https://discourse.julialang.org/t/human-readable-externalization-for-multi-dimensional-arrays/27214 "2019-08-13T15:53:05Z")

</div>

Is there an externalization format that is more or less human-readable in a pinch (eg like JSON), but supports multi-dimensional arrays (eg like HDF5), and has a package for Julia?

---

## [Running External Program - getting the programs results not just the stdout](https://discourse.julialang.org/t/running-external-program-getting-the-programs-results-not-just-the-stdout/27499)

<div class="topic-metadata">

**Author:** [@timmm](https://discourse.julialang.org/u/timmm)\
**Replies:** 4\
**Last updated:** [August 13, 2019, 3:28pm UTC](https://discourse.julialang.org/t/running-external-program-getting-the-programs-results-not-just-the-stdout/27499 "2019-08-13T15:28:16Z")

</div>

Hi, I have managed to confuse myself but I am sure there is a simple answer. I have a c++ script I can call this in the terminal with: ./script $InputFile \> $OutputFilePathAndName With the terminal printing the stdou…

---

## [What is a good design pattern for developing parallel types, one designed for safety and the other for performance?](https://discourse.julialang.org/t/what-is-a-good-design-pattern-for-developing-parallel-types-one-designed-for-safety-and-the-other-for-performance/27464)

<div class="topic-metadata">

**Author:** [@philip](https://discourse.julialang.org/u/philip)\
**Replies:** 14\
**Last updated:** [August 13, 2019, 1:46pm UTC](https://discourse.julialang.org/t/what-is-a-good-design-pattern-for-developing-parallel-types-one-designed-for-safety-and-the-other-for-performance/27464 "2019-08-13T13:46:07Z")

</div>

Let’s say I plan to do something a billion times, like simulate draws from a probability distribution. I want to ensure that my code is correct by writing a bunch of checks into the type constructor. E.g. julia\> struct…

---

## [Is the design of lpad wrong?](https://discourse.julialang.org/t/is-the-design-of-lpad-wrong/27494)

<div class="topic-metadata">

**Author:** [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Replies:** 4\
**Last updated:** [August 13, 2019, 12:40pm UTC](https://discourse.julialang.org/t/is-the-design-of-lpad-wrong/27494 "2019-08-13T12:40:23Z")

</div>

I debugged today the columns no aligning OK on displaying a table, and found that the problem boiled down to the behaviour of lpad. Say I am using lpad to pad the titles of columns to width 5. Now consider julia\> s=“Ã…

---

## [Tracing and saving line number of a function call](https://discourse.julialang.org/t/tracing-and-saving-line-number-of-a-function-call/27488)

<div class="topic-metadata">

**Author:** [@epogrebnyak](https://discourse.julialang.org/u/epogrebnyak)\
**Replies:** 3\
**Last updated:** [August 13, 2019, 11:58am UTC](https://discourse.julialang.org/t/tracing-and-saving-line-number-of-a-function-call/27488 "2019-08-13T11:58:01Z")

</div>

I’m trying to trace the filename and line of a function call to use it later in the program. Using stacktrace() in code below, but my goal is revealing line 6 number, and so far I got to knowing line 3. function trace…

---

## [Plots renders exponents not correctly(?)](https://discourse.julialang.org/t/plots-renders-exponents-not-correctly/27495)

<div class="topic-metadata">

**Author:** [@LS64](https://discourse.julialang.org/u/LS64)\
**Replies:** 0\
**Last updated:** [August 13, 2019, 11:38am UTC](https://discourse.julialang.org/t/plots-renders-exponents-not-correctly/27495 "2019-08-13T11:38:02Z")

</div>

Dear all, I try to plot (Plots, GR) some curves with a y-label that contains an exponent. plot\_3 = plot(Time, N, title = "Runs with BNF and Reduction in Oceans", title\_location = :center, label = "", xlabel…

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

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