Re: [julia-users] How to enter a file using gallium?

2016-11-22 Thread chobbes158
That's a good stopgap, if there's better options. Thanks!!

On Monday, November 21, 2016 at 8:19:50 PM UTC, Isaiah wrote:
>
> If breakpoints aren't working, I would suggest to your push object(s) of 
> interest into a global Vector{Any} and then debug with `@enter`.
>
> On Mon, Nov 21, 2016 at 11:00 AM,  
> wrote:
>
>> Well, if A is a complicated object/structure, it'll be almost impossible 
>> to first make up an A and call @enter function_to_debug(A).
>>
>>
>>
>> On Monday, November 21, 2016 at 2:32:16 PM UTC, Isaiah wrote:
>>>
>>> Any other means without resorting to breakpoints??
>>>
>>>
>>> Use `@enter function_to_debug( ... )` with the value of A that you are 
>>> interested in. 
>>>
>>> On Mon, Nov 21, 2016 at 6:30 AM,  wrote:
>>>
 Bump up for the following question:

 Suppose I have the following code where the variable A is defined 
 multiple times and after each definition it is used by the same function 
 function_to_debug. How can I step in function_to_debug with the first 
 definition/instantiation of A?
 A = ...
 function_to_debug(A)
 ...
 ...
 A = ...
 function_to_debug(A)

 Seems that the only choice is to use breakpoint. Any other means 
 without resorting to breakpoints??

>>>
>>>
>

Re: [julia-users] How to enter a file using gallium?

2016-11-21 Thread chobbes158
Well, if A is a complicated object/structure, it'll be almost impossible to 
first make up an A and call @enter function_to_debug(A).



On Monday, November 21, 2016 at 2:32:16 PM UTC, Isaiah wrote:
>
> Any other means without resorting to breakpoints??
>
>
> Use `@enter function_to_debug( ... )` with the value of A that you are 
> interested in. 
>
> On Mon, Nov 21, 2016 at 6:30 AM,  wrote:
>
>> Bump up for the following question:
>>
>> Suppose I have the following code where the variable A is defined 
>> multiple times and after each definition it is used by the same function 
>> function_to_debug. How can I step in function_to_debug with the first 
>> definition/instantiation of A?
>> A = ...
>> function_to_debug(A)
>> ...
>> ...
>> A = ...
>> function_to_debug(A)
>>
>> Seems that the only choice is to use breakpoint. Any other means without 
>> resorting to breakpoints??
>>
>
>

Re: [julia-users] How to enter a file using gallium?

2016-11-21 Thread chobbes158
Bump up for the following question:

Suppose I have the following code where the variable A is defined multiple 
times and after each definition it is used by the same function 
function_to_debug. How can I step in function_to_debug with the first 
definition/instantiation of A?
A = ...
function_to_debug(A)
...
...
A = ...
function_to_debug(A)

Seems that the only choice is to use breakpoint. Any other means without 
resorting to breakpoints??


Re: [julia-users] How to enter a file using gallium?

2016-11-19 Thread chobbes158
Thanks for the comments on my second question. I missed the acute prepended 
before 'stuff'.



On Saturday, November 19, 2016 at 3:14:13 PM UTC, Michele Zaffalon wrote:
>
> I don't know the answer to the first question. 
>
> For the second, you should check 
> https://github.com/Keno/ASTInterpreter.jl and in particular the 
> command `stuff. 
>
> On Sat, Nov 19, 2016 at 4:08 PM,   
> wrote: 
> > Thanks! It now works for me. Two more quick questions: 
> > 
> > 1. Suppose I have the following code where the variable A is defined 
> > multiple times and after each definition it is used by the same function 
> > function_to_debug. How can I step in function_to_debug with the first 
> > definition/instantiation of A? 
> > 
> > A = ... 
> > function_to_debug(A) 
> > ... 
> > ... 
> > A = ... 
> > function_to_debug(A) 
> > 
> > 
> > 2. As I'm step through the function_to_debug(), how can I print the 
> value of 
> > some variables. I know that I can use 'fr v' which prints everything. 
> How 
> > can I print just a single variable that I'm looking at? 
> > 
> > Thanks!! 
> > 
> > 
> > On Saturday, November 19, 2016 at 12:26:38 PM UTC, Michele Zaffalon 
> wrote: 
> >> 
> >> The @enter should be prepended to the function in the REPL, not in the 
> >> file itself. It should be something like this: 
> >> 
> >> julia> 
> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl") 
> >> 
> >> julia> @enter function_to_debug(args_to_function) 
> >> 
> >> On Sat, Nov 19, 2016 at 11:43 AM,   wrote: 
> >> > Thanks for the comments. I tried what you suggested by adding @enter 
> at 
> >> > the 
> >> > beginning of a line where a function is called. But an error was 
> thrown. 
> >> > 
> >> > julia> 
> >> > include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl") 
> >> > ERROR: LoadError: AssertionError: isa(arg,Expr) && arg.head == :call 
> >> >  in include_from_node1(::String) at ./loading.jl:488 
> >> > while loading 
> /home/calvin/Documents/git/codes/fc.jl/examples/test.jl, 
> >> > in 
> >> > expression starting on line 19 
> >> > 
> >> > Am I missing anything? Thanks! 
> >> > 
> >> > 
> >> > On Friday, November 18, 2016 at 8:11:45 PM UTC, Michele Zaffalon 
> wrote: 
> >> >> 
> >> >> You @enter the function, not the file. What function would you call 
> >> >> once 
> >> >> you include test.jl? That is the function to which you should 
> prepend 
> >> >> @enter. 
> >> >> 
> >> >> On Fri, Nov 18, 2016 at 6:49 PM,  wrote: 
> >> >>> 
> >> >>> 
> >> >>> 
> >> >>> Hi there, 
> >> >>> 
> >> >>> I'm totally new to the new debuggers. What I'm aiming at is to go 
> >> >>> through 
> >> >>> a file (it's a file calling other packages and functions therein.) 
> >> >>> line by 
> >> >>> line, just like in matlab. The first step is to step in the file 
> using 
> >> >>> gallium. I know how to traverse a function in terminal using 
> Gallium. 
> >> >>> But it 
> >> >>> seems that I can't enter a file by doing the same thing like: 
> >> >>> 
> >> >>> julia> @enter test.jl 
> >> >>> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at 
> >> >>> index 
> >> >>> [0] 
> >> >>> 
> >> >>> 
> >> >>> How can I enter a file via Gallium? Is it possible at all? Thanks. 
> >> >> 
> >> >> 
> >> > 
>


Re: [julia-users] How to enter a file using gallium?

2016-11-19 Thread chobbes158
Thanks! It now works for me. Two more quick questions:

1. Suppose I have the following code where the variable A is defined 
multiple times and after each definition it is used by the same function 
function_to_debug. How can I step in function_to_debug with the first 
definition/instantiation of A?

A = ...
function_to_debug(A)
...
...
A = ...
function_to_debug(A)


2. As I'm step through the function_to_debug(), how can I print the value 
of some variables. I know that I can use 'fr v' which prints everything. 
How can I print just a single variable that I'm looking at?

Thanks!!


On Saturday, November 19, 2016 at 12:26:38 PM UTC, Michele Zaffalon wrote:
>
> The @enter should be prepended to the function in the REPL, not in the 
> file itself. It should be something like this: 
>
> julia> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl") 
>
> julia> @enter function_to_debug(args_to_function) 
>
> On Sat, Nov 19, 2016 at 11:43 AM,   
> wrote: 
> > Thanks for the comments. I tried what you suggested by adding @enter at 
> the 
> > beginning of a line where a function is called. But an error was thrown. 
> > 
> > julia> 
> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl") 
> > ERROR: LoadError: AssertionError: isa(arg,Expr) && arg.head == :call 
> >  in include_from_node1(::String) at ./loading.jl:488 
> > while loading /home/calvin/Documents/git/codes/fc.jl/examples/test.jl, 
> in 
> > expression starting on line 19 
> > 
> > Am I missing anything? Thanks! 
> > 
> > 
> > On Friday, November 18, 2016 at 8:11:45 PM UTC, Michele Zaffalon wrote: 
> >> 
> >> You @enter the function, not the file. What function would you call 
> once 
> >> you include test.jl? That is the function to which you should prepend 
> >> @enter. 
> >> 
> >> On Fri, Nov 18, 2016 at 6:49 PM,  wrote: 
> >>> 
> >>> 
> >>> 
> >>> Hi there, 
> >>> 
> >>> I'm totally new to the new debuggers. What I'm aiming at is to go 
> through 
> >>> a file (it's a file calling other packages and functions therein.) 
> line by 
> >>> line, just like in matlab. The first step is to step in the file using 
> >>> gallium. I know how to traverse a function in terminal using Gallium. 
> But it 
> >>> seems that I can't enter a file by doing the same thing like: 
> >>> 
> >>> julia> @enter test.jl 
> >>> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at 
> index 
> >>> [0] 
> >>> 
> >>> 
> >>> How can I enter a file via Gallium? Is it possible at all? Thanks. 
> >> 
> >> 
> > 
>


Re: [julia-users] How to enter a file using gallium?

2016-11-19 Thread chobbes158
Thanks for the comments. I tried what you suggested by adding @enter at the 
beginning of a line where a function is called. But an error was thrown.

julia> include("/home/calvin/Documents/git/codes/fc.jl/examples/test.jl")
ERROR: LoadError: AssertionError: isa(arg,Expr) && arg.head == :call
 in include_from_node1(::String) at ./loading.jl:488
while loading /home/calvin/Documents/git/codes/fc.jl/examples/test.jl, in 
expression starting on line 19

Am I missing anything? Thanks!


On Friday, November 18, 2016 at 8:11:45 PM UTC, Michele Zaffalon wrote:
>
> You @enter the function, not the file. What function would you call once 
> you include test.jl? That is the function to which you should prepend 
> @enter.
>
> On Fri, Nov 18, 2016 at 6:49 PM,  wrote:
>
>>
>>
>> Hi there,
>>
>> I'm totally new to the new debuggers. What I'm aiming at is to go through 
>> a file (it's a file calling other packages and functions therein.) line by 
>> line, just like in matlab. The first step is to step in the file using 
>> gallium. I know how to traverse a function in terminal using Gallium. But 
>> it seems that I can't enter a file by doing the same thing like:
>>
>> julia> @enter test.jl
>> ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index [
>> 0]
>>
>>
>> How can I enter a file via Gallium? Is it possible at all? Thanks.
>>
>
>

[julia-users] How to enter a file using gallium?

2016-11-18 Thread chobbes158


Hi there,

I'm totally new to the new debuggers. What I'm aiming at is to go through a 
file (it's a file calling other packages and functions therein.) line by 
line, just like in matlab. The first step is to step in the file using 
gallium. I know how to traverse a function in terminal using Gallium. But 
it seems that I can't enter a file by doing the same thing like:

julia> @enter test.jl
ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index [0]


How can I enter a file via Gallium? Is it possible at all? Thanks.


Re: [julia-users] A foolproof question about ylim

2016-07-22 Thread chobbes158
Terrific! As a stranger to python, I've never thought that get and set 
methods are using the same keyword. Thanks!

On Friday, July 22, 2016 at 12:09:17 AM UTC+1, Yichao Yu wrote:
>
> On Thu, Jul 21, 2016 at 7:03 PM,   
> wrote: 
> > 
> > 
> > How can I get ylim when using PyPlot? I tried all the suggestions I 
> found on 
> > stackoverflow. None of them works, e.g. get_ylim(). Here is the error: 
> > 
> > ERROR: LoadError: UndefVarError: get_ylim not defined 
> > 
> > Can anyone give me an example of getting the current ylim? Thanks!! 
>
>
> Err, `ylim()`? I believe this is how you do that in python too. 
>


[julia-users] A foolproof question about ylim

2016-07-21 Thread chobbes158


How can I get ylim when using PyPlot? I tried all the suggestions I found 
on stackoverflow. None of them works, e.g. get_ylim(). Here is the error:

ERROR: LoadError: UndefVarError: get_ylim not defined

Can anyone give me an example of getting the current ylim? Thanks!!


Re: [julia-users] How to profile a module?

2016-07-07 Thread chobbes158
Thanks for reminding `copy(Profile.fetch())`. I totally forgot it. Thanks!


On Thursday, July 7, 2016 at 4:28:02 PM UTC+1, Isaiah wrote:
>
>
> http://docs.julialang.org/en/latest/manual/profile/#accumulation-and-clearing
>
> If you want to save results from a single session, use `savedprof = 
> copy(Profile.fetch())` and print with `Profile.print(savedprof)`.
>
> On Thu, Jul 7, 2016 at 11:07 AM,  wrote:
>
>> Thanks. Can I do profiling on B.g() and A.f() simultaneously? For example,
>>
>> import A, B
>> @profile p = B.g()
>> @profile A.f(p)
>>
>>
>> Then when I do `Profile.print()`, which `Profile` is it? The profile data 
>> for B.g() or A.f(p)? Is there a way to store the data separately into two 
>> different Profile variables?
>>
>>
>> On Thursday, July 7, 2016 at 2:39:30 PM UTC+1, Isaiah wrote:
>>>
>>> Yes
>>>
>>> On Thu, Jul 7, 2016 at 9:31 AM,  wrote:
>>>
 Do you mean that in the test file I do something like this?

 import A, B
 p = B.g()
 @profile A.f(p)




 On Thursday, July 7, 2016 at 1:22:24 PM UTC+1, Isaiah wrote:
>
> Profile the calls to B.g and A.f separately.
>
> On Thursday, July 7, 2016,  wrote:
>
>> Bump up.
>>
>
>>>
>

Re: [julia-users] How to profile a module?

2016-07-07 Thread chobbes158
Thanks. Can I do profiling on B.g() and A.f() simultaneously? For example,

import A, B
@profile p = B.g()
@profile A.f(p)


Then when I do `Profile.print()`, which `Profile` is it? The profile data 
for B.g() or A.f(p)? Is there a way to store the data separately into two 
different Profile variables?


On Thursday, July 7, 2016 at 2:39:30 PM UTC+1, Isaiah wrote:
>
> Yes
>
> On Thu, Jul 7, 2016 at 9:31 AM,  wrote:
>
>> Do you mean that in the test file I do something like this?
>>
>> import A, B
>> p = B.g()
>> @profile A.f(p)
>>
>>
>>
>>
>> On Thursday, July 7, 2016 at 1:22:24 PM UTC+1, Isaiah wrote:
>>>
>>> Profile the calls to B.g and A.f separately.
>>>
>>> On Thursday, July 7, 2016,  wrote:
>>>
 Bump up.

>>>
>

Re: [julia-users] How to profile a module?

2016-07-07 Thread chobbes158
Do you mean that in the test file I do something like this?

import A, B
p = B.g()
@profile A.f(p)




On Thursday, July 7, 2016 at 1:22:24 PM UTC+1, Isaiah wrote:
>
> Profile the calls to B.g and A.f separately.
>
> On Thursday, July 7, 2016,  wrote:
>
>> Bump up.
>>
>

Re: [julia-users] Re: How to profile a module?

2016-07-07 Thread chobbes158
Bump up.


Re: [julia-users] Re: How to profile a module?

2016-07-07 Thread chobbes158
Bump up.

On Tuesday, July 5, 2016 at 6:46:58 PM UTC+1, chobb...@gmail.com wrote:
>
> Thanks, Tim. The reason I can't run specific lines from the test file is 
> that the test needs to call module B first to get something which will be 
> passed as argument to a function in module A and it is this function that 
> I'm testing. Here is what it looks like:
>
> Module A:
> module A
> import B
> function f(p)
> ...
> B.g()
> ...
> end
> end
>
>
>
> Module B:
> module B
> function g()
> ...
> return p
> end
> end
>
> test file:
>
> import A, B
> p = B.g()
> A.f(p)
>
>
> I want to see how many times B.g() is called by A only or how much the 
> computation of B.g() is triggered by module A/A.f() only, instead of by A 
> and the test. Hope that I have made my point clear.
>
>
>
>
> On Tuesday, July 5, 2016 at 3:43:16 PM UTC+1, Tim Holy wrote:
>>
>> Ah. Can't you just run specific lines from that test file? You could even 
>> copy 
>> it and then delete the irrelevant lines using an editor, if you need to 
>> run 
>> many tests. 
>>
>> --Tim 
>>
>> On Tuesday, July 5, 2016 7:03:07 AM CDT chobb...@gmail.com wrote: 
>> > Tim, Thanks. 
>> > 
>> > The problem is this: I wrote a module A and made a test to test module 
>> A. 
>> > But both of module A and the test itself need to call another module B 
>> > frequently. I want to see how A is calling B and don't care how the 
>> test is 
>> > calling B. That's why I want to separate the profiling of module A from 
>> > that of both. This way I can easily the profiling via 
>> > 
>> > julia> Profile.print(format=:flat, sortedby=:count) 
>> > 
>> > Sorry for my dumb question. 
>> > 
>> > On Tuesday, July 5, 2016 at 12:49:37 PM UTC+1, Tim Holy wrote: 
>> > > I don't know what "profiling a module" means. You profile running 
>> code, 
>> > > wherever 
>> > > that code happens to live---and that's all there is to say. To 
>> profile the 
>> > > code 
>> > > in a module, you just have to write code that exercises the functions 
>> in 
>> > > the 
>> > > module. 
>> > > 
>> > > The meaning of the numbers is described here: 
>> > > http://docs.julialang.org/en/stable/manual/profile/#basic-usage 
>> > > The key words are "sampling profiler," the meaning of which is 
>> described 
>> > > at the 
>> > > top of that page (and see the wikipedia link). The number of samples 
>> is 
>> > > approximately proportional to the cost of the line (or its 
>> descendents). 
>> > > 
>> > > Best, 
>> > > --Tim 
>> > > 
>> > > On Tuesday, July 5, 2016 4:40:32 AM CDT chobb...@gmail.com 
>>  
>> > > 
>> > > wrote: 
>> > > > Bump up. 
>> > > > 
>> > > > On Monday, July 4, 2016 at 4:33:53 PM UTC+1, chobb...@gmail.com 
>> wrote: 
>> > > > > I want to profile a module which is tested by a test. Following 
>> the 
>> > > > > documentation ( 
>> > > 
>> > > 
>> http://docs.julialang.org/en/release-0.4/manual/profile/#options-for-contr 
>> > > 
>> > > > > olling-the-display-of-profile-results), I know how to profile 
>> them 
>> > > 
>> > > (module 
>> > > 
>> > > > > + test) together: 
>> > > > > 
>> > > > > @profile include("test.jl") 
>> > > > > 
>> > > > > 
>> > > > > But I have no idea for how to do the profiling only for the 
>> module. 
>> > > > > 
>> > > > > A second question is about the first number of each line in 
>> profiler's 
>> > > > > output. For example, the output from Julia Documentation: 
>> > > > > 
>> > > > > julia> Profile.print() 
>> > > > > 
>> > > > >   23 client.jl; _start; line: 373 
>> > > > >   
>> > > > > 23 client.jl; run_repl; line: 166 
>> > > > > 
>> > > > >23 client.jl; eval_user_input; line: 91 
>> > > > > 
>> > > > >   23 profile.jl; anonymous; line: 14 
>> > > > >   
>> > > > >  8  none; myfunc; line: 2 
>> > > > >   
>> > > > >   8 dSFMT.jl; dsfmt_gv_fill_array_close_open!; 
>> line: 
>> > > 128 
>> > > 
>> > > > >  15 none; myfunc; line: 3 
>> > > > >   
>> > > > >   2  reduce.jl; max; line: 35 
>> > > > >   2  reduce.jl; max; line: 36 
>> > > > >   11 reduce.jl; max; line: 37 
>> > > > > 
>> > > > > Is it appropriate to interpret the numbers 23, 8, 15, etc as the 
>> > > 
>> > > number of 
>> > > 
>> > > > > times the line is run or the time has been spent (relatively) on 
>> that 
>> > > > > line? 
>> > > > > 
>> > > > > 
>> > > > > I searched the group and there is no threads with a similar 
>> topic. Any 
>> > > > > comments? Thanks! 
>>
>>
>>

Re: [julia-users] Re: How to profile a module?

2016-07-05 Thread chobbes158
Thanks, Tim. The reason I can't run specific lines from the test file is 
that the test needs to call module B first to get something which will be 
passed as argument to a function in module A and it is this function that 
I'm testing. Here is what it looks like:

Module A:
module A
import B
function f(p)
...
B.g()
...
end
end



Module B:
module B
function g()
...
return p
end
end

test file:

import A, B
p = B.g()
A.f(p)


I want to see how many times B.g() is called by A only or how much the 
computation of B.g() is triggered by module A/A.f() only, instead of by A 
and the test. Hope that I have made my point clear.




On Tuesday, July 5, 2016 at 3:43:16 PM UTC+1, Tim Holy wrote:
>
> Ah. Can't you just run specific lines from that test file? You could even 
> copy 
> it and then delete the irrelevant lines using an editor, if you need to 
> run 
> many tests. 
>
> --Tim 
>
> On Tuesday, July 5, 2016 7:03:07 AM CDT chobb...@gmail.com  
> wrote: 
> > Tim, Thanks. 
> > 
> > The problem is this: I wrote a module A and made a test to test module 
> A. 
> > But both of module A and the test itself need to call another module B 
> > frequently. I want to see how A is calling B and don't care how the test 
> is 
> > calling B. That's why I want to separate the profiling of module A from 
> > that of both. This way I can easily the profiling via 
> > 
> > julia> Profile.print(format=:flat, sortedby=:count) 
> > 
> > Sorry for my dumb question. 
> > 
> > On Tuesday, July 5, 2016 at 12:49:37 PM UTC+1, Tim Holy wrote: 
> > > I don't know what "profiling a module" means. You profile running 
> code, 
> > > wherever 
> > > that code happens to live---and that's all there is to say. To profile 
> the 
> > > code 
> > > in a module, you just have to write code that exercises the functions 
> in 
> > > the 
> > > module. 
> > > 
> > > The meaning of the numbers is described here: 
> > > http://docs.julialang.org/en/stable/manual/profile/#basic-usage 
> > > The key words are "sampling profiler," the meaning of which is 
> described 
> > > at the 
> > > top of that page (and see the wikipedia link). The number of samples 
> is 
> > > approximately proportional to the cost of the line (or its 
> descendents). 
> > > 
> > > Best, 
> > > --Tim 
> > > 
> > > On Tuesday, July 5, 2016 4:40:32 AM CDT chobb...@gmail.com 
>  
> > > 
> > > wrote: 
> > > > Bump up. 
> > > > 
> > > > On Monday, July 4, 2016 at 4:33:53 PM UTC+1, chobb...@gmail.com 
> wrote: 
> > > > > I want to profile a module which is tested by a test. Following 
> the 
> > > > > documentation ( 
> > > 
> > > 
> http://docs.julialang.org/en/release-0.4/manual/profile/#options-for-contr 
> > > 
> > > > > olling-the-display-of-profile-results), I know how to profile them 
> > > 
> > > (module 
> > > 
> > > > > + test) together: 
> > > > > 
> > > > > @profile include("test.jl") 
> > > > > 
> > > > > 
> > > > > But I have no idea for how to do the profiling only for the 
> module. 
> > > > > 
> > > > > A second question is about the first number of each line in 
> profiler's 
> > > > > output. For example, the output from Julia Documentation: 
> > > > > 
> > > > > julia> Profile.print() 
> > > > > 
> > > > >   23 client.jl; _start; line: 373 
> > > > >   
> > > > > 23 client.jl; run_repl; line: 166 
> > > > > 
> > > > >23 client.jl; eval_user_input; line: 91 
> > > > > 
> > > > >   23 profile.jl; anonymous; line: 14 
> > > > >   
> > > > >  8  none; myfunc; line: 2 
> > > > >   
> > > > >   8 dSFMT.jl; dsfmt_gv_fill_array_close_open!; 
> line: 
> > > 128 
> > > 
> > > > >  15 none; myfunc; line: 3 
> > > > >   
> > > > >   2  reduce.jl; max; line: 35 
> > > > >   2  reduce.jl; max; line: 36 
> > > > >   11 reduce.jl; max; line: 37 
> > > > > 
> > > > > Is it appropriate to interpret the numbers 23, 8, 15, etc as the 
> > > 
> > > number of 
> > > 
> > > > > times the line is run or the time has been spent (relatively) on 
> that 
> > > > > line? 
> > > > > 
> > > > > 
> > > > > I searched the group and there is no threads with a similar topic. 
> Any 
> > > > > comments? Thanks! 
>
>
>

Re: [julia-users] Re: How to profile a module?

2016-07-05 Thread chobbes158
Tim, Thanks. 

The problem is this: I wrote a module A and made a test to test module A. 
But both of module A and the test itself need to call another module B 
frequently. I want to see how A is calling B and don't care how the test is 
calling B. That's why I want to separate the profiling of module A from 
that of both. This way I can easily the profiling via
 
julia> Profile.print(format=:flat, sortedby=:count)

Sorry for my dumb question. 




On Tuesday, July 5, 2016 at 12:49:37 PM UTC+1, Tim Holy wrote:
>
> I don't know what "profiling a module" means. You profile running code, 
> wherever 
> that code happens to live---and that's all there is to say. To profile the 
> code 
> in a module, you just have to write code that exercises the functions in 
> the 
> module. 
>
> The meaning of the numbers is described here: 
> http://docs.julialang.org/en/stable/manual/profile/#basic-usage 
> The key words are "sampling profiler," the meaning of which is described 
> at the 
> top of that page (and see the wikipedia link). The number of samples is 
> approximately proportional to the cost of the line (or its descendents). 
>
> Best, 
> --Tim 
>
> On Tuesday, July 5, 2016 4:40:32 AM CDT chobb...@gmail.com  
> wrote: 
> > Bump up. 
> > 
> > On Monday, July 4, 2016 at 4:33:53 PM UTC+1, chobb...@gmail.com wrote: 
> > > I want to profile a module which is tested by a test. Following the 
> > > documentation ( 
> > > 
> http://docs.julialang.org/en/release-0.4/manual/profile/#options-for-contr 
> > > olling-the-display-of-profile-results), I know how to profile them 
> (module 
> > > + test) together: 
> > > 
> > > @profile include("test.jl") 
> > > 
> > > 
> > > But I have no idea for how to do the profiling only for the module. 
> > > 
> > > A second question is about the first number of each line in profiler's 
> > > output. For example, the output from Julia Documentation: 
> > > 
> > > julia> Profile.print() 
> > > 
> > >   23 client.jl; _start; line: 373 
> > >   
> > > 23 client.jl; run_repl; line: 166 
> > > 
> > >23 client.jl; eval_user_input; line: 91 
> > > 
> > >   23 profile.jl; anonymous; line: 14 
> > >   
> > >  8  none; myfunc; line: 2 
> > >   
> > >   8 dSFMT.jl; dsfmt_gv_fill_array_close_open!; line: 
> 128 
> > >   
> > >  15 none; myfunc; line: 3 
> > >   
> > >   2  reduce.jl; max; line: 35 
> > >   2  reduce.jl; max; line: 36 
> > >   11 reduce.jl; max; line: 37 
> > > 
> > > Is it appropriate to interpret the numbers 23, 8, 15, etc as the 
> number of 
> > > times the line is run or the time has been spent (relatively) on that 
> > > line? 
> > > 
> > > 
> > > I searched the group and there is no threads with a similar topic. Any 
> > > comments? Thanks! 
>
>
>

[julia-users] Re: How to profile a module?

2016-07-05 Thread chobbes158
Bump up.

On Monday, July 4, 2016 at 4:33:53 PM UTC+1, chobb...@gmail.com wrote:
>
> I want to profile a module which is tested by a test. Following the 
> documentation (
> http://docs.julialang.org/en/release-0.4/manual/profile/#options-for-controlling-the-display-of-profile-results),
>  
> I know how to profile them (module + test) together:
>
> @profile include("test.jl")
>
>
> But I have no idea for how to do the profiling only for the module.
>
> A second question is about the first number of each line in profiler's 
> output. For example, the output from Julia Documentation:
>
> julia> Profile.print()
>   23 client.jl; _start; line: 373
> 23 client.jl; run_repl; line: 166
>23 client.jl; eval_user_input; line: 91
>   23 profile.jl; anonymous; line: 14
>  8  none; myfunc; line: 2
>   8 dSFMT.jl; dsfmt_gv_fill_array_close_open!; line: 128
>  15 none; myfunc; line: 3
>   2  reduce.jl; max; line: 35
>   2  reduce.jl; max; line: 36
>   11 reduce.jl; max; line: 37
>
> Is it appropriate to interpret the numbers 23, 8, 15, etc as the number of 
> times the line is run or the time has been spent (relatively) on that line?
>
>
> I searched the group and there is no threads with a similar topic. Any 
> comments? Thanks!
>


[julia-users] How to profile a module?

2016-07-04 Thread chobbes158
I want to profile a module which is tested by a test. Following the 
documentation 
(http://docs.julialang.org/en/release-0.4/manual/profile/#options-for-controlling-the-display-of-profile-results),
 
I know how to profile them (module + test) together:

@profile include("test.jl")


But I have no idea for how to do the profiling only for the module.

A second question is about the first number of each line in profiler's 
output. For example, the output from Julia Documentation:

julia> Profile.print()
  23 client.jl; _start; line: 373
23 client.jl; run_repl; line: 166
   23 client.jl; eval_user_input; line: 91
  23 profile.jl; anonymous; line: 14
 8  none; myfunc; line: 2
  8 dSFMT.jl; dsfmt_gv_fill_array_close_open!; line: 128
 15 none; myfunc; line: 3
  2  reduce.jl; max; line: 35
  2  reduce.jl; max; line: 36
  11 reduce.jl; max; line: 37

Is it appropriate to interpret the numbers 23, 8, 15, etc as the number of 
times the line is run or the time has been spent (relatively) on that line?


I searched the group and there is no threads with a similar topic. Any 
comments? Thanks!


Re: [julia-users] Re: a compilation question

2016-07-04 Thread chobbes158
Cedric,

Thanks for the tips!! Also thanks for reminding the use of `import` versus 
`using`. I think that's why reload doesn't work for me, as I stuck to 
`using`.

Calvin


On Sunday, July 3, 2016 at 10:21:42 PM UTC+1, Cedric St-Jean wrote:
>
> It doesn't work all the time for me either, but in general:
>
> - Don't `using A` if you want to reload A. Import it and write `A.foo()` 
> instead.
> - If B imports/uses A, you'll have to reload A first, then reload B.
> - Beware of the infamous issue 265 
> 
>
> On Sun, Jul 3, 2016 at 3:48 PM,  wrote:
>
>> I just found that `reload()` sometimes doesn't work at all. I `reloaded` 
>> a module that I modified. But I still see the same results as before the 
>> package was modified. Btw, this module is a local module, not a package 
>> installed via `Pkg.add()`. What might be a possible cause?
>>
>> Another question: I'm working on a module (let me call it C) which uses 
>> two other modules, say, A and B. C uses A and B, so the beginning of C 
>> looks like
>> using A
>> using B
>>
>> But B uses A too. So B starts as
>> using A
>>
>> Can this kind of multiple `using` cause any issues? Does it, at least, 
>> add more work to the compilation stage?
>>
>>
>>
>>
>>
>> On Saturday, July 2, 2016 at 3:18:04 AM UTC+1, Cedric St-Jean wrote:
>>
>>> I don't have a great solution to this, but this is what I do...
>>>
>>> 1. I think that `reload("PackageName")` should work without workspace(). 
>>> See http://docs.julialang.org/en/release-0.4/manual/workflow-tips/
>>> 2. I use `Autoreload.jl`. It's unfortunately not actively maintained, 
>>> but it works well enough for now if you don't have parametric types in the 
>>> autoreloaded modules
>>> 3. Reloading works better if you `include` files into one big module 
>>> instead of having multiple modules.
>>>
>>> I know, this sucks, but IIUC it's on the roadmap to improve this before 
>>> 1.0
>>>
>>> Cédric
>>>
>>> On Friday, July 1, 2016 at 9:37:32 AM UTC-4, chobb...@gmail.com wrote:

 Bump up..

>>>
>

[julia-users] Re: a compilation question

2016-07-03 Thread chobbes158
I just found that `reload()` sometimes doesn't work at all. I `reloaded` a 
module that I modified. But I still see the same results as before the 
package was modified. Btw, this module is a local module, not a package 
installed via `Pkg.add()`. What might be a possible cause?

Another question: I'm working on a module (let me call it C) which uses two 
other modules, say, A and B. C uses A and B, so the beginning of C looks 
like
using A
using B

But B uses A too. So B starts as
using A

Can this kind of multiple `using` cause any issues? Does it, at least, add 
more work to the compilation stage?





On Saturday, July 2, 2016 at 3:18:04 AM UTC+1, Cedric St-Jean wrote:
>
> I don't have a great solution to this, but this is what I do...
>
> 1. I think that `reload("PackageName")` should work without workspace(). 
> See http://docs.julialang.org/en/release-0.4/manual/workflow-tips/
> 2. I use `Autoreload.jl`. It's unfortunately not actively maintained, but 
> it works well enough for now if you don't have parametric types in the 
> autoreloaded modules
> 3. Reloading works better if you `include` files into one big module 
> instead of having multiple modules.
>
> I know, this sucks, but IIUC it's on the roadmap to improve this before 1.0
>
> Cédric
>
> On Friday, July 1, 2016 at 9:37:32 AM UTC-4, chobb...@gmail.com wrote:
>>
>> Bump up..
>>
>

[julia-users] Re: a compilation question

2016-07-03 Thread chobbes158
Yaakov,

Thanks a lot for suggesting `Pkg.test`. It's truly one of the most 
efficient ways to reload what is necessary smartly. Thanks!



On Sunday, July 3, 2016 at 11:02:28 AM UTC+1, Yaakov Borstein wrote:
>
> I have found that writing your code using a test first pattern ends up 
> being the most productive approach long-term and also solves the warnings 
> issue.  Running Pkg.test("mypack") takes care of reloading and you'll never 
> need to restart the REPL.  It's a change in workflow that requires a bit of 
> getting used to, but as Fowler once wrote, if you need to write print() or 
> debug() then you'll be best served with a test. 



[julia-users] Re: a compilation question

2016-07-02 Thread chobbes158
Thanks very much for the reply! `reload` is absolutely what I'm screaming 
for.

BTW, isn't `Autoreload` only useful for Ijulia users?

 

On Saturday, July 2, 2016 at 3:18:04 AM UTC+1, Cedric St-Jean wrote:
>
> I don't have a great solution to this, but this is what I do...
>
> 1. I think that `reload("PackageName")` should work without workspace(). 
> See http://docs.julialang.org/en/release-0.4/manual/workflow-tips/
> 2. I use `Autoreload.jl`. It's unfortunately not actively maintained, but 
> it works well enough for now if you don't have parametric types in the 
> autoreloaded modules
> 3. Reloading works better if you `include` files into one big module 
> instead of having multiple modules.
>
> I know, this sucks, but IIUC it's on the roadmap to improve this before 1.0
>
> Cédric
>
> On Friday, July 1, 2016 at 9:37:32 AM UTC-4, chobb...@gmail.com wrote:
>>
>> Bump up..
>>
>

[julia-users] Re: a compilation question

2016-07-01 Thread chobbes158
Bump up..


[julia-users] a compilation question

2016-06-30 Thread chobbes158


This is an entry-level question. So bear me please.

I am writing a package which uses three other packages, say A, B, C. Each 
time I made any change in A or B or C, I had to workspace() and re-ran. 
This is usually very time consuming.

1. Is there anyway to only clear the compilation of the modified package 
without re-compiling the rest which are totally intact? I guess this way a 
lot of compilation time can be saved.

2. After workspace() is called to clear what is in the memory, re-running 
the code always generates loads of warnings, e.g. 

WARNING: Method definition remote_do(Function, Main.Base.LocalProcess, Any
...) in module Compat at /home/kuan/.julia/v0.4/Compat/src/Compat.jl:880 
overwritten in module Compat at /home/kuan/.julia/v0.4/Compat/src/Compat.jl:
880.

What is the cause of such warnings? How to avoid them?

Thanks!


[julia-users] Re: Fast vector element-wise multiplication

2016-06-20 Thread chobbes158
Thanks for the confirmation! Yes, I need more tests to see what the best 
practice is for my particular problem. 



On Monday, June 20, 2016 at 3:05:31 PM UTC+1, Chris Rackauckas wrote:
>
> Most likely. I would also time it with and without @simd at your problem 
> size. For some reason I've had some simple loops do better without @simd. 
>
> On Monday, June 20, 2016 at 2:50:22 PM UTC+1, chobb...@gmail.com wrote:
>>
>> Thanks! I'm still using v0.4.5. In this case, is the code I highlighted 
>> above still the best choice for doing the job?
>>
>>
>> On Monday, June 20, 2016 at 1:57:25 PM UTC+1, Chris Rackauckas wrote:
>>>
>>> I think that for medium size (but not large) arrays in v0.5 you may want 
>>> to use @threads from the threadding branch, and then for really large 
>>> arrays you may want to use @parallel. But you'd have to test some timings.
>>>
>>> On Monday, June 20, 2016 at 11:38:15 AM UTC+1, chobb...@gmail.com wrote:

 I have the same question regarding how to calculate the entry-wise 
 vector product and find this thread. As a novice, I wonder if the 
 following 
 code snippet is still the standard for entry-wise vector multiplication 
 that one should stick to in practice? Thanks!


 @fastmath @inbounds @simd for i=1:n
 A[i] *= B[i]
 end



 On Tuesday, October 6, 2015 at 3:28:29 PM UTC+1, Lionel du Peloux wrote:
>
> Dear all,
>
> I'm looking for the fastest way to do element-wise vector 
> multiplication in Julia. The best I could have done is the following 
> implementation which still runs 1.5x slower than the dot product. I 
> assume 
> the dot product would include such an operation ... and then do a 
> cumulative sum over the element-wise product.
>
> The MKL lib includes such an operation (v?Mul) but it seems OpenBLAS 
> does not. So my question is :
>
> 1) is there any chance I can do vector element-wise multiplication 
> faster then the actual dot product ?
> 2) why the built-in element-wise multiplication operator (*.) is much 
> slower than my own implementation for such a basic linealg operation 
> (full 
> julia) ? 
>
> Thank you,
> Lionel
>
> Best custom implementation :
>
> function xpy!{T<:Number}(A::Vector{T},B::Vector{T})
>   n = size(A)[1]
>   if n == size(B)[1]
> for i=1:n
>   @inbounds A[i] *= B[i]
> end
>   end
>   return A
> end
>
> Bench mark results (JuliaBox, A = randn(30) :
>
> function  CPU (s) GC (%)  ALLOCATION (bytes)  
> CPU (x) 
> dot(A,B)  1.58e-040.0016  
> 1.0 xpy!(A,B) 2.31e-040.0080  
> 1.5 
> NumericExtensions.multiply!(P,Q)  3.60e-040.0080  
> 2.3 xpy!(A,B) - no @inbounds check4.36e-040.0080  
> 2.8 
> P.*Q  2.52e-0350.36   2400512 
> 16.0
> 
>
>

[julia-users] Re: Fast vector element-wise multiplication

2016-06-20 Thread chobbes158
Thanks! I'm still using v0.4.5. In this case, is the code I highlighted 
above still the best choice for doing the job?


On Monday, June 20, 2016 at 1:57:25 PM UTC+1, Chris Rackauckas wrote:
>
> I think that for medium size (but not large) arrays in v0.5 you may want 
> to use @threads from the threadding branch, and then for really large 
> arrays you may want to use @parallel. But you'd have to test some timings.
>
> On Monday, June 20, 2016 at 11:38:15 AM UTC+1, chobb...@gmail.com wrote:
>>
>> I have the same question regarding how to calculate the entry-wise vector 
>> product and find this thread. As a novice, I wonder if the following code 
>> snippet is still the standard for entry-wise vector multiplication that one 
>> should stick to in practice? Thanks!
>>
>>
>> @fastmath @inbounds @simd for i=1:n
>> A[i] *= B[i]
>> end
>>
>>
>>
>> On Tuesday, October 6, 2015 at 3:28:29 PM UTC+1, Lionel du Peloux wrote:
>>>
>>> Dear all,
>>>
>>> I'm looking for the fastest way to do element-wise vector multiplication 
>>> in Julia. The best I could have done is the following implementation which 
>>> still runs 1.5x slower than the dot product. I assume the dot product would 
>>> include such an operation ... and then do a cumulative sum over the 
>>> element-wise product.
>>>
>>> The MKL lib includes such an operation (v?Mul) but it seems OpenBLAS 
>>> does not. So my question is :
>>>
>>> 1) is there any chance I can do vector element-wise multiplication 
>>> faster then the actual dot product ?
>>> 2) why the built-in element-wise multiplication operator (*.) is much 
>>> slower than my own implementation for such a basic linealg operation (full 
>>> julia) ? 
>>>
>>> Thank you,
>>> Lionel
>>>
>>> Best custom implementation :
>>>
>>> function xpy!{T<:Number}(A::Vector{T},B::Vector{T})
>>>   n = size(A)[1]
>>>   if n == size(B)[1]
>>> for i=1:n
>>>   @inbounds A[i] *= B[i]
>>> end
>>>   end
>>>   return A
>>> end
>>>
>>> Bench mark results (JuliaBox, A = randn(30) :
>>>
>>> function  CPU (s) GC (%)  ALLOCATION (bytes)  
>>> CPU (x) 
>>> dot(A,B)  1.58e-040.0016  
>>> 1.0 xpy!(A,B) 2.31e-040.0080
>>>   1.5 
>>> NumericExtensions.multiply!(P,Q)  3.60e-040.0080  
>>> 2.3 xpy!(A,B) - no @inbounds check4.36e-040.0080
>>>   2.8 
>>> P.*Q  2.52e-0350.36   2400512 
>>> 16.0
>>> 
>>>
>>>

[julia-users] Re: Fast vector element-wise multiplication

2016-06-20 Thread chobbes158
I have the same question regarding how to calculate the entry-wise vector 
product and find this thread. As a novice, I wonder if the following code 
snippet is still the standard for entry-wise vector multiplication that one 
should stick to in practice? Thanks!


@fastmath @inbounds @simd for i=1:n
A[i] *= B[i]
end



On Tuesday, October 6, 2015 at 3:28:29 PM UTC+1, Lionel du Peloux wrote:
>
> Dear all,
>
> I'm looking for the fastest way to do element-wise vector multiplication 
> in Julia. The best I could have done is the following implementation which 
> still runs 1.5x slower than the dot product. I assume the dot product would 
> include such an operation ... and then do a cumulative sum over the 
> element-wise product.
>
> The MKL lib includes such an operation (v?Mul) but it seems OpenBLAS does 
> not. So my question is :
>
> 1) is there any chance I can do vector element-wise multiplication faster 
> then the actual dot product ?
> 2) why the built-in element-wise multiplication operator (*.) is much 
> slower than my own implementation for such a basic linealg operation (full 
> julia) ? 
>
> Thank you,
> Lionel
>
> Best custom implementation :
>
> function xpy!{T<:Number}(A::Vector{T},B::Vector{T})
>   n = size(A)[1]
>   if n == size(B)[1]
> for i=1:n
>   @inbounds A[i] *= B[i]
> end
>   end
>   return A
> end
>
> Bench mark results (JuliaBox, A = randn(30) :
>
> function  CPU (s) GC (%)  ALLOCATION (bytes)  CPU 
> (x) 
> dot(A,B)  1.58e-040.0016  1.0 
> xpy!(A,B) 2.31e-040.0080  
> 1.5 
> NumericExtensions.multiply!(P,Q)  3.60e-040.0080  2.3 
> xpy!(A,B) - no @inbounds check4.36e-040.0080  
> 2.8 
> P.*Q  2.52e-0350.36   2400512 
> 16.0
> 
>
>

[julia-users] persistent in Julia

2016-06-15 Thread chobbes158


I need to construct something which is a bit expensive. So I want to 
construct it only once and have it stored for further use. In Matlab, this 
is done by 'persistent'. Is there a similar thing in Julia? I searched the 
previous threads and didn't see any relevant discussion. Can anyone advise? 
Thanks!


Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Thanks for the explanation!! That's exactly what I need at the moment, 
though I clearly know that unpredictable return type could be dangerous. 
Many thanks.

On Sunday, May 15, 2016 at 9:07:12 PM UTC+1, Kristoffer Carlsson wrote:
>
> It is possible but seems like something undesirable because you then don't 
> know if an Array{T,1} or Array{T,2} will be returned by the function. This 
> is something Julia people like to call "type instability" when the type of 
> your returned variables depend not only on the type of the arguments to the 
> function. 
>
> If you really want this, then this is an example:
>
> function maybevec(A::AbstractMatrix)
> if size(A, 2) == 1 || size(A, 1) == 1
> return vec(A)
> else
> return A
> end 
> end
>
>
> julia> maybevec(rand(5,5))
> 5×5 Array{Float64,2}:
>  0.542099  0.901245  0.267711  0.260192  0.395683
>  0.361152  0.373492  0.231736  0.259319  0.933759
>  0.307834  0.460153  0.157018  0.712722  0.194619
>  0.869251  0.947844  0.53740.715395  0.67132 
>  0.928848  0.642071  0.948639  0.693701  0.562648
>
>
> julia> maybevec(rand(5,1))
> 5-element Array{Float64,1}:
>  0.579539
>  0.012443
>  0.307975
>  0.742628
>  0.997113
>
>
>
> On Sunday, May 15, 2016 at 9:17:27 PM UTC+2, chobb...@gmail.com wrote:
>>
>> Thanks for the pointer for reshape. 
>>
>> Sorry that I failed to make my question clear enough. In fact, I wonder 
>> if there is a function which can _automatically_ recast a single-column 
>> Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple 
>> rows.
>>
>>
>>
>>
>>
>> On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote:
>>>
>>> See reshape and vec. 
>>>
>>> Best, 
>>> --Tim 
>>>
>>> On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com wrote: 
>>> > Here is rookie question, which I have tried to find a similar question 
>>> and 
>>> > answer in the history of this group, but failed. Please bear me. 
>>> > 
>>> > Since Julia distinguishes between Array{Float64,1} and 
>>> Array{Float64,2}, 
>>> > even there is only one column in an Array{Float64,2}. Therefore, the 
>>> type 
>>> > of rand(5) and rand(5,1) are not same. 
>>> > 
>>> > julia> x = rand(5) 
>>> > 5-element Array{Float64,1}: 
>>> >  0.183247 
>>> >  0.480208 
>>> >  0.623144 
>>> >  0.342792 
>>> >  0.0400695 
>>> > 
>>> > julia> y = rand(5, 1) 
>>> > 5x1 Array{Float64,2}: 
>>> >  0.553224 
>>> >  0.0061835 
>>> >  0.762059 
>>> >  0.643796 
>>> >  0.655135 
>>> > 
>>> > 
>>> > Is there any way that I can upgrade x about to become an 
>>> Array{Float64,2}? 
>>> > And is there a way to downgrade y to become an Array{Float64,1}, when 
>>> it 
>>> > has only one column? 
>>> > 
>>> > In case that there is a similar discussion before, a link to the 
>>> previous 
>>> > thread is good enough and appreciated! 
>>> > 
>>> > Thanks! 
>>>
>>>

Re: [julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Thanks for the pointer for reshape. 

Sorry that I failed to make my question clear enough. In fact, I wonder if 
there is a function which can _automatically_ recast a single-column 
Array{T,2} to an Array{T,1} and do nothing if this Array{T,2} has multiple 
rows.





On Sunday, May 15, 2016 at 6:41:51 PM UTC+1, Tim Holy wrote:
>
> See reshape and vec. 
>
> Best, 
> --Tim 
>
> On Sunday, May 15, 2016 09:00:33 AM chobb...@gmail.com  
> wrote: 
> > Here is rookie question, which I have tried to find a similar question 
> and 
> > answer in the history of this group, but failed. Please bear me. 
> > 
> > Since Julia distinguishes between Array{Float64,1} and Array{Float64,2}, 
> > even there is only one column in an Array{Float64,2}. Therefore, the 
> type 
> > of rand(5) and rand(5,1) are not same. 
> > 
> > julia> x = rand(5) 
> > 5-element Array{Float64,1}: 
> >  0.183247 
> >  0.480208 
> >  0.623144 
> >  0.342792 
> >  0.0400695 
> > 
> > julia> y = rand(5, 1) 
> > 5x1 Array{Float64,2}: 
> >  0.553224 
> >  0.0061835 
> >  0.762059 
> >  0.643796 
> >  0.655135 
> > 
> > 
> > Is there any way that I can upgrade x about to become an 
> Array{Float64,2}? 
> > And is there a way to downgrade y to become an Array{Float64,1}, when it 
> > has only one column? 
> > 
> > In case that there is a similar discussion before, a link to the 
> previous 
> > thread is good enough and appreciated! 
> > 
> > Thanks! 
>
>

[julia-users] upgrade/downgrade between Array{Float64,1} and Array{Float64,2}

2016-05-15 Thread chobbes158
Here is rookie question, which I have tried to find a similar question and 
answer in the history of this group, but failed. Please bear me.

Since Julia distinguishes between Array{Float64,1} and Array{Float64,2}, 
even there is only one column in an Array{Float64,2}. Therefore, the type 
of rand(5) and rand(5,1) are not same.

julia> x = rand(5)
5-element Array{Float64,1}:
 0.183247
 0.480208
 0.623144
 0.342792
 0.0400695

julia> y = rand(5, 1)
5x1 Array{Float64,2}:
 0.553224
 0.0061835
 0.762059
 0.643796
 0.655135


Is there any way that I can upgrade x about to become an Array{Float64,2}? 
And is there a way to downgrade y to become an Array{Float64,1}, when it 
has only one column?

In case that there is a similar discussion before, a link to the previous 
thread is good enough and appreciated!

Thanks!


[julia-users] Re: How to use Debug.jl in Atom?

2016-05-11 Thread chobbes158
I'm a newbie as well. But as far as I know Debug.jl is already a 
yesterday's tool. You need to switch to Gallium and ASTInterpreter one day 
anyway. See the discussion in the following thread:

https://groups.google.com/forum/#!topic/julia-users/NEQmWBKZPbE

On Wednesday, May 11, 2016 at 9:27:31 AM UTC+1, Yao Lu wrote:
>
>
> 
>
>
> However, I cannot input anything in the console.
>


Re: [julia-users] How to display the value of a variable in the title of a plot?

2016-05-09 Thread chobbes158
Steven - Sorry. I just saw your last reply. 

Thanks for the hints. `close("all")` works absolutely superbly. But Qt 
backend is far beyond my universe. 

Thanks again! 

On Friday, May 6, 2016 at 6:17:12 PM UTC+1, Steven G. Johnson wrote:
>
>
>
> On Friday, May 6, 2016 at 12:55:45 PM UTC-4, chobb...@gmail.com wrote:
>>
>> Tom and Steven,
>>
>> Thanks the hints!!
>>
>> Still, how could I show all current figures by command? That is something 
>> like 'shg' in Matlab. 
>>
>
> I don't think Matplotlib supports this; the only things I could find were 
> specific to the Qt backend:
>
>
> http://stackoverflow.com/questions/8202228/make-matplotlib-plotting-window-pop-up-as-the-active-one
> https://github.com/matplotlib/matplotlib/issues/596
>  
>
>> Also, is there a command to close all current figures, i.e. a counterpart 
>> of 'clf' in Matlab?
>>>
>>>
> close("all") in PyPlot (from the Matplotlib docs). 
>
> In general, if you are using PyPlot and want to know how to do something, 
> just google the matplotlib documentation, and then translate the syntax 
> back to Julia.
>


Re: [julia-users] How to display the value of a variable in the title of a plot?

2016-05-06 Thread chobbes158
Tom and Steven,

Thanks the hints!!

Still, how could I show all current figures by command? That is something 
like 'shg' in Matlab. 

Also, is there a command to close all current figures, i.e. a counterpart 
of 'clf' in Matlab?

Thanks!




On Friday, May 6, 2016 at 4:50:12 PM UTC+1, Steven G. Johnson wrote:
>
>
>
> On Friday, May 6, 2016 at 11:38:20 AM UTC-4, Tom Breloff wrote:
>>
>> Just use string interpolation (this is a Julia thing, not specific to 
>> PyPlot).
>>
>> title("\pi = $pi")
>>
>>
> To get Matplotlib to use LaTeX for π, you need (escaped) dollar signs and 
> also to escape the backslash: title("\$\\pi\$ = $pi").  Or you can use 
> Unicode for \pi: title("π = $pi").
>
> Note that string(pi) is "π = 3.1415926535897...", however, so for this 
> particular example you probably want
> title("π ≈ $(Float64(pi))")
>


[julia-users] How to display the value of a variable in the title of a plot?

2016-05-06 Thread chobbes158
I tried my best to search answers to my following quick questions in this 
group and PyPlot's site, though I trust that my questions are just very 
basic ones:

1. How to display the value of a variable in the title of a plot? In 
matlab, I do the following to show the value of pi in the title:

title(['\pi = ' num2str(pi)])

Can anyone teach me on how to do this in PyPlot? 

2. Is there a counterpart of the `shg` command in PyPlot to pop the recent 
figures to the front?

Thanks!!






[julia-users] @edit could not determine location of method definition

2016-04-27 Thread chobbes158
Most of time, when I call @which, I'm usually returned with a 
dispatch/method and its location information, like this:
 
@which Domain(-1.1,5.2)
call{T<:Number}(::Type{BasicDecomposition.Domain{T}}, a::T<:Number, b::T<:
Number) at /home/calvin/Documents/git/DomainDecomposition.jl/src/wedge.jl:61

But sometimes, the location of the method is missing, though the correct 
method is given:

julia> @which Decompose(f,I)
Decompose(f::Function, interval::BasicDecomposition.DomainSet{N,T})

Of course, if I call @edit for the same method, an error is thrown saying 
that the location is not determined.

julia> @edit Decompose(f,I)
ERROR: could not determine location of method definition
 in functionloc at reflection.jl:324
 in edit at interactiveutil.jl:63

What could cause such a problem? What should I do if I really want to know 
the location of the method/dispatch?


[julia-users] How to print out the expression of a simple function

2016-04-26 Thread chobbes158
I wonder how to print the expression of a function, e.g. x.^2 for the 
following example.

julia> f(x) = x.^2
f (generic function with 1 method)

julia> f
f (generic function with 1 method)

If it is not possible for the expression of a function as simple as the 
above to be printed, is there a way to display more info for a function, 
instead of just the reference of the container f? 

I searched in the past threads and didn't any similar question. But this 
may be the case because what I'm asking is, again, a dumb question.

Thanks.

Calvin


Re: [julia-users] Re: Arrow Keys when debugging

2016-04-26 Thread chobbes158
I'm thrilled. It worked! Thanks for the hint!

On Tuesday, April 26, 2016 at 2:46:42 PM UTC+1, Scott T wrote:
>
> Try setting
>
> ENV["EDITOR"] = "atom"
>
> in .juliarc. This works for me on a linux system but you may need a 
> different command name to launch atom on mac or windows.
>
>
> On Tuesday, 26 April 2016 12:16:36 UTC+1, chobb...@gmail.com wrote:
>>
>> I know @which, but not @edit. Thanks!
>>
>> Btw, I have a hard time setting the default editor for Julia, following 
>> the suggestion in the following thread.
>>
>>
>> https://groups.google.com/forum/#!searchin/julia-users/default$20editor/julia-users/00OlSKal6uY/7XjDuNnPMUAJ
>>
>> Could you let me know the exact line I need to add in .juliarc, if I want 
>> to set Atom as the default? 
>>
>> Thanks!! 
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tuesday, April 26, 2016 at 8:38:00 AM UTC+1, Hans-Peter wrote:
>>>
>>> On Monday, 25 April 2016 23:34:03 UTC+2, chobb...@gmail.com wrote:

 ... want to see which constructor is called for construction, if 
 multiple constructors exist

>>>^ 
>>>
>>> Do you know the @which macro? E.g. @which DateTime(2016) or @which 
>>> DateTime("20151204"). To jump to the source code, there is @edit.
>>>
>>

Re: [julia-users] Re: Arrow Keys when debugging

2016-04-26 Thread chobbes158
I know @which, but not @edit. Thanks!

Btw, I have a hard time setting the default editor for Julia, following the 
suggestion in the following thread.

https://groups.google.com/forum/#!searchin/julia-users/default$20editor/julia-users/00OlSKal6uY/7XjDuNnPMUAJ

Could you let me know the exact line I need to add in .juliarc, if I want 
to set Atom as the default? 

Thanks!! 









On Tuesday, April 26, 2016 at 8:38:00 AM UTC+1, Hans-Peter wrote:
>
> On Monday, 25 April 2016 23:34:03 UTC+2, chobb...@gmail.com wrote:
>>
>> ... want to see which constructor is called for construction, if multiple 
>> constructors exist
>>
>^ 
>
> Do you know the @which macro? E.g. @which DateTime(2016) or @which 
> DateTime("20151204"). To jump to the source code, there is @edit.
>


Re: [julia-users] Re: Arrow Keys when debugging

2016-04-25 Thread chobbes158
Many thanks!

On Monday, April 25, 2016 at 10:39:08 PM UTC+1, Stefan Karpinski wrote:
>
> Yes, to all of the above.
>
> On Mon, Apr 25, 2016 at 5:34 PM,  wrote:
>
>> Thanks a lot for the info. 
>>
>> 1. I've been using Matlab debugger and gdb for fortran for many years. 
>> Will Gallium and AST Interpreter for Julia v5.0 give a comparable user 
>> experience? For example, I'm used to use debugger to step a code from line 
>> 1 through the end. Will Gallium and ASTI allow me to do so? Debug.jl only 
>> allows debugging in functions and it cannot be used to explore ctors, if I 
>> understand correctly. Due to the nature of multidispatch, I really want to 
>> see which constructor is called for construction, if multiple constructors 
>> exist.
>>
>> 2. Will there be any proper documentation for the new debugger? 
>>
>> Sorry for being a bit annoying. Thanks!!
>>
>>
>>
>> On Monday, April 25, 2016 at 9:26:16 PM UTC+1, Keno Fischer wrote:
>>>
>>> On Mon, Apr 25, 2016 at 11:12 AM,   wrote: 
>>> > Thanks for the reference. I quickly scanned the Readmes of Gallium and 
>>> > ASTInterpreter and found that they're probably too brief to start 
>>> with. Is 
>>> > there a more complete documentation or tutorial? What is the relation 
>>> > between Gallium and AST Interpreter? 
>>>
>>> ASTInterpreter is essentially the conceptual replacement of Debug.jl. 
>>> It takes a julia function and lets you step through it. Gallium adds 
>>> breakpointing, backtracing and other 
>>> features to make it a full debugger. You can use ASTInterpreter 
>>> without Gallium, but the 
>>> otherway around is not super useful. 
>>>
>>> > BTW, do I have to wait until the release of Julia v5.0 to use Gallium? 
>>>
>>> Gallium is available on currently julia master, but not on 0.4. 
>>>
>>> > Sorry, if my questions look dumb. 
>>> > 
>>> > Thanks!! 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > On Monday, April 25, 2016 at 3:20:33 PM UTC+1, Steven G. Johnson 
>>> wrote: 
>>> >> 
>>> >> 
>>> >> 
>>> >> On Monday, April 25, 2016 at 10:10:01 AM UTC-4, chobb...@gmail.com 
>>> wrote: 
>>> >>> 
>>> >>> I'm using the Julia Debugger 
>>> >>> 
>>> >>> https://github.com/toivoh/Debug.jl 
>>> >> 
>>> >> 
>>> >> That debugger is mostly a stopgap/prototype until we have a "real" 
>>> >> debugger based on LLDB, which allows you to run code at full speed 
>>> until you 
>>> >> hit a break point.  Such a debugger was recently introduced for Julia 
>>> 0.5, 
>>> >> and is much more full-featured than Debug.jl: 
>>> >> 
>>> >> https://github.com/Keno/Gallium.jl 
>>>
>>
>

Re: [julia-users] Re: Arrow Keys when debugging

2016-04-25 Thread chobbes158
Thanks a lot for the info. 

1. I've been using Matlab debugger and gdb for fortran for many years. Will 
Gallium and AST Interpreter for Julia v5.0 give a comparable user 
experience? For example, I'm used to use debugger to step a code from line 
1 through the end. Will Gallium and ASTI allow me to do so? Debug.jl only 
allows debugging in functions and it cannot be used to explore ctors, if I 
understand correctly. Due to the nature of multidispatch, I really want to 
see which constructor is called for construction, if multiple constructors 
exist.

2. Will there be any proper documentation for the new debugger? 

Sorry for being a bit annoying. Thanks!!



On Monday, April 25, 2016 at 9:26:16 PM UTC+1, Keno Fischer wrote:
>
> On Mon, Apr 25, 2016 at 11:12 AM,   
> wrote: 
> > Thanks for the reference. I quickly scanned the Readmes of Gallium and 
> > ASTInterpreter and found that they're probably too brief to start with. 
> Is 
> > there a more complete documentation or tutorial? What is the relation 
> > between Gallium and AST Interpreter? 
>
> ASTInterpreter is essentially the conceptual replacement of Debug.jl. 
> It takes a julia function and lets you step through it. Gallium adds 
> breakpointing, backtracing and other 
> features to make it a full debugger. You can use ASTInterpreter 
> without Gallium, but the 
> otherway around is not super useful. 
>
> > BTW, do I have to wait until the release of Julia v5.0 to use Gallium? 
>
> Gallium is available on currently julia master, but not on 0.4. 
>
> > Sorry, if my questions look dumb. 
> > 
> > Thanks!! 
> > 
> > 
> > 
> > 
> > 
> > On Monday, April 25, 2016 at 3:20:33 PM UTC+1, Steven G. Johnson wrote: 
> >> 
> >> 
> >> 
> >> On Monday, April 25, 2016 at 10:10:01 AM UTC-4, chobb...@gmail.com 
> wrote: 
> >>> 
> >>> I'm using the Julia Debugger 
> >>> 
> >>> https://github.com/toivoh/Debug.jl 
> >> 
> >> 
> >> That debugger is mostly a stopgap/prototype until we have a "real" 
> >> debugger based on LLDB, which allows you to run code at full speed 
> until you 
> >> hit a break point.  Such a debugger was recently introduced for Julia 
> 0.5, 
> >> and is much more full-featured than Debug.jl: 
> >> 
> >> https://github.com/Keno/Gallium.jl 
>


[julia-users] Re: Do I have to workspace() when a new breakpoint is introduced?

2016-04-25 Thread chobbes158
Yes, this is all about Debug.jl and has nothing to do with Gallium.



On Monday, April 25, 2016 at 4:03:37 PM UTC+1, Steven G. Johnson wrote:
>
>
>
> On Monday, April 25, 2016 at 7:23:06 AM UTC-4, Hans-Peter wrote:
>>
>> I think it's a bit too early for general debugger consumption (especially 
>> for someone new to Julia). The debugger most likely will come in 
>> well-rounded form with release 0.5 which, maybe, will be ready for the 
>> JuliaCon.
>>
>
> (Note that the poster is using Debug.jl, not the "real" Gallium debugger, 
> as was clarified in another thread.)
>


[julia-users] Re: Arrow Keys when debugging

2016-04-25 Thread chobbes158
Thanks for the reference. I quickly scanned the Readmes of Gallium and 
ASTInterpreter and found that they're probably too brief to start with. Is 
there a more complete documentation or tutorial? What is the relation 
between Gallium and AST Interpreter? 

BTW, do I have to wait until the release of Julia v5.0 to use Gallium?

Sorry, if my questions look dumb.

Thanks!!




On Monday, April 25, 2016 at 3:20:33 PM UTC+1, Steven G. Johnson wrote:
>
>
>
> On Monday, April 25, 2016 at 10:10:01 AM UTC-4, chobb...@gmail.com wrote:
>>
>> I'm using the Julia Debugger
>>
>> https://github.com/toivoh/Debug.jl
>>
>
> That debugger is mostly a stopgap/prototype until we have a "real" 
> debugger based on LLDB, which allows you to run code at full speed until 
> you hit a break point.  Such a debugger was recently introduced for Julia 
> 0.5, and is much more full-featured than Debug.jl:
>
> https://github.com/Keno/Gallium.jl
>
>

[julia-users] Re: Do I have to workspace() when a new breakpoint is introduced?

2016-04-25 Thread chobbes158
Thanks for the tips. It actually doesn't work, at least not on my machine. 
I try to reload the module in which new breakpoints are added and they're, 
again, ignored. Reloading the debugger doesn't help too. 

Thanks anyway.




On Monday, April 25, 2016 at 12:23:06 PM UTC+1, Hans-Peter wrote:
>
> > have to clear everything in the workspace by workspace() [...snip...] 
> ignore all my changes for debugging
>
> (remark: I didn't yet try out the debugger)
>
> You may put your code into a temporary module such that you only need to 
> reload the code you are working on, see e.g. 
> http://docs.julialang.org/en/release-0.4/manual/workflow-tips/. I'm not 
> sure if the debugger then pickups changes. 
>
> I think it's a bit too early for general debugger consumption (especially 
> for someone new to Julia). The debugger most likely will come in 
> well-rounded form with release 0.5 which, maybe, will be ready for the 
> JuliaCon.
>
>
>
>
>

[julia-users] Re: Arrow Keys when debugging

2016-04-25 Thread chobbes158
Thanks.

I'm using the Julia Debugger

https://github.com/toivoh/Debug.jl

in a bash terminal.

Are there any other debuggers? I thought this is the only one and the de 
facto official Julia debugger.

Thanks.


On Monday, April 25, 2016 at 2:52:17 PM UTC+1, Steven G. Johnson wrote:
>
> What debugger are you using?
>


[julia-users] Do I have to workspace() when a new breakpoint is introduced?

2016-04-25 Thread chobbes158


It seems to me that I have to clear everything in the workspace by 
workspace() if I want to introduce new breakpoints or remove existing 
breakpoints when debugging. Otherwise, the debugger simply ignore all my 
changes for debugging. But it takes huge amount of time when a lot of 
packages need to be loaded via "using". I wonder if there is a more 
efficient way to deal with this.

Thanks!!


[julia-users] Arrow Keys when debugging

2016-04-25 Thread chobbes158


I'm new to Julia. So bear me if the question is naive.

I'm wont to use up and down arrow keys to echo my previous commands and 
left and right keys to move in and out of a pair of parentheses I 
intentionally close first for adding contains. I found I can't do these 
when using Julia Debugger. 

Could anyone let me know if there is a way to retrieve these basic 
functionality of the arrow keys?

Thanks very much!