[julia-users] Re: CoinOptServices

2016-10-25 Thread Tony Kelman
do you have the lapack dll opened by some other julia process?

Re: [julia-users] use macros like a preprocessor directive?

2016-10-25 Thread Steven G. Johnson
You can use @static to implement a parse-time conditional

[julia-users] stop reading input from script

2016-10-25 Thread Steven G. Johnson
Wrap the unwanted code in a comment via

#=
.
.
=#

Re: [julia-users] Re: ImageView very slow

2016-10-25 Thread Tim Holy
Yes, it should be pretty responsive now---ImageView doesn't have to go
through a Python layer, so I think it's a bit snappier. It's been a while
since I've used Matlab, but at least when I first compared them ImageView
was considerably better than Matlab for interactive display of movies, etc.
But Tk does have pretty significant limitations; now that the Images
rewrite is largely done I'm planning to rewrite ImageView using Gtk. Not
started yet, though.

On Tue, Oct 25, 2016 at 5:24 PM, Paul B.  wrote:

> Tim, when you say you fixed this, you mean the deprecation warnings?  I'll
> definitely use the new version of Images.  I haven't had a chance yet since
> posting this.  Images and related libraries look great.
>
> The graphics functionality in Julia that deal with bitmaps like ImageView
> and pcolor in PyPlot seem slow.  I'm used to imagesc in MATLAB which can be
> unresponsive for very large images but not quite as sluggish as what I've
> been seeing.  From what little I found, it sounds like a lot of these use
> Tk which is controlled through text commands.  Am I mistaken?  Is there
> something maybe simpler but quicker than ImageView that will display a
> pseudo-color image?  Otherwise I might just bang something up that uses
> Images to save a PNG file then calls an external viewer to display it.
>
>>


[julia-users] Re: Importing Python data to Julia

2016-10-25 Thread Steven G. Johnson
Don't evaluate Julia code as strings. Just call Julia functions directly. 

j.inv(randMat)

should work

[julia-users] Re: stop reading input from script

2016-10-25 Thread Ethan Anderes


I don’t know the answer to your question…but it sounds similar to some 
functionality I was looking for a while back. I wanted to be able to pass a 
range of line numbers to include and only have those lines executed. 
Sometime like include(script.jl, 1:100) which would only run lines 1-100. I 
ended up writing the following function and putting it in my .juliarc.jl. 
It seems to work fine for my use case. Not sure if it will be useful to you 
tho. 

function Base.include{T<:Int}(path::AbstractString, lines::AbstractVector{T})
lns = open(readlines, path)
include_string(join(lns[lines]))
end

On Tuesday, October 25, 2016 at 2:27:41 PM UTC-7, David van Leeuwen wrote:

Hello, 
>
> is there a way in Julia for a file that is `include`d to signal that the 
> rest of the file should be ignored?  Something like `\endinput` in TeX.   
>
> I could use this in running testing scripts, putting such and `endinput` 
> further to the back while debugging the script.  Currently I wrap the 
> remainder of the script in `if false ... end`.  That works, when the 
> remainder is syntactically correct. 
>
> Thanks, 
>
> ---david
>
​


[julia-users] promote_op seems flakey (in a pure context)

2016-10-25 Thread Andy Ferris
I seem to be getting non-deterministic behaviour from `promote_op`, e.g. 
where the output of the function is different at the REPL, in a function 
and in a generated function.

Inside the function generator it sometimes works to give the correct result 
and sometimes returns `Any`. I haven't seen it fail at the REPL, but I'm 
getting test failures in StaticArrays master because of this.

I'm not sure if this is one of those "not valid in a pure context" (i.e. 
`@pure` or `@generated`) functions as it's implementation seems to involve 
inference and `Generator`s and so on. Or maybe it's a bug and I should file 
a report?

Thanks for any feedback,
Andy


Re: [julia-users] Re: Nemo AcbField error

2016-10-25 Thread Jeffrey Sarnoff
send me all the messages output, please

On Tue, Oct 25, 2016 at 7:41 PM, Jeffrey Sarnoff 
wrote:

> What happens if you restart that Julia from the windows menu (if that does
> not launch cygwin terminal)
> and  do >Pkg.build("Nemo") again?
>
> On Tue, Oct 25, 2016 at 7:37 PM, digxx  wrote:
>
>> Sry but I followed precisely ur steps i.e.:
>> I installed a completely new version in D:\Julia\Julia-0.5.0 and added an
>> environment variable JULIA_PKGDIR within D:\Julia because I didn't like the
>> default one.
>> I then initialized by Pkg.init()
>> I ran Pkg.update()  (prob not needed here coz its new)
>> I ran: Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
>> I exitted and restarted julia
>> I ran: Pkg.build("Nemo") and stumbled across:
>>
>> julia> Pkg.build("Nemo")
>> INFO: Building Nemo
>> WARNING: `@windows` is deprecated, use `@static is_windows()` instead
>>  in depwarn(::String, ::Symbol) at .\deprecated.jl:64
>>  in @windows(::Any, ::Any) at .\deprecated.jl:472
>>  in include_from_node1(::String) at .\loading.jl:488
>>  in evalfile(::String, ::Array{String,1}) at .\loading.jl:504 (repeats 2
>> times)
>>  in cd(::##2#4, ::String) at .\file.jl:48
>>  in (::##1#3)(::IOStream) at .\none:13
>>  in open(::##1#3, ::String, ::String) at .\iostream.jl:113
>>  in eval(::Module, ::Any) at .\boot.jl:234
>>  in process_options(::Base.JLOptions) at .\client.jl:239
>>  in _start() at .\client.jl:318
>> while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting
>> on line 1
>> 
>> ===[ ERROR: Nemo
>> ]===
>> 
>>
>> LoadError: chdir D:\Julia\v0.5\Nemo\deps\antic: no such file or directory
>> (ENOENT)
>> while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting
>> on line 121
>>
>> 
>> 
>> 
>> =
>>
>> 
>> ==[ BUILD ERRORS
>> ]===
>> 
>>
>> WARNING: Nemo had build errors.
>>
>>  - packages with build errors remain installed in D:\Julia\v0.5
>>  - build the package(s) and all dependencies with `Pkg.build("Nemo")`
>>  - build a single package by running its `deps/build.jl` script
>>
>> 
>> 
>> 
>> =
>>
>>
>


Re: [julia-users] Re: Nemo AcbField error

2016-10-25 Thread Jeffrey Sarnoff
What happens if you restart that Julia from the windows menu (if that does
not launch cygwin terminal)
and  do >Pkg.build("Nemo") again?

On Tue, Oct 25, 2016 at 7:37 PM, digxx  wrote:

> Sry but I followed precisely ur steps i.e.:
> I installed a completely new version in D:\Julia\Julia-0.5.0 and added an
> environment variable JULIA_PKGDIR within D:\Julia because I didn't like the
> default one.
> I then initialized by Pkg.init()
> I ran Pkg.update()  (prob not needed here coz its new)
> I ran: Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
> I exitted and restarted julia
> I ran: Pkg.build("Nemo") and stumbled across:
>
> julia> Pkg.build("Nemo")
> INFO: Building Nemo
> WARNING: `@windows` is deprecated, use `@static is_windows()` instead
>  in depwarn(::String, ::Symbol) at .\deprecated.jl:64
>  in @windows(::Any, ::Any) at .\deprecated.jl:472
>  in include_from_node1(::String) at .\loading.jl:488
>  in evalfile(::String, ::Array{String,1}) at .\loading.jl:504 (repeats 2
> times)
>  in cd(::##2#4, ::String) at .\file.jl:48
>  in (::##1#3)(::IOStream) at .\none:13
>  in open(::##1#3, ::String, ::String) at .\iostream.jl:113
>  in eval(::Module, ::Any) at .\boot.jl:234
>  in process_options(::Base.JLOptions) at .\client.jl:239
>  in _start() at .\client.jl:318
> while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting on
> line 1
> 
> ===[ ERROR: Nemo
> ]===
> 
>
> LoadError: chdir D:\Julia\v0.5\Nemo\deps\antic: no such file or directory
> (ENOENT)
> while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting on
> line 121
>
> 
> 
> 
> =
>
> 
> ==[ BUILD ERRORS
> ]===
> 
>
> WARNING: Nemo had build errors.
>
>  - packages with build errors remain installed in D:\Julia\v0.5
>  - build the package(s) and all dependencies with `Pkg.build("Nemo")`
>  - build a single package by running its `deps/build.jl` script
>
> 
> 
> 
> =
>
>


Re: [julia-users] Re: Nemo AcbField error

2016-10-25 Thread digxx
Sry but I followed precisely ur steps i.e.:
I installed a completely new version in D:\Julia\Julia-0.5.0 and added an 
environment variable JULIA_PKGDIR within D:\Julia because I didn't like the 
default one.
I then initialized by Pkg.init()
I ran Pkg.update()  (prob not needed here coz its new)
I ran: Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
I exitted and restarted julia
I ran: Pkg.build("Nemo") and stumbled across:

julia> Pkg.build("Nemo")
INFO: Building Nemo
WARNING: `@windows` is deprecated, use `@static is_windows()` instead
 in depwarn(::String, ::Symbol) at .\deprecated.jl:64
 in @windows(::Any, ::Any) at .\deprecated.jl:472
 in include_from_node1(::String) at .\loading.jl:488
 in evalfile(::String, ::Array{String,1}) at .\loading.jl:504 (repeats 2 
times)
 in cd(::##2#4, ::String) at .\file.jl:48
 in (::##1#3)(::IOStream) at .\none:13
 in open(::##1#3, ::String, ::String) at .\iostream.jl:113
 in eval(::Module, ::Any) at .\boot.jl:234
 in process_options(::Base.JLOptions) at .\client.jl:239
 in _start() at .\client.jl:318
while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting on 
line 1
===[
 
ERROR: Nemo 
]===

LoadError: chdir D:\Julia\v0.5\Nemo\deps\antic: no such file or directory 
(ENOENT)
while loading D:\Julia\v0.5\Nemo\deps\build.jl, in expression starting on 
line 121

=

==[
 
BUILD ERRORS 
]===

WARNING: Nemo had build errors.

 - packages with build errors remain installed in D:\Julia\v0.5
 - build the package(s) and all dependencies with `Pkg.build("Nemo")`
 - build a single package by running its `deps/build.jl` script

=



Re: [julia-users] Re: ImageView very slow

2016-10-25 Thread Paul B.
Tim, when you say you fixed this, you mean the deprecation warnings?  I'll 
definitely use the new version of Images.  I haven't had a chance yet since 
posting this.  Images and related libraries look great.

The graphics functionality in Julia that deal with bitmaps like ImageView 
and pcolor in PyPlot seem slow.  I'm used to imagesc in MATLAB which can be 
unresponsive for very large images but not quite as sluggish as what I've 
been seeing.  From what little I found, it sounds like a lot of these use 
Tk which is controlled through text commands.  Am I mistaken?  Is there 
something maybe simpler but quicker than ImageView that will display a 
pseudo-color image?  Otherwise I might just bang something up that uses 
Images to save a PNG file then calls an external viewer to display it.

>

Re: [julia-users] stop reading input from script

2016-10-25 Thread Abel Siqueira
Wrap the script in a function (functions) and use return?

Abel Soares Siqueira

2016-10-25 19:27 GMT-02:00 David van Leeuwen :

> Hello,
>
> is there a way in Julia for a file that is `include`d to signal that the
> rest of the file should be ignored?  Something like `\endinput` in TeX.
>
> I could use this in running testing scripts, putting such and `endinput`
> further to the back while debugging the script.  Currently I wrap the
> remainder of the script in `if false ... end`.  That works, when the
> remainder is syntactically correct.
>
> Thanks,
>
> ---david
>


[julia-users] Profile.print() options for easier reading of profile output data

2016-10-25 Thread Angel de Vicente
Hi,

I'm trying to profile a simple code I wrote that has just two
functions. When I call Profile.print() I get a lot of detail about
modules that (at least at this point) I'm not interested in profiling
(in this case, for example the Primes module, and the REPL itself).

,
| julia> Profile.print()
| 97 ./event.jl:68; (::Base.REPL.##3#4{Base.REPL.REPLBackend})()
|  97 ./REPL.jl:95; macro expansion
|   97 ./REPL.jl:64; eval_user_input(::Any, ::Base.REPL.REPLBackend)
|97 ./boot.jl:234; eval(::Module, ::Any)
| 97 ./:?; anonymous
|  97 ./profile.jl:16; macro expansion;
|   69 /home/angelv/temp/p21.jl:8; p21(::Int64)
|1  /home/angelv/temp/p21.jl:0; sumfactors(::Int64)
|1  /home/angelv/temp/p21.jl:23; sumfactors(::Int64)
| 1 ./abstractarray.jl:21; vect(::Int64, ::Vararg{Int64,N})
|49 /home/angelv/temp/p21.jl:24; sumfactors(::Int64)
| 1  ...v/.julia/v0.5/Primes/src/Primes.jl:246; factor!(::Int64, 
::Dict{Int64,Int64})
|  1 ...v/.julia/v0.5/Primes/src/Primes.jl:154; isprime(::Int64)
|   1 ...v/.julia/v0.5/Primes/src/Primes.jl:213; witnesses(::Int64)
|1 .../.julia/v0.5/Primes/src/Primes.jl:210; _witnesses(::UInt64)
| 1  ...v/.julia/v0.5/Primes/src/Primes.jl:252; factor!(::Int64, 
::Dict{Int64,Int64})
| 1  ...v/.julia/v0.5/Primes/src/Primes.jl:254; factor!(::Int64, 
::Dict{Int64,Int64})
|  1 ./dict.jl:692; get
| ...
`

I think it would be nice to have three more options to the Profile.print
function, which should not be difficult to implement: 

1. to print percentages
2. to limit the output based on a list of regex 
3. to be able to select the number of spaces added at each indentation
   level 

So, for example, I could make a call like

julia> Profile.print(consider=[r"/home/angelv/temp]",percentage=true,indent=3)
71.10%69 /home/angelv/temp/p21.jl:8; p21(::Int64)
   01.00%1  /home/angelv/temp/p21.jl:0; sumfactors(::Int64)
   01.00%1  /home/angelv/temp/p21.jl:23; sumfactors(::Int64)
   50.50%49 /home/angelv/temp/p21.jl:24; sumfactors(::Int64)
   18.60%18 /home/angelv/temp/p21.jl:25; sumfactors(::Int64)
28.90%28 /home/angelv/temp/p21.jl:11; p21(::Int64)
   19.60%19 /home/angelv/temp/p21.jl:24; sumfactors(::Int64)
   06.20%6  /home/angelv/temp/p21.jl:25; sumfactors(::Int64)
   01.00%1  /home/angelv/temp/p21.jl:27; sumfactors(::Int64)


This would make reading the profile data much simpler for when you are
developing new code and are not interested in profiling other modules.

Is this reasonable? Could this be implemented? (My proficiency with
Julia is very basic right now, but if this is considered a useful
addition, I could try to contribute with changes to profile.jl)

Cheers,
-- 
Ángel de Vicente
http://www.iac.es/galeria/angelv/  


[julia-users] stop reading input from script

2016-10-25 Thread David van Leeuwen
Hello, 

is there a way in Julia for a file that is `include`d to signal that the 
rest of the file should be ignored?  Something like `\endinput` in TeX.   

I could use this in running testing scripts, putting such and `endinput` 
further to the back while debugging the script.  Currently I wrap the 
remainder of the script in `if false ... end`.  That works, when the 
remainder is syntactically correct. 

Thanks, 

---david


[julia-users] ANN: best practices choosing and using names

2016-10-25 Thread Jeffrey Sarnoff

from the introduction:

It is easier to understand what `facial_recognition` does than it is to 
> understand what `facer` does.  

These brief guides collect information on best practices and sound 
> approaches using names with Julia.

   

The material is available here .



[julia-users] ANN: best practices choosing and using names

2016-10-25 Thread Jeffrey Sarnoff
from the introduction:

It is easier to understand what `facial_recognition` does than it is to 
> understand what `facer` does.  

These brief guides collect information on best practices and sound 
> approaches using names with Julia.

   

The material is available [here](https://github.com/JuliaPraxis/Naming).




Re: [julia-users] Binary read

2016-10-25 Thread Michele Zaffalon
The three read commands are reading the first, the second and the third
element of the file (and interpret them as Int32). That the values are in
general different should not be a surprise.

Yes, after you finish reading the file, you should close it:
f = open("numbers.dat")
anInt = read(f, Int32)
a_million_floats = read(f, Float64, 1_000_000)
close(f)





On Tue, Oct 25, 2016 at 10:46 PM, Aleksandr Mikheev 
wrote:

> Thank you very much, Michele! One more question, if you do not mind. If I
> do something like this:
>
> f = open("numbers.dat")
>
> a = read(f, Int32)
>
> a = read(f, Int32)
>
> a = read(f, Int32)
>
>
> then a is different each time. I believe I read something about that you
> should use command close() each you opened something. Is this correct?
>
>
> вторник, 25 октября 2016 г., 23:11:01 UTC+3 пользователь Michele Zaffalon
> написал:
>>
>> You open the file in the correct way. To read the integer, do read(f,
>> Int32) followed by read(f, Float64, 1_000_000) to read the million floats.
>> See the manual at http://docs.julialang.org/en/r
>> elease-0.5/stdlib/io-network/
>>
>> On Tue, Oct 25, 2016 at 10:05 PM, Aleksandr Mikheev 
>> wrote:
>>
>>> Hello, sorry if this question have already been asked, but I could not
>>> find a similar thread. So, I have a .dat ("numbers.dat") file, which I
>>> should open. I believe I should do something like this:
>>>
>>> f = open("numbers.dat")
>>>
>>>
>>> And after that I tried to read it:
>>>
>>> readlines(f)
>>>
>>>
>>> However, Julia writes the Error: "UnicodeError: invalid character
>>> index". My tutor told me that this is a binary file, so what I need is a
>>> binary read, such as fread in C/C++. I tried to read  the
>>> documentation, tried to google, but still cannot understand what should I
>>> do. Also, a quote from my tutor, which can probably help you to understand
>>> the problem better: "The first 4 bytes contain an integer (in this
>>> case, 1,000,000) and then 1,000,000 floats of 8 bytes each".
>>>
>>> Thank you in advance!
>>>
>>
>>


Re: [julia-users] parse Unicode string to Float64

2016-10-25 Thread Chris Stook
The StringEncodings package solves the problem.

Thank all,
Chris


Re: [julia-users] Binary read

2016-10-25 Thread Aleksandr Mikheev
Thank you very much, Michele! One more question, if you do not mind. If I 
do something like this:

f = open("numbers.dat")

a = read(f, Int32)

a = read(f, Int32) 

a = read(f, Int32)


then a is different each time. I believe I read something about that you 
should use command close() each you opened something. Is this correct? 


вторник, 25 октября 2016 г., 23:11:01 UTC+3 пользователь Michele Zaffalon 
написал:
>
> You open the file in the correct way. To read the integer, do read(f, 
> Int32) followed by read(f, Float64, 1_000_000) to read the million floats. 
> See the manual at 
> http://docs.julialang.org/en/release-0.5/stdlib/io-network/
>
> On Tue, Oct 25, 2016 at 10:05 PM, Aleksandr Mikheev  > wrote:
>
>> Hello, sorry if this question have already been asked, but I could not 
>> find a similar thread. So, I have a .dat ("numbers.dat") file, which I 
>> should open. I believe I should do something like this: 
>>
>> f = open("numbers.dat")
>>
>>
>> And after that I tried to read it:
>>
>> readlines(f)
>>
>>
>> However, Julia writes the Error: "UnicodeError: invalid character 
>> index". My tutor told me that this is a binary file, so what I need is a 
>> binary read, such as fread in C/C++. I tried to read  the documentation, 
>> tried to google, but still cannot understand what should I do. Also, a 
>> quote from my tutor, which can probably help you to understand the problem 
>> better: "The first 4 bytes contain an integer (in this case, 1,000,000) 
>> and then 1,000,000 floats of 8 bytes each".
>>
>> Thank you in advance!
>>
>
>

[julia-users] Re: ANN: ParallelAccelerator v0.2 for Julia 0.5 released.

2016-10-25 Thread Todd Anderson
Actually, it seems that the pull request into Julia metadata to set the 
default ParallelAccelerator version has not yet been merged.  So, if you 
want the simplest package update or to get the correct version with a 
simple Pkg.add then hold off until the merge happens.  I'll post here again 
when that happens.

thanks,

Todd


Re: [julia-users] Binary read

2016-10-25 Thread Michele Zaffalon
You open the file in the correct way. To read the integer, do read(f,
Int32) followed by read(f, Float64, 1_000_000) to read the million floats.
See the manual at
http://docs.julialang.org/en/release-0.5/stdlib/io-network/

On Tue, Oct 25, 2016 at 10:05 PM, Aleksandr Mikheev 
wrote:

> Hello, sorry if this question have already been asked, but I could not
> find a similar thread. So, I have a .dat ("numbers.dat") file, which I
> should open. I believe I should do something like this:
>
> f = open("numbers.dat")
>
>
> And after that I tried to read it:
>
> readlines(f)
>
>
> However, Julia writes the Error: "UnicodeError: invalid character index".
> My tutor told me that this is a binary file, so what I need is a binary
> read, such as fread in C/C++. I tried to read  the documentation, tried
> to google, but still cannot understand what should I do. Also, a quote from
> my tutor, which can probably help you to understand the problem better: "The
> first 4 bytes contain an integer (in this case, 1,000,000) and then
> 1,000,000 floats of 8 bytes each".
>
> Thank you in advance!
>


Re: [julia-users] Binary read

2016-10-25 Thread Yichao Yu
On Tue, Oct 25, 2016 at 4:05 PM, Aleksandr Mikheev
 wrote:
> Hello, sorry if this question have already been asked, but I could not find
> a similar thread. So, I have a .dat ("numbers.dat") file, which I should
> open. I believe I should do something like this:
>
>> f = open("numbers.dat")
>
>
> And after that I tried to read it:
>
>> readlines(f)

read(f, Int64)

>
>
> However, Julia writes the Error: "UnicodeError: invalid character index". My
> tutor told me that this is a binary file, so what I need is a binary read,
> such as fread in C/C++. I tried to read  the documentation, tried to google,
> but still cannot understand what should I do. Also, a quote from my tutor,
> which can probably help you to understand the problem better: "The first 4
> bytes contain an integer (in this case, 1,000,000) and then 1,000,000 floats
> of 8 bytes each".
>
> Thank you in advance!


[julia-users] Binary read

2016-10-25 Thread Aleksandr Mikheev
Hello, sorry if this question have already been asked, but I could not find 
a similar thread. So, I have a .dat ("numbers.dat") file, which I should 
open. I believe I should do something like this: 

f = open("numbers.dat")


And after that I tried to read it:

readlines(f)


However, Julia writes the Error: "UnicodeError: invalid character index". 
My tutor told me that this is a binary file, so what I need is a binary 
read, such as fread in C/C++. I tried to read  the documentation, tried to 
google, but still cannot understand what should I do. Also, a quote from my 
tutor, which can probably help you to understand the problem better: "The 
first 4 bytes contain an integer (in this case, 1,000,000) and then 
1,000,000 floats of 8 bytes each".

Thank you in advance!


Re: [julia-users] llvm call error

2016-10-25 Thread Yichao Yu
On Tue, Oct 25, 2016 at 3:55 PM,   wrote:
> I need some part of my julia code to be executed at run time and be loaded
> as llvm IR (or assembly). It is allowed to be IR or assembly code but not
> julia source code or c source code.

Why does it have to be IR or assembly?

>
> Are there other options like the output-bc option that  can work for me?
>
> What other approaches I can consider?

What problem are you trying to solve.

>
> Thanks for all the work making julia great!!
>
> On Tuesday, October 25, 2016 at 10:58:37 AM UTC-7, Stefan Karpinski wrote:
>>
>> Julia can already generate static code:
>>
>> http://juliacomputing.com/blog/2016/02/09/static-julia.html
>> http://juliacomputing.com/blog/2016/03/10/j2c-announcement.html
>>
>> However, Julia's @code_llvm output is not meant to be compilable. What are
>> you trying to do?
>>
>>
>> On Tue, Oct 25, 2016 at 1:11 PM,  wrote:
>>>
>>> Thanks, is it possible for julia to avoid generating jl_value_t
>>>
>>> When I use a scalar Int64 julia generates code with i64 as input and no
>>> jl_value_t appears. is it possible to do the same with arrays?
>>> Array{Float32,2} genrates a  jl_value_t? Is there an array type that can do
>>> this? For example fixed arrays?
>>>
>>> Finally, is this features planned to be supported if julia statically
>>> compiles?
>>>
>>> Thanks
>>>
>>> On Tuesday, October 25, 2016 at 9:23:02 AM UTC-7, Yichao Yu wrote:

 On Mon, Oct 24, 2016 at 8:15 PM,   wrote:
 > Hi All,
 >
 > I am trying to call llvm ir generated from julia.
 >
 > Here is my function:
 >
 > function incr(a::Array{Int64})  a+1; end
 >
 >
 > thus:
 >
 > @code_llvm(incr([1 2 5 6 7]))
 >
 > returns:
 >
 > define %jl_value_t* @julia_incr_62127(%jl_value_t*) #0 {
 > top:
 >   %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0
 >   ret %jl_value_t* %1
 > }
 >
 >
 >
 > Thus to call it using llvm I try :
 >
 > Base.llvmcall(("""declare %jl_value_t*
 > @julia_incr_62127(%jl_value_t*)""",
 > """top:
 >  %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64
 > 1) #0
 >  ret %jl_value_t* %1
 >"""),Vector{Int64},Tuple{Array{Int64}},[1 2 5 6 7])
 >
 >
 >
 >
 > and I get the error:
 >
 > ERROR: error compiling anonymous: Failed to parse LLVM Assembly:
 > julia: llvmcall:2:9: error: use of undefined type named 'jl_value_t'
 > declare %jl_value_t* @julia_incr_62127(%jl_value_t*)
 >
 >
 > I m not sure how to define jl_value_t.

 This is not supported.
 You also shouldn't call julia generated functions with `llvmcall`.

 >
 >
 > any help?
 >
 > Thanks
>>
>>
>


Re: [julia-users] llvm call error

2016-10-25 Thread iceblue25 . 1
I need some part of my julia code to be executed at run time and be loaded 
as llvm IR (or assembly). It is allowed to be IR or assembly code but not 
julia source code or c source code.

Are there other options like the output-bc option that  can work for me?

What other approaches I can consider?

Thanks for all the work making julia great!!

On Tuesday, October 25, 2016 at 10:58:37 AM UTC-7, Stefan Karpinski wrote:
>
> Julia can already generate static code:
>
>- http://juliacomputing.com/blog/2016/02/09/static-julia.html
>- http://juliacomputing.com/blog/2016/03/10/j2c-announcement.html
>
> However, Julia's @code_llvm output is not meant to be compilable. What are 
> you trying to do?
>
>
> On Tue, Oct 25, 2016 at 1:11 PM,  wrote:
>
>> Thanks, is it possible for julia to avoid generating jl_value_t
>>
>> When I use a scalar Int64 julia generates code with i64 as input and no 
>>  jl_value_t appears. is it possible to do the same with arrays?  
>> Array{Float32,2} genrates a  jl_value_t? Is there an array type that can do 
>> this? For example fixed arrays?
>>
>> Finally, is this features planned to be supported if julia statically 
>> compiles?
>>
>> Thanks
>>
>> On Tuesday, October 25, 2016 at 9:23:02 AM UTC-7, Yichao Yu wrote:
>>
>>> On Mon, Oct 24, 2016 at 8:15 PM,   wrote: 
>>> > Hi All, 
>>> > 
>>> > I am trying to call llvm ir generated from julia. 
>>> > 
>>> > Here is my function: 
>>> > 
>>> > function incr(a::Array{Int64})  a+1; end 
>>> > 
>>> > 
>>> > thus: 
>>> > 
>>> > @code_llvm(incr([1 2 5 6 7])) 
>>> > 
>>> > returns: 
>>> > 
>>> > define %jl_value_t* @julia_incr_62127(%jl_value_t*) #0 { 
>>> > top: 
>>> >   %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0 
>>> >   ret %jl_value_t* %1 
>>> > } 
>>> > 
>>> > 
>>> > 
>>> > Thus to call it using llvm I try : 
>>> > 
>>> > Base.llvmcall(("""declare %jl_value_t* 
>>> @julia_incr_62127(%jl_value_t*)""", 
>>> > """top: 
>>> >  %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 
>>> 1) #0 
>>> >  ret %jl_value_t* %1 
>>> >"""),Vector{Int64},Tuple{Array{Int64}},[1 2 5 6 7]) 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > and I get the error: 
>>> > 
>>> > ERROR: error compiling anonymous: Failed to parse LLVM Assembly: 
>>> > julia: llvmcall:2:9: error: use of undefined type named 'jl_value_t' 
>>> > declare %jl_value_t* @julia_incr_62127(%jl_value_t*) 
>>> > 
>>> > 
>>> > I m not sure how to define jl_value_t. 
>>>
>>> This is not supported. 
>>> You also shouldn't call julia generated functions with `llvmcall`. 
>>>
>>> > 
>>> > 
>>> > any help? 
>>> > 
>>> > Thanks 
>>>
>>
>

[julia-users] Which data structure do you suggest for handling this data?

2016-10-25 Thread MP

Hi all,

I have a grid network with a number nodes with (x,y) coordinates, and I 
have a couple of individuals that visit these nodes in the network. For 
instance, individual 1 visits nodes (1,3), (4,5), (8,9) and individual 2 
visits (4,3), (2,5). 

I need to access these nodes for each individual (let say in a for loop for 
all individuals) but I do not know the best way of doing it in Julia. 

Thanks in advance,


Re: [julia-users] Re: Trait for exactness of numbers

2016-10-25 Thread Tim Holy
> Why not use dispatch instead?

Because subtyping isn't powerful enough for all needs. For example:


julia> using Unitful

julia> const mm = u"mm"
mm

julia> isa(3.2mm, AbstractFloat)
false


You'd probably like to use the fancy logic of `FloatRange` if you're
constructing a range `3.2mm:0.1mm:4.8mm`, so the solution is to dispatch on
a trait that indicates that arithmetic isn't exact (which is what really is
going on inside that code anyway---who cares what kind of number type it
is).

Best,
--Tim

On Tue, Oct 25, 2016 at 12:55 PM, Ismael Venegas Castelló <
ismael.vc1...@gmail.com> wrote:

> Why not use dispatch instead?
>
> isexact(::Integer) = true
> isexact(::Rational) = true
> isexact(x::Complex) = isexact(x.re)
> isexact(::Any) = false


[julia-users] Inclusion of local modules in pyjulia

2016-10-25 Thread Corbin Foucart
Suppose that I have a local module in the current directory called 
'myModule.jl':

module
x() = "hello"
end

 In a Julia console, I can do the following:

> include("myModule.jl")
> myModule.x()
"hello"

I can do a whos() to check that indeed myModule is in the namespace. I am 
attempting to call this module in pyjulia with the following snippet:

julia = Julia( initialization args)
julia.eval('include(\"myMdoule.jl\"))
julia.myModule.x()

which outputs the following error:

File "juliaSetup.py", line 21, in 
julia.myModule.x()
AttributeError: 'Julia' object has no attribute 'myModule'

So Julia is a python object; is there a getter from which I can access the 
methods in myModule via the approach above, or do I have to set it up with:

julia.using("myModule")?



Re: [julia-users] llvm call error

2016-10-25 Thread Stefan Karpinski
Julia can already generate static code:

   - http://juliacomputing.com/blog/2016/02/09/static-julia.html
   - http://juliacomputing.com/blog/2016/03/10/j2c-announcement.html

However, Julia's @code_llvm output is not meant to be compilable. What are
you trying to do?


On Tue, Oct 25, 2016 at 1:11 PM,  wrote:

> Thanks, is it possible for julia to avoid generating jl_value_t
>
> When I use a scalar Int64 julia generates code with i64 as input and no
>  jl_value_t appears. is it possible to do the same with arrays?
> Array{Float32,2} genrates a  jl_value_t? Is there an array type that can do
> this? For example fixed arrays?
>
> Finally, is this features planned to be supported if julia statically
> compiles?
>
> Thanks
>
> On Tuesday, October 25, 2016 at 9:23:02 AM UTC-7, Yichao Yu wrote:
>
>> On Mon, Oct 24, 2016 at 8:15 PM,   wrote:
>> > Hi All,
>> >
>> > I am trying to call llvm ir generated from julia.
>> >
>> > Here is my function:
>> >
>> > function incr(a::Array{Int64})  a+1; end
>> >
>> >
>> > thus:
>> >
>> > @code_llvm(incr([1 2 5 6 7]))
>> >
>> > returns:
>> >
>> > define %jl_value_t* @julia_incr_62127(%jl_value_t*) #0 {
>> > top:
>> >   %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0
>> >   ret %jl_value_t* %1
>> > }
>> >
>> >
>> >
>> > Thus to call it using llvm I try :
>> >
>> > Base.llvmcall(("""declare %jl_value_t* @julia_incr_62127(%jl_value_t*)""",
>>
>> > """top:
>> >  %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64
>> 1) #0
>> >  ret %jl_value_t* %1
>> >"""),Vector{Int64},Tuple{Array{Int64}},[1 2 5 6 7])
>> >
>> >
>> >
>> >
>> > and I get the error:
>> >
>> > ERROR: error compiling anonymous: Failed to parse LLVM Assembly:
>> > julia: llvmcall:2:9: error: use of undefined type named 'jl_value_t'
>> > declare %jl_value_t* @julia_incr_62127(%jl_value_t*)
>> >
>> >
>> > I m not sure how to define jl_value_t.
>>
>> This is not supported.
>> You also shouldn't call julia generated functions with `llvmcall`.
>>
>> >
>> >
>> > any help?
>> >
>> > Thanks
>>
>


[julia-users] Re: Trait for exactness of numbers

2016-10-25 Thread Ismael Venegas Castelló
Why not use dispatch instead?

isexact(::Integer) = true
isexact(::Rational) = true
isexact(x::Complex) = isexact(x.re)
isexact(::Any) = false

Re: [julia-users] llvm call error

2016-10-25 Thread iceblue25 . 1
Thanks, is it possible for julia to avoid generating jl_value_t

When I use a scalar Int64 julia generates code with i64 as input and no 
 jl_value_t appears. is it possible to do the same with arrays? 
 Array{Float32,2} genrates a  jl_value_t? Is there an array type that can 
do this? For example fixed arrays?

Finally, is this features planned to be supported if julia statically 
compiles?

Thanks

On Tuesday, October 25, 2016 at 9:23:02 AM UTC-7, Yichao Yu wrote:
>
> On Mon, Oct 24, 2016 at 8:15 PM,   
> wrote: 
> > Hi All, 
> > 
> > I am trying to call llvm ir generated from julia. 
> > 
> > Here is my function: 
> > 
> > function incr(a::Array{Int64})  a+1; end 
> > 
> > 
> > thus: 
> > 
> > @code_llvm(incr([1 2 5 6 7])) 
> > 
> > returns: 
> > 
> > define %jl_value_t* @julia_incr_62127(%jl_value_t*) #0 { 
> > top: 
> >   %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0 
> >   ret %jl_value_t* %1 
> > } 
> > 
> > 
> > 
> > Thus to call it using llvm I try : 
> > 
> > Base.llvmcall(("""declare %jl_value_t* 
> @julia_incr_62127(%jl_value_t*)""", 
> > """top: 
> >  %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 
> 1) #0 
> >  ret %jl_value_t* %1 
> >"""),Vector{Int64},Tuple{Array{Int64}},[1 2 5 6 7]) 
> > 
> > 
> > 
> > 
> > and I get the error: 
> > 
> > ERROR: error compiling anonymous: Failed to parse LLVM Assembly: 
> > julia: llvmcall:2:9: error: use of undefined type named 'jl_value_t' 
> > declare %jl_value_t* @julia_incr_62127(%jl_value_t*) 
> > 
> > 
> > I m not sure how to define jl_value_t. 
>
> This is not supported. 
> You also shouldn't call julia generated functions with `llvmcall`. 
>
> > 
> > 
> > any help? 
> > 
> > Thanks 
>


[julia-users] ANN: ParallelAccelerator v0.2 for Julia 0.5 released.

2016-10-25 Thread Todd Anderson
The High Performance Scripting team at Intel Labs is pleased to announce 
the release of version 0.2 of ParallelAccelerator.jl, a package for 
high-performance parallel computing in Julia, primarily oriented around 
arrays and stencils.  In this release, we provide support for Julia 0.5 and 
introduce experimental support for the Julia native threading backend.  
While we still currently support Julia 0.4, such support should be 
considered deprecated and we recommend everyone move to Julia 0.5 as Julia 
0.4 support may be removed in the future.

The goal of ParallelAccelerator is to accelerate the computational kernel 
of an application by the programmer simply annotating the kernel function 
with the @acc (short for "accelerate") macro, provided by the 
ParallelAccelerator package.  In version 0.2, ParallelAccelerator still 
defaults to transforming the kernel to OpenMP C code that is then compiled 
with a system C compiler (ICC or GCC) and transparently handles the 
invocation of the C code from Julia as if the program were running normally.

However, ParallelAccelerator v0.2 also introduces experimental backend 
support for Julia's native threading (which is also experimental).  To 
enable native threading mode, set the environment variable 
PROSPECT_MODE=threads.  In this mode, ParallelAccelerator identifies pieces 
of code that can be run in parallel and then runs that code as if it had 
been annotated with Julia's @threads and goes through the standard Julia 
compiler pipeline with LLVM.  The ParallelAccelerator C backend has the 
limitation that the kernel functions and anything called by those cannot 
include code that is not type-stable to a single type.  In particular, 
variables of type Any are not supported.  In practice, this restriction was 
a significant limitation.  For the native threading backend, no such 
restriction is necessary and thus our backend should handle arbitrary Julia 
code.

Under the hood, ParallelAccelerator is essentially a domain-specific 
compiler written in Julia. It performs additional analysis and optimization 
on top of the Julia compiler. ParallelAccelerator discovers and exploits 
the implicit parallelism in source programs that use parallel programming 
patterns such as map, reduce, comprehension, and stencil. For example, 
Julia array operators such as .+, .-, .*, ./ are translated by 
ParallelAccelerator internally into data-parallel map operations over all 
elements of input arrays. For the most part, these patterns are already 
present in standard Julia, so programmers can use ParallelAccelerator to 
run the same Julia program without (significantly) modifying the source 
code.

Version 0.2 should be considered an alpha release, suitable for early 
adopters and Julia enthusiasts.  Please file bugs at 
https://travis-ci.org/IntelLabs/ParallelAccelerator.jl/issues .

See our GitHub repository at 
https://github.com/IntelLabs/ParallelAccelerator.jl for a complete list of 
prerequisites, supported platforms, example programs, and documentation.

Thanks to our colleagues at Intel and Intel Labs, the Julia team, and the 
broader Julia community for their support of our efforts!

Best regards,
The High Performance Scripting team
(Parallel Computing Lab, Intel Labs)


Re: [julia-users] llvm call error

2016-10-25 Thread Yichao Yu
On Mon, Oct 24, 2016 at 8:15 PM,   wrote:
> Hi All,
>
> I am trying to call llvm ir generated from julia.
>
> Here is my function:
>
> function incr(a::Array{Int64})  a+1; end
>
>
> thus:
>
> @code_llvm(incr([1 2 5 6 7]))
>
> returns:
>
> define %jl_value_t* @julia_incr_62127(%jl_value_t*) #0 {
> top:
>   %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0
>   ret %jl_value_t* %1
> }
>
>
>
> Thus to call it using llvm I try :
>
> Base.llvmcall(("""declare %jl_value_t* @julia_incr_62127(%jl_value_t*)""",
> """top:
>  %1 = call %jl_value_t* @"julia_.+_62128"(%jl_value_t* %0, i64 1) #0
>  ret %jl_value_t* %1
>"""),Vector{Int64},Tuple{Array{Int64}},[1 2 5 6 7])
>
>
>
>
> and I get the error:
>
> ERROR: error compiling anonymous: Failed to parse LLVM Assembly:
> julia: llvmcall:2:9: error: use of undefined type named 'jl_value_t'
> declare %jl_value_t* @julia_incr_62127(%jl_value_t*)
>
>
> I m not sure how to define jl_value_t.

This is not supported.
You also shouldn't call julia generated functions with `llvmcall`.

>
>
> any help?
>
> Thanks


[julia-users] Re: Calling all users of ParallelAccelerator.

2016-10-25 Thread Todd Anderson
The next version of ParallelAccelerator for Julia 0.5 has just been 
released with experimental support for Julia native threading.  Please see 
the new Julia users post for more details of the new release.


[julia-users] Re: CoinOptServices

2016-10-25 Thread Miles Lubin
Please open an issue on the CoinOptServices repository with as much 
information as you can to help reproduce the problem.

On Tuesday, October 25, 2016 at 11:04:56 AM UTC-4, Frank Kampas wrote:
>
> When I run Pkg.build("CoinOptServices") using Julia 5.0 and Windows 10, I 
> get load errors and a build error message.
>
> On Tuesday, October 25, 2016 at 9:01:29 AM UTC-4, Frank Kampas wrote:
>>
>> Is anybody working on fixing CoinOptServices?
>>
>

[julia-users] Re: CoinOptServices

2016-10-25 Thread Frank Kampas
When I run Pkg.build("CoinOptServices") using Julia 5.0 and Windows 10, I 
get load errors and a build error message.

On Tuesday, October 25, 2016 at 9:01:29 AM UTC-4, Frank Kampas wrote:
>
> Is anybody working on fixing CoinOptServices?
>


[julia-users] [ANN] QuickTypes.jl: Concise type definitions with default arguments

2016-10-25 Thread Cedric St-Jean
Types are central to Julia programming, but the built-in `type` and 
`immutable` definitions can be cumbersome to write. QuickTypes.jl 
 provides two alternative macros, 
*@qtype* and *@qimmutable, *with a more convenient syntax:

Pkg.add("QuickTypes")   # to install
using QuickTypes

@qtype Wall(width, height)

# Optional and keyword-arguments
@qtype Cat(name, age::Int, nlegs=4; species="Siamese")

# Parametric type
@qtype Pack{T}(animals::Vector{T})

# Inheritance
abstract Tree
@qtype Maple(qty_syrup::Float64) <: Tree

# Immutables work the same way
@qimmutable SquaredNumber(x2::Number)



[julia-users] Re: Importing Python data to Julia

2016-10-25 Thread Corbin Foucart
That worked; thanks! 

On Tuesday, October 25, 2016 at 6:36:25 AM UTC-4, Christoph Ortner wrote:
>
> I haven't tried, but I think it should be 
>
> result = j.inv(randMat)
>
>
> On Tuesday, 25 October 2016 05:05:47 UTC+1, Corbin Foucart wrote:
>>
>> How? If you don't mind my asking. It doesn't seem that documentation 
>> exists... Suppose in a python script, I have:
>>
>> [python imports]
>> [pyjulia initialization]
>> j = julia.Julia()
>>
>> randMat = np.random.rand(3, 3)
>> # what should I put here to pass randMat to julia?
>> result = j.eval("inv(julia_randmat)") 
>>
>> # ^^^ is this how I would move the result back to python?
>>
>>
>>
>> On Tuesday, October 18, 2016 at 7:50:03 PM UTC-4, Steven G. Johnson wrote:
>>>
>>>
>>>
>>> On Tuesday, October 18, 2016 at 4:42:51 PM UTC-4, Corbin Foucart wrote:

 2) Call Julia code directly from python (I don't want to perform some 
 trivial computation as in the examples I've found, I want to operate on 
 the 
 lists of numpy arrays)

>>>
>>> pyjulia can do this. 
>>>
>>

[julia-users] Re: CoinOptServices

2016-10-25 Thread Miles Lubin
I'm not aware of any broken functionality in CoinOptServices, but it hasn't 
been updated to get rid of deprecation warnings on 0.5. We'd welcome a PR.

On Tuesday, October 25, 2016 at 9:01:29 AM UTC-4, Frank Kampas wrote:
>
> Is anybody working on fixing CoinOptServices?
>


Re: [julia-users] parse Unicode string to Float64

2016-10-25 Thread Milan Bouchet-Valat
Le lundi 24 octobre 2016 à 21:44 -0700, Chris Stook a écrit :
> I'm trying to parse a text file which contains some floating point
> numbers.  The number 2.5 is represented by the string
> "\x002\0.\x005\0".  Parse will not convert this to a Float64.  Print
> works (prints "2.5") in Atom and Jupyter, but not in the REPL.
> 
> _
> _       _ _(_)_     |  A fresh approach to technical computing
> (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
> _ _   _| |_  __ _   |  Type "?help" for help.
> | | | | | | |/ _` |  |
> | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
> _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/                   |  x86_64-w64-mingw32
> 
> julia> print("\x002\0.\x005\0")
> �2�.�5�
> julia> parse(Float64,"\x002\0.\x005\0")
> ERROR: ArgumentError: invalid number format "\x002\0.\x005\0" for
> Float64
> in parse(::Type{Float64}, ::String) at .\parse.jl:167
> 
> julia>
> 
> I am not familiar with Unicode.  Is the Unicode valid?  How should I
> convert this to a Float?  I do not have control over the input file.
"Unicode" doesn't refer to a specific encoding. Julia expects UTF-8,
but this appears to be UTF16-BE (which is often abusively called
Unicode in the Windows world).

You can use my StringEncodings package to decode the file to a Julia
string (see the README):

julia> using StringEncodings

julia> parse(Float64, decode("\x002\0.\x005\0".data, "UTF-16BE"))
2.5


Regards


[julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Cedric St-Jean


count_zeros = sum( map(x->(x==0.0), actuals) )

# can be rewritten

count_zeros = sum(x==0.0 for x in actuals)


This shouldn't allocate, because it's using a generator.

I agree with DNF that _v1 is already straight-forward, as far as 
performance-sensitive code goes.

On Tuesday, October 25, 2016 at 6:34:45 AM UTC-4, DNF wrote:
>
> Could you explain why you are unhappy with v1? It seems like a 
> near-optimal implementation to me. It is idiomatic Julia, clean, clear, and 
> fast. Are you certain that you're not looking for a one-liner out of force 
> of habit?
>
> On Tuesday, October 25, 2016 at 9:15:54 AM UTC+2, Martin Florek wrote:
>>
>> Hi all,
>> I'm new in Julia and I'm doing refactoring. I have the following function:
>>
>> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>>   s = 0.0
>>   count = 0
>>   for i in 1:length(A)
>> if(A[i] != 0.0)
>>   s += abs( (A[i] - F[i]) / A[i])
>>   count += 1
>> end
>>   end
>>
>>   s, count 
>>
>> end   
>>
>> I'm looking for a simpler variant which is as follows:
>>
>> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
>> # A - actual target values
>> # F - forecasts (model estimations)
>>
>>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>>
>>   count = length(A) # ???
>>   s, countend
>>
>>
>> However with this variant can not determine the number of non-zero elements. 
>> I found option with length(A[A .!= 0.0]), but it has a large allocation. 
>> Please, someone knows a solution with generator, or variant v1 is very good 
>> choice?
>>
>>
>> Thanks in advance,
>> Martin
>>
>>

[julia-users] CoinOptServices

2016-10-25 Thread Frank Kampas
Is anybody working on fixing CoinOptServices?


[julia-users] Re: Importing Python data to Julia

2016-10-25 Thread Christoph Ortner
I haven't tried, but I think it should be 

result = j.inv(randMat)


On Tuesday, 25 October 2016 05:05:47 UTC+1, Corbin Foucart wrote:
>
> How? If you don't mind my asking. It doesn't seem that documentation 
> exists... Suppose in a python script, I have:
>
> [python imports]
> [pyjulia initialization]
> j = julia.Julia()
>
> randMat = np.random.rand(3, 3)
> # what should I put here to pass randMat to julia?
> result = j.eval("inv(julia_randmat)") 
>
> # ^^^ is this how I would move the result back to python?
>
>
>
> On Tuesday, October 18, 2016 at 7:50:03 PM UTC-4, Steven G. Johnson wrote:
>>
>>
>>
>> On Tuesday, October 18, 2016 at 4:42:51 PM UTC-4, Corbin Foucart wrote:
>>>
>>> 2) Call Julia code directly from python (I don't want to perform some 
>>> trivial computation as in the examples I've found, I want to operate on the 
>>> lists of numpy arrays)
>>>
>>
>> pyjulia can do this. 
>>
>

[julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread DNF
Could you explain why you are unhappy with v1? It seems like a near-optimal 
implementation to me. It is idiomatic Julia, clean, clear, and fast. Are 
you certain that you're not looking for a one-liner out of force of habit?

On Tuesday, October 25, 2016 at 9:15:54 AM UTC+2, Martin Florek wrote:
>
> Hi all,
> I'm new in Julia and I'm doing refactoring. I have the following function:
>
> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>   s = 0.0
>   count = 0
>   for i in 1:length(A)
> if(A[i] != 0.0)
>   s += abs( (A[i] - F[i]) / A[i])
>   count += 1
> end
>   end
>
>   s, count 
>
> end   
>
> I'm looking for a simpler variant which is as follows:
>
> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
> # A - actual target values
> # F - forecasts (model estimations)
>
>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>
>   count = length(A) # ???
>   s, countend
>
>
> However with this variant can not determine the number of non-zero elements. 
> I found option with length(A[A .!= 0.0]), but it has a large allocation. 
> Please, someone knows a solution with generator, or variant v1 is very good 
> choice?
>
>
> Thanks in advance,
> Martin
>
>

[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Simon Byrne
It seems like you have a bunch of null characters in the string for some 
reason. You could try stripping them out with replace:

julia> x = "\x002\0.\x005\0"

"\x002\0.\x005\0"


julia> y = replace(x,"\0","")

"2.5"


julia> parse(Float64, y)

2.5




On Tuesday, 25 October 2016 05:44:34 UTC+1, Chris Stook wrote:
>
> I'm trying to parse a text file which contains some floating point 
> numbers.  The number 2.5 is represented by the string "\x002\0.\x005\0". 
>  Parse will not convert this to a Float64.  Print works (prints "2.5") in 
> Atom and Jupyter, but not in the REPL.
>
> _
> _   _ _(_)_ |  A fresh approach to technical computing
> (_) | (_) (_)|  Documentation: http://docs.julialang.org
> _ _   _| |_  __ _   |  Type "?help" for help.
> | | | | | | |/ _` |  |
> | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
> _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/   |  x86_64-w64-mingw32
>
> julia> print("\x002\0.\x005\0")
> �2�.�5�
> julia> parse(Float64,"\x002\0.\x005\0")
> ERROR: ArgumentError: invalid number format "\x002\0.\x005\0" for Float64
> in parse(::Type{Float64}, ::String) at .\parse.jl:167
>
> julia>
>
> I am not familiar with Unicode.  Is the Unicode valid?  How should I 
> convert this to a Float?  I do not have control over the input file.
>
> Thanks,
> Chris
>
>

Re: [julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Gregory Salvan
maybe with reduce ?

```
function mapeBase_v4(A::Vector{Float64}, F::Vector{Float64})
  function abscount(prev, current)
current[2] == 0.0 && return prev
index, item = current
(prev[1] + abs( 1 - F[index] / item), prev[2] + 1)
  end
  reduce(abscount, (0.0, 0), enumerate(A))
end
```

2016-10-25 9:43 GMT+02:00 Jeffrey Sarnoff :

> This may do what you want.
>
> function mapeBase_v3(actuals::Vector{Float64}, forecasts::Vector{Float64})
> # actuals - actual target values
> # forecasts - forecasts (model estimations)
>
>   sum_reldiffs = sumabs((x - y) / x for (x, y) in zip(actuals, forecasts) if 
> x != 0.0)  # Generator
>
>   count_zeros = sum( map(x->(x==0.0), actuals) )
>   count_nonzeros = length(actuals) - count_zeros
>   sum_reldiffs, count_nonzeros
> end
>
>
>
>
> On Tuesday, October 25, 2016 at 3:15:54 AM UTC-4, Martin Florek wrote:
>>
>> Hi all,
>> I'm new in Julia and I'm doing refactoring. I have the following function:
>>
>> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>>   s = 0.0
>>   count = 0
>>   for i in 1:length(A)
>> if(A[i] != 0.0)
>>   s += abs( (A[i] - F[i]) / A[i])
>>   count += 1
>> end
>>   end
>>
>>   s, count
>>
>> end
>>
>> I'm looking for a simpler variant which is as follows:
>>
>> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
>> # A - actual target values
>> # F - forecasts (model estimations)
>>
>>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>>
>>   count = length(A) # ???
>>   s, countend
>>
>>
>> However with this variant can not determine the number of non-zero elements. 
>> I found option with length(A[A .!= 0.0]), but it has a large allocation. 
>> Please, someone knows a solution with generator, or variant v1 is very good 
>> choice?
>>
>>
>> Thanks in advance,
>> Martin
>>
>>


[julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Jeffrey Sarnoff
this change saves some space: `count_zeros = length( find(x->x==0.0, 
actuals) )`


On Tuesday, October 25, 2016 at 4:48:29 AM UTC-4, Jeffrey Sarnoff wrote:
>
> As given above, the time is in sum_reldiffs, the space is in the 
> count_zeros.
>
> On Tuesday, October 25, 2016 at 4:42:02 AM UTC-4, Jeffrey Sarnoff wrote:
>>
>> (you may like that visual noise if the code finds more than 1 year's use)
>> Which matters more to you saving time or saving space?
>>
>> On Tuesday, October 25, 2016 at 4:39:33 AM UTC-4, Martin Florek wrote:
>>>
>>> Thnaks, It is true, but when I apply @benchmark v3 is 6 times slower as 
>>> v1, also has a large allocation and I do not want it. For me speed is 
>>> important and v3 is not without visual noise, too. Any more thoughts?
>>>
>>> ben1 = @benchmark mapeBase_v1(a,f)
>>> BenchmarkTools.Trial: 
>>>   samples:  848
>>>   evals/sample: 1
>>>   time tolerance:   5.00%
>>>   memory tolerance: 1.00%
>>>   memory estimate:  32.00 bytes
>>>   allocs estimate:  1
>>>   minimum time: 4.35 ms (0.00% GC)
>>>   median time:  5.87 ms (0.00% GC)
>>>   mean time:5.89 ms (0.00% GC)
>>>   maximum time: 7.57 ms (0.00% GC)
>>>
>>> ben2 = @benchmark mapeBase_v3(a,f)
>>> BenchmarkTools.Trial: 
>>>   samples:  145
>>>   evals/sample: 1
>>>   time tolerance:   5.00%
>>>   memory tolerance: 1.00%
>>>   memory estimate:  977.03 kb
>>>   allocs estimate:  14
>>>   minimum time: 32.69 ms (0.00% GC)
>>>   median time:  33.91 ms (0.00% GC)
>>>   mean time:34.55 ms (0.10% GC)
>>>   maximum time: 49.03 ms (3.25% GC)
>>>
>>>
>>>
>>>
>>> On Tuesday, 25 October 2016 09:43:20 UTC+2, Jeffrey Sarnoff wrote:

 This may do what you want.

 function mapeBase_v3(actuals::Vector{Float64}, forecasts::Vector{Float64})
 # actuals - actual target values
 # forecasts - forecasts (model estimations)

   sum_reldiffs = sumabs((x - y) / x for (x, y) in zip(actuals, forecasts) 
 if x != 0.0)  # Generator

   count_zeros = sum( map(x->(x==0.0), actuals) )
   count_nonzeros = length(actuals) - count_zeros
   sum_reldiffs, count_nonzeros
 end




 On Tuesday, October 25, 2016 at 3:15:54 AM UTC-4, Martin Florek wrote:
>
> Hi all,
> I'm new in Julia and I'm doing refactoring. I have the following 
> function:
>
> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>   s = 0.0
>   count = 0
>   for i in 1:length(A)
> if(A[i] != 0.0)
>   s += abs( (A[i] - F[i]) / A[i])
>   count += 1
> end
>   end
>
>   s, count 
>
> end   
>
> I'm looking for a simpler variant which is as follows:
>
> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
> # A - actual target values
> # F - forecasts (model estimations)
>
>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>
>   count = length(A) # ???
>   s, countend
>
>
> However with this variant can not determine the number of non-zero 
> elements. I found option with length(A[A .!= 0.0]), but it has a large 
> allocation. Please, someone knows a solution with generator, or variant 
> v1 is very good choice?
>
>
> Thanks in advance,
> Martin
>
>

[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Chris Stook
I just need a vector of the values.  The names are known from the circuit 
file.

The problem is really just with converting the string to a Float64 value 
when the file is Unicode from LTspiceXVII.  Everything works fine with the 
ASCII from LTspiceIV.  More specifically, the capturing block which returns 
the string representation of 2.5 returns "\x002\0.\x005\0", which parse 
cannot convert to a Float64.  I'm not asking for you to debug my module, 
but just to clarify, the error is thrown on line 53 of 
https://github.com/cstook/LTspice.jl/blob/LTspiceXVII_compat/src/ParseLogFile.jl


[julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Martin Florek
Thnaks, It is true, but when I apply @benchmark v3 is 6 times slower as v1, 
also has a large allocation and I do not want it. For me speed is important 
and v3 is not without visual noise, too. Any more thoughts?

ben1 = @benchmark mapeBase_v1(a,f)
BenchmarkTools.Trial: 
  samples:  848
  evals/sample: 1
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  32.00 bytes
  allocs estimate:  1
  minimum time: 4.35 ms (0.00% GC)
  median time:  5.87 ms (0.00% GC)
  mean time:5.89 ms (0.00% GC)
  maximum time: 7.57 ms (0.00% GC)

ben2 = @benchmark mapeBase_v3(a,f)
BenchmarkTools.Trial: 
  samples:  145
  evals/sample: 1
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  977.03 kb
  allocs estimate:  14
  minimum time: 32.69 ms (0.00% GC)
  median time:  33.91 ms (0.00% GC)
  mean time:34.55 ms (0.10% GC)
  maximum time: 49.03 ms (3.25% GC)




On Tuesday, 25 October 2016 09:43:20 UTC+2, Jeffrey Sarnoff wrote:
>
> This may do what you want.
>
> function mapeBase_v3(actuals::Vector{Float64}, forecasts::Vector{Float64})
> # actuals - actual target values
> # forecasts - forecasts (model estimations)
>
>   sum_reldiffs = sumabs((x - y) / x for (x, y) in zip(actuals, forecasts) if 
> x != 0.0)  # Generator
>
>   count_zeros = sum( map(x->(x==0.0), actuals) )
>   count_nonzeros = length(actuals) - count_zeros
>   sum_reldiffs, count_nonzeros
> end
>
>
>
>
> On Tuesday, October 25, 2016 at 3:15:54 AM UTC-4, Martin Florek wrote:
>>
>> Hi all,
>> I'm new in Julia and I'm doing refactoring. I have the following function:
>>
>> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>>   s = 0.0
>>   count = 0
>>   for i in 1:length(A)
>> if(A[i] != 0.0)
>>   s += abs( (A[i] - F[i]) / A[i])
>>   count += 1
>> end
>>   end
>>
>>   s, count 
>>
>> end   
>>
>> I'm looking for a simpler variant which is as follows:
>>
>> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
>> # A - actual target values
>> # F - forecasts (model estimations)
>>
>>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>>
>>   count = length(A) # ???
>>   s, countend
>>
>>
>> However with this variant can not determine the number of non-zero elements. 
>> I found option with length(A[A .!= 0.0]), but it has a large allocation. 
>> Please, someone knows a solution with generator, or variant v1 is very good 
>> choice?
>>
>>
>> Thanks in advance,
>> Martin
>>
>>

Re: [julia-users] Trait for exactness of numbers

2016-10-25 Thread Mauro
You can use SimpleTraits.jl for this:

using SimpleTraits

# Using Jeffrey's function, define good defaults:
function isexact{X}(::Type{X})
if X<:Integer || X<:Rational
true
elseif X<:Complex
isexact(real(X))
else
false
end
end

@traitdef IsExact{X}
@generated SimpleTraits.trait{X}(::Type{IsExact{X}}) =
isexact(X) ? :(IsExact{X}) : :(Not{IsExact{X}})

@traitfn f(xIsExact) = println("exact algo with $x")
@traitfn f(x(!IsExact)) = println("in-exact algo with $x")

f(5) # exact algo with 5
f(5.0)

# make a new type which is exact
type MyNumber end
isexact(::Type{MyNumber}) = true # note, the default is to be not exact
f(MyNumber())

Let me know if you got questions.

On Mon, 2016-10-24 at 20:09, jw3126  wrote:
> A couple of times I was in a situation, where I had two algorithms solving
> the same problem, one which was faster and one which was more numerically
> stable. Now for some types of numbers (FloatingPoint, Complex{Float64}...)
> numerical stability is important while for others it does not matter (e.g.
> Integer, Complex{Int64}...) etc.
> In such situations it would be handy to have a mechanism (a trait) which
> decides whether a type is exact or prone to rounding.
> Maybe there is already such a thing somewhere?


[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Jeffrey Sarnoff
I got this log file:
Circuit: * C:\Users\Jeff\Documents\LTspiceXVII\examples\test.asc

Direct Newton iteration for .op point succeeded.

current: i(r1)=2.5


Date: Tue Oct 25 03:55:44 2016
Total elapsed time: 0.134 seconds.

tnom = 27
temp = 27
method = modified trap
totiter = 2091
traniter = 2088
tranpoints = 1045
accept = 1045
rejected = 0
matrix size = 2
fillins = 0
solver = Normal
Matrix Compiler1: 36 bytes object code size  0.0/0.0/[0.0]
Matrix Compiler2: off  [0.0]/0.1/0.1


Are you trying to get a vector of all the rhs names and all the lhs values? 
It is easier to help if you tell me the goal (in detail).

On Tuesday, October 25, 2016 at 3:31:43 AM UTC-4, Chris Stook wrote:
>
> The circuit file is test1.asc (
> https://github.com/cstook/LTspice.jl/blob/master/test/test1.asc).  You 
> should be able to open it with LTspice and run the simulation to produce 
> the log file.
>
> The log file is a human readable text file, which I am parsing to get the 
> measurements.  LTspiceIV used ASCII for the log file and everything was 
> fine.  You can look at the documentation for my module LTspice.jl (
> http://www.chrisstook.com/LTspice.jl/) to see what I'm trying to do.
>


[julia-users] Re: Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Jeffrey Sarnoff
This may do what you want.

function mapeBase_v3(actuals::Vector{Float64}, forecasts::Vector{Float64})
# actuals - actual target values
# forecasts - forecasts (model estimations)

  sum_reldiffs = sumabs((x - y) / x for (x, y) in zip(actuals, forecasts) if x 
!= 0.0)  # Generator

  count_zeros = sum( map(x->(x==0.0), actuals) )
  count_nonzeros = length(actuals) - count_zeros
  sum_reldiffs, count_nonzeros
end




On Tuesday, October 25, 2016 at 3:15:54 AM UTC-4, Martin Florek wrote:
>
> Hi all,
> I'm new in Julia and I'm doing refactoring. I have the following function:
>
> function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
>   s = 0.0
>   count = 0
>   for i in 1:length(A)
> if(A[i] != 0.0)
>   s += abs( (A[i] - F[i]) / A[i])
>   count += 1
> end
>   end
>
>   s, count 
>
> end   
>
> I'm looking for a simpler variant which is as follows:
>
> function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
> # A - actual target values
> # F - forecasts (model estimations)
>
>   s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator
>
>   count = length(A) # ???
>   s, countend
>
>
> However with this variant can not determine the number of non-zero elements. 
> I found option with length(A[A .!= 0.0]), but it has a large allocation. 
> Please, someone knows a solution with generator, or variant v1 is very good 
> choice?
>
>
> Thanks in advance,
> Martin
>
>

[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Chris Stook
The circuit file is test1.asc (
https://github.com/cstook/LTspice.jl/blob/master/test/test1.asc).  You 
should be able to open it with LTspice and run the simulation to produce 
the log file.

The log file is a human readable text file, which I am parsing to get the 
measurements.  LTspiceIV used ASCII for the log file and everything was 
fine.  You can look at the documentation for my module LTspice.jl (
http://www.chrisstook.com/LTspice.jl/) to see what I'm trying to do.


[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Jeffrey Sarnoff
I downloaded that software, did you create that log file? If so, how?

It is likely that what is being stored in the log file is not a sequence of 
numbers in a vanilla format.  So parsing it as a sequence of strings is not 
going to work.

from their help:   

OK, that works for bitmaps, but can I get the data itself to an application 
> like Excel?
> There is an export utility(Waveform Menu: File=>Export) that allows data 
> to be exported to an ASCII file. There is also a 3rd party free utility 
> written by Helmut Sennewald. It is available from the independent users' 
> group http://groups.yahoo.com/group/LTspice. This utility allows various 
> forms of manipulation of the data including the ability to merge waveforms 
> from different simulation runs.



>
On Tuesday, October 25, 2016 at 3:08:23 AM UTC-4, Chris Stook wrote:
>
> The file (
> https://github.com/cstook/LTspice.jl/blob/LTspiceXVII_compat/test/test1.log) 
> is a .log file produced by LTspiceXVII (
> http://www.linear.com/designtools/software/).  I'm using regular 
> expressions to parse the file.  The code below shows the problem.
>
> io = open("test1.log","r")
> for line in readlines(io)
>   m = match(r".*",line)
>   print(line)
>   println(m)
> end
>
> Circuit: * C:\Users\Chris\.julia\v0.5\LTspice\test\test1.asc
> RegexMatch("C\0i\0r\0c\0u\0i\0t\0:\0 \0*\0 
> \0C\0:\0\\\0U\0s\0e\0r\0s\0\\\0C\0h\0r\0i\0s\0\\\0.\0j\0u\0l\0i\0a\0\\\0v\x000\0.\x005\0\\\0L\0T\0s\0p\0i\0c\0e\0\\\0t\0e\0s\0t\0\\\0t\0e\0s\0t\x001\0.\0a\0s\0c\0")
>
> RegexMatch("\0")
> Direct Newton iteration for .op point succeeded.
> RegexMatch("\0D\0i\0r\0e\0c\0t\0 \0N\0e\0w\0t\0o\0n\0 
> \0i\0t\0e\0r\0a\0t\0i\0o\0n\0 \0f\0o\0r\0 \0.\0o\0p\0 \0p\0o\0i\0n\0t\0 
> \0s\0u\0c\0c\0e\0e\0d\0e\0d\0.\0")
>
> RegexMatch("\0")
> current: i(r1)=2.5
> RegexMatch("\0c\0u\0r\0r\0e\0n\0t\0:\0 
> \0i\0(\0r\x001\0)\0=\x002\0.\x005\0")
>
> RegexMatch("\0")
>
> RegexMatch("\0")
> Date: Mon Oct 24 20:11:13 2016
> RegexMatch("\0D\0a\0t\0e\0:\0 \0M\0o\0n\0 \0O\0c\0t\0 \x002\x004\0 
> \x002\x000\0:\x001\x001\0:\x001\x003\0 \x002\x000\x001\x006\0")
> Total elapsed time: 0.024 seconds.
> RegexMatch("\0T\0o\0t\0a\0l\0 \0e\0l\0a\0p\0s\0e\0d\0 \0t\0i\0m\0e\0:\0 
> \x000\0.\x000\x002\x004\0 \0s\0e\0c\0o\0n\0d\0s\0.\0")
>
> RegexMatch("\0")
> tnom = 27
> RegexMatch("\0t\0n\0o\0m\0 \0=\0 \x002\x007\0")
> temp = 27
> RegexMatch("\0t\0e\0m\0p\0 \0=\0 \x002\x007\0")
> method = modified trap
> RegexMatch("\0m\0e\0t\0h\0o\0d\0 \0=\0 \0m\0o\0d\0i\0f\0i\0e\0d\0 
> \0t\0r\0a\0p\0")
> totiter = 2091
> RegexMatch("\0t\0o\0t\0i\0t\0e\0r\0 \0=\0 \x002\x000\09\x001\0")
> traniter = 2088
> RegexMatch("\0t\0r\0a\0n\0i\0t\0e\0r\0 \0=\0 \x002\x000\08\08\0")
> tranpoints = 1045
> RegexMatch("\0t\0r\0a\0n\0p\0o\0i\0n\0t\0s\0 \0=\0 \x001\x000\x004\x005\0")
> accept = 1045
> RegexMatch("\0a\0c\0c\0e\0p\0t\0 \0=\0 \x001\x000\x004\x005\0")
> rejected = 0
> RegexMatch("\0r\0e\0j\0e\0c\0t\0e\0d\0 \0=\0 \x000\0")
> matrix size = 2
> RegexMatch("\0m\0a\0t\0r\0i\0x\0 \0s\0i\0z\0e\0 \0=\0 \x002\0")
> fillins = 0
> RegexMatch("\0f\0i\0l\0l\0i\0n\0s\0 \0=\0 \x000\0")
> solver = Normal
> RegexMatch("\0s\0o\0l\0v\0e\0r\0 \0=\0 \0N\0o\0r\0m\0a\0l\0")
> Matrix Compiler1: off  [0.0]/0.0/0.0
> RegexMatch("\0M\0a\0t\0r\0i\0x\0 \0C\0o\0m\0p\0i\0l\0e\0r\x001\0:\0 
> \0o\0f\0f\0 \0 \0[\x000\0.\x000\0]\0/\x000\0.\x000\0/\x000\0.\x000\0")
> Matrix Compiler2: 96 bytes object code size  0.0/0.0/[0.0]
> RegexMatch("\0M\0a\0t\0r\0i\0x\0 \0C\0o\0m\0p\0i\0l\0e\0r\x002\0:\0 
> \09\x006\0 \0b\0y\0t\0e\0s\0 \0o\0b\0j\0e\0c\0t\0 \0c\0o\0d\0e\0 
> \0s\0i\0z\0e\0 \0 \x000\0.\x000\0/\x000\0.\x000\0/\0[\x000\0.\x000\0]\0")
>
> RegexMatch("\0")
>
> RegexMatch("\0")
> RegexMatch("\0")
>
>

[julia-users] Comprehension (generator) with statement IF and the number of true

2016-10-25 Thread Martin Florek
Hi all,
I'm new in Julia and I'm doing refactoring. I have the following function:

function mapeBase_v1(A::Vector{Float64}, F::Vector{Float64})
  s = 0.0
  count = 0
  for i in 1:length(A)
if(A[i] != 0.0)
  s += abs( (A[i] - F[i]) / A[i])
  count += 1
end
  end

  s, count 

end   

I'm looking for a simpler variant which is as follows:

function mapeBase_v2(A::Vector{Float64}, F::Vector{Float64})
# A - actual target values
# F - forecasts (model estimations)

  s = sumabs((x - y) / x for (x, y) in zip(A, F) if x != 0) # Generator

  count = length(A) # ???
  s, countend


However with this variant can not determine the number of non-zero elements. I 
found option with length(A[A .!= 0.0]), but it has a large allocation. Please, 
someone knows a solution with generator, or variant v1 is very good choice?


Thanks in advance,
Martin



[julia-users] Re: parse Unicode string to Float64

2016-10-25 Thread Chris Stook
The file (
https://github.com/cstook/LTspice.jl/blob/LTspiceXVII_compat/test/test1.log) 
is a .log file produced by LTspiceXVII (
http://www.linear.com/designtools/software/).  I'm using regular 
expressions to parse the file.  The code below shows the problem.

io = open("test1.log","r")
for line in readlines(io)
  m = match(r".*",line)
  print(line)
  println(m)
end

Circuit: * C:\Users\Chris\.julia\v0.5\LTspice\test\test1.asc
RegexMatch("C\0i\0r\0c\0u\0i\0t\0:\0 \0*\0 
\0C\0:\0\\\0U\0s\0e\0r\0s\0\\\0C\0h\0r\0i\0s\0\\\0.\0j\0u\0l\0i\0a\0\\\0v\x000\0.\x005\0\\\0L\0T\0s\0p\0i\0c\0e\0\\\0t\0e\0s\0t\0\\\0t\0e\0s\0t\x001\0.\0a\0s\0c\0")

RegexMatch("\0")
Direct Newton iteration for .op point succeeded.
RegexMatch("\0D\0i\0r\0e\0c\0t\0 \0N\0e\0w\0t\0o\0n\0 
\0i\0t\0e\0r\0a\0t\0i\0o\0n\0 \0f\0o\0r\0 \0.\0o\0p\0 \0p\0o\0i\0n\0t\0 
\0s\0u\0c\0c\0e\0e\0d\0e\0d\0.\0")

RegexMatch("\0")
current: i(r1)=2.5
RegexMatch("\0c\0u\0r\0r\0e\0n\0t\0:\0 \0i\0(\0r\x001\0)\0=\x002\0.\x005\0")

RegexMatch("\0")

RegexMatch("\0")
Date: Mon Oct 24 20:11:13 2016
RegexMatch("\0D\0a\0t\0e\0:\0 \0M\0o\0n\0 \0O\0c\0t\0 \x002\x004\0 
\x002\x000\0:\x001\x001\0:\x001\x003\0 \x002\x000\x001\x006\0")
Total elapsed time: 0.024 seconds.
RegexMatch("\0T\0o\0t\0a\0l\0 \0e\0l\0a\0p\0s\0e\0d\0 \0t\0i\0m\0e\0:\0 
\x000\0.\x000\x002\x004\0 \0s\0e\0c\0o\0n\0d\0s\0.\0")

RegexMatch("\0")
tnom = 27
RegexMatch("\0t\0n\0o\0m\0 \0=\0 \x002\x007\0")
temp = 27
RegexMatch("\0t\0e\0m\0p\0 \0=\0 \x002\x007\0")
method = modified trap
RegexMatch("\0m\0e\0t\0h\0o\0d\0 \0=\0 \0m\0o\0d\0i\0f\0i\0e\0d\0 
\0t\0r\0a\0p\0")
totiter = 2091
RegexMatch("\0t\0o\0t\0i\0t\0e\0r\0 \0=\0 \x002\x000\09\x001\0")
traniter = 2088
RegexMatch("\0t\0r\0a\0n\0i\0t\0e\0r\0 \0=\0 \x002\x000\08\08\0")
tranpoints = 1045
RegexMatch("\0t\0r\0a\0n\0p\0o\0i\0n\0t\0s\0 \0=\0 \x001\x000\x004\x005\0")
accept = 1045
RegexMatch("\0a\0c\0c\0e\0p\0t\0 \0=\0 \x001\x000\x004\x005\0")
rejected = 0
RegexMatch("\0r\0e\0j\0e\0c\0t\0e\0d\0 \0=\0 \x000\0")
matrix size = 2
RegexMatch("\0m\0a\0t\0r\0i\0x\0 \0s\0i\0z\0e\0 \0=\0 \x002\0")
fillins = 0
RegexMatch("\0f\0i\0l\0l\0i\0n\0s\0 \0=\0 \x000\0")
solver = Normal
RegexMatch("\0s\0o\0l\0v\0e\0r\0 \0=\0 \0N\0o\0r\0m\0a\0l\0")
Matrix Compiler1: off  [0.0]/0.0/0.0
RegexMatch("\0M\0a\0t\0r\0i\0x\0 \0C\0o\0m\0p\0i\0l\0e\0r\x001\0:\0 
\0o\0f\0f\0 \0 \0[\x000\0.\x000\0]\0/\x000\0.\x000\0/\x000\0.\x000\0")
Matrix Compiler2: 96 bytes object code size  0.0/0.0/[0.0]
RegexMatch("\0M\0a\0t\0r\0i\0x\0 \0C\0o\0m\0p\0i\0l\0e\0r\x002\0:\0 
\09\x006\0 \0b\0y\0t\0e\0s\0 \0o\0b\0j\0e\0c\0t\0 \0c\0o\0d\0e\0 
\0s\0i\0z\0e\0 \0 \x000\0.\x000\0/\x000\0.\x000\0/\0[\x000\0.\x000\0]\0")

RegexMatch("\0")

RegexMatch("\0")
RegexMatch("\0")