[julia-users] Re: Change bold text in REPL to normal

2016-02-08 Thread Nitin Arora
+1, i am looking for a solution here as well.

On Monday, February 8, 2016 at 12:10:28 AM UTC-8, cormu...@mac.com wrote:
>
> I'm trying to improve the appearance of text in my Julia REPL. According 
> to this PR (https://github.com/JuliaLang/julia/pull/11250) (which sadly 
> seems to have ground to a halt), it should be possible to control the 
> appearance of text in the REPL by adding lines to the .juliarc.jl file. 
>
> I've tried adding stuff like:
>
> ENV["JULIA_WARN_COLOR"] = :normal
> ENV["JULIA_INFO_COLOR"] = :normal
>
> to the .juliarc.jl. I've also tried various commands in the REPL, such as:
>
> julia> Base.active_repl.prompt_color = Base.text_colors[:normal]
>
> and various other things, but nothing has yet worked. But I feel I'm 
> close! :). 
>
> Anybody successfully controlled the colors in the REPL?
>
>

[julia-users] Re: leaky if semantics

2016-02-08 Thread Benjamin Deonovic
If you keep reading from the link you gave:

The variable relation is declared inside the if block, but used outside. 
However, when depending on this behavior, make sure all possible code paths 
define a value for the variable. The following change to the above function 
results in a runtime error

julia> function test(x,y)
 if x < y
   relation = "less than"
 elseif x == y
   relation = "equal to"
 end
 println("x is ", relation, " y.")
   endtest (generic function with 1 method)
julia> test(1,2)x is less than y.
julia> test(2,1)ERROR: UndefVarError: relation not defined
 in test at none:7

You will see that when i==2 you won't define x and therefore you will get 
the runtime error. 

On Monday, February 8, 2016 at 5:41:40 AM UTC-6, David van Leeuwen wrote:
>
> Hello, 
>
> According to 
> http://docs.julialang.org/en/release-0.4/manual/control-flow/#man-conditional-evaluation
>  variables 
> in if blocks do not introduce lexical scope, and hence are available 
> afterwards.   This makes sense and is what I need. 
>
> However, it seems afterwards relates to position in the encapsulating 
> block, and not to execution time. 
>
> function testif()
> for i in 1:2
> if i==1
> x = 0
> end
> if x==2
> println(x)
> end
> end
> end
>
>
> This code gives me an undefined `x` in the print statement, where I would 
> have expected `x` to be initialized in the first iteration.  It seems I 
> need to define `x` outside the for loop, even though I don't need it there. 
>  
>
> Is this interpretation in Julia intentional?
>
> Cheers, 
>
> ---david
>
>

[julia-users] Latest master: make command fails

2016-02-08 Thread Lutfullah Tomak
Hi All
After 'git pull' or new 'git clone', 'make full-source-dist' or 'make -C 
deps getall'
fails with

make[1]: *** No rule to make target 
'/path/to/julia/deps/srccache/libunwind-1.1-julia.tar.gz', needed by 
'get-unwind'.  Stop.
make[1]: *** Waiting for unfinished jobs

Do I have to get 'libunwind-1.1-julia.tar.gz' from somewhere manually?



Re: [julia-users] Memory allocation free array slices ?

2016-02-08 Thread mschauer
A further possibility is to work with vector of FixedSizeArrays (a julia 
package). You can cast a dxn array to an n-array of immutable 
d-FixedSizeVectors (they have the same memory layout) and then access the 
columns directly using stack allocation (just the same as you would work 
with a complex vector instead of a 2xn array)



Am Montag, 8. Februar 2016 00:39:28 UTC+1 schrieb Nitin Arora:
>
> Thanks and Tim and Stefan, if there is anyway I can contribute to help, do 
> let me know.
>
> thanks,
> Nitin
>
> On Sunday, February 7, 2016 at 8:24:38 AM UTC-8, Stefan Karpinski wrote:
>>
>> Being able to stack-allocate objects that refer to the heap is an 
>> important case that we need to address, but doing so is non-trivial and 
>> hasn't been done yet.
>>
>> On Sunday, February 7, 2016, Tim Holy  wrote:
>>
>>> I filed an issue, https://github.com/JuliaLang/julia/issues/14955, 
>>> which you
>>> can check to learn about progress on this problem.
>>>
>>> Best,
>>> --Tim
>>>
>>> On Saturday, February 06, 2016 03:35:34 PM Nitin Arora wrote:
>>> > I see, thanks for the information. I think, if possible, this feature 
>>> will
>>> > help the language a lot.
>>> >
>>> > I have recommended Julia to many of my colleagues (they all love it 
>>> over
>>> > Fortran and Matlab) and most of them seem to run into this issue. I 
>>> think,
>>> > a modern language with soo much elegance and potential, like Julia, 
>>> should
>>> > nail such major issues. I am sure by V-1.0 we will have the best 
>>> scientific
>>> > programming language ever :-)
>>> >
>>> > thanks,
>>> > Nitin
>>> >
>>> > On Saturday, February 6, 2016 at 3:55:56 AM UTC-8, Tim Holy wrote:
>>> > > On Friday, February 05, 2016 05:24:04 PM Nitin Arora wrote:
>>> > > > Thanks Tim, this is very useful. I will probably use 
>>> CartesianRange now.
>>> > > >
>>> > > > Is Julia 0.5 Arraypocalypse planning to address this issue as well 
>>> ?
>>> > >
>>> > > I don't think there's a way to solve this by changing our 
>>> implementation
>>> > > of
>>> > > views; I think it's more of a compiler issue, and the fact that
>>> > >
>>> > > julia> isbits(CartesianRange((3,5)))
>>> > > true
>>> > >
>>> > > julia> immutable ArrayWrapper{M}
>>> > >
>>> > >data::M
>>> > >
>>> > >end
>>> > >
>>> > > julia> z = rand(5,5);
>>> > >
>>> > > julia> isbits(ArrayWrapper(z))
>>> > > false
>>> > >
>>> > >
>>> > > Since I don't work on the compiler, I can't speak for what's going to
>>> > > happen
>>> > > there, but I'd be surprised if this changes in 0.5.
>>> > >
>>> > > Best,
>>> > > --Tim
>>> > >
>>> > > > thanks,
>>> > > > Nitin
>>> > > >
>>> > > > On Friday, February 5, 2016 at 3:24:34 PM UTC-8, Tim Holy wrote:
>>> > > > > On Friday, February 05, 2016 08:17:21 AM Kevin Squire wrote:
>>> > > > > > I think this needs to be @time bar(A).
>>> > > > >
>>> > > > > Yeah, sorry for the typo.
>>> > > > >
>>> > > > > > I get
>>> > > > > >
>>> > > > > > julia> @time bar(A)
>>> > > > > >
>>> > > > > >   0.000269 seconds (5 allocations: 176 bytes)
>>> > > > > >
>>> > > > > > 20010.937886591404
>>> > > > >
>>> > > > > That's just REPL allocation. Since A has 1 columns, if this
>>> > >
>>> > > strategy
>>> > >
>>> > > > > were
>>> > > > > allocating you'd expect "1+n allocations," where n comes 
>>> from the
>>> > > > > REPL.
>>> > > > >
>>> > > > > --Tim
>>>
>>>

Re: [julia-users] leaky if semantics

2016-02-08 Thread FQ
did you mean to write 'i==2' instead of 'x==2' in the second if statement?


Am 08.02.2016 um 12:41 schrieb David van Leeuwen:
> Hello, 
> 
> According
> to 
> http://docs.julialang.org/en/release-0.4/manual/control-flow/#man-conditional-evaluation
>  variables
> in if blocks do not introduce lexical scope, and hence are available
> afterwards.   This makes sense and is what I need. 
> 
> However, it seems afterwards relates to position in the encapsulating
> block, and not to execution time. 
> 
> |
> functiontestif()
> |
> for i in 1:2
> if i==1
> x = 0
> end
> if x==2
> println(x)
> end
> end
> end
> 
> 
> This code gives me an undefined `x` in the print statement, where I
> would have expected `x` to be initialized in the first iteration.  It
> seems I need to define `x` outside the for loop, even though I don't
> need it there.  
> 
> Is this interpretation in Julia intentional?
> 
> Cheers, 
> 
> ---david
> 



Re: [julia-users] associating outer constructors with different names with a type

2016-02-08 Thread Uri Patish
Hi Stefan, Toivo. Thanks for joining the discussion. 

Toivo you are on point. Having though more on the matter, I think the right 
to describe the sitution is a s follows. Suppose we have two immutable 
types whose data layout is exactly the same, their behavior is exactly the 
same, and the only difference between them is their invariant which is 
enforced through two different constructors. In this case, I think it would 
be wrong to hide this information both from the compiler, and from other 
programmers. Even though I'm no expert in compilation, seems to me that 
providing this additional information about the type equivalence to the 
compiler can only benefit the optimization that happen under the hood. 
Second, from the programmer perspective, I would say that emphasizing that 
two types are only different in their constructors increases code 
readiability. For someone whose reading the code, having one less type to 
remember makes things easier. It makes the type hierarchy more parsimonious.

>From an information theoretic perspective, defining two different types in 
case denies any reciever of the code (compiliers or other programmers) the 
fact that they are equivanlent. I cannot see any way how this could be 
beneficial. 

In practice, I think the right way to go about this is to define a single 
type, and have few overloaded constructors. In Julia, this can be achieved 
by adding another parameter of value type. The only problem with this 
solution is that this makes the constructor a little more cumbersome to 
use. To overcome this, I can see two solutions. The first, which I like 
less, is to have a constructor alias. In this case, Julia would know to 
associate other constructors with the type, thus, allowing the use of <:, 
or any other method that operates on datatypes with the other constructors. 
The second solution, which I prefer, is adding or changing type aliases to 
type references. The problem with type aliases is that they merely provide 
shorthand notation, which I assuming, is removed by the Julia parser. If on 
the other hand, one could define a type reference which would indicate that 
the new type has exactly the same data layout as another type, but allowing 
the dispatch system to distiguish between the two types in terms of method 
calls, then this situation would have a great solution. The code in case 
would look like,

immutable SomeType
  value::Int
end

typeref SomePositiveType SomeType
function SomePositiveType(value::Int)
  if value < 0
error("value must be positive")
  end
  SomeType(value)
end

typeref SomeNegativeType SomeType
function SomeNegativeType(value::Int)
  if value > 0
error("value must be negative")
  end
  SomeType(value)
end

If type references were an option, following the last discussion, then my 
answer to Tim and Stefan would be yes. Int, UInt, and Float64 should all be 
type references to a more basic type, maybe Number64. 

Uri



[julia-users] Re: leaky if semantics

2016-02-08 Thread elextr
The x is not kept between iterations of the for 
see 
http://docs.julialang.org/en/release-0.4/manual/variables-and-scoping/#for-loops-and-comprehensions

On Monday, February 8, 2016 at 9:41:40 PM UTC+10, David van Leeuwen wrote:
>
> Hello, 
>
> According to 
> http://docs.julialang.org/en/release-0.4/manual/control-flow/#man-conditional-evaluation
>  variables 
> in if blocks do not introduce lexical scope, and hence are available 
> afterwards.   This makes sense and is what I need. 
>
> However, it seems afterwards relates to position in the encapsulating 
> block, and not to execution time. 
>
> function testif()
> for i in 1:2
> if i==1
> x = 0
> end
> if x==2
> println(x)
> end
> end
> end
>
>
> This code gives me an undefined `x` in the print statement, where I would 
> have expected `x` to be initialized in the first iteration.  It seems I 
> need to define `x` outside the for loop, even though I don't need it there. 
>  
>
> Is this interpretation in Julia intentional?
>
> Cheers, 
>
> ---david
>
>

[julia-users] Re: Nullable{Date}

2016-02-08 Thread 'Greg Plowman' via julia-users
If only Nullables can be null, could we formally define this?

isnull(x::Nullable) = x.isnull # already defined in nullable.jl
isnull(x) = false  # extra definition for everything else



> isnull( lp15 ) --> true
> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull( 
> ::Date )
>



[julia-users] Nullable{Date}

2016-02-08 Thread Michael Landis
I'm so confused

I thought this would be cool:
isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()

lp15 = LeapDay(2015) --> Nullable{Date}()
lp16 = LeapDay(2016) --> 2016-02-29

no surprises there, but when I test the return values ...

isnull( lp15 ) --> true
isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull( 
::Date )

What IS the secret Nullable{Date} formulation?


[julia-users] Re: Nullable{Date}

2016-02-08 Thread Christopher Alexander
I really like that construction!

On Monday, February 8, 2016 at 10:49:41 PM UTC-5, Greg Plowman wrote:
>
> If only Nullables can be null, could we formally define this?
>
> isnull(x::Nullable) = x.isnull # already defined in nullable.jl
> isnull(x) = false  # extra definition for everything else
>
>
>
>> isnull( lp15 ) --> true
>> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull( 
>> ::Date )
>>
>
>

Re: [julia-users] Re: Nullable{Date}

2016-02-08 Thread Michael Landis
Why can't there be a base type upon which all others are based (perhaps by 
default)?  The base class could handle the Nullable situation and 
everything else would magically inherit that capability.  Making a union of 
a NULL and the actual type is pretty painful for the programmer.  Weren't 
we going for a smart compiler that would make life easier on the 
programmer?  What we have now is programmers going out of their way to make 
life easy for the compiler.  That seems back-assward to me.


[julia-users] Re: Nullable{Date}

2016-02-08 Thread Christopher Alexander
For a null date, I usually just use Date() (Dates.Date()), which returns 
Jan 1, 0001.  Also, you know that there is already a method to check 
whether or not a year is a leap year right? 

Dates.isleapyear(y), returns a Bool. 
 http://docs.julialang.org/en/release-0.4/manual/dates/

On Monday, February 8, 2016 at 10:08:25 PM UTC-5, Michael Landis wrote:
>
> I'm so confused
>
> I thought this would be cool:
> isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
> LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
>
> lp15 = LeapDay(2015) --> Nullable{Date}()
> lp16 = LeapDay(2016) --> 2016-02-29
>
> no surprises there, but when I test the return values ...
>
> isnull( lp15 ) --> true
> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull( 
> ::Date )
>
> What IS the secret Nullable{Date} formulation?
>


Re: [julia-users] Nullable{Date}

2016-02-08 Thread Michael Landis
Thanks Erik.  Much appreciated...

On Mon, Feb 8, 2016 at 7:11 PM, Erik Schnetter  wrote:

> You need to write
>
> LeapDay(yr) = isLeapYr(yr) ? Nullable(Date(yr,2,29)) : Nullable{Date}()
>
> so that the return value is always a Nullable{Date}.
>
> -erik
>
> On Mon, Feb 8, 2016 at 10:08 PM, Michael Landis
>  wrote:
> > I'm so confused
> >
> > I thought this would be cool:
> > isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
> > LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
> >
> > lp15 = LeapDay(2015) --> Nullable{Date}()
> > lp16 = LeapDay(2016) --> 2016-02-29
> >
> > no surprises there, but when I test the return values ...
> >
> > isnull( lp15 ) --> true
> > isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull(
> > ::Date )
> >
> > What IS the secret Nullable{Date} formulation?
>
>
>
> --
> Erik Schnetter 
> http://www.perimeterinstitute.ca/personal/eschnetter/
>


Re: [julia-users] Nullable{Date}

2016-02-08 Thread Michael Landis
I know there's a language theorist out there that thinks having typed
Nullables confers some sort of linguistic purity, but I think it's a royal
pain.  Every function needs to know whether Nullable is possible from all
of it's callers?  What you gain in semantic purity, you pay for in the
configuration back end.  I thought the whole point of the language was
write what you mean.  Typed Nullables seem counter to that strategic
objective.

On Mon, Feb 8, 2016 at 7:11 PM, Erik Schnetter  wrote:

> You need to write
>
> LeapDay(yr) = isLeapYr(yr) ? Nullable(Date(yr,2,29)) : Nullable{Date}()
>
> so that the return value is always a Nullable{Date}.
>
> -erik
>
> On Mon, Feb 8, 2016 at 10:08 PM, Michael Landis
>  wrote:
> > I'm so confused
> >
> > I thought this would be cool:
> > isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
> > LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
> >
> > lp15 = LeapDay(2015) --> Nullable{Date}()
> > lp16 = LeapDay(2016) --> 2016-02-29
> >
> > no surprises there, but when I test the return values ...
> >
> > isnull( lp15 ) --> true
> > isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull(
> > ::Date )
> >
> > What IS the secret Nullable{Date} formulation?
>
>
>
> --
> Erik Schnetter 
> http://www.perimeterinstitute.ca/personal/eschnetter/
>


Re: [julia-users] Re: Nullable{Date}

2016-02-08 Thread Jacob Quinn
The problem with that proposition is that it introduces type instability.
i.e. the user would be tempted to write code like Michael's original
example like

LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()

where the function `LeapDay` can actually return two different, distinct
types: `Date` or `Nullable{Date}`. Those familiar with efficient codegen
know that these kinds of type instabilities kill code performance.

-Jacob

On Mon, Feb 8, 2016 at 8:55 PM, Christopher Alexander 
wrote:

> I really like that construction!
>
>
> On Monday, February 8, 2016 at 10:49:41 PM UTC-5, Greg Plowman wrote:
>>
>> If only Nullables can be null, could we formally define this?
>>
>> isnull(x::Nullable) = x.isnull # already defined in nullable.jl
>> isnull(x) = false  # extra definition for everything else
>>
>>
>>
>>> isnull( lp15 ) --> true
>>> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull(
>>> ::Date )
>>>
>>
>>


Re: [julia-users] load a Julia dataframe from Microsoft SQL Server table

2016-02-08 Thread Jameson
Calling the ANSI version doesn't preclude the possibility of getting UTF16 
data back. In particular, that would be code page 1200 (utf16le) or 1201 
(utf16be) for Microsoft Windows. MSDN is inconsistent in their usage of A 
and whether it means ANSI, OEM, localized-locale, or application-dependent 
(aka other) and generally makes no statement about how the bytes may need 
to be handled or interpreted.


On Friday, February 5, 2016 at 1:44:20 PM UTC-5, Stefan Karpinski wrote:
>
> It does, but that's not what we're seeing – at least with some ODBC 
> drivers.
>
> On Fri, Feb 5, 2016 at 1:18 PM, David Anthoff  
> wrote:
>
>>
>> https://msdn.microsoft.com/en-us/library/ms716246%28v=vs.85%29.aspx?f=255=-2147217396
>>
>>  
>>
>> suggests that if you call the version without the A or W suffix you get 
>> the ANSI version. 
>>
>>  
>>
>> *From:* julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] 
>> *On Behalf Of *Scott Jones
>> *Sent:* Thursday, February 4, 2016 1:55 PM
>> *To:* julia-users 
>> *Subject:* Re: [julia-users] load a Julia dataframe from Microsoft SQL 
>> Server table
>>
>>  
>>
>>
>>
>> On Thursday, February 4, 2016 at 4:29:46 PM UTC-5, Stefan Karpinski wrote:
>>
>> On Thu, Feb 4, 2016 at 1:50 PM, Scott Jones  
>> wrote:
>>
>>  
>>
>> This still doesn't explain why some drivers are accepting UCS-2/UTF-16 
>> when called with the non-Unicode API.
>>
>>  
>>
>> When you do so, are you actually calling the functions with the A, or 
>> just the macro without either A or W?
>>
>> The macro will compile to either the A or the W form, depending on how 
>> your application is built.
>>
>>  
>>
>> This is a better page in MSDN: 
>> https://msdn.microsoft.com/en-us/library/ms712612(v=vs.85).aspx describing 
>> what is going on.
>>
>>  
>>
>> The ODBC package calls the functions without A or W. What it's calling 
>> can't be a macro since macros aren't callable via ccall. But changing ODBC 
>> to call the W version of everything may be the fix here.
>>
>>  
>>
>> That very well may be the solution: looking for example at libiodbc on 
>> the Mac, it has 3 different versions of all those functions, and I'm not 
>> sure just what behavior you get when using the form without the A or W.  
>> I've always used ODBC with the C headers, unlike the direct linking that 
>> Julia is doing, so that it always gets the W version since I compile as a 
>> Unicode build. 
>>
>
>

Re: [julia-users] Re: Nullable{Date}

2016-02-08 Thread Michael Landis
ah, cool.  Missed that.  Thanks.  The pain in returning a Nullable{Date} is
that now I have to unpack it for things like dayofyear().  Nullable
introduces a rat's nest of unnecessary complications.

On Mon, Feb 8, 2016 at 7:35 PM, Christopher Alexander 
wrote:

> For a null date, I usually just use Date() (Dates.Date()), which returns
> Jan 1, 0001.  Also, you know that there is already a method to check
> whether or not a year is a leap year right?
>
> Dates.isleapyear(y), returns a Bool.
> http://docs.julialang.org/en/release-0.4/manual/dates/
>
>
> On Monday, February 8, 2016 at 10:08:25 PM UTC-5, Michael Landis wrote:
>>
>> I'm so confused
>>
>> I thought this would be cool:
>> isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
>> LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
>>
>> lp15 = LeapDay(2015) --> Nullable{Date}()
>> lp16 = LeapDay(2016) --> 2016-02-29
>>
>> no surprises there, but when I test the return values ...
>>
>> isnull( lp15 ) --> true
>> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull(
>> ::Date )
>>
>> What IS the secret Nullable{Date} formulation?
>>
>


Re: [julia-users] Re: Nullable{Date}

2016-02-08 Thread Kevin Squire
To be fair, writing code like this is perfectly fine, if you're not
concerned about performance (in the area of code that this is written in).

I find for my own code that I'll typically write something in a clean but
possibly inefficient way, and the profile and optimize where I find
bottlenecks.

Conversely, you'll find the trend in Julia mainline is to write very
efficient code for the core system, and remove or discourage design
patterns which produce inefficient code.

Cheers!
   Kevin


On Mon, Feb 8, 2016 at 8:13 PM, Jacob Quinn  wrote:

> The problem with that proposition is that it introduces type instability.
> i.e. the user would be tempted to write code like Michael's original
> example like
>
> LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
>
> where the function `LeapDay` can actually return two different, distinct
> types: `Date` or `Nullable{Date}`. Those familiar with efficient codegen
> know that these kinds of type instabilities kill code performance.
>
> -Jacob
>
> On Mon, Feb 8, 2016 at 8:55 PM, Christopher Alexander 
> wrote:
>
>> I really like that construction!
>>
>>
>> On Monday, February 8, 2016 at 10:49:41 PM UTC-5, Greg Plowman wrote:
>>>
>>> If only Nullables can be null, could we formally define this?
>>>
>>> isnull(x::Nullable) = x.isnull # already defined in nullable.jl
>>> isnull(x) = false  # extra definition for everything
>>> else
>>>
>>>
>>>
 isnull( lp15 ) --> true
 isnull( lp16 ) -->  MethodError: `isnull` has no method matching
 isnull( ::Date )

>>>
>>>
>


Re: [julia-users] Nullable{Date}

2016-02-08 Thread Erik Schnetter
You need to write

LeapDay(yr) = isLeapYr(yr) ? Nullable(Date(yr,2,29)) : Nullable{Date}()

so that the return value is always a Nullable{Date}.

-erik

On Mon, Feb 8, 2016 at 10:08 PM, Michael Landis
 wrote:
> I'm so confused
>
> I thought this would be cool:
> isLeapYr(yr::Int64) = yr % 400 == 0  ||  (yr % 4 == 0  &&  yr % 100 != 0)
> LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}()
>
> lp15 = LeapDay(2015) --> Nullable{Date}()
> lp16 = LeapDay(2016) --> 2016-02-29
>
> no surprises there, but when I test the return values ...
>
> isnull( lp15 ) --> true
> isnull( lp16 ) -->  MethodError: `isnull` has no method matching isnull(
> ::Date )
>
> What IS the secret Nullable{Date} formulation?



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


Re: [julia-users] Latest master: make command fails

2016-02-08 Thread Yichao Yu
Should be fixed by https://github.com/JuliaLang/julia/pull/14965 now.

On Mon, Feb 8, 2016 at 7:18 AM, Lutfullah Tomak  wrote:
> Hi All
> After 'git pull' or new 'git clone', 'make full-source-dist' or 'make -C
> deps getall'
> fails with
>
> make[1]: *** No rule to make target
> '/path/to/julia/deps/srccache/libunwind-1.1-julia.tar.gz', needed by
> 'get-unwind'.  Stop.
> make[1]: *** Waiting for unfinished jobs
>
> Do I have to get 'libunwind-1.1-julia.tar.gz' from somewhere manually?
>


Re: [julia-users] Latest master: make command fails

2016-02-08 Thread Lutfullah Tomak
Thanks Yichao, it works now.

Re: [julia-users] Julia version mismatch

2016-02-08 Thread Zheng Wendell
After `make cleanall`, the problem is solved.

Thanks! @Mauro


[julia-users] RingArrays.jl - A sliding window into a larger array

2016-02-08 Thread Samuel Massinon
RingArrays is a way to access a large dataset in incremental chucks to 
limit the amount of memory you need. You would use a RingArray when you are 
wanting to work with a massive dataset like an array.

https://github.com/invenia/RingArrays.jl


[julia-users] Re: Eclipse plugin for Julia

2016-02-08 Thread Harold C.
Dear Viral,

Julia is absolutely splendid but the available IDEs… not so much. While I'm 
optimistic about the evolving Atom-based Juno, I've been wondering if 
there's any chance of cooperation with RStudio developers. Could it be 
adapted for Julia? Despite Qt and little customisation features (where Atom 
is clearly dominant), I think it's the best available IDE for scientific 
computing.

Harold

On Saturday, 6 February 2016 12:52:33 UTC+1, Viral Shah wrote:
>
> We've put together an Eclipse plugin for Julia and open sourced it. This 
> includes some early work, and the plans are to take it to the next level 
> with participation from everyone.
>
> Blog post: http://juliacomputing.com/blog/2016/02/06/Eclipse-JuliaDT.html
>
> Repository: https://github.com/JuliaComputing/JuliaDT
>
> I am quite hopeful that with all the progress made on Juno/Atom and 
> Eclipse, we should have two good IDEs soon.
>
> -viral
>


Re: [julia-users] How to debug Pkg "failed to connect" issue?

2016-02-08 Thread Yichao Yu
On Mon, Feb 8, 2016 at 12:53 PM, Arch Robison  wrote:
> How do I go about debugging why the Julia package manager can't connect to
> Github?  I've tried the usual firewall workarounds (see below).  Either of
> the following works fine:
>
> git clone https://github.com/JuliaLang/METADATA.jl
>
> git clone git://github.com/JuliaLang/METADATA.jl
>
> But within Julia, Pkg.init() fails with:
>
> julia> Pkg.init()
> INFO: Initializing package repository /nfs/fx/home/adrobiso/.julia/v0.5
> INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
> ERROR: GitError(Code:ERROR, Class:OS, Failed to connect to github.com:
> Connection timed out)

Given the error and that you want to use proxy. Maybe
https://github.com/JuliaLang/julia/issues/13472 ?

>
>
> I've already have the following variables set:
> HTTP_PROXY=http://proxy-us.intel.com:911
> HTTPS_PROXY=http://proxy-us.intel.com:911
> http_proxy=http://proxy-us.intel.com:911
> https_proxy=http://proxy-us.intel.com:911
>
> and I've run:
> git config --global url."https://".insteadOf git://
> git config --global http.proxy $HTTP_PROXY
>
> Suggestions?
>
> - Arch
>


[julia-users] How to debug Pkg "failed to connect" issue?

2016-02-08 Thread Arch Robison
How do I go about debugging why the Julia package manager can't connect to 
Github?  I've tried the usual firewall workarounds (see below).  Either of 
the following works fine:

git clone https://github.com/JuliaLang/METADATA.jl

git clone git://github.com/JuliaLang/METADATA.jl

But within Julia, Pkg.init() fails with:

julia> Pkg.init()
INFO: Initializing package repository /nfs/fx/home/adrobiso/.julia/v0.5
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
ERROR: GitError(Code:ERROR, Class:OS, Failed to connect to github.com: 
Connection timed out)


I've already have the following variables set: 
HTTP_PROXY=http://proxy-us.intel.com:911
HTTPS_PROXY=http://proxy-us.intel.com:911
http_proxy=http://proxy-us.intel.com:911
https_proxy=http://proxy-us.intel.com:911

and I've run:
git config --global url."https://".insteadOf git://
git config --global http.proxy $HTTP_PROXY

Suggestions?

- Arch



[julia-users] Re: Eclipse plugin for Julia

2016-02-08 Thread Oleg Mikulchenko
Congratulations, Viral! 

And thank you very much - people really need it. For me it is like a 
deal-maker, now I can go back to Julia, even accepting some rough edges in 
Eclipse plugin. 

Oleg 



Re: [julia-users] Re: Eclipse plugin for Julia

2016-02-08 Thread Stefan Karpinski
On Mon, Feb 8, 2016 at 1:39 PM, Oleg Mikulchenko 
wrote:

> And thank you very much - people really need it. For me it is like a
> deal-maker, now I can go back to Julia, even accepting some rough edges in
> Eclipse plugin.


Glad it helps! If you find encounter issues with the Eclipse, please do
file them.


Re: [julia-users] Re: Announcing "Persist": Evaluating Julia expressions in the background

2016-02-08 Thread Erik Schnetter
On Thu, Feb 4, 2016 at 12:33 PM, cdm  wrote:
>
> any thoughts on how this relates to threading / multi-threading and
> parallelisation ... ?

By design, this starts a new instance of Julia. Multi-threading within
the submitted job will work just fine. The new job can also start
additional processes either via the standard mechanism, or (better,
but not yet implemented) by integrating it with the MPI cluster
manager.

When you start a job via Persist, there is already an option "nprocs"
that you can use to choose the number of processes that Slurm should
reserve for the job.

-erik

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


Re: [julia-users] Re: Announcing "Persist": Evaluating Julia expressions in the background

2016-02-08 Thread Erik Schnetter
On Wed, Feb 3, 2016 at 9:04 PM, William Patterson  wrote:
> Hi Eric,
> I think this package is great. It increases code readability and provides
> functionality otherwise unavailable in Julia and other languages.
>
> I do have one question though: How do I set slurm parameters such as
> --mem-per-cpu, --cpus-per-task, etc? Forgive me if this has already been
> explained.

Will

I see that this is currently not yet possible. It should be
straightforward to add, by allowing additional keyword arguments to
the "submit" function. Can you open a feature request for the package?

-erik

> Thanks,
> --Will
>
> On Friday, November 27, 2015 at 7:14:40 AM UTC-8, Erik Schnetter wrote:
>>
>> I'd like to kindly draw your attention to a new package "Persist":
>> .
>>
>> This package mainly provides one macro `@persist` that evaluates a Julia
>> expression in the background, in a separate Julia process, independent of
>> the current Julia shell. The main point is that this evaluation will not be
>> interrupted or aborted if the current Julia shell exits. This is a
>> convenient shortcut to writing a small Julia script and executing it in the
>> background; think of it as an `@spawn` that persists even when the Julia
>> shell exits. The readme on Github has details and examples.
>>
>> Persist can also use Slurm to submit a job. There are several obvious
>> ideas (integration with ClusterManager, better integration with MPI, etc.)
>> that I'd like to explore in the feature; your feedback is welcome.
>>
>>
>>
>> Some philosophical points:
>>
>> Current HPC queuing managers conflate two ideas: resource management
>> (getting access to compute nodes that are usually oversubscribed) and
>> persistent execution (ensuring that a calculation is not aborted if the
>> shell is closed or the network connection to the HPC system drops). However,
>> from a user's point of view these two should ideally be separate:
>> (1) When I'm developing or debugging or visualizing, I'd like interactive
>> access to compute nodes
>> (2) When I'm using the Julia shell or Jupyter, I'd like to be able to
>> easily start certain long-running calculations in the background.
>>
>> The package "ClusterManagers" offers feature (1); I hope that HPC queueing
>> systems will become more flexible over time to simplify such interactive
>> access.
>>
>> This package "Persist" offers feature (2).
>>
>> -erik
>>
>> --
>> Erik Schnetter 
>> http://www.perimeterinstitute.ca/personal/eschnetter/



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


Re: [julia-users] Re: Announcing "Persist": Evaluating Julia expressions in the background

2016-02-08 Thread Erik Schnetter
Nitin

If you have used Persist and found it useful, then I'd be happy if you
could let me know which parts worked and which parts didn't work, or
caused problems.

Thanks,
-erik

On Thu, Feb 4, 2016 at 6:07 PM, Nitin Arora  wrote:
> Thank you ! This will help my workflow a lot.
>
> On Friday, November 27, 2015 at 7:14:40 AM UTC-8, Erik Schnetter wrote:
>>
>> I'd like to kindly draw your attention to a new package "Persist":
>> .
>>
>> This package mainly provides one macro `@persist` that evaluates a Julia
>> expression in the background, in a separate Julia process, independent of
>> the current Julia shell. The main point is that this evaluation will not be
>> interrupted or aborted if the current Julia shell exits. This is a
>> convenient shortcut to writing a small Julia script and executing it in the
>> background; think of it as an `@spawn` that persists even when the Julia
>> shell exits. The readme on Github has details and examples.
>>
>> Persist can also use Slurm to submit a job. There are several obvious
>> ideas (integration with ClusterManager, better integration with MPI, etc.)
>> that I'd like to explore in the feature; your feedback is welcome.
>>
>>
>>
>> Some philosophical points:
>>
>> Current HPC queuing managers conflate two ideas: resource management
>> (getting access to compute nodes that are usually oversubscribed) and
>> persistent execution (ensuring that a calculation is not aborted if the
>> shell is closed or the network connection to the HPC system drops). However,
>> from a user's point of view these two should ideally be separate:
>> (1) When I'm developing or debugging or visualizing, I'd like interactive
>> access to compute nodes
>> (2) When I'm using the Julia shell or Jupyter, I'd like to be able to
>> easily start certain long-running calculations in the background.
>>
>> The package "ClusterManagers" offers feature (1); I hope that HPC queueing
>> systems will become more flexible over time to simplify such interactive
>> access.
>>
>> This package "Persist" offers feature (2).
>>
>> -erik
>>
>> --
>> Erik Schnetter 
>> http://www.perimeterinstitute.ca/personal/eschnetter/



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


[julia-users] julia build fails on arm

2016-02-08 Thread Lutfullah Tomak
I tried to build julia master on arm but build fails while linking libjulia.so
Fail message reads as

LINK usr/bin/julia
/path/to/julia/usr/lib/libjulia.so: undefined reference to `__register_frame'
/path/to/julia/usr/lib/libjulia.so: undefined reference to `__deregister_frame'
collect2: error: ld returned 1 exit status
Makefile:78: recipe for target '/path/to/julia/usr/bin/julia' failed
make[1]: *** [/path/to/julia/usr/bin/julia] Error 1
Makefile:93: recipe for target 'julia-ui-release' failed
make: *** [julia-ui-release] Error 2

Any suggestion?

[julia-users] julia build fails on arm

2016-02-08 Thread Lutfullah Tomak
I think there is a pull request now for this at

https://github.com/JuliaLang/julia/pull/14996

Sorry for the noise.

[julia-users] log the result to @code_warntype to a file

2016-02-08 Thread ben
Is there a convenient way to do this?

If not, what is the inconvenient way?

I managed to log to a file by redirecting stdout

~~~
rdstdout, wrstdout = redirect_stdout()
@code_warntype(myuglyfunction())
filename=string(Int(Dates.datetime2unix(now(*"-type-stability.log"
file=open(filename,"w")
write(file,readavailable(rdstdout))
close(file)
~~~

but I am not sure how to resume the normal behavior of stdout after that

Thanks!

ben


Re: [julia-users] log the result to @code_warntype to a file

2016-02-08 Thread ben
Thanks for the pointer. Unfortunately, I saw this function but I was not 
able to figure out what the second argument should be Sorry about this. 
Can you give me a minimal working example, for instance the equivalent of 
`@code_warntype 2+2`?

On Monday, February 8, 2016 at 6:21:59 PM UTC-5, Yichao Yu wrote:
>
> On Mon, Feb 8, 2016 at 6:11 PM, ben  
> wrote: 
> > Is there a convenient way to do this? 
> > 
> > If not, what is the inconvenient way? 
> > 
> > I managed to log to a file by redirecting stdout 
>
> Use the `code_warntype` function and pass a file handle to it as the 
> first argument. 
>
> > 
> > ~~~ 
> > rdstdout, wrstdout = redirect_stdout() 
> > @code_warntype(myuglyfunction()) 
> > filename=string(Int(Dates.datetime2unix(now(*"-type-stability.log" 
> > file=open(filename,"w") 
> > write(file,readavailable(rdstdout)) 
> > close(file) 
> > ~~~ 
> > 
> > but I am not sure how to resume the normal behavior of stdout after that 
> > 
> > Thanks! 
> > 
> > ben 
>


Re: [julia-users] julia build fails on arm

2016-02-08 Thread Yichao Yu
On Mon, Feb 8, 2016 at 7:23 PM, Lutfullah Tomak  wrote:
> I think there is a pull request now for this at
>
> https://github.com/JuliaLang/julia/pull/14996

Yep, this is the failure that PR fixes.

>
> Sorry for the noise.


Re: [julia-users] log the result to @code_warntype to a file

2016-02-08 Thread ben
Thank you!