# General Usage

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

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

**Page:** 1002

---

## [Equals Problem](https://discourse.julialang.org/t/equals-problem/8530)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 3\
**Last updated:** [January 22, 2018, 9:08pm UTC](https://discourse.julialang.org/t/equals-problem/8530 "2018-01-22T21:08:50Z")

</div>

julia\> struct Field name::Symbol typ::Type Field(name::Symbol,typ::Symbol) = new(name,eval(typ)) end julia\> #no need to check the type! closest function Base.broadcast(::ty…

---

## [Object Serialization In Julia](https://discourse.julialang.org/t/object-serialization-in-julia/8442)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [January 22, 2018, 8:14pm UTC](https://discourse.julialang.org/t/object-serialization-in-julia/8442 "2018-01-22T20:14:43Z")

</div>

Is there a package for serialization/deserialization of types in Julia? Thanks

---

## [Clang.jl large library](https://discourse.julialang.org/t/clang-jl-large-library/8483)

<div class="topic-metadata">

**Author:** [@mopg](https://discourse.julialang.org/u/mopg)\
**Replies:** 8\
**Last updated:** [January 22, 2018, 6:42pm UTC](https://discourse.julialang.org/t/clang-jl-large-library/8483 "2018-01-22T18:42:14Z")

</div>

I am trying to link Julia to a large C library. I was thinking that that wouldn’t be an issue given that everyone always says it is straightforward to link C to Julia with minimal performance loss. My problem is that I h…

---

## [Examples/tutorials for using PyPlot (directly)](https://discourse.julialang.org/t/examples-tutorials-for-using-pyplot-directly/8486)

<div class="topic-metadata">

**Author:** [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Replies:** 13\
**Last updated:** [January 22, 2018, 10:53am UTC](https://discourse.julialang.org/t/examples-tutorials-for-using-pyplot-directly/8486 "2018-01-22T10:53:32Z")

</div>

I am writing up some notes for some students (several who have never done computer programming before) to do basic plotting. The issue is that the documentation for PyPlot is targeted at people who are able to read the …

---

## [How does scope work for declaring functions](https://discourse.julialang.org/t/how-does-scope-work-for-declaring-functions/8474)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 12\
**Last updated:** [January 22, 2018, 10:37am UTC](https://discourse.julialang.org/t/how-does-scope-work-for-declaring-functions/8474 "2018-01-22T10:37:54Z")

</div>

I have not found any good resources on this. I cannot find anything helpful in the Julia docs entry on scopes. However I have had problems with it and found enough instances were I have no idea what is going on and would…

---

## [Recursive code\_warntype?](https://discourse.julialang.org/t/recursive-code-warntype/8513)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 4\
**Last updated:** [January 22, 2018, 9:58am UTC](https://discourse.julialang.org/t/recursive-code-warntype/8513 "2018-01-22T09:58:22Z")

</div>

Is there any way to check type instabilities on all functions called by the main function recursively only displaying as far as the last instability (i.e. only package functions not Julia Base functions) or up to a certa…

---

## [Embedding: thread safety requirements](https://discourse.julialang.org/t/embedding-thread-safety-requirements/3304)

<div class="topic-metadata">

**Author:** [@twadleigh](https://discourse.julialang.org/u/twadleigh)\
**Replies:** 3\
**Last updated:** [January 22, 2018, 4:22am UTC](https://discourse.julialang.org/t/embedding-thread-safety-requirements/3304 "2018-01-22T04:22:20Z")

</div>

The embedding section of the manual is silent on this topic, but I’m under the impression that the embedding API is not thread-safe. I want to be able to invoke an instance of the Julia runtime from different threads in …

---

## [NamedTuple vs Field](https://discourse.julialang.org/t/namedtuple-vs-field/8423)

<div class="topic-metadata">

**Author:** [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Replies:** 9\
**Last updated:** [January 21, 2018, 2:46pm UTC](https://discourse.julialang.org/t/namedtuple-vs-field/8423 "2018-01-21T14:46:23Z")

</div>

I was wondering whether there is a performance penalty of using NamedTuples instead of just Fields of structs. If, for example, I have an Atom and depending on what calculations you want to do there could be different da…

---

## [Help Installing julia v0.5.2/v0.6 on fresh ubuntu install](https://discourse.julialang.org/t/help-installing-julia-v0-5-2-v0-6-on-fresh-ubuntu-install/3640)

<div class="topic-metadata">

**Author:** [@TravisA9](https://discourse.julialang.org/u/TravisA9)\
**Replies:** 16\
**Last updated:** [January 21, 2018, 10:34am UTC](https://discourse.julialang.org/t/help-installing-julia-v0-5-2-v0-6-on-fresh-ubuntu-install/3640 "2018-01-21T10:34:26Z")

</div>

Hello, I have \[re\]installed julia on several windows and linux systems over the last 2 or 3 years with little problem but I’m having trouble on a fresh install of Ubuntu 17.x I’m sure I’m probably overlooking something …

---

## [using Interact.jl on windows](https://discourse.julialang.org/t/using-interact-jl-on-windows/8499)

<div class="topic-metadata">

**Author:** [@magzpavz](https://discourse.julialang.org/u/magzpavz)\
**Replies:** 2\
**Last updated:** [January 21, 2018, 2:07am UTC](https://discourse.julialang.org/t/using-interact-jl-on-windows/8499 "2018-01-21T02:07:58Z")

</div>

I just wanted to share something here in case another person with a Windows computer is trying to follow Steven Johnson’s IAP 2018 class. In lecture 2 they suggest you use the package Interact.jl. This package by default…

---

## [Cfunction pointer back to Function?](https://discourse.julialang.org/t/cfunction-pointer-back-to-function/8488)

<div class="topic-metadata">

**Author:** [@jayschwa](https://discourse.julialang.org/u/jayschwa)\
**Replies:** 6\
**Last updated:** [January 20, 2018, 10:38pm UTC](https://discourse.julialang.org/t/cfunction-pointer-back-to-function/8488 "2018-01-20T22:38:41Z")

</div>

julia\> foo() = Cint(1) foo (generic function with 1 method) julia\> ptr = cfunction(foo, Cint, Tuple{}) Ptr{Nothing} @0x00007f5dacc48510 Is it possible to derive foo from ptr?

---

## [How to implement fast range reads for my custome-defined array?](https://discourse.julialang.org/t/how-to-implement-fast-range-reads-for-my-custome-defined-array/8490)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 2\
**Last updated:** [January 20, 2018, 10:33pm UTC](https://discourse.julialang.org/t/how-to-implement-fast-range-reads-for-my-custome-defined-array/8490 "2018-01-20T22:33:29Z")

</div>

I need to implement my own array type underlying which is still a Vector, but reading/writing to it is much much slower than reading/writing the vanilla Julia array. I can reproduce the problem in this simple program bel…

---

## [Translate Matlab code to Julia code](https://discourse.julialang.org/t/translate-matlab-code-to-julia-code/8485)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 4\
**Last updated:** [January 20, 2018, 3:53pm UTC](https://discourse.julialang.org/t/translate-matlab-code-to-julia-code/8485 "2018-01-20T15:53:43Z")

</div>

I am trying to translate my Matlab code to Julia code, so I can use Julia as my main tool in teaching. I ran into an issue that I could not solve. Below is my Matlab code: clear all m = 0; % mean sd= 1; %std deviation …

---

## [What is \`Char\`?](https://discourse.julialang.org/t/what-is-char/8480)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 6\
**Last updated:** [January 20, 2018, 2:47pm UTC](https://discourse.julialang.org/t/what-is-char/8480 "2018-01-20T14:47:46Z")

</div>

Here’s something that came as a surprise A = UInt8\['a', 'b', 'c'\] ptr = convert(Ptr{Char}, pointer(A)) a = unsafe\_load(ptr, 1) # this is not 'a'; it is '\\U636261' so Julia for some reason decided to load a 24-bit Ch…

---

## [Plots.jl with GR: exporting to PDF](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461)

<div class="topic-metadata">

**Author:** [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Replies:** 6\
**Last updated:** [January 20, 2018, 12:59pm UTC](https://discourse.julialang.org/t/plots-jl-with-gr-exporting-to-pdf/8461 "2018-01-20T12:59:16Z")

</div>

Exporting to PDF by savefig() cuts off part of the (vertical) axis label in the resulting PDF file. Is there a way to increase the size of the resulting bounding box or at least to manipulate the relative distance of th…

---

## [Fallback method error reporting](https://discourse.julialang.org/t/fallback-method-error-reporting/8473)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [January 19, 2018, 1:46pm UTC](https://discourse.julialang.org/t/fallback-method-error-reporting/8473 "2018-01-19T13:46:42Z")

</div>

In an API I ask the user to define custom types and also methods for them for a collection of functions. When this is not done, a MethodError is thrown automatically since nothing is defined, but I wonder if I could make…

---

## [Decoding conflict in requirements](https://discourse.julialang.org/t/decoding-conflict-in-requirements/8471)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 11\
**Last updated:** [January 20, 2018, 10:16am UTC](https://discourse.julialang.org/t/decoding-conflict-in-requirements/8471 "2018-01-20T10:16:54Z")

</div>

May someone help me decode the following conflict in requirements, or point me to a reference? julia\> Pkg.checkout("Optim") INFO: Checking out Optim master... INFO: Pulling Optim latest master... WARNING: julia is fixed…

---

## [Make functions in modules use functions in global scope](https://discourse.julialang.org/t/make-functions-in-modules-use-functions-in-global-scope/8481)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 6\
**Last updated:** [January 19, 2018, 8:48pm UTC](https://discourse.julialang.org/t/make-functions-in-modules-use-functions-in-global-scope/8481 "2018-01-19T20:48:53Z")

</div>

I have this module: export test\_func function test\_func() return funk(x) end end and I have this program funk(x) = 2 test\_func() which gives the error UndefVarError: funk not defined. Is there a …

---

## [PyCall: Weirdish PyArray conversion performance behaviour](https://discourse.julialang.org/t/pycall-weirdish-pyarray-conversion-performance-behaviour/8454)

<div class="topic-metadata">

**Author:** [@davidavdav](https://discourse.julialang.org/u/davidavdav)\
**Replies:** 2\
**Last updated:** [January 19, 2018, 2:48pm UTC](https://discourse.julialang.org/t/pycall-weirdish-pyarray-conversion-performance-behaviour/8454 "2018-01-19T14:48:21Z")

</div>

Hello, I have a PyCall-wrapped python module (musdb) that natively gives me PyArray{Float64}, which can be fairly large. At some stage I need an Array{Float32} of this, but conversion times vary a lot: @elapsed conver…

---

## [Fetch image from webcam](https://discourse.julialang.org/t/fetch-image-from-webcam/8463)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [January 19, 2018, 1:57pm UTC](https://discourse.julialang.org/t/fetch-image-from-webcam/8463 "2018-01-19T13:57:29Z")

</div>

I want to fetch an image from a connected webcam. I’d rather avoid saving the image to disk. I know I can achieve this with VideoIO: using Images import VideoIO f = VideoIO.opencamera("/dev/video1") img = read(f) But s…

---

## [Stack arrays into array with extra dimension](https://discourse.julialang.org/t/stack-arrays-into-array-with-extra-dimension/8470)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [January 19, 2018, 12:29pm UTC](https://discourse.julialang.org/t/stack-arrays-into-array-with-extra-dimension/8470 "2018-01-19T12:29:18Z")

</div>

This pattern comes up often for me (eg analyizing simulations, posterior predictive checks). I have a solution, but I wonder if there is a better one. MWE: """ Collect arrays in the argument such that \`stack1(v)\[1, fil…

---

## [Recommended setup for developing packages](https://discourse.julialang.org/t/recommended-setup-for-developing-packages/5725)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 19\
**Last updated:** [January 19, 2018, 11:10am UTC](https://discourse.julialang.org/t/recommended-setup-for-developing-packages/5725 "2018-01-19T11:10:17Z")

</div>

When I work on my own Julia packages, I currently do a Pkg.clone(...) from my git repository to install the package with all its dependencies and register it to the package system. After that I delete the package folder …

---

## [Mediand, std, var to accept function as first argument](https://discourse.julialang.org/t/mediand-std-var-to-accept-function-as-first-argument/8313)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 15\
**Last updated:** [January 19, 2018, 8:36am UTC](https://discourse.julialang.org/t/mediand-std-var-to-accept-function-as-first-argument/8313 "2018-01-19T08:36:57Z")

</div>

Functions sum, mean, maximum etc. accept a function as first argument mean(f::Function, v) Apply the function f to each element of v and take the mean. julia\> mean(√, \[1, 2, 3\]) 1.3820881233139908 Functions std…

---

## [Weird behaviour when flattening generator expression with vcat](https://discourse.julialang.org/t/weird-behaviour-when-flattening-generator-expression-with-vcat/8382)

<div class="topic-metadata">

**Author:** [@Paethon](https://discourse.julialang.org/u/Paethon)\
**Replies:** 12\
**Last updated:** [January 19, 2018, 8:24am UTC](https://discourse.julialang.org/t/weird-behaviour-when-flattening-generator-expression-with-vcat/8382 "2018-01-19T08:24:11Z")

</div>

Hi I am using Julia 0.6.2 and have written the following function. (Data generation added as by request) # Generate testdata function fillpath(path, nbfiles) cd(path) mkdir("juliatest") cd("juliatest") …

---

## [How do these Union{Missing, T}s differ in practice?](https://discourse.julialang.org/t/how-do-these-union-missing-t-s-differ-in-practice/8464)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 2\
**Last updated:** [January 19, 2018, 6:56am UTC](https://discourse.julialang.org/t/how-do-these-union-missing-t-s-differ-in-practice/8464 "2018-01-19T06:56:44Z")

</div>

const MaybeReal = Union{Missing, Real} const RealMaybe = Union{Missing, T} where T\<:Real

---

## [Unsafe\_string and C\_NULL](https://discourse.julialang.org/t/unsafe-string-and-c-null/8459)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 1\
**Last updated:** [January 18, 2018, 5:51pm UTC](https://discourse.julialang.org/t/unsafe-string-and-c-null/8459 "2018-01-18T17:51:06Z")

</div>

I just want to make sure I am not reinventing the wheel here. A library of C functions I am working with return const char \* which I want to use as a Julia String. If the string should be empty they return C\_NULL. I c…

---

## [Multithreading on the Mac](https://discourse.julialang.org/t/multithreading-on-the-mac/8436)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 8\
**Last updated:** [January 18, 2018, 4:28pm UTC](https://discourse.julialang.org/t/multithreading-on-the-mac/8436 "2018-01-18T16:28:51Z")

</div>

Has anyone made some (good) experiences with MT on the Mac? I have a code that runs well MTed on Linux (up to 64 cores w/ corresponding number of threads), but it clearly leaves some performance on the table when run on …

---

## [Documenting a functor / callable struct](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444)

<div class="topic-metadata">

**Author:** [@jmert](https://discourse.julialang.org/u/jmert)\
**Replies:** 5\
**Last updated:** [January 18, 2018, 1:47pm UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444 "2018-01-18T13:47:26Z")

</div>

I’m interested in providing a docstring for a functor / callable struct I’m using, but I have to questions about that: How do you correctly query for the doc string at the REPL? The ?MyFunc (assuming code below) obviou…

---

## [Localizing variables: performance implications?](https://discourse.julialang.org/t/localizing-variables-performance-implications/8329)

<div class="topic-metadata">

**Author:** [@SepandMeenu](https://discourse.julialang.org/u/SepandMeenu)\
**Replies:** 7\
**Last updated:** [January 18, 2018, 12:23pm UTC](https://discourse.julialang.org/t/localizing-variables-performance-implications/8329 "2018-01-18T12:23:15Z")

</div>

Is there any advantage to localizing variables in a Julia function? As an example, suppose that MyStruct is a mutable struct with a field x: mutable struct MyStruct x0 # ... end and a function which takes an…

---

## [How do I disable deprecated warnings in Julia 0.6?](https://discourse.julialang.org/t/how-do-i-disable-deprecated-warnings-in-julia-0-6/6173)

<div class="topic-metadata">

**Author:** [@fufjvnvnf](https://discourse.julialang.org/u/fufjvnvnf)\
**Replies:** 2\
**Last updated:** [January 18, 2018, 12:10pm UTC](https://discourse.julialang.org/t/how-do-i-disable-deprecated-warnings-in-julia-0-6/6173 "2018-01-18T12:10:15Z")

</div>

Many of the packages I try to use comes way before Julia 0.6, and they are throwing deprecated warnings everywhere. Is there a way to disable all deprecated warnings on startup?

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

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