[julia-users] Re: Setting min()=Inf and max()=-Inf

2016-04-12 Thread Anonymous
Those are good points, although I always kind of wondered why Float gets Inf while Int doesn't, I guess there's no way to have Inf belong to 2 distinct concrete types. On Tuesday, April 12, 2016 at 8:08:19 PM UTC-7, Steven G. Johnson wrote: > > > > On Tuesday, April 12, 2016 at 10:22:10 PM

[julia-users] Re: [ANN] Cuba.jl: library for multidimensional numerical integration

2016-04-12 Thread Steven G. Johnson
On Tuesday, April 12, 2016 at 4:51:07 PM UTC-4, Kaj Wiik wrote: > > Very nice work indeed! > > Is it possible to pass 'userdata' to integrand in Julia? It is mentioned > in sources but is not listed in keywords. > You don't need an explicit userdata argument -- this is just a crude simulation

[julia-users] Re: Need help with GR and PyPlot

2016-04-12 Thread Steven G. Johnson
The PyPlot library doesn't currently support the GR backend, mainly because it doesn't know how to do event loops for this backend (which is important for interactive plotting, so that showing the plot doesn't freeze everything else). As I understand it, GR can use Qt or wx for the UI? In

[julia-users] Re: Setting min()=Inf and max()=-Inf

2016-04-12 Thread Steven G. Johnson
On Tuesday, April 12, 2016 at 10:22:10 PM UTC-4, Anonymous wrote: > > Have the Julia developers considered the effects of setting Base.min()=Inf > and Base.max()=-Inf. This is common in real analysis since it plays nice > with set theory, i.e. > It only plays nicely with sets of real

[julia-users] Re: Setting min()=Inf and max()=-Inf

2016-04-12 Thread Anonymous
Hi Eric, Yes that's what I've currently done for a package I'm developing, I was just wondering if this was ever considered as being the default setting, and if the creators decided not to do it because it doesn't play nice with some other aspect of Julia. On Tuesday, April 12, 2016 at

[julia-users] Re: Setting min()=Inf and max()=-Inf

2016-04-12 Thread Eric Forgy
Hi Anonymous, One of the nice things about Julia is that if you want that feature in your code, you just need to do this: import Base: min, max min() = Inf max() = -Inf Voila. It will be a good/fast as if it was in Base (because it is now - for you and anyone using your package) :) I hope

[julia-users] Setting min()=Inf and max()=-Inf

2016-04-12 Thread Anonymous
Have the Julia developers considered the effects of setting Base.min()=Inf and Base.max()=-Inf. This is common in real analysis since it plays nice with set theory, i.e. A ⊆ B => max(A) ≤ max(B) A ⊆ B => min(A) ≥ min(B) Thus since the empty set ø is a subset of every set, the max of it

[julia-users] Need help with GR and PyPlot

2016-04-12 Thread Daniel Carrera
Hello, So... GR is a new plotting framework that is faster than Matplotlib and can be used as a backend for Matplotlib, including Julia's PyPlot package. https://github.com/jheinen/gr http://gr-framework.org/tutorials/matplotlib.html I have installed GR, > Pkg.add("GR") and my reading of the

[julia-users] Re: I am trying to figure out how to pass DataTypes for a dataframe to @ListStore in Gtk.jl

2016-04-12 Thread Eric Forgy
Hi, I'm not sitting at a computer at the moment, but just curious if you've tried ls = @ListStore(eltypes(df)...) Sorry for the noise if that doesn't work :)

[julia-users] Re: I am trying to figure out how to pass DataTypes for a dataframe to @ListStore in Gtk.jl

2016-04-12 Thread Min-Woong Sohn
Yes, I have already looked at the example. I question was how to pass a bunch of DataTypes from a dataframe to the @ListStore(). For example, ls = @ListStore(Int64,Float64) works, while ls = @ListStore(tuple(eltypes(df)...)) does not. I was wondering whether there is a function in Gtk like

Re: [julia-users] Re: sparse rank, sparse nullspace, sparse linear algebra over rationals?

2016-04-12 Thread Laurent Bartholdi
@Stefan: sorry, I had meant that Julia doesn't yet have sparse non-(real/complex) matrices. However, I see that that's wrong too: I can create sparse matrices with Int64 entries. It would now make a lot of sense to implement the algorithms in linbox so as to compute rank etc. of Int or BigInt

Re: [julia-users] MAT/HDF5 writing uint64?

2016-04-12 Thread Dömötör Gulyás
Hi Tim, thanks for the reply, it turned out that not MAT/HDF5 was at fault, but my code that did the array-of-objects to struct-of-arrays (or rather dict-of-arrays) conversion, as the former is incredibly wasteful and hard to deal with in Matlab. For some reason, the way I dynamically created new

[julia-users] Re: [ANN] Cuba.jl: library for multidimensional numerical integration

2016-04-12 Thread Kaj Wiik
Very nice work indeed! Is it possible to pass 'userdata' to integrand in Julia? It is mentioned in sources but is not listed in keywords. Thanks, Kaj On Tuesday, April 12, 2016 at 5:34:32 PM UTC+3, Mosè Giordano wrote: > > A quick update: with new version 0.0.5 the syntax of the integrand >

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Fred
Thank you ! I think I will use this solution : julia> a = [] 0-element Array{Any,1} julia> b = [] 0-element Array{Any,1} julia> push!(a, 1) 1-element Array{Any,1}: 1 julia> push!(a, 2) 2-element Array{Any,1}: 1 2 julia> a 4-element Array{Any,1}: 1 2 3 4 julia> b 4-element

Re: [julia-users] Re: sparse rank, sparse nullspace, sparse linear algebra over rationals?

2016-04-12 Thread Stefan Karpinski
Julia does have complex sparse matrices: julia> C = sparse(rand(1:10, 10), rand(1:10, 10), randn(10) + randn(10)im, 10, 10) 10x10 sparse matrix with 9 Complex{Float64} entries: [7 , 1] = 1.1711-0.587334im [5 , 3] = 0.940755+1.00755im [1 , 4] = 1.51515-1.77335im [4 , 4] =

Re: [julia-users] Re: sparse rank, sparse nullspace, sparse linear algebra over rationals?

2016-04-12 Thread Alex Dowling
Hello Laurent, Thank you for the prompt reply. I noticed your pure Julia code converted to a full matrix. Any luck with the sparse SVD routines? I thought more about my application, and I really want to know the smallest n < 10 singular values and associated vectors for the system. Tight

[julia-users] Re: [ANN] Cuba.jl: library for multidimensional numerical integration

2016-04-12 Thread Oliver Schulz
Very nice, Mose! I thought I might have to write a Julia wrapper for Cuba at some point, but you beat me to it (which I'm grateful for!). :-) I noticed that you're maintaining a modified version of Cuba for this - I guess because the upstream Cuba doesn't support "make shared"? Are you in

Re: [julia-users] Re: sparse rank, sparse nullspace, sparse linear algebra over rationals?

2016-04-12 Thread Laurent Bartholdi
It's tricky, but sprank is definitely not competitive with finer implementations. As you certainly know, rank calculations are very unstable, so if your matrix has integer entries you should prefer an exact method, or a calculation in a finite field. (Sadly, Julia does not contain, yet, sparse

[julia-users] Re: I am trying to figure out how to pass DataTypes for a dataframe to @ListStore in Gtk.jl

2016-04-12 Thread jonathan . bieler
There's an example in the tests: https://github.com/JuliaLang/Gtk.jl/blob/master/test/gui.jl#L476 So it seems like you need to declare your ListStore with the proper types, and the iterate over your dataframe and push the data in.

[julia-users] Re: Gilbert–Johnson–Keerthi distance algorithm

2016-04-12 Thread Tony Kelman
No, wound up not needing it.

[julia-users] Re: sparse rank, sparse nullspace, sparse linear algebra over rationals?

2016-04-12 Thread Alex Dowling
Hello, I am also looking to compute the (approximate) rank of a sparse matrix. For my applications I'm consider dimensions of 10k - 100k by 10k - 100k, not millions by millions. I've previously done this in MATLAB using the sprank command .

Re: [julia-users] MAT/HDF5 writing uint64?

2016-04-12 Thread Tim Holy
I'm not quite following, are these changes to MAT or to how you call MAT? If the former, can you submit the changes to MAT as a pull request? See http://docs.julialang.org/en/stable/manual/packages/#package-development If you can't, let us know and maybe someone else will do it. Best, --Tim

Re: [julia-users] scoping wat

2016-04-12 Thread Didier Verna
Cedric St-Jean wrote: > Your let is broken, it's a no-op. let always creates local bindings :-D I know, it was just for the sake of the example. The let was just to introduce a block, I couldn't do that with begin since begin doesn't introduce a block! > I agree

Re: [julia-users] scoping wat

2016-04-12 Thread Jeff Bezanson
It looks to me like everything in the `for` loop behaves like variables inside a `let` block. Yes, one could argue that a `for` loop variable should always be a new variable, making it equivalent to let i for i = itr ... end end but that does make the constructs less orthogonal.

Re: [julia-users] Re: scoping wat

2016-04-12 Thread Didier Verna
FANG Colin wrote: > I think the complicated scoping rules are inevitable in Julia as it is > a dynamic language. This is wrong. Dynamic is not more complicated (look at Lisp, the rules are very simple). The complication comes from the rules varying depending on the

Re: [julia-users] Creating new globals

2016-04-12 Thread Didier Verna
Cedric St-Jean wrote: > I don't think the point of global is to create a global variable, but > moreso to update one. Yes, that what's I thought. > I use global in dlet to implement special variables: Nice attempt at dynamic scope ! :-) -- ELS'16 registration

[julia-users] Re: [ANN] Cuba.jl: library for multidimensional numerical integration

2016-04-12 Thread Chris Rackauckas
Nice! I was looking for a Vegas function awhile ago and the GSL.jl one isn't bound correctly yet. This will be a nice addition to the Julia package list. Good job! On Sunday, April 10, 2016 at 1:34:53 PM UTC-7, Mosè Giordano wrote: > > Dear all, > > I am proud to announce Cuba.jl

[julia-users] Re: Help with parallel computing for optimization.

2016-04-12 Thread Jiahao Chen
Looks like the bug report ClusterManagers.jl#31. Can you try Pkg.checkout("ClusterManagers") and see if that works for you?

Re: [julia-users] scoping wat

2016-04-12 Thread Stefan Karpinski
On Tue, Apr 12, 2016 at 12:33 PM, Jeff Bezanson wrote: > > And then, some like "for" do or don't, it depends. > > Is that really true? I don't believe there is a case where `for` > behaves differently than `let`. > julia> i = 1 1 julia> for i = 2:10

[julia-users] I am trying to figure out how to pass DataTypes for a dataframe to @ListStore in Gtk.jl

2016-04-12 Thread Min-Woong Sohn
I tried: ls = @ListStore(tuple(eltypes(df)...)) but did not work. Does anyone know how I can do this?

Re: [julia-users] MAT/HDF5 writing uint64?

2016-04-12 Thread Dömötör Gulyás
Alright, while the previous code didn't properly propagate data types for some reason, this does: obj = objects[1] fieldNames = fieldnames(objects[1]) typeDict = mapreduce(name -> Dict(string(name) => typeof(obj.(name))), merge, fieldNames) outDict = Dict(map(fieldType ->

Re: [julia-users] scoping wat

2016-04-12 Thread Jeff Bezanson
As for how assignments introduce local variables: it was quite deliberate (and the right decision IMO) that the *presence* of an assignment to a variable creates a local variable, and not whether the assignment has actually executed yet. I'm talking about this example: x = 10 function foo()

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread John Pearson
In this very long discussion (and maybe some PRs referenced therein). I think the rationale was that it doesn't really make sense to have Normal, etc.

[julia-users] Re: [ANN] VulkanCore

2016-04-12 Thread Simon Danisch
Thanks :) @Eric Forgy: I hope that we can bring some of the comfort you have in the Web to native Julia and GPU computing ;) If and when that'll be achieved is an open question... >I haven't tried GLVisualize - isn't there a problem with high-performance 3D in a stop-the-world GC'ed language

Re: [julia-users] Nested global functions

2016-04-12 Thread Stefan Karpinski
Issue created: https://github.com/JuliaLang/julia/issues/15844. On Tue, Apr 12, 2016 at 11:28 AM, Stefan Karpinski wrote: > This should definitely be added. > > On Tue, Apr 12, 2016 at 9:02 AM, Yichao Yu wrote: > >> On Tue, Apr 12, 2016 at 5:22 AM,

Re: [julia-users] Nested global functions

2016-04-12 Thread Stefan Karpinski
This should definitely be added. On Tue, Apr 12, 2016 at 9:02 AM, Yichao Yu wrote: > On Tue, Apr 12, 2016 at 5:22 AM, Didier Verna > wrote: > > > > Hello, > > > > I would have expected that this would work (but this is a syntax error): > > let > >

Re: [julia-users] MAT/HDF5 writing uint64?

2016-04-12 Thread Dömötör Gulyás
I've apparently made some progress... the following code: outDict = mapreduce(name -> Dict(string(name) => Array{typeof(obj.(name)), 1}()), merge, fieldNames) produced all Array{Float64,1} arrays, and I'm still trying to figure out why, as typeDict = mapreduce(name -> Dict(string(name) =>

Re: [julia-users] Creating new globals

2016-04-12 Thread Scott Jones
The syntax to make an empty generic function wasn't added until v0.4, so that may be why older code uses global. On Tuesday, April 12, 2016 at 8:05:36 AM UTC-4, Didier Verna wrote: > > Mauro wrote: > > > If I understand correctly, you argue that all global bindings should

[julia-users] Re: Gilbert–Johnson–Keerthi distance algorithm

2016-04-12 Thread Edward Schmerling
Hi Tony, I just found this post - I haven't implemented a GJK solver in Julia (I'm currently calling existing C++ implementations through Cxx.jl ), but did you ever get around to working on this? Thanks, Ed On Wednesday, June 3, 2015 at 5:47:44 AM UTC-7, Tony

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread Jason Merrill
On Tuesday, April 12, 2016 at 8:29:25 AM UTC-4, John Pearson wrote: > > AD numbers are subtypes of Real. This is not quite mathematically correct > (there's a long discussion on GitHub), but in this case, practicality beats > purity. > Do you have a reference to the discussion about AD numbers

[julia-users] Some sort of sandboxing and scheduling and persistence of state

2016-04-12 Thread Aaron R. M.
Hey I'm looking for a solution to some problems that i have using Julia as a general purpose language. Given that there are no access modifiers i cannot restrict people calling functions i don't want them to call. Use case is a game (yeah that's somewhat new territory) that has its codebase

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Fred
Thank you very much Matt. In fact I will work with floats, but the idea to concatenate 2 columns is good ! Le mardi 12 avril 2016 16:58:21 UTC+2, Matt Bauman a écrit : > > It'd probably be fastest if you can pre-allocate your array: > > A = Array(ASCIIString, 3, 2) > for i=1:size(A, 1) >

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 10:58 AM, Matt Bauman wrote: > It'd probably be fastest if you can pre-allocate your array: > > A = Array(ASCIIString, 3, 2) > for i=1:size(A, 1) > A[i, 1] = string('w'+i, 1) > A[i, 2] = string('w'+i, 2) > end > > If you don't know how many

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Matt Bauman
It'd probably be fastest if you can pre-allocate your array: A = Array(ASCIIString, 3, 2) for i=1:size(A, 1) A[i, 1] = string('w'+i, 1) A[i, 2] = string('w'+i, 2) end If you don't know how many elements you'll have, you can use two column vectors, `c1` and `c2`, and push to them

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread John Pearson
The new parameterized distributions will promote the inputs to the same type (see here ). Some of the multivariate parameterizations in this

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Fred
Thank you very much Tim ! In fact I want to create an X,Y array so if I create a 1D array, I can only append to it (x1,y1) then (x2,y2)... (xn, yn), because I calculate x1 before x2... julia> d = ["x1", "y1", "x2", "y2", "x3", "y3"] 6-element Array{ASCIIString,1}: "x1" "y1" "x2" "y2" "x3"

Re: [julia-users] scoping wat

2016-04-12 Thread Erik Schnetter
On Tue, Apr 12, 2016 at 9:05 AM, Cedric St-Jean wrote: > > On Tuesday, April 12, 2016 at 8:52:23 AM UTC-4, Didier Verna wrote: >> >> Mauro wrote: >> >> > Maybe you can be a bit more explicit in what you mean, examples would >> > help too. >> >>

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread Jameson Quinn
Yes, parameterizing Normal (and other distributions) would solve my problem perfectly. The question then is: would it be necessary to separately parameterize each parameter, or is it better to just force people to use either exclusively floats or exclusively AD numbers? On Tuesday, 12 April

[julia-users] Re: [ANN] Cuba.jl: library for multidimensional numerical integration

2016-04-12 Thread Mosè Giordano
A quick update: with new version 0.0.5 the syntax of the integrand function has been changed and now the integrand function should be passed as in Cubature,jl, for the case of vector-valued integrands. So, for example, to integrate log(x)/sqrt(x) for x in [0, 1], one can use one of the

Re: [julia-users] What is Task switch not allowed from inside gc finalizer?

2016-04-12 Thread Tim Holy
Presumably you could also `push!` the output to some global buffer, whose contents then get displayed at some later time. Best, --Tim On Tuesday, April 12, 2016 09:42:33 AM Yichao Yu wrote: > On Tue, Apr 12, 2016 at 9:31 AM, FANG Colin wrote: > > What's the easiest way to

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Tim Holy
Note that in `a = Array{Float64,2}`, `a` is a *type*, not an *instance*. You presumably mean `a = Array(Float64, 0, 0)`. But Yichao is right that you can't grow a 2d array, only a 1d one. Best, --Tim On Tuesday, April 12, 2016 09:44:16 AM Yichao Yu wrote: > On Tue, Apr 12, 2016 at 9:38 AM,

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Fred
Thank you very much Yichao ! This explain all the problems I have... But it still unclear : I cannot create an empty 1D array and resize it : julia> b = Array[] 0-element Array{Array{T,N},1} julia> b = Array[] 0-element Array{Array{T,N},1} julia> reshape(b,2,2) ERROR: DimensionMismatch("new

Re: [julia-users] is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread Erik Schnetter
On Tue, Apr 12, 2016 at 3:43 AM, DNF wrote: > But what if you do have a very small number of elements? Let's say I am > working with 2D or 3D points and wonder whether to represent them as > vectors, tuples or a custom type, like > > immutable Point2D{T<:Real} > x::T >

Re: [julia-users] Re: is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread DNF
On Tuesday, April 12, 2016 at 3:50:13 PM UTC+2, Yichao Yu wrote: > > > NTuple is just a constructor for tuple so there's no difference. > Ah. OK, thanks. It's a bit clearer now.

[julia-users] MAT/HDF5 writing uint64?

2016-04-12 Thread Dömötör Gulyás
Hi, in an attempt to export some data to Matlab that's an 'uint64' array, I discovered that apparently all arrays are written out as 'double', thus mangling my data. Is there a way to get the MAT package to respect data types when writing the .mat files? As an aside, I checked that reading

Re: [julia-users] Re: is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 9:43 AM, DNF wrote: > Ah! [Foreheadslapping] For some reason I thought it didn't matter in this > case, but of course it does. > > So, is this less of a problem with NTuple as array then, than with Tuple, > because the length is known? NTuple is just a

Re: [julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 9:38 AM, Fred wrote: > Hi ! > > The questions I have is so trivial that I spend a long time trying to find > an example on the doc and on the web but I did not manage to do exactly what > I want : > > I want to create an empty 2D array : the

Re: [julia-users] What is Task switch not allowed from inside gc finalizer?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 9:31 AM, FANG Colin wrote: > What's the easiest way to print the object in finalizer? ccall(:jl_, Void, (Any,), obj) or if it can be delayed to the next task switch. @schedule ... > > On 12 April 2016 at 14:16, Yichao Yu wrote:

Re: [julia-users] Re: is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread DNF
Ah! [Foreheadslapping] For some reason I thought it didn't matter in this case, but of course it does. So, is this less of a problem with NTuple as array then, than with Tuple, because the length is known? On Tuesday, April 12, 2016 at 3:06:09 PM UTC+2, Yichao Yu wrote: > > On Tue, Apr 12,

Re: [julia-users] local types or macros?

2016-04-12 Thread Cedric St-Jean
On Tue, Apr 12, 2016 at 9:25 AM, Yichao Yu wrote: > On Tue, Apr 12, 2016 at 9:18 AM, Cedric St-Jean > wrote: > > > > > > On Tuesday, April 12, 2016 at 8:59:54 AM UTC-4, Yichao Yu wrote: > >> > >> > >> Macros cannot be scope local (without major change

[julia-users] Creating an empty 2D array and append values to it

2016-04-12 Thread Fred
Hi ! The questions I have is so trivial that I spend a long time trying to find an example on the doc and on the web but I did not manage to do exactly what I want : I want to create an empty 2D array : the function readdlm create exactly the kind of array I want if I read a CSV file with 2

Re: [julia-users] What is Task switch not allowed from inside gc finalizer?

2016-04-12 Thread FANG Colin
What's the easiest way to print the object in finalizer? On 12 April 2016 at 14:16, Yichao Yu wrote: > On Tue, Apr 12, 2016 at 8:15 AM, FANG Colin wrote: > > type C > >x::Symbol > > > >function C(x::Symbol) > > c = new(x) > >

Re: [julia-users] local types or macros?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 9:18 AM, Cedric St-Jean wrote: > > > On Tuesday, April 12, 2016 at 8:59:54 AM UTC-4, Yichao Yu wrote: >> >> >> Macros cannot be scope local (without major change of everything) >> since they are executed at compile time and doesn't know anything in

Re: [julia-users] local types or macros?

2016-04-12 Thread Cedric St-Jean
On Tuesday, April 12, 2016 at 8:59:54 AM UTC-4, Yichao Yu wrote: > > > Macros cannot be scope local (without major change of everything) > since they are executed at compile time and doesn't know anything in > the scope. > Local macros in Lisp are expanded at compile-time. They're useful

Re: [julia-users] What is Task switch not allowed from inside gc finalizer?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 8:15 AM, FANG Colin wrote: > type C >x::Symbol > >function C(x::Symbol) > c = new(x) > finalizer(c, c->println(1, c, 2)) > c > end > end > > a = C(:x) > a = 1 > gc() > > error in running finalizer: ErrorException("task

Re: [julia-users] const functions

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 7:56 AM, Mauro wrote: > On Tue, 2016-04-12 at 13:47, Didier Verna wrote: >> Mauro wrote: >> >>> yes, this just binds a function to a variable. This also works: >>> >>> julia> foo() = 1 >>> foo (generic

Re: [julia-users] Re: is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 5:43 AM, DNF wrote: > Wow! That is a huge difference. > > I suspected that my benchmark was flawed, but I don't understand in what > way, since is doesn't seem like anything is being inappropriately optimized > away. Quite the contrary, my benchmark is

Re: [julia-users] scoping wat

2016-04-12 Thread Cedric St-Jean
On Tuesday, April 12, 2016 at 8:52:23 AM UTC-4, Didier Verna wrote: > > Mauro wrote: > > > Maybe you can be a bit more explicit in what you mean, examples would > > help too. > > Sorry for the fuzziness. This is an example of what I mean: > > let > x = 10 > end >

[julia-users] Re: scoping wat

2016-04-12 Thread FANG Colin
I think the complicated scoping rules are inevitable in Julia as it is a dynamic language. Every layer of flexibility in the language comes with a cost. static languages normally have simple scoping rules (And IDE can help a lot with static analysis). Functional languages have even simpler

Re: [julia-users] Nested global functions

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 5:22 AM, Didier Verna wrote: > > Hello, > > I would have expected that this would work (but this is a syntax error): > let > global function f(x) 2x end > end FWIW, this can be written as global f function f AFAIK nothing is preventing

Re: [julia-users] local types or macros?

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 5:18 AM, Didier Verna wrote: > > What's the reason for restricting types and macros to the toplevel? > Isn't there something like macrolet? For types, it will be much harder for the compiler to infer anything about it, if a new type is to be

[julia-users] Re: Defining Python classes from Julia

2016-04-12 Thread Cedric St-Jean
Hello World in Django involves 4 Python files, whose relationships I'm not 100% clear on, so I haven't written an example for it. But this framework-less web server works, so I don't see why Django wouldn't using PyCall @pyimport textwrap @pyimport BaseHTTPServer as HS @pydef type

Re: [julia-users] scoping wat

2016-04-12 Thread FANG Colin
Python has similar rules. x = 10 def foo(): print x x = 5 print x foo() UnboundLocalError: local variable 'x' referenced before assignment On Tuesday, April 12, 2016 at 1:52:23 PM UTC+1, Didier Verna wrote: > > Mauro wrote: > > > Maybe you can be a bit

Re: [julia-users] local vs. let

2016-04-12 Thread Yichao Yu
On Tue, Apr 12, 2016 at 5:07 AM, Didier Verna wrote: > > It seems to me that forcing a variable to be local with the "local" > keyword is just like creating a new binding for it using "let". So why > both? local can also be used to pre-declare a variable to lift the

Re: [julia-users] scoping wat

2016-04-12 Thread Didier Verna
Mauro wrote: > Maybe you can be a bit more explicit in what you mean, examples would > help too. Sorry for the fuzziness. This is an example of what I mean: let x = 10 end here, the same expression "x = 10" will either assign a new value to x if such a /global/

Re: [julia-users] Access to gmp from library?

2016-04-12 Thread Milan Bouchet-Valat
Le samedi 09 avril 2016 à 12:16 -0400, Isaiah Norton a écrit : > > 1) It seems that Julia includes libgmp.{so,dylib} but not gmp.h, > > which is necessary for the C library's compilation >   > There was some prior discussion about this, for a similar reason [1], > but I think they eventually

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread John Pearson
Yes, this will work, I think. What you're doing is adding an outer constructor to Normal that in fact constructs something else. The only problem you might run into is that other functions that expect a Normal may not accept your custom type. More info: For Distributions.jl, the strategy has

[julia-users] What is Task switch not allowed from inside gc finalizer?

2016-04-12 Thread FANG Colin
type C x::Symbol function C(x::Symbol) c = new(x) finalizer(c, c->println(1, c, 2)) c end end a = C(:x) a = 1 gc() error in running finalizer: ErrorException("task switch not allowed from inside gc finalizer") However, it works if I manually call finalizer(a).

Re: [julia-users] Creating new globals

2016-04-12 Thread Cedric St-Jean
I don't think the point of global is to create a global variable, but moreso to update one. Julia follows Python rules, aa = 10 function foo() aa = 20 end foo() aa # returns 10. Would return 20 if global had been used. I've also seen a lot of code like function bar() @eval global

Re: [julia-users] Creating new globals

2016-04-12 Thread Didier Verna
Mauro wrote: > If I understand correctly, you argue that all global bindings should > be declared in the (lexical) global scope. An inner scope could then > use that binding by using `global`. But new global bindings could not > be created in local scopes. I think that

Re: [julia-users] const functions

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 13:47, Didier Verna wrote: > Mauro wrote: > >> yes, this just binds a function to a variable. This also works: >> >> julia> foo() = 1 >> foo (generic function with 1 method) >> >> julia> bar = foo >> foo (generic function with 1

[julia-users] Re: What version of libstdc++6 does libjulia.so use?

2016-04-12 Thread Tony Kelman
Perhaps trying to make everything rtld local, and/or renaming the Julia included copy of libstdc++ and using something like patchelf to fix up all the other libraries and executables that link to it.

Re: [julia-users] Creating new globals

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 12:21, Didier Verna wrote: > Mauro wrote: > >> On Tue, 2016-04-12 at 11:10, Didier Verna wrote: >>> Hello, >>> >>> I'm wondering if anyone has ever seen an actual use for dynamically >>> creating a new

[julia-users] Re: Defining Python classes from Julia

2016-04-12 Thread Páll Haraldsson
On Friday, April 8, 2016 at 8:59:33 PM UTC, Steven G. Johnson wrote: > > Just FYI, cstjean has implemented a really cool new feature in PyCall ( > https://github.com/stevengj/PyCall.jl/pull/250 ... requires PyCall > master at the moment): you can now define new Python classes easily from >

Re: [julia-users] How to load data from a *.mat file on all workers in Julia 0.4.5 without require()?

2016-04-12 Thread Tim Holy
This is covered is multiple previous posts to the mailing list. https://groups.google.com/forum/#!searchin/julia-users/@everywhere$20using/julia-users/5Xf7duBT6WI/Q8sCr44qBwAJ https://groups.google.com/d/msg/julia-users/KKscQCby0GM/cOr2Dr3aAAAJ Best, --Tim On Tuesday, April 12, 2016 03:41:48 AM

[julia-users] How to load data from a *.mat file on all workers in Julia 0.4.5 without require()?

2016-04-12 Thread 'Jhan Jar' via julia-users
Hi, In Julia 0.3.5, the following loaded data on all workers: addprocs(3) require("data_loading_script.jl") Contents of my data_loading_script.jl were akin to: using MAT source_file = matopen(data_filename) var1 = read(source_file, "var1"); var2 = read(source_file,

Re: [julia-users] Symbolic Distributions?

2016-04-12 Thread Jameson Quinn
Hmm... I guess that this may be a non-issue. I tried the following: type Foo a::Float64 end function Foo(a::Int64) a end Foo(1.0) #Foo(1.0) Foo(1) #1 ...and it seems there's no syntactic issues with having a function named the same as a type which returns

Re: [julia-users] Creating new globals

2016-04-12 Thread Didier Verna
Mauro wrote: > On Tue, 2016-04-12 at 11:10, Didier Verna wrote: >> Hello, >> >> I'm wondering if anyone has ever seen an actual use for dynamically >> creating a new global variable by using the "global" keyword from >> within a local scope? > >

Re: [julia-users] scoping wat

2016-04-12 Thread Mauro
Maybe you can be a bit more explicit in what you mean, examples would help too. The only bit of the scoping rules which I find a bit questionable is that functions in a local scope have soft-scope (otherwise they have hard-scope). This has been discussed on github, search for "nonlocal". On

Re: [julia-users] Modules and r/o

2016-04-12 Thread Didier Verna
Mauro wrote: > On Tue, 2016-04-12 at 11:03, Didier Verna wrote: >> What is the rationale behind module state being read-only from the outside? > > Encapsulation? Seems good to me. Hmmm. Not convinced. There are different facets to

Re: [julia-users] const functions

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 11:40, Didier Verna wrote: > What's the rationale behind making "function" const? Is there a > performance reason? Yes, globals need to be const to be fast. > you can't do > > function foo() 0 end > foo = 10 > > but you can still change the

Re: [julia-users] Creating new globals

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 11:10, Didier Verna wrote: > Hello, > > I'm wondering if anyone has ever seen an actual use for dynamically > creating a new global variable by using the "global" keyword from within > a local scope?

[julia-users] Re: is accessing tuple elements more efficient than accessing elements of a 1d array?

2016-04-12 Thread DNF
Wow! That is a huge difference. I suspected that my benchmark was flawed, but I don't understand in what way, since is doesn't seem like anything is being inappropriately optimized away. Quite the contrary, my benchmark is running slowly with lots of allocations. The question remains, though,

Re: [julia-users] Modules and r/o

2016-04-12 Thread Mauro
On Tue, 2016-04-12 at 11:03, Didier Verna wrote: > What is the rationale behind module state being read-only from the outside? Encapsulation? Seems good to me. > Is this only be default (i.e., is there a construct to still allow > writing)? Use a function julia>

[julia-users] const functions

2016-04-12 Thread Didier Verna
What's the rationale behind making "function" const? Is there a performance reason? you can't do function foo() 0 end foo = 10 but you can still change the function's definition (so it's methods; even if the generic remains the same object I guess), and besides, you can however do this:

[julia-users] Nested global functions

2016-04-12 Thread Didier Verna
Hello, I would have expected that this would work (but this is a syntax error): let global function f(x) 2x end end This is ok however: let global f = x -> 2x end Why isn't the first form allowed? Thanks. -- ELS'16 registration open! http://www.european-lisp-symposium.org Lisp,

[julia-users] local types or macros?

2016-04-12 Thread Didier Verna
What's the reason for restricting types and macros to the toplevel? Isn't there something like macrolet? Thanks. -- ELS'16 registration open! http://www.european-lisp-symposium.org Lisp, Jazz, Aïkido: http://www.didierverna.info

[julia-users] scoping wat

2016-04-12 Thread Didier Verna
Hi, I'm quite puzzled by the complication of Julia's scoping rules, and in particular this way of constantly and implicitly mixing binding and assignment, with varying semantics according to the context. The manual is not convincing (at least to me) in justifying what's happening. Most of the

[julia-users] Creating new globals

2016-04-12 Thread Didier Verna
Hello, I'm wondering if anyone has ever seen an actual use for dynamically creating a new global variable by using the "global" keyword from within a local scope? -- ELS'16 registration open! http://www.european-lisp-symposium.org Lisp, Jazz, Aïkido: http://www.didierverna.info

[julia-users] local vs. let

2016-04-12 Thread Didier Verna
It seems to me that forcing a variable to be local with the "local" keyword is just like creating a new binding for it using "let". So why both? -- ELS'16 registration open! http://www.european-lisp-symposium.org Lisp, Jazz, Aïkido: http://www.didierverna.info

  1   2   >