# General Usage

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

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

**Page:** 901

---

## [Lift and wrap array with custom indexes](https://discourse.julialang.org/t/lift-and-wrap-array-with-custom-indexes/19436)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 13\
**Last updated:** [January 20, 2019, 11:13pm UTC](https://discourse.julialang.org/t/lift-and-wrap-array-with-custom-indexes/19436 "2019-01-20T23:13:55Z")

</div>

I have a function coded for “normal” 1:n axes that takes a matrix, does some manipulation, including slices, LU, etc, gets a vector. I want to generalize this to work with arrays of custom indexes (eg OffsetArray), wi…

---

## [WARNING: Base.GLOBAL\_RNG is deprecated: it has been moved to the standard library package \`Random\`](https://discourse.julialang.org/t/warning-base-global-rng-is-deprecated-it-has-been-moved-to-the-standard-library-package-random/19852)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 5\
**Last updated:** [January 20, 2019, 9:31pm UTC](https://discourse.julialang.org/t/warning-base-global-rng-is-deprecated-it-has-been-moved-to-the-standard-library-package-random/19852 "2019-01-20T21:31:49Z")

</div>

Julia has exited. Press Enter to start a new session. Starting Julia... \_ \_ \_ \_(\_)\_ | A fresh approach to technical computing (\_) | (\_) (\_) | Documentation: https://docs.julialang.o…

---

## [Arguments for Value types](https://discourse.julialang.org/t/arguments-for-value-types/19845)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 2\
**Last updated:** [January 20, 2019, 6:09pm UTC](https://discourse.julialang.org/t/arguments-for-value-types/19845 "2019-01-20T18:09:22Z")

</div>

Are Value types supposed to be able to take any Julia value as an argument? julia\> Val((2,42)) Val{(2, 42)}() julia\> Val(("ok","then")) ERROR: TypeError: in Type, in parameter, expected Type, got Tuple{String,String} S…

---

## [Redefining a function on the fly](https://discourse.julialang.org/t/redefining-a-function-on-the-fly/19815)

<div class="topic-metadata">

**Author:** [@lucaregini](https://discourse.julialang.org/u/lucaregini)\
**Replies:** 10\
**Last updated:** [January 20, 2019, 5:36pm UTC](https://discourse.julialang.org/t/redefining-a-function-on-the-fly/19815 "2019-01-20T17:36:07Z")

</div>

Is it possible to redefine a running function on the fly in Julia? For example given the two following functions: function omy(i) sleep(100) println(“hello”) end function test() for i=1:200 omy(i) end end If I…

---

## [WARNING: Base.MersenneTwister is deprecated: it has been moved to the standard library package \`Random\`](https://discourse.julialang.org/t/warning-base-mersennetwister-is-deprecated-it-has-been-moved-to-the-standard-library-package-random/19842)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 10\
**Last updated:** [January 20, 2019, 3:01pm UTC](https://discourse.julialang.org/t/warning-base-mersennetwister-is-deprecated-it-has-been-moved-to-the-standard-library-package-random/19842 "2019-01-20T15:01:33Z")

</div>

I got this warning. Then, I did “using Random” and also “import Random”. But it did not work still. Can anyone please let me know what’s going on? I’m using Julia version 0.7. julia\> using Random julia\> rand(MersenneTw…

---

## [Making my package enviroment "Evergreen"](https://discourse.julialang.org/t/making-my-package-enviroment-evergreen/19817)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 3\
**Last updated:** [January 20, 2019, 1:06pm UTC](https://discourse.julialang.org/t/making-my-package-enviroment-evergreen/19817 "2019-01-20T13:06:02Z")

</div>

You may have noticed that your web-browser is ever-green If you check your About Firefox today you’ll see you are running FireFox v64.0.2. Now that version was release on January 9, 2019. You might be thinking: “But I…

---

## [Static view](https://discourse.julialang.org/t/static-view/19836)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [January 20, 2019, 11:52am UTC](https://discourse.julialang.org/t/static-view/19836 "2019-01-20T11:52:32Z")

</div>

I am slicing up a Vector{T} to pieces of heterogeneous lengths, which are known at compile-time. Getting StaticArrays would help. Does the following (much simplified for the MWE) make sense? using StaticArrays struct S…

---

## [Optimize a simple code for performance](https://discourse.julialang.org/t/optimize-a-simple-code-for-performance/19809)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 3\
**Last updated:** [January 20, 2019, 9:36am UTC](https://discourse.julialang.org/t/optimize-a-simple-code-for-performance/19809 "2019-01-20T09:36:39Z")

</div>

Hi folks, the other day I was discussing with a colleague about how to speed up things in Julia for performance, and was wondering if anybody could help me improve (so as to learn) the following code. This is a minimal…

---

## [Using UnicodePlots for pretty printing a type](https://discourse.julialang.org/t/using-unicodeplots-for-pretty-printing-a-type/19808)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 6\
**Last updated:** [January 19, 2019, 11:50pm UTC](https://discourse.julialang.org/t/using-unicodeplots-for-pretty-printing-a-type/19808 "2019-01-19T23:50:25Z")

</div>

Hi All, We got a julia struct that represents a sparse matrix. In the literature this matrix is often represented with its plot (like with imshow) because it only has 0s or 1s. We want to define custom show methods for…

---

## [Got a looping of "warning: replacing module myModule"](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 7\
**Last updated:** [January 19, 2019, 11:16pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828 "2019-01-19T23:16:23Z")

</div>

Hi. I have a folder with four .jl file. One is the module file with name myModule.jl, the second one type.jl is the file with all the type definitions, the third one gen\_csv file is the file of function definitions, the …

---

## [Poisson equation solver](https://discourse.julialang.org/t/poisson-equation-solver/19786)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 12\
**Last updated:** [January 19, 2019, 11:11pm UTC](https://discourse.julialang.org/t/poisson-equation-solver/19786 "2019-01-19T23:11:23Z")

</div>

I would like to solve the poisson equation on an annulus (the problem is also rotation symmetric). Is there a recommended package for this? Ideally I would like something that does not need manual installation of depend…

---

## [Removing objects on memory, again. Alternatives to A = nothing?](https://discourse.julialang.org/t/removing-objects-on-memory-again-alternatives-to-a-nothing/19744)

<div class="topic-metadata">

**Author:** [@Juan](https://discourse.julialang.org/u/Juan)\
**Replies:** 8\
**Last updated:** [January 19, 2019, 9:01pm UTC](https://discourse.julialang.org/t/removing-objects-on-memory-again-alternatives-to-a-nothing/19744 "2019-01-19T21:01:55Z")

</div>

I know the documentations says: Julia does not have an analog of MATLAB’s clear function; once a name is defined in a Julia session (technically, in module Main ), it is always present. If memory usage is your conc…

---

## [Is there a way to convert UInt to Int without overflow check?](https://discourse.julialang.org/t/is-there-a-way-to-convert-uint-to-int-without-overflow-check/19820)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 5\
**Last updated:** [January 19, 2019, 5:57pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-convert-uint-to-int-without-overflow-check/19820 "2019-01-19T17:57:56Z")

</div>

Thanks to @kristoffer.carlsson I fixed the immediate problem and can make my PR better (more general); the possible “better compiler” part below still stands; Julia could have done this for the code as is. In my PR for …

---

## [Testing using pre-existing input files](https://discourse.julialang.org/t/testing-using-pre-existing-input-files/19822)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [January 19, 2019, 5:21pm UTC](https://discourse.julialang.org/t/testing-using-pre-existing-input-files/19822 "2019-01-19T17:21:38Z")

</div>

I wonder what the “standard” approach might be to the following problem: A package has tests which refer to pre-existing input files in the package/test folder. When the package is tested within a different folder, the …

---

## [What is the purpose of \`let\` blocks in global scope?](https://discourse.julialang.org/t/what-is-the-purpose-of-let-blocks-in-global-scope/19795)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 3\
**Last updated:** [January 19, 2019, 3:49pm UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-let-blocks-in-global-scope/19795 "2019-01-19T15:49:30Z")

</div>

I was looking at the implementation of randstring when I saw something I didn’t quite understand. function randstring end let b = UInt8\['0':'9';'A':'Z';'a':'z'\] global randstring randstring(r::AbstractRNG, char…

---

## [Detecting a closed channel?](https://discourse.julialang.org/t/detecting-a-closed-channel/9289)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 3\
**Last updated:** [January 19, 2019, 3:32pm UTC](https://discourse.julialang.org/t/detecting-a-closed-channel/9289 "2019-01-19T15:32:41Z")

</div>

i have a very simple producer/consumer situation. chan = Channel{Array{Float64,1}}(1) f1() = use\_data(chan, npoints) t = @task f1() schedule(t) yield() while true data = calc() …

---

## [embedding NamedTuple](https://discourse.julialang.org/t/embedding-namedtuple/19816)

<div class="topic-metadata">

**Author:** [@dmitry-kazakov](https://discourse.julialang.org/u/dmitry-kazakov)\
**Replies:** 0\
**Last updated:** [January 19, 2019, 2:42pm UTC](https://discourse.julialang.org/t/embedding-namedtuple/19816 "2019-01-19T14:42:48Z")

</div>

How to create NamedTuple from C? Considering parameters const char \* names and value\_t \* elements. Or at least getting the type of to use with jl\_new\_structv.

---

## [Bug in matrix times subarray with decreasing index](https://discourse.julialang.org/t/bug-in-matrix-times-subarray-with-decreasing-index/19802)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 2\
**Last updated:** [January 19, 2019, 1:19pm UTC](https://discourse.julialang.org/t/bug-in-matrix-times-subarray-with-decreasing-index/19802 "2019-01-19T13:19:34Z")

</div>

Simple MWE: A = ones(2,2) v = \[1.0; 2.0\] A \* v # \[3.0; 3.0\] A \* v\[2:-1:1\] # \[3.0; 3.0\] A \* view(v, 2:-1:1) # \[2.0; 2.0\] ???? Is this a bug?

---

## [Problem Float32 sparse matrix solver](https://discourse.julialang.org/t/problem-float32-sparse-matrix-solver/19812)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 2\
**Last updated:** [January 19, 2019, 12:29pm UTC](https://discourse.julialang.org/t/problem-float32-sparse-matrix-solver/19812 "2019-01-19T12:29:53Z")

</div>

Hi, The following code fails (MethodError: no method matching lu!(::SparseMatrixCSC{Float32,Int64}, ::Val{true}; check=true)) with julia 1.0.3. using SparseArrays const MyFloat=Float32 n=40 d3=zeros(MyFloat,(n,n)) for…

---

## [Complementarity - Segmentation fault](https://discourse.julialang.org/t/complementarity-segmentation-fault/19804)

<div class="topic-metadata">

**Author:** [@Tims\_Corbett](https://discourse.julialang.org/u/Tims_Corbett)\
**Replies:** 0\
**Last updated:** [January 19, 2019, 6:00am UTC](https://discourse.julialang.org/t/complementarity-segmentation-fault/19804 "2019-01-19T06:00:40Z")

</div>

singularity exec intelmpi-julia0.6.4.img/ julia -e “using Complementarity” signal (11): Segmentation fault while loading /root/.julia/v0.6/ForwardDiff/src/ForwardDiff.jl, in expression starting on line 12 jl\_field\_off…

---

## [MAT Pkg is not defined](https://discourse.julialang.org/t/mat-pkg-is-not-defined/19798)

<div class="topic-metadata">

**Author:** [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Replies:** 1\
**Last updated:** [January 18, 2019, 10:20pm UTC](https://discourse.julialang.org/t/mat-pkg-is-not-defined/19798 "2019-01-18T22:20:20Z")

</div>

Hi All, I have Julia 1.0.3 installed on my computer. I added Pkg MAT but when I want to use the package I get the following error. Can you please let me know what is wrong with it? syntax: extra token "MatlabHDF5File" …

---

## [Is there a way to keep a Python 2 and Python 3 version of PyCall in two separate environments?](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 4\
**Last updated:** [January 18, 2019, 8:52pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763 "2019-01-18T20:52:53Z")

</div>

I’ve got separate projects which use Python 2 or Python 3 dependencies via PyCall. I want to avoid having to recompile everything whenever I need to switch Python versions, so I was hoping I could put a Python-2-built Py…

---

## [Is there a difference between function my\_func(x::SomeAbstractType) and my\_func(x::T) where T \<: SomeAbstractType](https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793)

<div class="topic-metadata">

**Author:** [@philip](https://discourse.julialang.org/u/philip)\
**Replies:** 1\
**Last updated:** [January 18, 2019, 7:43pm UTC](https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793 "2019-01-18T19:43:52Z")

</div>

It doesn’t look like it based on output from @code\_lowered and @code\_native, but I also didn’t read that these are explicitly equivalent. Clearly they are not equivalent in the case of some containing type (e.g. Point{T}…

---

## [Fortran + Julia](https://discourse.julialang.org/t/fortran-julia/2699)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 9\
**Last updated:** [January 18, 2019, 4:27pm UTC](https://discourse.julialang.org/t/fortran-julia/2699 "2019-01-18T16:27:59Z")

</div>

I have something in Fortran like this: subroutine METHOD in file method.f calling subroutine eval; subroutine EVAL in main.f; program MAIN calling METHOD, also in main.f. I can easily call METHOD from Julia with cc…

---

## [Can't get DataFrames and IndexedTables working together.. in Juno!](https://discourse.julialang.org/t/cant-get-dataframes-and-indexedtables-working-together-in-juno/19781)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [January 18, 2019, 1:00pm UTC](https://discourse.julialang.org/t/cant-get-dataframes-and-indexedtables-working-together-in-juno/19781 "2019-01-18T13:00:54Z")

</div>

using DataFrames, IndexedTables REPL, Jupyter or even Juno embedded REPL ==\> all fine Juno code area (“SHIFT-ENTER”) ==\> Juno remains stuck with the gear forever Julia 1.0.2 and latest packages

---

## [Alternatives to access SQL Server from Julia](https://discourse.julialang.org/t/alternatives-to-access-sql-server-from-julia/19751)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 6\
**Last updated:** [January 18, 2019, 10:52am UTC](https://discourse.julialang.org/t/alternatives-to-access-sql-server-from-julia/19751 "2019-01-18T10:52:41Z")

</div>

Hi guys! I am trying to fetch data from SQL Server using Julia. I tried to use ODBC.jl, but there are many bugs. My data is too long and it seems that ODBC.jl is putting garbage due to buffer size or something. I canno…

---

## [Dataframe : Length of column](https://discourse.julialang.org/t/dataframe-length-of-column/19664)

<div class="topic-metadata">

**Author:** [@RobLW](https://discourse.julialang.org/u/RobLW)\
**Replies:** 4\
**Last updated:** [January 18, 2019, 10:12am UTC](https://discourse.julialang.org/t/dataframe-length-of-column/19664 "2019-01-18T10:12:06Z")

</div>

Hello, If I have a DataFrame that for example is 91 rows 3 columns, and I would like to add a 4th column to it which measures the length of the data found in column 3. How can I apply this over each row please. The fol…

---

## [Dispatch using Union and order of arguments](https://discourse.julialang.org/t/dispatch-using-union-and-order-of-arguments/19732)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 5\
**Last updated:** [January 18, 2019, 4:55am UTC](https://discourse.julialang.org/t/dispatch-using-union-and-order-of-arguments/19732 "2019-01-18T04:55:38Z")

</div>

I tried to subtract a type T from a union type with this function (a “poor man’s Core.Compiler.typesubtract”): typesubtract(::Type{Union{T,S}}, ::Type{T}) where {S, T} = S typesubtract(::Type{S}, ::Type{T}) where {S, T}…

---

## [Initialization of R fails on julia 1.1](https://discourse.julialang.org/t/initialization-of-r-fails-on-julia-1-1/19735)

<div class="topic-metadata">

**Author:** [@randy3k](https://discourse.julialang.org/u/randy3k)\
**Replies:** 1\
**Last updated:** [January 17, 2019, 7:38pm UTC](https://discourse.julialang.org/t/initialization-of-r-fails-on-julia-1-1/19735 "2019-01-17T19:38:15Z")

</div>

The following discussion is initiated by the bug report of RCall.jl Error C stack usage too close to the limit (when precompiling w Julia 1.2) · Issue #289 · JuliaInterop/RCall.jl · GitHub saying that RCall.jl is not wo…

---

## [Is there a way to seamlessly inherit vector arithmetic on new types?](https://discourse.julialang.org/t/is-there-a-way-to-seamlessly-inherit-vector-arithmetic-on-new-types/19713)

<div class="topic-metadata">

**Author:** [@philip](https://discourse.julialang.org/u/philip)\
**Replies:** 8\
**Last updated:** [January 17, 2019, 7:19pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-seamlessly-inherit-vector-arithmetic-on-new-types/19713 "2019-01-17T19:19:34Z")

</div>

I’m sure this is doable via macro by iterating through fields of a type, though I don’t have enough fluency with metaprogramming to know how to write this macro easily. But e.g. say I am going to be able to create a bunc…

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

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