# General Usage

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

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

**Page:** 1024

---

## [Ccall() to ioctl](https://discourse.julialang.org/t/ccall-to-ioctl/6219)

<div class="topic-metadata">

**Author:** [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)\
**Replies:** 16\
**Last updated:** [October 3, 2017, 9:07pm UTC](https://discourse.julialang.org/t/ccall-to-ioctl/6219 "2017-10-03T21:07:04Z")

</div>

Hi, I’m trying to make a ccall to ioctl, but I seem to be getting the parameter types wrong. Here’s some code: const I2C\_SLAVE = 0x0703 addr = 0x1D if ((file = open(filename,"r+")) \< 0) error("Failed to open the b…

---

## [Bad default behavior for \`Date\` string parsing](https://discourse.julialang.org/t/bad-default-behavior-for-date-string-parsing/6202)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 2\
**Last updated:** [October 3, 2017, 8:48pm UTC](https://discourse.julialang.org/t/bad-default-behavior-for-date-string-parsing/6202 "2017-10-03T20:48:18Z")

</div>

Expected behavior: Date("") throws an ArgumentError. (DateTime("") does this). Actual behavior: Date("") returns Date() == Date(1,1,1). This seems bad. Has this already been discussed? Comments before I submit an iss…

---

## [Does Julia allow subpackages?](https://discourse.julialang.org/t/does-julia-allow-subpackages/6207)

<div class="topic-metadata">

**Author:** [@Alexander\_Belopolsky](https://discourse.julialang.org/u/Alexander_Belopolsky)\
**Replies:** 5\
**Last updated:** [October 3, 2017, 5:20pm UTC](https://discourse.julialang.org/t/does-julia-allow-subpackages/6207 "2017-10-03T17:20:49Z")

</div>

Is it possible to define a module A and a submodule B without including B code in A directly or via an include() call? The goal is for “import A” not to load A.B and require users to explicitly “import A.B”.

---

## ["using" module within the same file where module was defined](https://discourse.julialang.org/t/using-module-within-the-same-file-where-module-was-defined/6211)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [October 3, 2017, 2:22pm UTC](https://discourse.julialang.org/t/using-module-within-the-same-file-where-module-was-defined/6211 "2017-10-03T14:22:08Z")

</div>

I have the following scheme for writing tests: in a single file I define multiple modules, which are then “used” and the test function defined within them is run. module mmiscellaneous1mmm using FinEtools using Test…

---

## [Accessing a list of a function's keyword arguments?](https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215)

<div class="topic-metadata">

**Author:** [@carlosbrody](https://discourse.julialang.org/u/carlosbrody)\
**Replies:** 1\
**Last updated:** [October 3, 2017, 12:22pm UTC](https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215 "2017-10-03T12:22:15Z")

</div>

Can code inside function access a list of ll its keyword arguments? I am writing a function with multiple keyword arguments, and I want to check the type of each of the arguments. An example might be something like fun…

---

## [Sending code to workers](https://discourse.julialang.org/t/sending-code-to-workers/6216)

<div class="topic-metadata">

**Author:** [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Replies:** 0\
**Last updated:** [October 3, 2017, 12:07pm UTC](https://discourse.julialang.org/t/sending-code-to-workers/6216 "2017-10-03T12:07:57Z")

</div>

As I want to keep everything as simple as possible, I figured out that I can send code to all Julia workers simply by @eval @everywhere Base.include\_string($(readstring(open("mycode.jl")))) and that works amazingly we…

---

## [Uninitialized ("random") value of bits type](https://discourse.julialang.org/t/uninitialized-random-value-of-bits-type/6197)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [October 3, 2017, 11:20am UTC](https://discourse.julialang.org/t/uninitialized-random-value-of-bits-type/6197 "2017-10-03T11:20:36Z")

</div>

I need a “placeholder” value of a (parametric) bits type, for type stability, in certain branches of my code. Ie I need a function f such that f(T) isa T. When T \<: Number, zero(T) works, but I need something more genera…

---

## [Properly using \`finalizer\`, \`ccall\`, \`cconvert\` and \`unsafe\_convert\`](https://discourse.julialang.org/t/properly-using-finalizer-ccall-cconvert-and-unsafe-convert/6183)

<div class="topic-metadata">

**Author:** [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Replies:** 13\
**Last updated:** [October 3, 2017, 7:56am UTC](https://discourse.julialang.org/t/properly-using-finalizer-ccall-cconvert-and-unsafe-convert/6183 "2017-10-03T07:56:33Z")

</div>

I have problems when using finalizers with my Julia v0.6. I am using Atom when writing/running the code if this makes any difference. As for the minimal working example, consider having the following C API: extern "C" …

---

## [Continuous integration with Drone.io](https://discourse.julialang.org/t/continuous-integration-with-drone-io/6203)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 1\
**Last updated:** [October 3, 2017, 7:46am UTC](https://discourse.julialang.org/t/continuous-integration-with-drone-io/6203 "2017-10-03T07:46:17Z")

</div>

Hello, sorry for cross posting here… but I think it could be worth to do it. I installed RancherOS http://rancher.com/rancher-os/ (a small Docker distribution) and have both Gitea https://gitea.io/ (an hosted Github li…

---

## [Bug in Nullable?](https://discourse.julialang.org/t/bug-in-nullable/6210)

<div class="topic-metadata">

**Author:** [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Replies:** 1\
**Last updated:** [October 3, 2017, 3:16am UTC](https://discourse.julialang.org/t/bug-in-nullable/6210 "2017-10-03T03:16:39Z")

</div>

Tried isfinite(Nullable(1)) Get error ERROR: MethodError: no method matching isfinite(::Nullable{Int64}) Closest candidates are: isfinite(::Float16) at float.jl:539 isfinite(::BigFloat) at mpfr.jl:831 isfinite(:…

---

## [Equivalent of map\_coordinates in Julia](https://discourse.julialang.org/t/equivalent-of-map-coordinates-in-julia/5648)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 3\
**Last updated:** [October 2, 2017, 6:10pm UTC](https://discourse.julialang.org/t/equivalent-of-map-coordinates-in-julia/5648 "2017-10-02T18:10:51Z")

</div>

Is someone aware of a Julia equivalent of the Python function scipy.ndimage.map\_coordinates? I’ve looked at Interpolations.jl but couldn’t find this exact feature. In order to port a code from Python to Julia I need th…

---

## [Passing NULL as an argument through ccall?](https://discourse.julialang.org/t/passing-null-as-an-argument-through-ccall/6190)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 4\
**Last updated:** [October 2, 2017, 4:34pm UTC](https://discourse.julialang.org/t/passing-null-as-an-argument-through-ccall/6190 "2017-10-02T16:34:44Z")

</div>

I cannot seem to figure out how to pass NULL as an argument to a function through the C interface. I’m using Ref{UInt8} as the argument type. I’m thinking that I could probably declare it as an Int and just pass 0, but…

---

## [Running Generators as single line version of a for loop](https://discourse.julialang.org/t/running-generators-as-single-line-version-of-a-for-loop/6196)

<div class="topic-metadata">

**Author:** [@krcools](https://discourse.julialang.org/u/krcools)\
**Replies:** 5\
**Last updated:** [October 2, 2017, 4:26pm UTC](https://discourse.julialang.org/t/running-generators-as-single-line-version-of-a-for-loop/6196 "2017-10-02T16:26:20Z")

</div>

Is there an elegant way to run a Generator? What I want is this: \>@run println(i) for i in 1:3 1 2 3 By the following definition I can get pretty close: \>macro run(ex) :(for x in ($ex); end) end \>@run (println…

---

## [TOPLEVEL Expressions](https://discourse.julialang.org/t/toplevel-expressions/6153)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [October 2, 2017, 7:01am UTC](https://discourse.julialang.org/t/toplevel-expressions/6153 "2017-10-02T07:01:12Z")

</div>

What is a top level expression? And what is the difference between expressions whose head is :toplevel and :top? Thanks

---

## [How to assert type after if-else](https://discourse.julialang.org/t/how-to-assert-type-after-if-else/6185)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 5\
**Last updated:** [October 2, 2017, 6:57am UTC](https://discourse.julialang.org/t/how-to-assert-type-after-if-else/6185 "2017-10-02T06:57:51Z")

</div>

Suppose my code looks like this: if condition x = complicated\_expression y = another\_complicated\_expression else x = a\_third\_complicated\_expression y = a fourth\_complicated\_expres…

---

## [Bring back deprecation warnings](https://discourse.julialang.org/t/bring-back-deprecation-warnings/6181)

<div class="topic-metadata">

**Author:** [@anon67531922](https://discourse.julialang.org/u/anon67531922)\
**Replies:** 6\
**Last updated:** [October 1, 2017, 4:59pm UTC](https://discourse.julialang.org/t/bring-back-deprecation-warnings/6181 "2017-10-01T16:59:59Z")

</div>

Hi, It’s been a while since I did any work with Julia and want to update some packages for 0.6. When I installed my packages, several deprecation warnings showed, but they only showed once. How can I see the deprecation…

---

## [Read Vector{UInt8} lines from a gzipped file (optimization)](https://discourse.julialang.org/t/read-vector-uint8-lines-from-a-gzipped-file-optimization/6135)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [October 1, 2017, 1:58pm UTC](https://discourse.julialang.org/t/read-vector-uint8-lines-from-a-gzipped-file-optimization/6135 "2017-10-01T13:58:53Z")

</div>

I am reading (and parsing) a huge dataset, essentially ASCII lines in gzipped files. I have optimized the parsing part, now I am trying to figure out how to just read the lines efficiently. I am using the excellent Code…

---

## [@eval and module scope](https://discourse.julialang.org/t/eval-and-module-scope/6166)

<div class="topic-metadata">

**Author:** [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Replies:** 5\
**Last updated:** [October 1, 2017, 6:36am UTC](https://discourse.julialang.org/t/eval-and-module-scope/6166 "2017-10-01T06:36:01Z")

</div>

(migrated from Slack) Consider this code function define\_ops(x) for sym in (:pos, :pes) @eval $(sym)(y) = y + $x end end define\_ops(2) pos(3) #5 Works perfectly But if I try to do it in …

---

## [Problems with addprocs connection to second machine](https://discourse.julialang.org/t/problems-with-addprocs-connection-to-second-machine/6060)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 11\
**Last updated:** [September 30, 2017, 7:36pm UTC](https://discourse.julialang.org/t/problems-with-addprocs-connection-to-second-machine/6060 "2017-09-30T19:36:27Z")

</div>

I am having problems connecting to julia on a second machine via ssh. it is odd, because a plain run call allows me to connect fine. the addprocs call always times out. here is my example: julia\> versioninfo() Julia Ver…

---

## [Unit testing non standard string literal macros](https://discourse.julialang.org/t/unit-testing-non-standard-string-literal-macros/6164)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 0\
**Last updated:** [September 30, 2017, 9:10am UTC](https://discourse.julialang.org/t/unit-testing-non-standard-string-literal-macros/6164 "2017-09-30T09:10:31Z")

</div>

What’s the recommended way to write unit tests for non-standard string literal macros, say foo\_str? Best I could come up with is str = "what goes in" x = @eval @foo\_str($str) @test something(x) == supposed\_to\_be(str) I…

---

## [Which approach for an efficient and handy "getData(dim1,dim2..)" function?](https://discourse.julialang.org/t/which-approach-for-an-efficient-and-handy-getdata-dim1-dim2-function/6131)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [September 29, 2017, 2:52pm UTC](https://discourse.julialang.org/t/which-approach-for-an-efficient-and-handy-getdata-dim1-dim2-function/6131 "2017-09-29T14:52:03Z")

</div>

Hello, I need to write some code where often I need to pick-up (and sometimes set) multidimensional data. The query function must have some own-logic. For example, for some dimension it should return the national data …

---

## [PyCall: couldn't find libpython](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 4\
**Last updated:** [September 29, 2017, 12:07pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116 "2017-09-29T12:07:19Z")

</div>

I’m in the rather unfortunate position of having to use CentOS (unfortunate because everything on the latest version of CentOS is ancient). Anyway, of course there is no way of installing a reasonablly recent version of…

---

## [Efficient sorting of 2 Vectors with many duplicate values?](https://discourse.julialang.org/t/efficient-sorting-of-2-vectors-with-many-duplicate-values/6156)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 2\
**Last updated:** [September 29, 2017, 11:53am UTC](https://discourse.julialang.org/t/efficient-sorting-of-2-vectors-with-many-duplicate-values/6156 "2017-09-29T11:53:36Z")

</div>

I have two vectors, X, Y that represent positions of 2D points. Both of these vectors have a lot of duplicates, but there is no duplicate point (i.e. many points have same x or y coords, but no points have both x and y t…

---

## [Does command interpolation work on Windows?](https://discourse.julialang.org/t/does-command-interpolation-work-on-windows/6139)

<div class="topic-metadata">

**Author:** [@Diego\_Javier\_Zea](https://discourse.julialang.org/u/Diego_Javier_Zea)\
**Replies:** 2\
**Last updated:** [September 29, 2017, 10:34am UTC](https://discourse.julialang.org/t/does-command-interpolation-work-on-windows/6139 "2017-09-29T10:34:06Z")

</div>

I have a code that does something like: run(̣\`$julia\_path $script\_path\`) It works perfect on linux (where I’m developing), but I’m getting the following error on AppVeyor (Windows): ERROR: LoadError: syntax: invalid …

---

## [Get first match in a dictionary of tuples](https://discourse.julialang.org/t/get-first-match-in-a-dictionary-of-tuples/6128)

<div class="topic-metadata">

**Author:** [@tuckermcclure](https://discourse.julialang.org/u/tuckermcclure)\
**Replies:** 11\
**Last updated:** [September 28, 2017, 7:38pm UTC](https://discourse.julialang.org/t/get-first-match-in-a-dictionary-of-tuples/6128 "2017-09-28T19:38:36Z")

</div>

I have a dictionary of tuples. Inside one of those tuples is one thing I care about. What’s the best way to find that one thing? How can I make it fast? I feel like I have some things to learn about associative collectio…

---

## [How set the MPI.jl environment and how to know which compiler is using?](https://discourse.julialang.org/t/how-set-the-mpi-jl-environment-and-how-to-know-which-compiler-is-using/5979)

<div class="topic-metadata">

**Author:** [@mmonterrubio](https://discourse.julialang.org/u/mmonterrubio)\
**Replies:** 11\
**Last updated:** [September 28, 2017, 2:59pm UTC](https://discourse.julialang.org/t/how-set-the-mpi-jl-environment-and-how-to-know-which-compiler-is-using/5979 "2017-09-28T14:59:44Z")

</div>

Hello, I’m new in MPI for Julia and I want to use it for my model. My problem is related with the linking between the package folder .julia/v6.0/MPI with the MPI. It seems that Julia lost the link and I don’t know how t…

---

## [Apply recipe based on eltype](https://discourse.julialang.org/t/apply-recipe-based-on-eltype/6133)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 1\
**Last updated:** [September 28, 2017, 2:00pm UTC](https://discourse.julialang.org/t/apply-recipe-based-on-eltype/6133 "2017-09-28T14:00:37Z")

</div>

I have a type like this struct Errorful val::Float64 std::Float64 end that represents a number with an error bar. I would like to have a @recipe, such that plotting an array of these @assert eltype(ys) == Erro…

---

## [Does Julia have an analog of Python's readinto method?](https://discourse.julialang.org/t/does-julia-have-an-analog-of-pythons-readinto-method/6123)

<div class="topic-metadata">

**Author:** [@Alexander\_Belopolsky](https://discourse.julialang.org/u/Alexander_Belopolsky)\
**Replies:** 1\
**Last updated:** [September 27, 2017, 8:58pm UTC](https://discourse.julialang.org/t/does-julia-have-an-analog-of-pythons-readinto-method/6123 "2017-09-27T20:58:18Z")

</div>

Is there a way to read data from a binary stream directly into a pre-existing vector without making a copy? In Python, I can use the readinto method. Does Julia have anything similar?

---

## [How to do one-liners and other short conditionals?](https://discourse.julialang.org/t/how-to-do-one-liners-and-other-short-conditionals/6100)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 10\
**Last updated:** [September 27, 2017, 8:28pm UTC](https://discourse.julialang.org/t/how-to-do-one-liners-and-other-short-conditionals/6100 "2017-09-27T20:28:47Z")

</div>

Sometimes I want to write a quick and dirty conditional, i.e. munge\_data!(x,y) if isempty(x) But instead you have to write: if isempty(x) munge\_data!(x,y) end // which I don’t think is as readable. How do other peo…

---

## [Getting Varargs typestable](https://discourse.julialang.org/t/getting-varargs-typestable/6122)

<div class="topic-metadata">

**Author:** [@foobar\_lv](https://discourse.julialang.org/u/foobar_lv)\
**Replies:** 2\
**Last updated:** [September 27, 2017, 8:24pm UTC](https://discourse.julialang.org/t/getting-varargs-typestable/6122 "2017-09-27T20:24:54Z")

</div>

I find myself in the situation of having to evaluate some boolean circuits on a lot of inputs. Well, this is what bitvector is supposed to be good at, but it currently accepts a very limited number of hand-coded circuits…

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

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