# General Usage

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

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

**Page:** 844

---

## [Calculate SVM dual loss effeciently](https://discourse.julialang.org/t/calculate-svm-dual-loss-effeciently/27171)

<div class="topic-metadata">

**Author:** [@Charlie\_He](https://discourse.julialang.org/u/Charlie_He)\
**Replies:** 0\
**Last updated:** [August 5, 2019, 10:12am UTC](https://discourse.julialang.org/t/calculate-svm-dual-loss-effeciently/27171 "2019-08-05T10:12:30Z")

</div>

I am trying to implement a SVM dual optimization problem in Julia. My data set is the 60000x784 MNIST number recognition dataset. Here are my functions for The linear version is very fast: function dual\_loss(α::Vec, X:…

---

## [Checking the uniqueness of a tuple](https://discourse.julialang.org/t/checking-the-uniqueness-of-a-tuple/27161)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 3\
**Last updated:** [August 5, 2019, 9:55am UTC](https://discourse.julialang.org/t/checking-the-uniqueness-of-a-tuple/27161 "2019-08-05T09:55:00Z")

</div>

I have an array of tuples, i.e. Array{Tuple{Int64, Int64}} which I would like to filter by unique items. That is, my uniqueness criteria for a tuple is that (x\_1, x\_2) = (x\_2, x\_1). So if I have a = \[(1, 2), (3, 4), (…

---

## [IndexedTable to DataFrame](https://discourse.julialang.org/t/indexedtable-to-dataframe/26528)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 3\
**Last updated:** [August 5, 2019, 8:17am UTC](https://discourse.julialang.org/t/indexedtable-to-dataframe/26528 "2019-08-05T08:17:32Z")

</div>

I am wondering how to convert an IndexedTable to a DataFrame. There are two posts that offer (partial) solutions to this, but I am not sure if that is (still) the best way. For now, it is not clear to me when it is pr…

---

## [How to use SparseArrays single precision (Float32)?](https://discourse.julialang.org/t/how-to-use-sparsearrays-single-precision-float32/27150)

<div class="topic-metadata">

**Author:** [@Jorge\_Vieyra](https://discourse.julialang.org/u/Jorge_Vieyra)\
**Replies:** 2\
**Last updated:** [August 4, 2019, 11:19pm UTC](https://discourse.julialang.org/t/how-to-use-sparsearrays-single-precision-float32/27150 "2019-08-04T23:19:11Z")

</div>

Hi All, I was just experimenting with a Float32 matrix because I want to see if it’s faster and with enough precision. However to my surprise, I realized that this is not doing what I am expecting: backslash '' (ldiv…

---

## [Support with embedding julia in C++](https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054)

<div class="topic-metadata">

**Author:** [@yogi](https://discourse.julialang.org/u/yogi)\
**Replies:** 12\
**Last updated:** [August 4, 2019, 10:46pm UTC](https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054 "2019-08-04T22:46:02Z")

</div>

We are embedding julia in C++. The first few calls to the function are completed successfully, but after a few times the following error comes up. while loading no file, in expression starting on line 389 jl\_subtype\_le…

---

## [Unexpected 4x slowdown when computing many svds in loop](https://discourse.julialang.org/t/unexpected-4x-slowdown-when-computing-many-svds-in-loop/27148)

<div class="topic-metadata">

**Author:** [@egcjm](https://discourse.julialang.org/u/egcjm)\
**Replies:** 4\
**Last updated:** [August 4, 2019, 4:01pm UTC](https://discourse.julialang.org/t/unexpected-4x-slowdown-when-computing-many-svds-in-loop/27148 "2019-08-04T16:01:06Z")

</div>

I compute svds of N roughly ~100x100 matrices and note a 4x slowdown when I do this in a loop for N \> 100. function f\_svd(n::Int64,a::Array{Float64,2}) for i in 1:n u,s,v = svd(a); end end (in my r…

---

## [Handling multipart/form-data with Mux or HTTP](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918)

<div class="topic-metadata">

**Author:** [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Replies:** 3\
**Last updated:** [August 4, 2019, 1:48pm UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918 "2019-08-04T13:48:21Z")

</div>

Hi everyone! I’m trying to handle the upload of files (several files at the same time) using Mux. I would like to be able to loop over the input parts and for each of them : get the name of the file get the content of…

---

## [Sending Dataframes of different lengths to a CSV file](https://discourse.julialang.org/t/sending-dataframes-of-different-lengths-to-a-csv-file/27064)

<div class="topic-metadata">

**Author:** [@MuadhF](https://discourse.julialang.org/u/MuadhF)\
**Replies:** 3\
**Last updated:** [August 4, 2019, 6:53am UTC](https://discourse.julialang.org/t/sending-dataframes-of-different-lengths-to-a-csv-file/27064 "2019-08-04T06:53:02Z")

</div>

Hi, Is there a way to send DataFrames of different lengths to a CSV file, so that when I open them in Excel, they would appear side by side? Or is there simply a way to create a single DataFrame with varying column len…

---

## [Generated Code needs 2 scopes! module level scope and current scope](https://discourse.julialang.org/t/generated-code-needs-2-scopes-module-level-scope-and-current-scope/27125)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [August 4, 2019, 2:13am UTC](https://discourse.julialang.org/t/generated-code-needs-2-scopes-module-level-scope-and-current-scope/27125 "2019-08-04T02:13:15Z")

</div>

macro instantiate(typ) quote struct $typ end $typ() end |\> esc end tt = @instantiate(TT) # this is ok julia\> f(x) = begin @instantiate NN …

---

## [Is the "isbits union" optimization enabled in Julia 1.1?](https://discourse.julialang.org/t/is-the-isbits-union-optimization-enabled-in-julia-1-1/27130)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 6\
**Last updated:** [August 4, 2019, 2:10am UTC](https://discourse.julialang.org/t/is-the-isbits-union-optimization-enabled-in-julia-1-1/27130 "2019-08-04T02:10:15Z")

</div>

According to the documentation, the so-called “isbits Union optimization” should apply to the following type definition: struct S x :: Union{UInt8, Int16} end Therefore, I would expect isbitstype(S) to be true. Howev…

---

## [How does the General registry work?](https://discourse.julialang.org/t/how-does-the-general-registry-work/27120)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [August 3, 2019, 7:40am UTC](https://discourse.julialang.org/t/how-does-the-general-registry-work/27120 "2019-08-03T07:40:07Z")

</div>

I understand the mechanics, but I am unsure about the actual rules since there is no README (sorry if I missed some discussion or announcement, I tried to look in all the docs). Specifically, From the METADATA days, I…

---

## [Getting the closest method or dispatching method with parameter types without calling](https://discourse.julialang.org/t/getting-the-closest-method-or-dispatching-method-with-parameter-types-without-calling/27057)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 11\
**Last updated:** [August 2, 2019, 6:51pm UTC](https://discourse.julialang.org/t/getting-the-closest-method-or-dispatching-method-with-parameter-types-without-calling/27057 "2019-08-02T18:51:33Z")

</div>

Hi, julia\> f(x::Int,y::Float64) = x\*y f (generic function with 1 method) julia\> f(x::Float64,y::Int) = x/y f (generic function with 2 methods) julia\> f(x::Float64,y::Float64) = x+y f (generic function with 3 methods) …

---

## [Threading 1.3: Run timer on free thread](https://discourse.julialang.org/t/threading-1-3-run-timer-on-free-thread/27110)

<div class="topic-metadata">

**Author:** [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Replies:** 1\
**Last updated:** [August 2, 2019, 2:33pm UTC](https://discourse.julialang.org/t/threading-1-3-run-timer-on-free-thread/27110 "2019-08-02T14:33:41Z")

</div>

I am trying out the new threading infrastructure (1.3) and have code that uses a Timer. It seems that the timer currently is not scheduled on a different thread than the main thread. Is there a way to change that?

---

## [How to dispatch according to the number I put in the type parameter?](https://discourse.julialang.org/t/how-to-dispatch-according-to-the-number-i-put-in-the-type-parameter/27071)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 5\
**Last updated:** [August 2, 2019, 1:11pm UTC](https://discourse.julialang.org/t/how-to-dispatch-according-to-the-number-i-put-in-the-type-parameter/27071 "2019-08-02T13:11:13Z")

</div>

struct MM{N} end f(x::MM{N}) where N\>5 = println("GREATER THAN 5") f(x::MM{N}) where N\<3 = println("LESS THAN 3") f(MM{2}()) I want to dispatch according to the number I put in the type parameter. Is there a way to do…

---

## [Reading gz'ed CSV does not work - length of provided header doesn't match the number of columns](https://discourse.julialang.org/t/reading-gzed-csv-does-not-work-length-of-provided-header-doesnt-match-the-number-of-columns/27106)

<div class="topic-metadata">

**Author:** [@hmmueller](https://discourse.julialang.org/u/hmmueller)\
**Replies:** 7\
**Last updated:** [August 2, 2019, 12:21pm UTC](https://discourse.julialang.org/t/reading-gzed-csv-does-not-work-length-of-provided-header-doesnt-match-the-number-of-columns/27106 "2019-08-02T12:21:51Z")

</div>

I have a trivial program working on a simple gz’ed CSV (available here): using CSV df = CSV.File("Perf\_Health\_MSSQL\\$PTSQL\_Buffer Manager\_Page life expectancy\_21-8h.csv.gz", header=\[:domain, :host, :feature, :oid, …

---

## [Interpolation of expression](https://discourse.julialang.org/t/interpolation-of-expression/27102)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [August 2, 2019, 11:19am UTC](https://discourse.julialang.org/t/interpolation-of-expression/27102 "2019-08-02T11:19:30Z")

</div>

Is there a more elegant way of interpolating x\_i = i, without having to work with strings? This is what I am using now: for i = 1:3 eval(Meta.parse("x$i = $i")) end I haven’t figured out metaprogramming yet …

---

## [When does julia give up on type inference?](https://discourse.julialang.org/t/when-does-julia-give-up-on-type-inference/27077)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 7\
**Last updated:** [August 2, 2019, 9:54am UTC](https://discourse.julialang.org/t/when-does-julia-give-up-on-type-inference/27077 "2019-08-02T09:54:29Z")

</div>

f is a function that has quite a few methods and I use it somewhere deep in the call stack. I have two very similar methods, g, in one of them the return type of f is always inferred correctly for all x, and in the other…

---

## [Cos(pi/2) does not return 0](https://discourse.julialang.org/t/cos-pi-2-does-not-return-0/27081)

<div class="topic-metadata">

**Author:** [@fhagemann](https://discourse.julialang.org/u/fhagemann)\
**Replies:** 6\
**Last updated:** [August 1, 2019, 10:15pm UTC](https://discourse.julialang.org/t/cos-pi-2-does-not-return-0/27081 "2019-08-01T22:15:33Z")

</div>

Hi! While trying out some stuff in Julia, I came across the fact that cos(pi/2) does not give exact 0, but some type dependent output (6e-17 for Float64, -4e-8 for Float32, 5e-4 for Float16). Is this intended? And what …

---

## [Windows 10 WSL: stuck on "using Maxima"](https://discourse.julialang.org/t/windows-10-wsl-stuck-on-using-maxima/27093)

<div class="topic-metadata">

**Author:** [@bernie-wu](https://discourse.julialang.org/u/bernie-wu)\
**Replies:** 0\
**Last updated:** [August 1, 2019, 8:45pm UTC](https://discourse.julialang.org/t/windows-10-wsl-stuck-on-using-maxima/27093 "2019-08-01T20:45:34Z")

</div>

Hi, I am moving all of my developments from windows to Linux because Linux is just more convenient. I am using WSL. Version information can be found below. I installed maxima first before running using Maxima.jl sudo …

---

## [Question about JuMPChance](https://discourse.julialang.org/t/question-about-jumpchance/27056)

<div class="topic-metadata">

**Author:** [@Y\_Li](https://discourse.julialang.org/u/Y_Li)\
**Replies:** 0\
**Last updated:** [August 1, 2019, 12:22am UTC](https://discourse.julialang.org/t/question-about-jumpchance/27056 "2019-08-01T00:22:32Z")

</div>

Hi, this is my first time using JuMPChance package, there seems to be some problems regarding to setting @indepnormal variables. Blockquote using JuMPChance using JuMP using Gurobi var\_para = \[0.1 0.1 0.1\] m\_chanc…

---

## [Store array in cells of DataFrame?](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 2\
**Last updated:** [August 1, 2019, 6:55pm UTC](https://discourse.julialang.org/t/store-array-in-cells-of-dataframe/27088 "2019-08-01T18:55:19Z")

</div>

I’m having trouble with the following behavior: julia\> df = DataFrame(a = Array\[\], b = Int\[\]); push!(df, \[\[1,2,3\], 6\]) 1×2 DataFrame │ Row │ a │ b │ │ │ Array │ Int64 │ ├─────┼───────────┼───────┤ │ …

---

## [Freeze versions for a specific project](https://discourse.julialang.org/t/freeze-versions-for-a-specific-project/27074)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 6\
**Last updated:** [August 1, 2019, 1:24pm UTC](https://discourse.julialang.org/t/freeze-versions-for-a-specific-project/27074 "2019-08-01T13:24:31Z")

</div>

Say I have a project, it has its Project.toml and Manifest.toml files. Everything works right now. How can I freeze/pin the versions of everything this project uses so that whenever I use this project in the future it wi…

---

## [Array of Arrays for months?](https://discourse.julialang.org/t/array-of-arrays-for-months/27022)

<div class="topic-metadata">

**Author:** [@MuadhF](https://discourse.julialang.org/u/MuadhF)\
**Replies:** 6\
**Last updated:** [August 1, 2019, 11:42am UTC](https://discourse.julialang.org/t/array-of-arrays-for-months/27022 "2019-08-01T11:42:37Z")

</div>

Hi, I want to create an array of arrays, where each sub-array contains the period t (month). For example, t\[1\] = \[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12\] t\[2\] = \[ 13, 14, 15, 16 ...\] and so on. I managed to do this using …

---

## [Typed keyword vararg](https://discourse.julialang.org/t/typed-keyword-vararg/26961)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 8\
**Last updated:** [August 1, 2019, 7:54am UTC](https://discourse.julialang.org/t/typed-keyword-vararg/26961 "2019-08-01T07:54:22Z")

</div>

g(;kwargs::Int...) = println(kwargs) julia\> g(x=1,y=2) ERROR: MethodError: no method matching #g#16(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol,Symbol},NamedTuple{(:x, :y),Tuple{Int64,Int64}}}, ::typeof(g)) Closest…

---

## [Allocations in mapreduce/sum etc](https://discourse.julialang.org/t/allocations-in-mapreduce-sum-etc/27053)

<div class="topic-metadata">

**Author:** [@tchr](https://discourse.julialang.org/u/tchr)\
**Replies:** 2\
**Last updated:** [August 1, 2019, 4:11am UTC](https://discourse.julialang.org/t/allocations-in-mapreduce-sum-etc/27053 "2019-08-01T04:11:02Z")

</div>

I’m confused by why the following allocates (this is a reduced example that arose from trying to implement a function from #32739 via higher order functions instead of explicit loops): g(v) = mapreduce(i-\>v\[1\]\*i, +, eac…

---

## [Face Install pkg error on juliabox](https://discourse.julialang.org/t/face-install-pkg-error-on-juliabox/27061)

<div class="topic-metadata">

**Author:** [@imrankhan\_juliaLang](https://discourse.julialang.org/u/imrankhan_juliaLang)\
**Replies:** 0\
**Last updated:** [August 1, 2019, 3:33am UTC](https://discourse.julialang.org/t/face-install-pkg-error-on-juliabox/27061 "2019-08-01T03:33:14Z")

</div>

---

## [Using a \`RemoteChannel\` to talk to the master process in \`pmap\`](https://discourse.julialang.org/t/using-a-remotechannel-to-talk-to-the-master-process-in-pmap/27059)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 0\
**Last updated:** [August 1, 2019, 3:15am UTC](https://discourse.julialang.org/t/using-a-remotechannel-to-talk-to-the-master-process-in-pmap/27059 "2019-08-01T03:15:03Z")

</div>

In my project, I am running large agent-based models on a cluster environment. My typical workflow is a function main that does a complete independent simulation (can take up to 10 minutes!). I usually run pmap after ad…

---

## [Sparse Array Sum along axis](https://discourse.julialang.org/t/sparse-array-sum-along-axis/27054)

<div class="topic-metadata">

**Author:** [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Replies:** 3\
**Last updated:** [August 1, 2019, 1:25am UTC](https://discourse.julialang.org/t/sparse-array-sum-along-axis/27054 "2019-08-01T01:25:10Z")

</div>

Does sum along a dimensional axis not work with sparse arrays? a = sparse(\[1,2,3\], \[1,2,3\], \[ 1, 1, 2\]) sum(a, 1) ERROR: MethodError: objects of type SparseMatrixCSC{Int64,Int64} are not callable Use square brackets \[\]…

---

## [How to reuse the address "/" in Mux.jl+Interact.jl](https://discourse.julialang.org/t/how-to-reuse-the-address-in-mux-jl-interact-jl/27033)

<div class="topic-metadata">

**Author:** [@seeni](https://discourse.julialang.org/u/seeni)\
**Replies:** 1\
**Last updated:** [August 1, 2019, 12:30am UTC](https://discourse.julialang.org/t/how-to-reuse-the-address-in-mux-jl-interact-jl/27033 "2019-08-01T00:30:34Z")

</div>

Am using windows PC to develop my web app using Interact.jl and Mux.jl. It is to load dynamic form by clicking menu buttons in the same address “/” always (ie, to overwrite the existing page) by reusing the “/” address. …

---

## [Iterate over sparse array](https://discourse.julialang.org/t/iterate-over-sparse-array/27055)

<div class="topic-metadata">

**Author:** [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Replies:** 1\
**Last updated:** [July 31, 2019, 11:40pm UTC](https://discourse.julialang.org/t/iterate-over-sparse-array/27055 "2019-07-31T23:40:26Z")

</div>

Since you can create a sparse matrix with row-indices, column-indices, and values, how do you get those back after the creation of the matrix? i = \[1, 2, 3\] j = \[1, 2, 3\] v = \[1, 1, 2\] a = sparse(i, j, v) I hoping for…

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

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