Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Gustavo Goretkin
Similarly,

julia> immutable bar
   a::Float64
   end

julia> bar(NaN) == bar(NaN)
true

julia> NaN == NaN
false

On Mon, Dec 7, 2015 at 8:24 PM, Seth  wrote:

> I was just about to post this result, which I don't understand. Why should
>
> 0.0 == -0.0
>
> but bar(0.0) != bar(-0.0) when bar is immutable? (yes, you can override ==
> for this to be ==(x::bar, y::bar) = x.a == y.a, but that seems as if it
> should be unnecessary.)
>
>
> On Monday, December 7, 2015 at 5:14:28 PM UTC-8, Yichao Yu wrote:
>
>> On Mon, Dec 7, 2015 at 7:01 PM, Davide Lasagna 
>> wrote:
>> > Cool! Thanks
>>
>> Also note that since your type is mutable, the default `==` is object
>> identity and your `a` and `b` won't equal even if their content are
>> the same by default. An `immutable` type will compare the content by
>> default (although `-0.0` and `0.0` have different bit pattern and
>> won't equal as a field by default as you pointed out).
>>
>> ```
>> julia> type foo
>>a::Float64
>>end
>>
>> julia> b = foo(0)
>> foo(0.0)
>>
>> julia> a = foo(0)
>> foo(0.0)
>>
>> julia> a == b
>> false
>>
>> julia> immutable bar
>>a::Float64
>>end
>>
>> julia> b = bar(0)
>> bar(0.0)
>>
>> julia> a = bar(0)
>> bar(0.0)
>>
>> julia> a == b
>> true
>>
>> julia> bar(0.0) == bar(-0.0)
>> false
>> ```
>>
>


Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Seth
I was just about to post this result, which I don't understand. Why should

0.0 == -0.0

but bar(0.0) != bar(-0.0) when bar is immutable? (yes, you can override == 
for this to be ==(x::bar, y::bar) = x.a == y.a, but that seems as if it 
should be unnecessary.)


On Monday, December 7, 2015 at 5:14:28 PM UTC-8, Yichao Yu wrote:
>
> On Mon, Dec 7, 2015 at 7:01 PM, Davide Lasagna  > wrote: 
> > Cool! Thanks 
>
> Also note that since your type is mutable, the default `==` is object 
> identity and your `a` and `b` won't equal even if their content are 
> the same by default. An `immutable` type will compare the content by 
> default (although `-0.0` and `0.0` have different bit pattern and 
> won't equal as a field by default as you pointed out). 
>
> ``` 
> julia> type foo 
>a::Float64 
>end 
>
> julia> b = foo(0) 
> foo(0.0) 
>
> julia> a = foo(0) 
> foo(0.0) 
>
> julia> a == b 
> false 
>
> julia> immutable bar 
>a::Float64 
>end 
>
> julia> b = bar(0) 
> bar(0.0) 
>
> julia> a = bar(0) 
> bar(0.0) 
>
> julia> a == b 
> true 
>
> julia> bar(0.0) == bar(-0.0) 
> false 
> ``` 
>


Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Yichao Yu
On Mon, Dec 7, 2015 at 7:01 PM, Davide Lasagna  wrote:
> Cool! Thanks

Also note that since your type is mutable, the default `==` is object
identity and your `a` and `b` won't equal even if their content are
the same by default. An `immutable` type will compare the content by
default (although `-0.0` and `0.0` have different bit pattern and
won't equal as a field by default as you pointed out).

```
julia> type foo
   a::Float64
   end

julia> b = foo(0)
foo(0.0)

julia> a = foo(0)
foo(0.0)

julia> a == b
false

julia> immutable bar
   a::Float64
   end

julia> b = bar(0)
bar(0.0)

julia> a = bar(0)
bar(0.0)

julia> a == b
true

julia> bar(0.0) == bar(-0.0)
false
```


[julia-users] Solving overdetermined linear system with constraints

2015-12-07 Thread Steven G. Johnson
Look up "linear programming" (LP) problems. 

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Davide Lasagna
Cool! Thanks

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Stefan Karpinski
There are always going to be cases where you want one behavior and others
where you want another. You can change this by overloading == for your type.

On Mon, Dec 7, 2015 at 6:54 PM, Davide Lasagna 
wrote:

> I understand the reason why -0.0 == 0.0, but then this should happen also
> for two objects of the same type that have 0.0 and -0.0 as the value of
> their single field as shown below.
>
> julia> -0.0 == 0.0
>   true
>
> julia> type foo
>a::Float64
>end
>
> julia> b = foo(-0.0)
>   foo(-0.0)
>
> julia> a = foo(0.0)
>   foo(0.0)
>
> julia> a == b
>   false
>
> Where should I look at?
>
> Cheers
>


Re: [julia-users] Re: constructors and parametric typealias

2015-12-07 Thread Stefan Karpinski
Yes, you can overload the call operator for arbitrary types.

On Mon, Dec 7, 2015 at 6:44 PM, Davide Lasagna 
wrote:

> Sorry to dig up this old post, but I wonder if this has been
> solved/addressed in 0.4?
>
> Thanks
>
>
> On Friday, June 28, 2013 at 12:51:26 AM UTC+1, Kevin Squire wrote:
>>
>> Short non-answer: if declare something as a typealias with type
>> parameters, you can use it to match types, but (as you've found out) you
>> can't use it as a constructor.
>>
>> I asked a very related question recently, and the response was that using
>> them as constructors wouldn't be supported.  (I'm still hoping Jeff
>> Bezanson reconsiders, but perhaps it's technically challenging or
>> inefficient.)
>>
>> https://github.com/JuliaLang/julia/issues/3427
>>
>> If you don't care about matching types, you can just not declare it as a
>> typealias, and it will look and act like a constructor.
>>
>> In the issue above, I got around this limitation by the inelegant
>> solution of naming the typealias with an underscore, and creating the
>> function as you did above:
>>
>> typealias _OrderedDict{K,V} OrderedDictBase{K,V,LinkedDictItem,
>> LinkedDictItem}
>> OrderedDict(K::Type, V::Type) = OrderedDictBase{K,V,LinkedDictItem,
>> LinkedDictItem}()
>>
>> Kevin
>>
>> On Thursday, June 27, 2013 2:28:00 PM UTC-7, juthoh...@gmail.com wrote:
>>>
>>> I have a question regarding the way constructors work in parametric
>>> typealias. Let me sketch using an example.
>>> Suppose I started by defining a general pair type:
>>> type Pair{T1,T2}
>>> element1::T1
>>> element2::T2
>>> end
>>>
>>> If no special constructor is defined, as in the case above, Julia
>>> provides constructors such that I can create:
>>> - pair objects of specified T1 and T2, for example
>>> Pair{Int64,Float64}(a,b), provided that a is some Int64 and b is a Float64
>>> - pair objects where T1 and T2 are automatically inferred from the
>>> arguments, i.e. Pair(a,b) will result in an object of type
>>> Pair{typeof(a),typeof(b)}
>>>
>>> If I define a special inner constructor to replace the constructor of
>>> the first line, I also have to provide an outer constructor that replaces
>>> the functionality of the second line. Is my understanding so far correct?
>>>
>>> Now I add some aliases to the game. If I define
>>> typealias IntPair Pair{Int,Int}
>>>
>>>
>>> then Julia automatically provides a constructor such that I can do
>>> IntPair(a,b), which will create an object of type Pair{Int,Int} provided
>>> that a and b are integers
>>>
>>> Now I define a parametric typealias, such as
>>> typealias EqualPair{T} Pair{T,T}
>>>
>>>
>>> then Julia does provide a constructor if I specify the type, i.e.
>>> EqualPair{Int}(a,b) will work if a and b are integers, and returns an
>>> object of type Pair{Int,Int}. However, there is no automatic interference
>>> of the type T if I do not specify it:
>>> EqualPair(a,b) returns
>>> "ERROR: type: apply: expected Function, got Type{Pair{T,T}}"
>>>
>>> And now comes my question: If I now try to define the more general
>>> constructor myself, by writing either
>>> EqualPair{T}(a::T,b::T)=Pair{T,T}(a,b)
>>> or
>>> EqualPair{T}(a::T,b::T)=EqualPair{T}(a,b)
>>> I get, in both cases, an error:
>>> "ERROR: invalid method definition: not a generic function"
>>>
>>> How should I then define a constructor for EqualPair that is more
>>> general than the one provided by Julia?
>>>
>>


[julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Davide Lasagna
I understand the reason why -0.0 == 0.0, but then this should happen also 
for two objects of the same type that have 0.0 and -0.0 as the value of 
their single field as shown below.

julia> -0.0 == 0.0
  true

julia> type foo
   a::Float64
   end 

julia> b = foo(-0.0)
  foo(-0.0)

julia> a = foo(0.0)
  foo(0.0)

julia> a == b
  false

Where should I look at?

Cheers


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
Eventually I wish to capture both stdout and stderr; first I want to learn
to capture stdin using open(). And, you did mention stderr in your first
reply :)

Thanks for the link; I'm keeping an eye out on it, but in its current state
its not useful.

-- mb

On Mon, Dec 7, 2015 at 4:01 PM, James Gilbert  wrote:

> This is more recent, and is probably what you need!
>
>   Issue 14042: Document capture of stdout/stderr from external command
> 
>
>


[julia-users] Re: constructors and parametric typealias

2015-12-07 Thread Davide Lasagna
Sorry to dig up this old post, but I wonder if this has been 
solved/addressed in 0.4?

Thanks

On Friday, June 28, 2013 at 12:51:26 AM UTC+1, Kevin Squire wrote:
>
> Short non-answer: if declare something as a typealias with type 
> parameters, you can use it to match types, but (as you've found out) you 
> can't use it as a constructor.
>
> I asked a very related question recently, and the response was that using 
> them as constructors wouldn't be supported.  (I'm still hoping Jeff 
> Bezanson reconsiders, but perhaps it's technically challenging or 
> inefficient.)
>
> https://github.com/JuliaLang/julia/issues/3427
>
> If you don't care about matching types, you can just not declare it as a 
> typealias, and it will look and act like a constructor.
>
> In the issue above, I got around this limitation by the inelegant solution 
> of naming the typealias with an underscore, and creating the function as 
> you did above:
>
> typealias _OrderedDict{K,V} OrderedDictBase{K,V,LinkedDictItem,
> LinkedDictItem}
> OrderedDict(K::Type, V::Type) = OrderedDictBase{K,V,LinkedDictItem,
> LinkedDictItem}()
>
> Kevin
>
> On Thursday, June 27, 2013 2:28:00 PM UTC-7, juthoh...@gmail.com wrote:
>>
>> I have a question regarding the way constructors work in parametric 
>> typealias. Let me sketch using an example.
>> Suppose I started by defining a general pair type:
>> type Pair{T1,T2}
>> element1::T1
>> element2::T2
>> end
>>
>> If no special constructor is defined, as in the case above, Julia 
>> provides constructors such that I can create:
>> - pair objects of specified T1 and T2, for example 
>> Pair{Int64,Float64}(a,b), provided that a is some Int64 and b is a Float64
>> - pair objects where T1 and T2 are automatically inferred from the 
>> arguments, i.e. Pair(a,b) will result in an object of type 
>> Pair{typeof(a),typeof(b)}
>>
>> If I define a special inner constructor to replace the constructor of the 
>> first line, I also have to provide an outer constructor that replaces the 
>> functionality of the second line. Is my understanding so far correct?
>>
>> Now I add some aliases to the game. If I define
>> typealias IntPair Pair{Int,Int}
>>
>>
>> then Julia automatically provides a constructor such that I can do
>> IntPair(a,b), which will create an object of type Pair{Int,Int} provided 
>> that a and b are integers
>>
>> Now I define a parametric typealias, such as
>> typealias EqualPair{T} Pair{T,T}
>>
>>
>> then Julia does provide a constructor if I specify the type, i.e. 
>> EqualPair{Int}(a,b) will work if a and b are integers, and returns an 
>> object of type Pair{Int,Int}. However, there is no automatic interference 
>> of the type T if I do not specify it:
>> EqualPair(a,b) returns 
>> "ERROR: type: apply: expected Function, got Type{Pair{T,T}}"
>>
>> And now comes my question: If I now try to define the more general 
>> constructor myself, by writing either
>> EqualPair{T}(a::T,b::T)=Pair{T,T}(a,b)
>> or
>> EqualPair{T}(a::T,b::T)=EqualPair{T}(a,b)
>> I get, in both cases, an error:
>> "ERROR: invalid method definition: not a generic function"
>>
>> How should I then define a constructor for EqualPair that is more general 
>> than the one provided by Julia?
>>
>

[julia-users] Re: debugging in Emacs/ESS

2015-12-07 Thread Jingpeng Wu
I have the same problem. Anyone have any hint will be appreciated.

On Sunday, October 5, 2014 at 6:20:17 AM UTC-4, Tamas Papp wrote:
>
> Hi, 
>
> What facilities are there for debugging in Julia, running in Emacs/ESS? 
> I could not find anything in the ESS or Julia manuals. 
>
> Best, 
>
> Tamas 
>


[julia-users] Re: Solving overdetermined linear system with constraints

2015-12-07 Thread amiksvi
Thank you Tony, I think it's exactly what I needed.


Re: [julia-users] Embedding Julia in Xcode project

2015-12-07 Thread Ales Tsurko
A huge thanks for the direction! It's helped me a lot with understanding of 
my problem! But now I can't find from where sys.dylib is calling. I've 
checked out the dependencies, but didn't found why the path is 
../lib/julia/sys.dylib Also the path for sys.dylib is @rpath/sys.dylib, 
which is the same as for libjulia.dylib, but I've no problems with the 
libjulia only with sys.dylib... It's blowing my mind. Where did this come 
from?

понедельник, 7 декабря 2015 г., 20:33:01 UTC+3 пользователь Isaiah написал:
>
> You can change the lookup path using `install_name_tool`. See e.g. [1] and 
> check other answers on StackOverflow.
>
> [1] 
> http://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/
>
> On Sun, Dec 6, 2015 at 9:05 AM, Ales Tsurko  > wrote:
>
>> Hello there! I'm trying to embed Julia in Xcode project. And what I don't 
>> understand is how to link Julia without installing Julia.
>> Currently I've done this steps:
>>
>> 1. Copied /include/ and /lib/ directories from Julia.app to my Xcode's 
>> project directory. Also I've changed directory structure from /lib/julia/ 
>> and /include/julia/ to just /lib/ and /include/, so in my project's 
>> directory it's in /julia/lib and /julia/include/ ;
>> 2. Linked libjulia.dylib;
>> 3. In the Build Settings added $(PROJECT_DIR)/julia/lib to Runpath Search 
>> Path;
>> 4. Added copy files phase with julia.h to Build Phases.
>>
>> And I get this error:
>>
>> *ERROR: system image file 
>>> "/Users/alestsurko/Library/Developer/Xcode/DerivedData/AUJulia-cudsforcspcktlaicnqzwclmzbye/Build/Products/Debug/AUJulia.app/Contents/MacOS/../lib/julia/sys.dylib"
>>>  
>>> not found*
>>
>>
>> It looks like something search library as if it was in the Julia.app 
>> directory structure. But I don't know how to change it. Is it possible at 
>> all or installing Julia is the required step?
>>
>
>

Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread James Gilbert
This is more recent, and is probably what you need!

  Issue 14042: Document capture of stdout/stderr from external command 




[julia-users] Re: Adding 1 to an Array{Array{Int64,1},1}

2015-12-07 Thread Sisyphuss
Have you tried doing it in a function?


On Saturday, December 5, 2015 at 2:16:12 AM UTC+1, Chris wrote:
>
> I am confused about the following:
>
> julia> a = [[1,1] for i = 1:5]
> 5-element Array{Array{Int64,1},1}:
>  [1,1]
>  [1,1]
>  [1,1]
>  [1,1]
>  [1,1]
>
> julia> a + 1
> 5-element Array{Any,1}:
>  [2,2]
>  [2,2]
>  [2,2]
>  [2,2]
>  [2,2]
>
> Specifically, why does the type change from Array{Array{Int64,1},1} to 
> Array{Any,1}, and what can I do to keep it as Array{Array{Int64,1},1}?
>
> Thanks,
> Chris
>


Re: [julia-users] Convert SubString{ASCIIString} to String

2015-12-07 Thread milktrader
Actually, I've closed the issue you created with a new commit so once 0.5.1 
is available on METADATA you should get this resolved with a Pkg.update().

On Monday, December 7, 2015 at 3:22:48 PM UTC-5, milktrader wrote:
>
> Can you post the first 10 lines or so of the file you'd like to parse?
>
> Dan
>
> On Sunday, December 6, 2015 at 12:34:02 PM UTC-5, Charles Santana wrote:
>>
>> Hi, thanks for all your suggestions!
>>
>> @Eric: unfortunately readcsv and readtable give me the same situation as 
>> readdlm. 
>>
>> @Milan: thanks for the suggestion. Just created it: 
>> https://github.com/milktrader/Quandl.jl/issues/91
>>
>> Best,
>>
>> Charles
>>
>> On 5 December 2015 at 23:07, Milan Bouchet-Valat  wrote:
>>
>>> Le vendredi 04 décembre 2015 à 23:47 +0100, Charles Novaes de Santana a
>>> écrit :
>>> > Hi people,
>>> >
>>> > Maybe it is a trivial question for most of you, but I really could
>>> > not find a way to solve my problem.
>>> >
>>> > I am using the function quandlget(id::ASCIIString) from the library
>>> > https://github.com/milktrader/Quandl.jl (a great contribution, by the
>>> > way!)
>>> >
>>> > Everything works fine when I use it in a straightforward way:
>>> >
>>> > julia> mydat = quandl("GOOG/NASDAQ_GOOG",rows=100,format="DataFrame")
>>> > 100x6 DataFrames.DataFrame
>>> > | Row | Date   | Open   | High   | Low| Close  | Volume|
>>> > |-||||||---|
>>> > | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>>> > | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>>> > | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>>> >
>>> >
>>> > or when I do:
>>> >
>>> > julia> myid = "GOOG/NASDAQ_GOOG"
>>> > "GOOG/NASDAQ_GOOG"
>>> >
>>> > julia> typeof(myid)
>>> > ASCIIString
>>> >
>>> > julia> mydat = quandl(myid,rows=100,format="DataFrame")
>>> > 100x6 DataFrames.DataFrame
>>> > | Row | Date   | Open   | High   | Low| Close  | Volume|
>>> > |-||||||---|
>>> > | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>>> > | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>>> > | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>>> >
>>> >
>>> > However, I get an error when I read my data from an external file.
>>> > Assume I have an ascii file containing only one line:
>>> >
>>> > $ echo "GOOG/NASDAQ_GOOG" > portfolio.txt
>>> >
>>> > $ cat portfolio.txt
>>> > GOOG/NASDAQ_GOOG
>>> >
>>> >
>>> > I just read the content of this file by using readdlm and try to use
>>> > it to call the same function quandl, but it does not work.
>>> >
>>> > julia> myportfolio = readdlm("./portfolio.txt",'\n')
>>> > 1x1 Array{Any,2}:
>>> >  "GOOG/NASDAQ_GOOG"
>>> >
>>> > julia> typeof(myportfolio[1])
>>> > SubString{ASCIIString}
>>> >
>>> > julia> mydat = quandl(myportfolio[1],rows=100,format="DataFrame")
>>> > ERROR: MethodError: `quandlget` has no method matching
>>> > quandlget(::SubString{ASCIIString})
>>> Though the other posts give good solutions to your problem, you could
>>> also file an issue against Quandl.jl to change quandlget() to accept
>>> any AbstractString, and not only ASCIIString. That would be helpful in
>>> legitimate cases.
>>>
>>>
>>> Regards
>>>
>>> > I suppose the easiest way to solve this problem is to convert my
>>> > SubString{ASCIIString} variable to ASCIIString. Am I right here? How
>>> > can I do it?
>>> >
>>> > Does any of you have another suggestion? May be I could read my data
>>> > in a different way instead of using readdlm?
>>> >
>>> > Thanks for any tip!
>>> >
>>> > best,
>>> >
>>> > Charles
>>> > --
>>> > Um axé! :)
>>> >
>>> > --
>>> > Charles Novaes de Santana, PhD
>>> > http://www.imedea.uib-csic.es/~charles
>>>
>>
>>
>>
>> -- 
>> Um axé! :)
>>
>> --
>> Charles Novaes de Santana, PhD
>> http://www.imedea.uib-csic.es/~charles
>>
>

[julia-users] Re: Array of matrices

2015-12-07 Thread Sisyphuss
[Matrix{Float64}() for i = 1:5]
works too.


On Sunday, December 6, 2015 at 3:25:53 AM UTC+1, Eric Forgy wrote:
>
> Close :)
>
> You can try:
>
> julia> x = [Matrix() for i=1:5]
> 5-element Array{Array{Any,2},1}:
>  0x0 Array{Any,2}
>  0x0 Array{Any,2}
>  0x0 Array{Any,2}
>  0x0 Array{Any,2}
>  0x0 Array{Any,2}
>
> Also:
>
> julia> x = [rand(i,i) for i=1:5]
> 5-element Array{Array{Float64,2},1}:
>  1x1 Array{Float64,2}:
>  0.518641 
> 
> 
>   
>  2x2 Array{Float64,2}:
>  0.219756  0.753237
>  0.294669  0.718687   
> 
>   
>
>  3x3 Array{Float64,2}:
>  0.951481  0.114902  0.632999
>  0.934798  0.528655  0.759751
>  0.695776  0.013846  0.568784 
> 
>   
>
>  4x4 Array{Float64,2}:
>  0.0338033  0.999119  0.914414  0.114614
>  0.947484   0.16535   0.512054  0.115579
>  0.135501   0.317845  0.832064  0.16373
>  0.365693   0.879762  0.313289  0.0339317 
>   
>
>  5x5 Array{Float64,2}:
>  0.181271   0.68545   0.749937   0.116528  0.193043
>  0.545848   0.787693  0.793377   0.405328  0.797003
>  0.0121521  0.476136  0.0411077  0.200597  0.496779
>  0.503430.32037   0.455482   0.260218  0.308114
>  0.855837   0.471426  0.723162   0.591161  0.128503
>
>
>
> On Sunday, December 6, 2015 at 10:21:13 AM UTC+8, Lex wrote:
>>
>> Hi 
>>
>> I am not sure how to create an array of fixed size which may store 
>> matrices of different dimensions for later applying algebraic operations. 
>> Any help is appreciated.
>> Some of the things I tried:
>>
>> x = [Matrix{} for i=1:5]
>>
>>
>> x = [Any for i=1:5]
>> for i in 1:5
>>   x[i] = Any
>> end
>>
>>
>>
>>
>>

[julia-users] Re: Anyone going to NIPS (Montreal) this week?

2015-12-07 Thread Sisyphuss
Article rejected :(

On Sunday, December 6, 2015 at 10:04:02 PM UTC+1, Cedric St-Jean wrote:
>
> It would be nice to gather for a beer and see what everyone uses Julia for 
> in the field of machine learning.
>


[julia-users] ANN: Julia v0.4.2 released

2015-12-07 Thread Tony Kelman
Hello all! The latest bugfix release of the Julia 0.4.x line has been 
released. Binaries are available from the usual place 
, and as is typical with such things, 
please report all issues to either the issue tracker 
, or email the julia-users list. 
(If you respond to this message on julia-users, please do not cc julia-news 
which is intended to be low-volume.)

This is a bugfix release, see this commit log 
 for the list 
of bugs fixed between 0.4.1 and 0.4.2. Bugfix backports to the 0.4.x line 
will be continuing with a target of one point release per month. If you are 
a package author and want to rely on functionality that did not work in 
0.4.0 or 0.4.1 but does work in 0.4.2 in your package, please be sure to 
change the minimum julia version in your REQUIRE file to 0.4.2 accordingly. 
If you're not sure about this, you can test your package specifically 
against 0.4.0 or 0.4.1 on Travis and/or locally.

These are recommended upgrades for anyone using previous releases, and 
should act as drop-in replacements for 0.4.0 or 0.4.1. If you find any 
regressions relative to previous releases, please let us know.

-Tony



Re: [julia-users] Convert SubString{ASCIIString} to String

2015-12-07 Thread milktrader
Can you post the first 10 lines or so of the file you'd like to parse?

Dan

On Sunday, December 6, 2015 at 12:34:02 PM UTC-5, Charles Santana wrote:
>
> Hi, thanks for all your suggestions!
>
> @Eric: unfortunately readcsv and readtable give me the same situation as 
> readdlm. 
>
> @Milan: thanks for the suggestion. Just created it: 
> https://github.com/milktrader/Quandl.jl/issues/91
>
> Best,
>
> Charles
>
> On 5 December 2015 at 23:07, Milan Bouchet-Valat  > wrote:
>
>> Le vendredi 04 décembre 2015 à 23:47 +0100, Charles Novaes de Santana a
>> écrit :
>> > Hi people,
>> >
>> > Maybe it is a trivial question for most of you, but I really could
>> > not find a way to solve my problem.
>> >
>> > I am using the function quandlget(id::ASCIIString) from the library
>> > https://github.com/milktrader/Quandl.jl (a great contribution, by the
>> > way!)
>> >
>> > Everything works fine when I use it in a straightforward way:
>> >
>> > julia> mydat = quandl("GOOG/NASDAQ_GOOG",rows=100,format="DataFrame")
>> > 100x6 DataFrames.DataFrame
>> > | Row | Date   | Open   | High   | Low| Close  | Volume|
>> > |-||||||---|
>> > | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>> > | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>> > | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>> >
>> >
>> > or when I do:
>> >
>> > julia> myid = "GOOG/NASDAQ_GOOG"
>> > "GOOG/NASDAQ_GOOG"
>> >
>> > julia> typeof(myid)
>> > ASCIIString
>> >
>> > julia> mydat = quandl(myid,rows=100,format="DataFrame")
>> > 100x6 DataFrames.DataFrame
>> > | Row | Date   | Open   | High   | Low| Close  | Volume|
>> > |-||||||---|
>> > | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>> > | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>> > | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>> >
>> >
>> > However, I get an error when I read my data from an external file.
>> > Assume I have an ascii file containing only one line:
>> >
>> > $ echo "GOOG/NASDAQ_GOOG" > portfolio.txt
>> >
>> > $ cat portfolio.txt
>> > GOOG/NASDAQ_GOOG
>> >
>> >
>> > I just read the content of this file by using readdlm and try to use
>> > it to call the same function quandl, but it does not work.
>> >
>> > julia> myportfolio = readdlm("./portfolio.txt",'\n')
>> > 1x1 Array{Any,2}:
>> >  "GOOG/NASDAQ_GOOG"
>> >
>> > julia> typeof(myportfolio[1])
>> > SubString{ASCIIString}
>> >
>> > julia> mydat = quandl(myportfolio[1],rows=100,format="DataFrame")
>> > ERROR: MethodError: `quandlget` has no method matching
>> > quandlget(::SubString{ASCIIString})
>> Though the other posts give good solutions to your problem, you could
>> also file an issue against Quandl.jl to change quandlget() to accept
>> any AbstractString, and not only ASCIIString. That would be helpful in
>> legitimate cases.
>>
>>
>> Regards
>>
>> > I suppose the easiest way to solve this problem is to convert my
>> > SubString{ASCIIString} variable to ASCIIString. Am I right here? How
>> > can I do it?
>> >
>> > Does any of you have another suggestion? May be I could read my data
>> > in a different way instead of using readdlm?
>> >
>> > Thanks for any tip!
>> >
>> > best,
>> >
>> > Charles
>> > --
>> > Um axé! :)
>> >
>> > --
>> > Charles Novaes de Santana, PhD
>> > http://www.imedea.uib-csic.es/~charles
>>
>
>
>
> -- 
> Um axé! :)
>
> --
> Charles Novaes de Santana, PhD
> http://www.imedea.uib-csic.es/~charles
>


Re: [julia-users] 3D image matrix

2015-12-07 Thread Rivo Sarmento
Hi André,

The output of `methos(view)` in both version are:

Julia version 0.3

julia> methods(view)
# 3 methods for generic function "view":
view{A<:AbstractArray{T,N}}(img::A<:AbstractArray{T,N}) at 
/home/rivo/.julia/v0.3/ImageView/src/display.jl:233
view{A<:AbstractArray{T,N}}(imgc::ImageCanvas,img::A<:AbstractArray{T,N}) 
at /home/rivo/.julia/v0.3/ImageView/src/display.jl:344
view{A<:AbstractArray{T,N}}(c::Canvas,img::A<:AbstractArray{T,N}) at 
/home/rivo/.julia/v0.3/ImageView/src/display.jl:364


Julia version 0.4
# 3 methods for generic function "view":
view{A<:AbstractArray{T,N}}(img::A<:AbstractArray{T,N}) at 
/home/rivo/.julia/v0.4/ImageView/src/display.jl:233
view{A<:AbstractArray{T,N}}(imgc::ImageView.ImageCanvas, 
img::A<:AbstractArray{T,N}) at 
/home/rivo/.julia/v0.4/ImageView/src/display.jl:344
view{A<:AbstractArray{T,N}}(c::Tk.Canvas, img::A<:AbstractArray{T,N}) at 
/home/rivo/.julia/v0.4/ImageView/src/display.jl:364


And yes, it is version 0.3.2.

You're welcome,
 

Em quinta-feira, 3 de dezembro de 2015 14:22:22 UTC-3, André Lage escreveu:
>
> hi Rivo,
>
> Could you try to run this code (plot the image) in Julia 0.4.1?
>
> What's the output of `methods(view)` in both versions 0.3.? and 0.4.1 (are 
> you sure it's Julia 0.3.2 or it'd be 0.3.8 instead)?
>
> Thanks,
>
>
> André.
>
> On Wednesday, December 2, 2015 at 11:06:13 AM UTC-3, Rivo Sarmento wrote:
>>
>> ImageView.view(img) works also, thanks!
>>
>> This is a Polarimetric SAR image from San Andreas Fault, CA. 
>>
>> Em terça-feira, 1 de dezembro de 2015 23:08:59 UTC-3, Benjamin Deonovic 
>> escreveu:
>>>
>>> So whats the image of? 
>>>
>>> On Tuesday, December 1, 2015 at 4:50:51 PM UTC-6, Rivo Sarmento wrote:

 Currently the imports, or using package, are in the begining of the 
 code.
 I got it to work only if using is the last step before using `view`.

 I can't think of a particular reason for it to happen. Although, in my 
 0.3.2 Julia importing ImageView returns:

 julia> using ImageView
 Warning: could not import Base.Text into Tk

 I finally got, as we can see in the attached file, thank you very much.

 Em terça-feira, 1 de dezembro de 2015 19:19:03 UTC-3, Tim Holy escreveu:
>
> On Tuesday, December 01, 2015 01:36:28 PM Rivo Sarmento wrote: 
> > But `view` returns: 
> > 
> > julia> view(img) 
> > ERROR: `view` has no method matching 
> > view(::Image{Float64,3,Array{Float64,3}}) 
>
> Are you sure you first said 
> using ImageView? 
>
> julia> methods(view) 
> # 3 methods for generic function "view": 
> view{A<:AbstractArray{T,N}}(img::A<:AbstractArray{T,N}) at 
> /home/tim/.julia/v0.4/ImageView/src/display.jl:233 
> view{A<:AbstractArray{T,N}}(imgc::ImageView.ImageCanvas, 
> img::A<:AbstractArray{T,N}) at 
> /home/tim/.julia/v0.4/ImageView/src/display.jl:344 
> view{A<:AbstractArray{T,N}}(c::Tk.Canvas, img::A<:AbstractArray{T,N}) 
> at 
> /home/tim/.julia/v0.4/ImageView/src/display.jl:364 
>
> That first method covers any AbstractArray. 
>
> --Tim 
>
>

Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread James Gilbert
Ah, first time you've mentioned stderr!


[julia-users] Connectivity to PostgreSQL

2015-12-07 Thread Tony Kelman
You can try Pkg.checkout or Pkg.clone to see if master or unregistered packages 
work better right now. Pkg.free goes back to tagged releases. ODBC is being 
worked on and should be tagged soon.

Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
Yes, but the problem is that readandwrite() does not provide access to
stderr (see https://github.com/JuliaLang/julia/issues/11824). That's why
I've been trying alternative solutions.

On Mon, Dec 7, 2015 at 1:17 PM, James Gilbert  wrote:

> Turns out that there is a function *readandwrite()
> * 
> which
> does exactly what we need:
>
> function main()
> letters = ["v", "w", "x", "y", "z"]
> str = join(["$a$b\n" for a in letters, b in letters])
> print("\nBefore grep:\n", str)
>
> (grepout, grepin, grep) = readandwrite(`grep y`)
> print(grepin, str)
> close(grepin)
> filtered_str = readall(grepout)
> print("\nAfter grep:\n", filtered_str)
> end
>
>
> main()
>
>
>


[julia-users] Connectivity to PostgreSQL

2015-12-07 Thread Johann Spies
I am a new Julia user and am working with Debian.

Connectivity to PostgreSQL is important to me.

I have installed odbc-postgresql on my computer and could do:

> isql 'PostgreSQL test' js
+---+
| Connected!|
|   |
| sql-statement |
| help [tablename]  |
| quit  |
|   |
+---+
SQL> quit
js@artikel ~> 

Then I installed ODBC using Pkg.add("ODBC") in Julia.

However when I want to use it I get a lot of warnings and in the end an 
error:

julia> using ODBC
WARNING: requiring "Dates" in module "ODBC" did not define a corresponding 
module.
WARNING: dlopen is deprecated, use Libdl.dlopen instead.

etc... (A lot of warnings removed)

WARNING: Base.String is deprecated, use AbstractString instead.
  likely near /home/js/.julia/v0.4/ODBC/src/ODBC.jl:16
ERROR: LoadError: TypeError: Array: in parameter, expected Type{T}, got 
Tuple{DataType,DataType}
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in require at ./loading.jl:243
while loading /home/js/.julia/v0.4/ODBC/src/ODBC.jl, in expression starting 
on line 16

I see there is a PostgreSQL.lj which depends on DBI.jl (both of which not 
in the official package list).

I have tried to use Python's  psychopg2 (through PyCall)  and successfully 
connected to the database, but I could not define a cursor.

So what is the best way to achieve stable and reliable communication with 
my database?

Regards.

Johann




[julia-users] Gtk.jl, Segfault when calling setproperty! inside signal handler

2015-12-07 Thread FQ
Hi,

I have a julia program that uses gtk builder to create a gui from a
glade file. The gui contains a stack widget that contains a
filechooserwidget and a drawingarea.

A stack is a container widget that displays only one of its children at
a time, and has a property called "visible-child" that determines which
child is visible.

The ui has an 'open' togglebutton on top that should switch between the
filechooserwidget and the drawingarea. However, it crashes julia instead.

Here's my code (paste to REPL for testing):
http://pastebin.com/embed_iframe.php?i=Ub9y8puE

The Glade file containing the ui:
http://pastebin.com/embed_iframe.php?i=DSWLkG84

and the error i get when clicking the button:
http://pastebin.com/raw.php?i=4bnZuYWE

The weird thing ist, the command that seems to be causing the segfault
is the

Gtk.setproperty!(stack, "visible-child",filechooserwidget)

inside the signal handler. However, when I run the exact same command
manually on REPL, it displays the filechooserwidget as it is supposed to.

Is this a bug in my code or in Gtk.jl? I'd appreciate any hints on how
to fix this or debug it further :)

Thanks and regards :)
fq


Re: [julia-users] Re: Why are Eigenvectors more sparse than left singular vectors?

2015-12-07 Thread Stefan Karpinski
On Mon, Dec 7, 2015 at 11:26 AM, Jonas Kersulis 
wrote:

> As far as speed goes, I thought svd would be faster because it avoids the
> multiplication A'A.


One matmul is not much compared to either eig or svd, so the major
consideration here is whether eig or svd is more expensive – and svd is
significantly more expensive.


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread James Gilbert
Turns out that there is a function *readandwrite() 
* 
which 
does exactly what we need:

function main()
letters = ["v", "w", "x", "y", "z"]
str = join(["$a$b\n" for a in letters, b in letters])
print("\nBefore grep:\n", str)

(grepout, grepin, grep) = readandwrite(`grep y`)
print(grepin, str)
close(grepin)
filtered_str = readall(grepout)
print("\nAfter grep:\n", filtered_str)
end


main()




Re: [julia-users] Re: range bug in 0.4.1?

2015-12-07 Thread Tomas Lycken
I think it makes perfect sense. If you need a range object where you know 
the start and ending points, you use colon (i.e. `start:step:stop`). If you 
know how many elements you want and what step, but you don't know (or care 
so much) about the stopping point, you use `range`. Just because *you* don't 
have need for it, doesn't mean no-one else does :)

// T

On Monday, December 7, 2015 at 9:53:38 AM UTC+1, Jürgen Bohnert wrote:
>
> I honestly cannot imagine a good application justifying this 'range' 
> function being in the main namespace. What it does is quite 
> counter-intuitive. Or maybe renaming it would be an option?
> Anyway thanks for all your answers guys.
>
> Best,
> Juergen
>
>
> Am Montag, 7. Dezember 2015 04:11:07 UTC+1 schrieb whycrying:
>>
>> Ah. The second argument is the length of the range.
>>
>> And the three arguments's:
>>
>> julia> which(range,(Int,Int,Int))
>>> range{T,S}(a::T, step::S, len::Integer) at range.jl:101
>>>
>>
>> Not so consistent.
>>
>> Well, this is different from Python.
>> Look range in Python(via iPython):
>>
>> In [3]: range?
>>> Docstring:
>>> range(stop) -> range object
>>> range(start, stop[, step]) -> range object
>>>
>>> Return a sequence of numbers from start to stop by step.
>>> Type:  type
>>>
>>
>>
>>
>> -- 
>> https://www.zhangkaizhao.com/
>>
>

Re: [julia-users] Re: CUDART and CURAND problem on running the same "do" loop twice

2015-12-07 Thread Joaquim Masset Lacombe Dias Garcia
And it also works on windows if CUDA version is 7.5!

On Wed, Nov 25, 2015 at 7:58 PM, Joaquim Masset Lacombe Dias Garcia <
joaquimdgar...@gmail.com> wrote:

> Wow! it seems that something is wrong in CUDA 7.0 !
>
> I updated my MAC to cuda 7.5 and bith the C code and julia code worked
> fine!
> This other guy:
>
> http://stackoverflow.com/questions/33904554/curand-error-while-alternating-with-device-initialization-and-reset-in-cuda-7-0?noredirect=1#comment55573150_33904554
>
> had the C code running smoothly on windows with CUDA 7.5
>
> I will try the julia code on my windows notebook later this week with CUDA
> 7.5
>
> If somebody else could confirm the problem on curand in cuda 7.0, we could
> add that in CURAND.jl documentation.
>
>
>
> Em quarta-feira, 25 de novembro de 2015 19:20:48 UTC-2, Andrei Zh escreveu:
>>
>> @Joaquim Would it be possible for you to upgrade or donwgrade your CUDA
>> version?
>>
>> Meanwhile, we are still waiting for other people with Windows or Mac :D
>>
>> On Wed, Nov 25, 2015 at 6:35 PM, Sergio Muniz  wrote:
>>
>>> It works fine here, on Ubuntu 14.04 and CUDA 6.5.
>>>
>>> Cheers,
>>> [S].
>>>
>>>
>>>
>>>
>>> On Tuesday, November 24, 2015 at 9:30:32 PM UTC-2, Joaquim Masset
>>> Lacombe Dias Garcia wrote:

 Interesting, both my machines (windows and mac) have CUDA 7.0, possibly
 thats the issue, since the C code in
 https://github.com/JuliaGPU/CURAND.jl/issues/3#issuecomment-159319580
 fails in both.

 If some linux user could test this version, our statistics would be
 more complete. I will try 6.5 and 7.5

 Em terça-feira, 24 de novembro de 2015 21:21:41 UTC-2, Tim Holy
 escreveu:
>
> 6.5
>
> --Tim
>
> On Wednesday, November 25, 2015 01:37:22 AM Andrei wrote:
> > On Tue, Nov 24, 2015 at 8:03 PM, Kristoffer Carlsson <
> kcarl...@gmail.com>
> > wrote:
> > > The original code in the OP fails for me
> >
> > Yes, this is expected behavior: for convenience, CURAND.jl creates
> default
> > random number generator, which obviously becomes invalid after
> > `device_reset()`. At the same time, my last code snippet creates new
> and
> > explicit RNG, which fixes the issue on Linux.
> >
> > The problem is that on some platforms even creating new generator
> doesn't
> > help, so I'm trying to understand the difference.
> >
> > @Tim, @Kristoffer, could you also specify CUDA version in use,
> please?
>
>
>>


Re: [julia-users] Embedding Julia in Xcode project

2015-12-07 Thread Isaiah Norton
You can change the lookup path using `install_name_tool`. See e.g. [1] and
check other answers on StackOverflow.

[1]
http://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/

On Sun, Dec 6, 2015 at 9:05 AM, Ales Tsurko  wrote:

> Hello there! I'm trying to embed Julia in Xcode project. And what I don't
> understand is how to link Julia without installing Julia.
> Currently I've done this steps:
>
> 1. Copied /include/ and /lib/ directories from Julia.app to my Xcode's
> project directory. Also I've changed directory structure from /lib/julia/
> and /include/julia/ to just /lib/ and /include/, so in my project's
> directory it's in /julia/lib and /julia/include/ ;
> 2. Linked libjulia.dylib;
> 3. In the Build Settings added $(PROJECT_DIR)/julia/lib to Runpath Search
> Path;
> 4. Added copy files phase with julia.h to Build Phases.
>
> And I get this error:
>
> *ERROR: system image file
>> "/Users/alestsurko/Library/Developer/Xcode/DerivedData/AUJulia-cudsforcspcktlaicnqzwclmzbye/Build/Products/Debug/AUJulia.app/Contents/MacOS/../lib/julia/sys.dylib"
>> not found*
>
>
> It looks like something search library as if it was in the Julia.app
> directory structure. But I don't know how to change it. Is it possible at
> all or installing Julia is the required step?
>


Re: [julia-users] optimization levels in julia?

2015-12-07 Thread Erik Schnetter
Use the `@fastmath` macro. This dynamically enables floating-point
optimizations in the expression (or function) to which you apply it.
Compare `@inbounds`, `@simd`.

-erik

On Sun, Dec 6, 2015 at 5:23 PM, Meik Hellmund 
wrote:

> Hi,
>
> It seems that julia does not "optimize away" constant expressions in
> functions:
>
> julia> f(x)=x+2-2
> f (generic function with 1 method)
>
> julia> f(1.e-18)
> 0.0
>
> This is of course correct in Float64 arithmetics.
> But I wonder: In languages like Fortran and C the result of such code
>  depends on the "optimization flags" used when compiling.
> With optimization, the compiler would reduce the function to f(x)=x.
> Is there something comparable in Julia?
>
> Another test. Compare
> f(x)=x+sin(.34567)
>
> to
>
> const sn=sin(.34567)
> g(x)=x+sn
>
>
> julia> y=0; @time(for i in 1:10^9; y=f(y); end)
>  22.489526 seconds (2.00 G allocations: 29.802 GB, 3.50% gc time)
>
> julia> y=0; @time(for i in 1:10^9; y=g(y); end)
>  16.268512 seconds (1000.00 M allocations: 14.901 GB, 2.61% gc time)
>
>
> It looks like Julia does not optimize even the simplest constant
> expressions so that they are  evaluated  only once.
> And why, by all means, does it allocate so much memory for that?
>  Is there something I overlook?
>
>  Best wishes,
> Meik
>
>


-- 
Erik Schnetter 
http://www.perimeterinstitute.ca/personal/eschnetter/


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
I didn't think that section applied to my case, since I have two processes,
each reading/writing to a different pipe.

I've also tried to use IOBuffer() and IOStream(), but without any success.

Thanks,

-- mb

On Mon, Dec 7, 2015 at 8:34 AM, James Gilbert  wrote:

> I think the answer to your problem might be in the "Avoiding Deadlock in
> Pipelines" section in the "Running External Programs" page:
>
>
> http://docs.julialang.org/en/release-0.4/manual/running-external-programs/#avoiding-deadlock-in-pipelines
>
> I've been experimenting to try to get something to work without success.
> The *writeall()* function used in that section of the documentation
> doesn't exist.
>
> I was hoping to be able to use *IOBuffer()* or *IOStream() *variables to
> provide input and capture output and stderr for external programs.
>


[julia-users] Re: Why are Eigenvectors more sparse than left singular vectors?

2015-12-07 Thread Jonas Kersulis


Here is the result of rounding each basis to 15 places. I definitely should 
have done that before in the interest of comparing apples to apples. From 
this figure, I can believe the vectors are the same (up to scaling and 
order).




The matrix has 6 rows and full row rank. If I use eigs or svds to obtain 
the 6 nonzero Eigenvectors/left singular vectors, then augment the vectors 
with zeros (to yield square matrices) and take the QR decomposition, Q will 
be a completed basis. Here is what Q looks like:



It's the same in both cases, as expected.


As far as speed goes, I thought svd would be faster because it avoids the 
multiplication A'A. I'm still not sure I understand why it would be slower.


Thanks for your help, I appreciate it!




On Thursday, December 3, 2015 at 8:23:00 PM UTC-5, Steven G. Johnson wrote:
>
> PS. eig(A'A) is typically going to be much faster (but less accurate) than 
> svd(A), so I'm not sure why you say that the latter is faster.  e.g. here 
> are some sample timings (timing everything twice to avoid the initial 
> compilation cost):
>
> *julia>* A = rand(1000,200);
>
>
> *julia>* @time eig(A'A); @time eig(A'A);
>
>   0.790879 seconds (1.12 M allocations: 52.454 MB, 3.47% gc time)
>
>   0.027542 seconds (37 allocations: 1.294 MB)
>
>
> *julia>* @time svd(A); @time svd(A);
>
>   0.160237 seconds (90.29 k allocations: 8.908 MB)
>
>   0.079330 seconds (28 allocations: 4.908 MB)
>
>
> *julia>* @time svd(A'); @time svd(A');
>
>   0.234619 seconds (107 allocations: 7.659 MB, 1.39% gc time)
>
>   0.234533 seconds (33 allocations: 7.655 MB)
>
>

[julia-users] Re: Anyone going to NIPS (Montreal) this week?

2015-12-07 Thread Jonathan Malmaud
I might go for some of the workshops. 

On Sunday, December 6, 2015 at 4:04:02 PM UTC-5, Cedric St-Jean wrote:
>
> It would be nice to gather for a beer and see what everyone uses Julia for 
> in the field of machine learning.
>


[julia-users] conditional dependencies on packages with macros

2015-12-07 Thread Seth
Is there a way to specify a conditional dependency (that is, use package 
Foo if it's available and define functions that use things from Foo; 
otherwise, don't define the functions or throw an error message) on 
packages that contain macros? isdefined(Main, :Package) won't work since 
the macros from Package are evaluated prior to this conditional, and it 
will throw an error.

I was using Requires.jl to do this, but one issue I ran into is that an 
error in the code within the @require block is not propagated as an error; 
it's presented as a warning, which means that things like unit tests will 
pass even if the code is incorrect.


[julia-users] Re: Clebsch-Gordan and/or 3j symbols in julia ?

2015-12-07 Thread Jānis Erdmanis
You might try to interface fortran implementation 
https://github.com/valandil/wignerSymbols/blob/master/src/wignerSymbols-fortran.f
 
, but I never have done such thing. 

On Monday, December 7, 2015 at 10:59:57 AM UTC+2, Ferran Mazzanti wrote:
>
> Hi folks,
>
> since I'm in the quantum mechanics world and I'm moving towards Julia, I 
> was wondering if there's a simple way (package?) that anybody knowa
> which allows to evaluate Clebsch-Gordan coefficints or Wigner 3-j symbols. 
> I'm actually trying to get integrals of three Spherical Harmonics done
> in Julia, so that's why I ask, but eventually I know I'll need the 
> coefficients for future simulations also.
>
> Thanks for your kind help,
>
> Ferran.
>


[julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread James Gilbert
I think the answer to your problem might be in the "Avoiding Deadlock in 
Pipelines" section in the "Running External Programs" page:

  
http://docs.julialang.org/en/release-0.4/manual/running-external-programs/#avoiding-deadlock-in-pipelines

I've been experimenting to try to get something to work without success. 
The *writeall()* function used in that section of the documentation doesn't 
exist.

I was hoping to be able to use *IOBuffer()* or *IOStream() *variables to 
provide input and capture output and stderr for external programs.


Re: [julia-users] Re: optimization levels in julia?

2015-12-07 Thread Yichao Yu
On Mon, Dec 7, 2015 at 6:00 AM,   wrote:
> You are making the assumption that `sin(.34567)` is a constant, but in Julia
> technically sin is dependent on global state, specifically the rounding and
> denormalisation modes
> http://docs.julialang.org/en/release-0.4/stdlib/numbers/?highlight=rounding#Base.set_rounding.
> It these change during the loop, then the answer may not be the same, and
> like all global state Julia can't infer that.  Whereas you have demonstrated
> that you can tell Julia its a constant with the same value as calculated at
> initialisation.
>

Ref https://github.com/JuliaLang/julia/issues/9942

>
> On Monday, December 7, 2015 at 7:59:08 PM UTC+10, Meik Hellmund wrote:
>>
>>
>> Thank you for pointing out the problem with a global y and its type.
>> I hope my new code example below is better. I want to point at
>> the relative performance difference of the functions f and g.
>>
>> I am experimenting with Julia for  a couple of weeks and I like it very
>> much.
>> In my experience, every language has a different  borderline between
>> "The programmer should think about optimal performance" and
>> "Don't overoptimize, the compiler is smarter than you".
>>
>> So I just want to understand if Julia does
>> constant expression evaluation at compile time or not
>>
>> I think julia 0.4.1 does not. My code:
>> #-
>> function stupidtest(f)
>> for x in 1 : 10^8
>>f(x)
>> end
>> end
>>
>> f(x) =  x + log(2.) * sin(.34567)^2
>>
>> const z = log(2.) * sin(.34567)^2
>> g(x) = x + z
>>
>> @time( stupidtest(f) )
>> @time( stupidtest(g) )
>> #--- EOF--
>>
>> $julia --optimize --inline=yes --check-bounds=no --math-mode=fast
>> mycode.jl
>>   2.869774 seconds (200.00 M allocations: 2.980 GB, 3.39% gc time)
>>   1.855530 seconds (200.00 M allocations: 2.980 GB, 4.32% gc time)
>>
>>
>> It also seems that I (with a C++/Fortran background) do not really
>> understand
>> some aspects of the language. Why does a loop with a function call
>> need so much memory allocations?
>>
>> Any explanations are appreciated!
>>
>> Cheers, Meik
>>
>>
>


[julia-users] Re: Funny object wrapper in Julia

2015-12-07 Thread Bart Janssens
Hi Olli,

I'm considering an approach like this for wrapping C++ class member 
functions in my CppWrapper package. I just wonder, is this kind of 
object.member_function(arguments) syntax acceptable for Julia, or is 
member_function(object, other_arguments) preferred? The former will be more 
natural for people used to the C++ interface, while the latter conforms 
better to Julia's way of working I think.

Cheers,

Bart

On Saturday, November 28, 2015 at 6:19:29 PM UTC+1, Olli Väinölä wrote:

> julia> class_1.set_a(10)
> 10
>
> julia> class_1.get_a()
> 10
>
> not sure if someone has already invented this but in PyPlot I guess same 
> has been archived with a Dict. Still, all fun and games.
>
>

[julia-users] Re: optimization levels in julia?

2015-12-07 Thread elextr
You are making the assumption that `sin(.34567)` is a constant, but in 
Julia technically sin is dependent on global state, specifically the 
rounding and denormalisation modes 
http://docs.julialang.org/en/release-0.4/stdlib/numbers/?highlight=rounding#Base.set_rounding.
 
 It these change during the loop, then the answer may not be the same, and 
like all global state Julia can't infer that.  Whereas you have 
demonstrated that you can tell Julia its a constant with the same value as 
calculated at initialisation.

On Monday, December 7, 2015 at 7:59:08 PM UTC+10, Meik Hellmund wrote:
>
>
> Thank you for pointing out the problem with a global y and its type. 
> I hope my new code example below is better. I want to point at 
> the relative performance difference of the functions f and g.  
>
> I am experimenting with Julia for  a couple of weeks and I like it very 
> much. 
> In my experience, every language has a different  borderline between 
> "The programmer should think about optimal performance" and 
> "Don't overoptimize, the compiler is smarter than you". 
>
> So I just want to understand if Julia does 
> constant expression evaluation at compile time or not
>
> I think julia 0.4.1 does not. My code:
> #-
> function stupidtest(f)
> for x in 1 : 10^8
>f(x)
> end
> end
>
> f(x) =  x + log(2.) * sin(.34567)^2
>
> const z = log(2.) * sin(.34567)^2
> g(x) = x + z
>
> @time( stupidtest(f) )
> @time( stupidtest(g) )
> #--- EOF--
>
> $julia --optimize --inline=yes --check-bounds=no --math-mode=fast 
> mycode.jl 
>   2.869774 seconds (200.00 M allocations: 2.980 GB, 3.39% gc time)
>   1.855530 seconds (200.00 M allocations: 2.980 GB, 4.32% gc time)
>
>
> It also seems that I (with a C++/Fortran background) do not really 
> understand 
> some aspects of the language. Why does a loop with a function call
> need so much memory allocations?
>
> Any explanations are appreciated!
>  
> Cheers, Meik
>
>
>

[julia-users] Re: optimization levels in julia?

2015-12-07 Thread Kristoffer Carlsson
You have already been linked the performance tip link once: 
http://julia.readthedocs.org/en/latest/manual/performance-tips/

It even explicitly says:

"Unexpected memory allocation is almost always a sign of some problem with your 
code, usually a problem with type-stability. Consequently, in addition to the 
allocation itself, it’s very likely that the code generated for your function 
is far from optimal. Take such indications seriously and follow the advice 
below."

When you start with something new, it is generally appreciated if you try take 
some time to read the documentation. Explaining the same thing to everyone is 
an O(N) effort while writing a good documentation explaining it is O(1).

[julia-users] Re: Solving overdetermined linear system with constraints

2015-12-07 Thread Tony Kelman
Oh you do have an objective function, I read that too quickly. You can do 
that by just adding

@setObjective(mod, Max, c*x + d*y)

to what I said earlier, before calling solve(mod).

(and that should've been rand(8) parameters, not sure where I got 10 from)


On Monday, December 7, 2015 at 1:43:13 AM UTC-8, ami...@gmail.com wrote:
>
> Hello,
>
> This question has to do as much with maths as with Julia packages, I'd 
> like to solve the following system of equations:
>
> a x + b y = k
> c x + d y <= l
> x <= m
> y <= n
>
> What would be the best approach to see if a solution exists and, if 
> several exist, I'd like to get the one which maximizes c x + d y. I know 
> there are Optimization packages, such as Optim but I don't know if a method 
> would be of help with what I want to do...
>
> Thanks for any hints!
>


[julia-users] Re: Solving overdetermined linear system with constraints

2015-12-07 Thread Tony Kelman
Use JuMP.jl, along with a linear programming solver like 
GLPKMathProgInterface.jl or Clp.jl.


julia> a, b, c, d, k, l, m, n = rand(10)
10-element Array{Float64,1}:
 0.568178
 0.743421
 0.113813
 0.690676
 0.338844
 0.915844
 0.657439
 0.954301
 0.328077
 0.679144

julia> using JuMP, GLPKMathProgInterface

julia> mod = Model()
Feasibility problem with:
 * 0 linear constraints
 * 0 variables
Solver set to Default

julia> @defVar(mod, x <= m)
x

julia> @defVar(mod, y <= n)
y

julia> @addConstraint(mod, a*x + b*y == k)
0.5681781704802831 x + 0.7434209900078323 y = 0.33884370309297873

julia> @addConstraint(mod, c*x + d*y <= l)
0.11381341105125764 x + 0.6906761760414999 y ≤ 0.9158442543667298

julia> solve(mod)
:Optimal

julia> getValue(x)
0.6574386150144564

julia> getValue(y)
-0.0466741817293331


This is a feasibility problem (no objective function) so it'll give you a 
single feasible point. Enumerating the entire feasible region for a linear 
program requires some computational geometry that I'm not sure we have a 
Julia package for just yet. In a small number of variables you can probably 
enumerate vertices by selecting appropriate objective functions though.


On Monday, December 7, 2015 at 1:43:13 AM UTC-8, ami...@gmail.com wrote:
>
> Hello,
>
> This question has to do as much with maths as with Julia packages, I'd 
> like to solve the following system of equations:
>
> a x + b y = k
> c x + d y <= l
> x <= m
> y <= n
>
> What would be the best approach to see if a solution exists and, if 
> several exist, I'd like to get the one which maximizes c x + d y. I know 
> there are Optimization packages, such as Optim but I don't know if a method 
> would be of help with what I want to do...
>
> Thanks for any hints!
>


Re: [julia-users] Re: optimization levels in julia?

2015-12-07 Thread Milan Bouchet-Valat
Le lundi 07 décembre 2015 à 01:59 -0800, Meik Hellmund a écrit :
> 
> Thank you for pointing out the problem with a global y and its type. 
> I hope my new code example below is better. I want to point at 
> the relative performance difference of the functions f and g.  
> 
> I am experimenting with Julia for  a couple of weeks and I like it
> very much. 
> In my experience, every language has a different  borderline between 
> "The programmer should think about optimal performance" and 
> "Don't overoptimize, the compiler is smarter than you". 
> 
> So I just want to understand if Julia does 
> constant expression evaluation at compile time or not
> 
> I think julia 0.4.1 does not. My code:
> #-
> function stupidtest(f)
> for x in 1 : 10^8
>f(x)
> end
> end
> 
> f(x) =  x + log(2.) * sin(.34567)^2
> 
> const z = log(2.) * sin(.34567)^2
> g(x) = x + z
> 
> @time( stupidtest(f) )
> @time( stupidtest(g) )
> #--- EOF--
> 
> $julia --optimize --inline=yes --check-bounds=no --math-mode=fast
> mycode.jl 
>   2.869774 seconds (200.00 M allocations: 2.980 GB, 3.39% gc time)
>   1.855530 seconds (200.00 M allocations: 2.980 GB, 4.32% gc time)
> 
> 
> It also seems that I (with a C++/Fortran background) do not really
> understand 
> some aspects of the language. Why does a loop with a function call
> need so much memory allocations?
> 
> Any explanations are appreciated!
I think passing functions as an argument isn't as fast as it could be
at the moment. Try defining two completely different test functions:

julia> f(x) =  x + log(2.) * sin(.34567)^2
f (generic function with 1 method)

julia> const z = log(2.) * sin(.34567)^2
0.07957594310953507

julia> g(x) = x + z
g (generic function with 1 method)

julia> function stupidtestf()
  for x in 1 : 10^8
 f(x)
  end
  end
stupidtestf (generic function with 1 method)

julia> function stupidtestg()
  for x in 1 : 10^8
 g(x)
  end
  end
stupidtestg (generic function with 1 method)

julia> @time( stupidtestf() )
  1.623907 seconds (2.13 k allocations:
109.855 KB)

julia> @time stupidtestf()
  1.631431 seconds (4 allocations: 160 bytes)

julia> @time stupidtestg()
  0.003252 seconds (1.81 k allocations: 92.401 KB)

julia> @time stupidtestg()
  0.02 seconds (4 allocations: 160 bytes)

Here the difference is well visible.


Also, benchmarking should be done after starting Julia and calling the
function once to avoid including compilation time and allocations.


Regards


[julia-users] Re: optimization levels in julia?

2015-12-07 Thread Meik Hellmund

Thank you for pointing out the problem with a global y and its type. 
I hope my new code example below is better. I want to point at 
the relative performance difference of the functions f and g.  

I am experimenting with Julia for  a couple of weeks and I like it very 
much. 
In my experience, every language has a different  borderline between 
"The programmer should think about optimal performance" and 
"Don't overoptimize, the compiler is smarter than you". 

So I just want to understand if Julia does 
constant expression evaluation at compile time or not

I think julia 0.4.1 does not. My code:
#-
function stupidtest(f)
for x in 1 : 10^8
   f(x)
end
end

f(x) =  x + log(2.) * sin(.34567)^2

const z = log(2.) * sin(.34567)^2
g(x) = x + z

@time( stupidtest(f) )
@time( stupidtest(g) )
#--- EOF--

$julia --optimize --inline=yes --check-bounds=no --math-mode=fast mycode.jl 
  2.869774 seconds (200.00 M allocations: 2.980 GB, 3.39% gc time)
  1.855530 seconds (200.00 M allocations: 2.980 GB, 4.32% gc time)


It also seems that I (with a C++/Fortran background) do not really 
understand 
some aspects of the language. Why does a loop with a function call
need so much memory allocations?

Any explanations are appreciated!
 
Cheers, Meik




[julia-users] Solving overdetermined linear system with constraints

2015-12-07 Thread amiksvi
Hello,

This question has to do as much with maths as with Julia packages, I'd like 
to solve the following system of equations:

a x + b y = k
c x + d y <= l
x <= m
y <= n

What would be the best approach to see if a solution exists and, if several 
exist, I'd like to get the one which maximizes c x + d y. I know there are 
Optimization packages, such as Optim but I don't know if a method would be 
of help with what I want to do...

Thanks for any hints!


[julia-users] Clebsch-Gordan and/or 3j symbols in julia ?

2015-12-07 Thread Ferran Mazzanti
Hi folks,

since I'm in the quantum mechanics world and I'm moving towards Julia, I 
was wondering if there's a simple way (package?) that anybody knowa
which allows to evaluate Clebsch-Gordan coefficints or Wigner 3-j symbols. 
I'm actually trying to get integrals of three Spherical Harmonics done
in Julia, so that's why I ask, but eventually I know I'll need the 
coefficients for future simulations also.

Thanks for your kind help,

Ferran.


Re: [julia-users] Re: range bug in 0.4.1?

2015-12-07 Thread Jürgen Bohnert
I honestly cannot imagine a good application justifying this 'range' 
function being in the main namespace. What it does is quite 
counter-intuitive. Or maybe renaming it would be an option?
Anyway thanks for all your answers guys.

Best,
Juergen


Am Montag, 7. Dezember 2015 04:11:07 UTC+1 schrieb whycrying:
>
> Ah. The second argument is the length of the range.
>
> And the three arguments's:
>
> julia> which(range,(Int,Int,Int))
>> range{T,S}(a::T, step::S, len::Integer) at range.jl:101
>>
>
> Not so consistent.
>
> Well, this is different from Python.
> Look range in Python(via iPython):
>
> In [3]: range?
>> Docstring:
>> range(stop) -> range object
>> range(start, stop[, step]) -> range object
>>
>> Return a sequence of numbers from start to stop by step.
>> Type:  type
>>
>
>
>
> -- 
> https://www.zhangkaizhao.com/
>


[julia-users] Re: range bug in 0.4.1?

2015-12-07 Thread Jürgen Bohnert
Thanks for pointing this out. Briefly skimming over the doc had me 
confusing 'length' with the expected 'stop' argument.

Am Sonntag, 6. Dezember 2015 08:56:11 UTC+1 schrieb Gabor:
>
> I am also surprised at this behaviour, but it is certainly not a bug.
> Have a look at the help:
>
> help?> range
>   range(start, [step], length)
>   Construct a range by length, given a starting value and optional step 
> (defaults to 1).
>
> help?> colon
>   ..  \:(start, [step], stop)
>   Range operator. ``a:b`` constructs a range from ``a`` to ``b`` with a 
> step size of 1, 
>   and ``a:s:b`` is similar but uses a step size of ``s``. 
>   These syntaxes call the function ``colon``.
>   The colon is also used in indexing to select whole dimensions.
>   colon(start, [step], stop)
>   Called by : syntax for constructing ranges.
>
>
> On Sunday, December 6, 2015 at 8:41:34 AM UTC+1, Jürgen Bohnert wrote:
>>
>>
>>
>> Hi everyone,
>>
>> I found some really strange behaviour of the 'range' function
>>
>> range(1,5)
>> > 1:5
>> everything is OK
>>
>> range(2,5)
>> > 2:6
>> NOT OK!
>>
>> range(10,20)
>> > 10:29
>> NOT OK!
>>
>> However, if I define the range like so
>> 10:20
>> > 10:20
>> OK and obviously works for all you guys as well.
>>
>> Am I missing some syntax or is this a bug?
>>
>>
>>
>> Also: is there a way to redefine the default behaviour of the 
>> range-syntax? It's really annoying having to 'Int' everything when I'm just 
>> specifying limits that get coerced to 'Float' because of division but are 
>> otherwise 'X.0'
>> N=2^3 -1
>> > 7
>> imid = (N+1)/2
>> > 4.0
>> range(imid-2, imid+2)
>> > ERROR: MethodError: 'range' has no method matching range(::Float64, ::
>> Float64)
>>
>> Thanks for helping,
>> Juergen
>>
>> julia build:
>> Version 0.4.1 (2015-11-08 10:33 UTC)
>> both:
>>
>>- x86_64-w64-mingw32
>>- x86_64-linux-gnu
>>
>>
>>
>>
>>
>>
>>
>>