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

2016-10-24 Thread Jeffrey Sarnoff
This is rather odd, your character codes are control codes (0x02 STX, start 
of text; 0x05 ENQ, enquiry) and really do not belong in a numeric string.
Do all the entries use that pattern "\x002\anumber.\x005\bnumber"?  If so, 
and the intended number is anumber.bnumber, there would be a way.
What is the file extension on the input file, and do you know what program 
generated it?

On Tuesday, October 25, 2016 at 12:44:34 AM UTC-4, 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
>
>

[julia-users] parse Unicode string to Float64

2016-10-24 Thread Chris Stook
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



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

2016-10-24 Thread Corbin Foucart
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: pyjulia initialization error

2016-10-24 Thread Corbin Foucart
I am posting the solution to the problem in case anyone else has this 
issue. It is important to set the PYTHON variable in Julia to the binary 
used in the python virtual environment. For example, once the virtual 
environment is activated,

% (venv) which python
>  /path/to/venv/binary

then in the Julia console:

% ENV["PYTHON"] = "/path/to/venv/binary"

my error in particular was including "~" in the path out of habit, which 
expands in bash, but obviously not in Julia. "import _locale" worked in the 
Python terminal because it was launched with the correct binary. 


On Monday, October 24, 2016 at 5:38:04 PM UTC-4, Corbin Foucart wrote:
>
> I would like to use pyjulia, but I am having some issue setting it up in 
> my python virtual environment. I have followed the instructions here: 
> https://github.com/JuliaPy/pyjulia
>
> I am running the following script:
>
>  import julia
>  j = 
> julia.Julia(jl_runtime_path='/share/apps/julia/julia-3c9d75391c/bin/julia', 
> debug=True) 
>
> The output:
>
> % python juliaSetup.py 
> >JULIA_HOME = /share/apps/julia/julia-3c9d75391c/bin,  libjulia_path = 
> /share/apps/julia/julia-3c9d75391c/bin/../lib/libjulia.so.0.5
> >calling jl_init(/share/apps/julia/julia-3c9d75391c/bin)
> >seems to work...
> >exception occured? None
> >WARNING: redefining constant JULIA_HOME
> >exception occured? None
> >exception occured? None
> >exception occured? None
> >Traceback (most recent call last):
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 552, in 
> main()
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 530, in main
> known_paths = addusersitepackages(known_paths)
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 266, in addusersitepackages
> user_site = getusersitepackages()
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 241, in getusersitepackages
> user_base = getuserbase() # this will also set USER_BASE
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
> line 231, in getuserbase
> USER_BASE = get_config_var('userbase')
>  > File 
> "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
> line 520, in get_config_var
> return get_config_vars().get(name)
>  > File 
> "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
> line 453, in get_config_vars
> import re
>  > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/re.py", 
> line 108, in 
> import _locale
> > SystemError: dynamic module not initialized properly
>
> Pursuant to the error stack, I launched a python terminal and tried 
> "import _locale" with no issue. Does anyone know what is going on?
>
>

Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Angel de Vicente
Hi,

Tim Holy  writes:
> That document is aimed at developers to tell them how to make their package
> ready for arrays that have custom indices. As a user, the key line is:
>
>> Such array types are expected to be supplied through packages.
>
> I recommend the OffsetArrays package.
>
> Great to see someone interested in trying this. Definitely report any bugs you
> find; as Isaiah said, this is still experimental functionality, and many
> packages probably aren't fully ready yet. It will mostly take users who want
> that functionality to notice where it needs to be added.

OK, great, I just tried the example of my first mail, and things seem to
work OK. For my use case, obviously not as convenient as the native
support of Fortran, but great that it works. If I find things that don't
work I will let you know. For the moment, from my brief testing, the
only thing I found is that something like mg[:,:] = 0 raises an error,
as you can see below (due to its dependence on "size").

Thanks a lot (Julia looks like a great language with a great
community! :-) )

,
| julia> m=rand(1:10,(3,3))
| 3×3 Array{Int64,2}:
|  4   1  3
|  4  10  9
|  8   6  6
| 
| julia> mg=OffsetArray(Int,0:4,0:4)
| OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}} with indices 0:4×0:4:
|  140473481981296  140473483139344  140473481980240  140473481980528  
140473481980752
|  140473481981392  140473483138224  140473481980304  140473481980592  
140473481980784
|  140473481981456  140473481979952  140473481980432  140473481980624  
140473481980816
|  140473481981520  140473481979984  140473481980464  140473481980656  
140473481980848
|  140473481981648  140473481980208  140473481980496  140473481980720  
140473481980880
| 
| julia> mg[:,:]=0
| ERROR: size not supported for arrays with indices (0:4,0:4); see 
http://docs.julialang.org/en/latest/devdocs/offset-arrays/
|  in errmsg(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}) at 
/home/angelv/.julia/v0.5/OffsetArrays/src/OffsetArrays.jl:47
|  in trailingsize(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, ::Int64) 
at ./abstractarray.jl:201
|  in macro expansion at ./multidimensional.jl:424 [inlined]
|  in 
_unsafe_batchsetindex!(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, 
::Base.Repeated{Int64}, ::Colon, ::Colon) at ./multidimensional.jl:421
|  in setindex!(::OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}}, ::Int64, 
::Colon, ::Colon) at ./abstractarray.jl:832
| 
| julia> mg[indices(mg,1),indices(mg,2)]=0
| 0
| 
| julia> mg[1:3,1:3]=m
| 3×3 Array{Int64,2}:
|  4   1  3
|  4  10  9
|  8   6  6
| 
| julia> mg
| OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}} with indices 0:4×0:4:
|  0  0   0  0  0
|  0  4   1  3  0
|  0  4  10  9  0
|  0  8   6  6  0
|  0  0   0  0  0
`

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


[julia-users] Re: ERROR: UndefVarError: PkgDev not defined

2016-10-24 Thread J Luis
Ok, sorry. Found it. Needed to 

 using PkgDev

but not that obvious since for using Pkg one do not need to 'using' it.

segunda-feira, 24 de Outubro de 2016 às 22:57:06 UTC+1, J Luis escreveu:
>
> Hi,
>
> I'm trying to tag a new version of a package for the first time (initial 
> tag was done with 0.4) but
>
> Pkg.update()
> ...
> WARNING: julia is fixed at 0.5.0-rc4+0 conflicting with requirement for 
> GLFW: [0.5.0,∞)
> INFO: Upgrading ArgParse: v0.3.1 => v0.4.0
> INFO: Upgrading Compat: v0.9.2 => v0.9.3
> INFO: Upgrading PkgDev: v0.1.2 => v0.1.3
>
> julia> PkgDev.tag(:patch)
> ERROR: UndefVarError: PkgDev not defined
>
> julia> PkgDev.tag("GMT",:patch)
> ERROR: UndefVarError: PkgDev not defined
>
> julia> PkgDev.tag("GMT",v"0.0.2")
> ERROR: UndefVarError: PkgDev not defined
>
> What's wrong here?
>
>

Re: [julia-users] ERROR: UndefVarError: PkgDev not defined

2016-10-24 Thread Yichao Yu
On Mon, Oct 24, 2016 at 5:57 PM, J Luis  wrote:
> Hi,
>
> I'm trying to tag a new version of a package for the first time (initial tag
> was done with 0.4) but
>
> Pkg.update()
> ...
> WARNING: julia is fixed at 0.5.0-rc4+0 conflicting with requirement for
> GLFW: [0.5.0,∞)
> INFO: Upgrading ArgParse: v0.3.1 => v0.4.0
> INFO: Upgrading Compat: v0.9.2 => v0.9.3
> INFO: Upgrading PkgDev: v0.1.2 => v0.1.3
>
> julia> PkgDev.tag(:patch)
> ERROR: UndefVarError: PkgDev not defined
>
> julia> PkgDev.tag("GMT",:patch)
> ERROR: UndefVarError: PkgDev not defined
>
> julia> PkgDev.tag("GMT",v"0.0.2")
> ERROR: UndefVarError: PkgDev not defined
>
> What's wrong here?

PkgDev is a normal package and you need to install and import it
before using it.

>


[julia-users] ERROR: UndefVarError: PkgDev not defined

2016-10-24 Thread J Luis
Hi,

I'm trying to tag a new version of a package for the first time (initial 
tag was done with 0.4) but

Pkg.update()
...
WARNING: julia is fixed at 0.5.0-rc4+0 conflicting with requirement for GLFW
: [0.5.0,∞)
INFO: Upgrading ArgParse: v0.3.1 => v0.4.0
INFO: Upgrading Compat: v0.9.2 => v0.9.3
INFO: Upgrading PkgDev: v0.1.2 => v0.1.3

julia> PkgDev.tag(:patch)
ERROR: UndefVarError: PkgDev not defined

julia> PkgDev.tag("GMT",:patch)
ERROR: UndefVarError: PkgDev not defined

julia> PkgDev.tag("GMT",v"0.0.2")
ERROR: UndefVarError: PkgDev not defined

What's wrong here?



[julia-users] Re: Julia and the Tower of Babel

2016-10-24 Thread Jeffrey Sarnoff
Actually, all is good.  The current docs do not take a stand on the use of 
case following an acronym.  


On Monday, October 24, 2016 at 1:38:39 PM UTC-4, Jeffrey Sarnoff wrote:
>
> update on package names that begin with an acronym .. following much 
> discussion, the rule which a strong preponderance of participants favor:
>the acronym is to be uppercased and the following words camelcased, no 
> separator.
>so: CSSscripts, HTMLlinks, XMLparser.
>
> This does not match the current docs:
>  the acronym is to be uppercased and the second word is to be 
> capitalized, no separator.  
>  so: CSSScripts, HTMLLinks, XMLParser  
>
> The reasoning I found most persuasive is that the current docs' rule
> undermines Julia's developing reputation for expressive clarity. 
>
> On Friday, October 14, 2016 at 3:15:44 PM UTC-4, Jeffrey Sarnoff wrote:
>>
>> Just clarifying: For a two part package name that begins with an acronym 
>> and ends in a word   
>>   
>> the present guidance:   
>>  the acronym is to be uppercased and the second word is to be 
>> capitalized, no separator.  
>>  so: CSSScripts, HTMLLinks  
>>
>> the desired guidance (from 24hrs of feedback):   
>>  the acronym is to be titlecased and the second word is to be 
>> capitalized, no separator.   
>>  so: CssScripts, HtmlLinks
>>
>> What is behind the present guidance?
>>
>>
>> On Saturday, October 8, 2016 at 8:42:05 AM UTC-4, Jeffrey Sarnoff wrote:
>>>
>>> I have created a new Organization on github: *JuliaPraxis.*
>>> Everyone who has added to this thread will get an invitation to join, 
>>> and so contribute.
>>> I will set up the site and let you know how do include your wor(l)d 
>>> views.
>>>
>>> Anyone else is welcome to post to this thread, and I will send an 
>>> invitation.
>>>
>>>
>>>
>>> On Saturday, October 8, 2016 at 6:59:51 AM UTC-4, Chris Rackauckas wrote:

 Conventions would have to be arrived at before this is possible.

 On Saturday, October 8, 2016 at 3:39:55 AM UTC-7, Traktor Toni wrote:
>
> In my opinion the solutions to this are very clear, or would be:
>
> 1. make a mandatory linter for all julia code
> 2. julia IDEs should offer good intellisense
>
> Am Freitag, 7. Oktober 2016 17:35:46 UTC+2 schrieb Gabriel Gellner:
>>
>> Something that I have been noticing, as I convert more of my research 
>> code over to Julia, is how the super easy to use package manager (which 
>> I 
>> love), coupled with the talent base of the Julia community seems to have 
>> a 
>> detrimental effect on the API consistency of the many “micro” packages 
>> that 
>> cover what I would consider the de-facto standard library.
>>
>> What I mean is that whereas a commercial package like 
>> Matlab/Mathematica etc., being written under one large umbrella, will 
>> largely (clearly not always) choose consistent names for similar API 
>> keyword arguments, and have similar calling conventions for master 
>> function 
>> like tools (`optimize` versus `lbfgs`, etc), which I am starting to 
>> realize 
>> is one of the great selling points of these packages as an end user. I 
>> can 
>> usually guess what a keyword will be in Mathematica, whereas even after 
>> a 
>> year of using Julia almost exclusively I find I have to look at the 
>> documentation (or the source code depending on the documentation ...) to 
>> figure out the keyword names in many common packages.
>>
>> Similarly, in my experience with open source tools, due to the 
>> complexity of the package management, we get large “batteries included” 
>> distributions that cover a lot of the standard stuff for doing science, 
>> like python’s numpy + scipy combination. Whereas in Julia the equivalent 
>> of 
>> scipy is split over many, separately developed packages (Base, Optim.jl, 
>> NLopt.jl, Roots.jl, NLsolve.jl, ODE.jl/DifferentialEquations.jl). Many 
>> of 
>> these packages are stupid awesome, but they can have dramatically 
>> different 
>> naming conventions and calling behavior, for essential equivalent 
>> behavior. 
>> Recently I noticed that tolerances, for example, are named as 
>> `atol/rtol` 
>> versus `abstol/reltol` versus `abs_tol/rel_tol`, which means is 
>> extremely 
>> easy to have a piece of scientific code that will need to use all three 
>> conventions across different calls to seemingly similar libraries. 
>>
>> Having brought this up I find that the community is largely 
>> sympathetic and, in general, would support a common convention, the 
>> issue I 
>> have slowly realized is that it is rarely that straightforward. In the 
>> above example the abstol/reltol versus abs_tol/rel_tol seems like an 
>> easy 
>> example of what can be tidied up, but the latter underscored name is 
>> consistent 

[julia-users] pyjulia initialization error

2016-10-24 Thread Corbin Foucart
I would like to use pyjulia, but I am having some issue setting it up in my 
python virtual environment. I have followed the instructions here: 
https://github.com/JuliaPy/pyjulia

I am running the following script:

 import julia
 j = 
julia.Julia(jl_runtime_path='/share/apps/julia/julia-3c9d75391c/bin/julia', 
debug=True) 

The output:

% python juliaSetup.py 
>JULIA_HOME = /share/apps/julia/julia-3c9d75391c/bin,  libjulia_path = 
/share/apps/julia/julia-3c9d75391c/bin/../lib/libjulia.so.0.5
>calling jl_init(/share/apps/julia/julia-3c9d75391c/bin)
>seems to work...
>exception occured? None
>WARNING: redefining constant JULIA_HOME
>exception occured? None
>exception occured? None
>exception occured? None
>Traceback (most recent call last):
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
line 552, in 
main()
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
line 530, in main
known_paths = addusersitepackages(known_paths)
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
line 266, in addusersitepackages
user_site = getusersitepackages()
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/site.py", 
line 231, in getuserbase
USER_BASE = get_config_var('userbase')
 > File 
"/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
line 520, in get_config_var
return get_config_vars().get(name)
 > File 
"/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/sysconfig.py", 
line 453, in get_config_vars
import re
 > File "/home/foucartc/.julia/v0.5/Conda/deps/usr/lib/python2.7/re.py", 
line 108, in 
import _locale
> SystemError: dynamic module not initialized properly

Pursuant to the error stack, I launched a python terminal and tried "import 
_locale" with no issue. Does anyone know what is going on?



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

2016-10-24 Thread Tim Holy
+1. We need number traits for a variety of circumstances; I was also
contemplating them as a step in generalizing the FloatRange/StepRange
distinction, for example to Unitful numbers (numbers with physical units).
You need type-stability for the created range object, so I think a trait is
the only way to go here.

--Tim

On Mon, Oct 24, 2016 at 3:30 PM, Jeffrey Sarnoff 
wrote:

> for values, something like this may do:
>
> function isexact(x)
> if isa(x, Integer) || isa(x, Rational)
> true
> elseif isa(x, Complex)
> isExact(x.re)
> else
> false
> end
>  end
>
>
>
>
> On Monday, October 24, 2016 at 2:09:09 PM UTC-4, 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?
>>
>


Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Tim Holy
That document is aimed at developers to tell them how to make their package
ready for arrays that have custom indices. As a user, the key line is:

> Such array types are expected to be supplied through packages.

I recommend the OffsetArrays package.

Great to see someone interested in trying this. Definitely report any bugs
you find; as Isaiah said, this is still experimental functionality, and
many packages probably aren't fully ready yet. It will mostly take users
who want that functionality to notice where it needs to be added.

Best,
--Tim

On Mon, Oct 24, 2016 at 1:34 PM, Angel de Vicente <
angel.vicente.garr...@gmail.com> wrote:

> Hi,
>
> Isaiah Norton  writes:
> > mg = zeros(Int,(0:4,0:4))
> >
> > This isn't related to indexing -- it doesn't work with `1:4`
> > either.
>
> But it doesn't complain if I do:
> ,
> | julia> mg=zeros(Int,(0:4))
> | 5-element Array{Int64,1}:
> |  0
> |  0
> |  0
> |  0
> |  0
> `
>
> (though then I cannot access mg[0], the indices would go as for a
> standard Julia array, 1 to 5.
>
>
> > Use:
> > zeros(Int, 4, 4)
>
> Probably I'm missing something very basic, but then I would just have a
> normal array, where the indices would go from 1:4, in each dimension.
>
> In the page on "Arrays with custom indices" I don't see any clear
> example, so I'm a bit lost as to how I could create an array wih
> non-standard inidces and how to use it. Any basic example would be
> greatly appreciated.
>
> Thanks and sorry if I'm asking very basic questions, I just had a week
> or so of exposure to Julia...
> --
> Ángel de Vicente
> http://www.iac.es/galeria/angelv/
>


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

2016-10-24 Thread Jeffrey Sarnoff
for values, something like this may do:

function isexact(x)
if isa(x, Integer) || isa(x, Rational)
true
elseif isa(x, Complex)
isExact(x.re)
else
false
end
 end




On Monday, October 24, 2016 at 2:09:09 PM UTC-4, 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] How do I use Guide.yticks() with a log scale?

2016-10-24 Thread Dean Schulze

When I plot the DataFrame below using Scale.y_log10 the y-axis has ticks 
for half powers of 10 (e.g. 10^5.5).  The plot is correct, but it's weird 
seeing half powers of 10 on a log plot.

If I add Guide.yticks(ticks=ymarks) with the following values

ymarks=[10^4,10^5,10^6,10^7]


I get a plot with the y-axis running up to 10^1000.

How can I get rid of the half powers of 10 on the y-axis ticks?



9×2 DataFrames.DataFrame
│ Row │ x │ y   │
├─┼───┼─┤
│ 1   │ 5000  │ 35950   │
│ 2   │ 1 │ 71961   │
│ 3   │ 15000 │ 108145  │
│ 4   │ 2 │ 154528  │
│ 5   │ 24000 │ 395218  │
│ 6   │ 28000 │ 689465  │
│ 7   │ 32000 │ 2646407 │
│ 8   │ 36000 │ 3138533 │
│ 9   │ 4 │ 8648694 │


ymarks=[10^4,10^5,10^6,10^7]
plot(df, x="x",y="y",Scale.y_log10, Guide.yticks(ticks=ymarks) )




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

2016-10-24 Thread Jeffrey Sarnoff
and just run julia from the terminal, not cygwin

On Monday, October 24, 2016 at 4:08:26 PM UTC-4, Jeffrey Sarnoff wrote:
>
> It is not clear to me what the difference is in your install and what I 
> did.  I can do r=ArbField(64); r(1) .. there is a warning the first time, 
> but it works.
>
> If you want, go back to the new installation and do
> > Pkg.build("Nemo")
> then (a) show us what it says [everything]
> and then  try
> > r=ArbField(64)
> > r(1)
> and show us what it says [everything]
>
>
> On Monday, October 24, 2016 at 3:22:47 PM UTC-4, digxx wrote:
>>
>> Maybe to point out: the installation in the part where I tried to do it 
>> directly via the repl command window was in a completely new .julia path 
>> (to try it fresh from the beginning) with no influence of already existing 
>> stuff...
>>
>

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

2016-10-24 Thread Jeffrey Sarnoff
It is not clear to me what the difference is in your install and what I 
did.  I can do r=ArbField(64); r(1) .. there is a warning the first time, 
but it works.

If you want, go back to the new installation and do
> Pkg.build("Nemo")
then (a) show us what it says [everything]
and then  try
> r=ArbField(64)
> r(1)
and show us what it says [everything]


On Monday, October 24, 2016 at 3:22:47 PM UTC-4, digxx wrote:
>
> Maybe to point out: the installation in the part where I tried to do it 
> directly via the repl command window was in a completely new .julia path 
> (to try it fresh from the beginning) with no influence of already existing 
> stuff...
>


[julia-users] Re: request many processes (addprocs()) simultaneously such that each can be used when obtained?

2016-10-24 Thread Ryan Gardner
Alright, well I hacked up a copy of ClusterManagers such that I added an 
obtain_procs() function that actually gets the available process and 
generates and stores the relevant WorkerConfigs with the ClusterManager. 
 This function does not require any locks to be obtained.

Then addprocs() (specifically the new ClusterManagers.launch function) just 
adds the generated WorkerConfigs to the instances_arr.  The locking around 
addprocs doesn't cause any problems now since the function is very fast.

If anyone sees any problems with this, please let me know.  Or, if you know 
exactly why the lock must be grabbed with addprocs, let me know.  I'm 
hoping it's really just a lock on the instances_arr as far as launch is 
concerned.  I couldn't see anything else in the old ClusterManagers.launch 
that might have concurrent access problems although I didn't dive into 
WorkerConfig().  If that needs a lock, I'll have to create one, but that 
seems odd to me.

In any case, a design change seems necessary here.  I think either addprocs 
needs to be changed so that locks are only taken at short critical times - 
this would probably require cluster managers to implement their code with 
proper locking of resources.  Alternatively, a two function architecture 
could start to be used, like I implemented, where addprocs is always fast.

Thanks.


Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Mauro
I think you have to make your own type.  You can't just request that
ordinary arrays use different indexing.

On Mon, 2016-10-24 at 20:34, Angel de Vicente  
wrote:
> Hi,
>
> Isaiah Norton  writes:
>> mg = zeros(Int,(0:4,0:4))
>>
>> This isn't related to indexing -- it doesn't work with `1:4`
>> either.
>
> But it doesn't complain if I do:
> ,
> | julia> mg=zeros(Int,(0:4))
> | 5-element Array{Int64,1}:
> |  0
> |  0
> |  0
> |  0
> |  0
> `
>
> (though then I cannot access mg[0], the indices would go as for a
> standard Julia array, 1 to 5.
>
>
>> Use:
>> zeros(Int, 4, 4)
>
> Probably I'm missing something very basic, but then I would just have a
> normal array, where the indices would go from 1:4, in each dimension.
>
> In the page on "Arrays with custom indices" I don't see any clear
> example, so I'm a bit lost as to how I could create an array wih
> non-standard inidces and how to use it. Any basic example would be
> greatly appreciated.
>
> Thanks and sorry if I'm asking very basic questions, I just had a week
> or so of exposure to Julia...


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

2016-10-24 Thread digxx
Maybe to point out: the installation in the part where I tried to do it 
directly via the repl command window was in a completely new .julia path 
(to try it fresh from the beginning) with no influence of already existing 
stuff...


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

2016-10-24 Thread digxx
Sorry again. But it is 64bit windows version just started in cygwin. I 
didn't think it makes any difference though
However the behaviour seems different:
When I start the Julia Repl command window directly I dont even get that 
far that Nemo is eventually installed: Following the steps prodived by 
Jeffrey Sarnoff I get when building:
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 C:\Users\Diger\.julia\v0.5\Nemo\deps\build.jl, in expression 
starting on line 1
===[
 
ERROR: Nemo 
]===

LoadError: chdir C:\Users\Diger\.julia\v0.5\Nemo\deps\antic: no such file 
or directory (ENOENT)
while loading C:\Users\Diger\.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 C:\Users\Diger\.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

=


Starting Julia within cygwin however goes through all the steps described 
by J. Sarnoff...(the warnings and so on...)
This was nevertheless ever an issue: I did get it installed that way 
before...
It is just within Nemo (which seems to start properly) where I still cannot 
run the command
r=ArbField(64)
r(1)
or likewise for an AcbField...
julia> r(1)
ERROR: error compiling ArbField: error compiling Type: could not load 
library "libarb"
▒



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

2016-10-24 Thread Jeffrey Sarnoff
Here are the usual Windows versions for 32-bit Windows 

 and for 64-bit Windows 


On Monday, October 24, 2016 at 2:23:24 PM UTC-4, Bill Hart wrote:
>
> We don't support Cygwin. The Nemo binaries are native Windows binaries.
>
> I was unaware there was a Cygwin version of Julia.
>
> Bill.
>
> On 24 October 2016 at 19:48, Jeffrey Sarnoff  > wrote:
>
>> I tried this on windows, it worked:
>> delete the directory Nemo (found with Pkg.dir() subdir Nemo))
>> delete the corresponding directory METADATA/Nemo (Pkg.dir("METADATA") 
>> subdir Nemo)
>> and if they exist, .cache/Nemo, METADATA/.cache/Nemo
>> restart Julia, do Pkg.update()
>> > Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
>> when its done, quit and restart Julia
>> > Pkg.build("Nemo")
>> when its done, restart Julia
>> > using Nemo
>> # a bunch of warnings, then Welcome to Nemo ...
>> restart Julia
>> > using  Nemo 
>> Welcome to Nemo ... (without the warnings)
>>
>>
>> On Monday, October 24, 2016 at 1:24:30 PM UTC-4, digxx wrote:
>>>
>>> Hey,
>>> Thx for ur reply. I tried both deleting all the files and run Pkg.build 
>>> again...
>>> It however did not work as are all the files present too :-(
>>> Julia in cygwin is correct...
>>>
>>
>

Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Angel de Vicente
Hi,

Isaiah Norton  writes:
> mg = zeros(Int,(0:4,0:4))
>
> This isn't related to indexing -- it doesn't work with `1:4`
> either. 

But it doesn't complain if I do:
,
| julia> mg=zeros(Int,(0:4))
| 5-element Array{Int64,1}:
|  0
|  0
|  0
|  0
|  0
`

(though then I cannot access mg[0], the indices would go as for a
standard Julia array, 1 to 5.


> Use:
> zeros(Int, 4, 4)

Probably I'm missing something very basic, but then I would just have a
normal array, where the indices would go from 1:4, in each dimension. 

In the page on "Arrays with custom indices" I don't see any clear
example, so I'm a bit lost as to how I could create an array wih
non-standard inidces and how to use it. Any basic example would be
greatly appreciated.

Thanks and sorry if I'm asking very basic questions, I just had a week
or so of exposure to Julia...
-- 
Ángel de Vicente
http://www.iac.es/galeria/angelv/  


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

2016-10-24 Thread 'Bill Hart' via julia-users
We don't support Cygwin. The Nemo binaries are native Windows binaries.

I was unaware there was a Cygwin version of Julia.

Bill.

On 24 October 2016 at 19:48, Jeffrey Sarnoff 
wrote:

> I tried this on windows, it worked:
> delete the directory Nemo (found with Pkg.dir() subdir Nemo))
> delete the corresponding directory METADATA/Nemo (Pkg.dir("METADATA")
> subdir Nemo)
> and if they exist, .cache/Nemo, METADATA/.cache/Nemo
> restart Julia, do Pkg.update()
> > Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
> when its done, quit and restart Julia
> > Pkg.build("Nemo")
> when its done, restart Julia
> > using Nemo
> # a bunch of warnings, then Welcome to Nemo ...
> restart Julia
> > using  Nemo
> Welcome to Nemo ... (without the warnings)
>
>
> On Monday, October 24, 2016 at 1:24:30 PM UTC-4, digxx wrote:
>>
>> Hey,
>> Thx for ur reply. I tried both deleting all the files and run Pkg.build
>> again...
>> It however did not work as are all the files present too :-(
>> Julia in cygwin is correct...
>>
>


[julia-users] Trait for exactness of numbers

2016-10-24 Thread jw3126
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: request many processes (addprocs()) simultaneously such that each can be used when obtained?

2016-10-24 Thread Ryan Gardner
For reference, here is the 0.4.3 code for addprocs()


# The main function for adding worker processes.   
 
# `manager` is of type ClusterManager. The respective managers are 
responsible  
# for launching the workers. All keyword arguments (plus a few default 
values)  
# are available as a dictionary to the `launch` methods 

#   

# Only one addprocs can be in progress at any time 
 
#   

const worker_lock = ReentrantLock()
function addprocs(manager::ClusterManager; kwargs...)
lock(worker_lock)
try
addprocs_locked(manager::ClusterManager; kwargs...)
finally
unlock(worker_lock)
end
end



guess that confirms what's going on... hah.




On Monday, October 24, 2016 at 1:40:22 PM UTC-4, Ryan Gardner wrote:
>
> I'm trying to write code for sun grid engine (sge) although I think the 
> general idea applies to any addprocs.  I would like to be able to request a 
> gazillion nodes, and start using each shortly after it becomes available.
>
> An example of what I want is roughly this code:
>
>for j=1:100
>   @async begin
>  new_worker = addprocs_sge(1); #request to add one sun grid engine 
> process
>  worker_init(new_worker) #brings new worker into the work
>end
>end
>
> The problem with this code is that addprocs (and thus addprocs_sge) seems 
> to be something like one big critical section, so the @async is effectively 
> non-existent, and the procs get added serially.  The big problem with this 
> is that it might take a day before I get even the first worker (when 
> addprocs_sge returns).  With this code, I would wait that day and only then 
> would I start the request for the second worker, which might take 
> approximately another day, and so on.  I want to get all my requests in the 
> queue, right from the start, so once I get the first worker, I'm also next 
> in line for the second, third, ...
>
>
>
> The alternative code below effectively gets the request for all workers in 
> the queue right from the start
>
>new_workers = addprocs(100)  #request to add 1,000,000 sun grid 
> engine processes
>worker_init(new_workers)
>
> but the problem with it is that I don't get any work done until all 
> 1,000,000 processes become available because the call to addprocs doesn't 
> return until it has everything (even though nodes on sge start to become 
> owned and blocked by me while it's trying to collect the whole million).
>
> Is there a way around this?  (I'm using Julia 0.4.3.  I would love to 
> upgrade, but I use a large amount of code that I don't control and isn't 
> going to be updated any time soon.  At the same time, I'd be interested in 
> solutions related to other versions regardless.)  Thanks.
>
> Ryan
>
>

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

2016-10-24 Thread Jeffrey Sarnoff
I tried this on windows, it worked:
delete the directory Nemo (found with Pkg.dir() subdir Nemo))
delete the corresponding directory METADATA/Nemo (Pkg.dir("METADATA") 
subdir Nemo)
and if they exist, .cache/Nemo, METADATA/.cache/Nemo
restart Julia, do Pkg.update()
> Pkg.clone("https://github.com/Nemocas/Nemo.jl;)
when its done, quit and restart Julia
> Pkg.build("Nemo")
when its done, restart Julia
> using Nemo
# a bunch of warnings, then Welcome to Nemo ...
restart Julia
> using  Nemo 
Welcome to Nemo ... (without the warnings)


On Monday, October 24, 2016 at 1:24:30 PM UTC-4, digxx wrote:
>
> Hey,
> Thx for ur reply. I tried both deleting all the files and run Pkg.build 
> again...
> It however did not work as are all the files present too :-(
> Julia in cygwin is correct...
>


[julia-users] Re: Julia and the Tower of Babel

2016-10-24 Thread Jeffrey Sarnoff
update on package names that begin with an acronym .. following much 
discussion, the rule which a strong preponderance of participants favor:
   the acronym is to be uppercased and the following words camelcased, no 
separator.
   so: CSSscripts, HTMLlinks, XMLparser.

This does not match the current docs:
 the acronym is to be uppercased and the second word is to be 
capitalized, no separator.  
 so: CSSScripts, HTMLLinks, XMLParser  

The reasoning I found most persuasive is that the current docs' rule
undermines Julia's developing reputation for expressive clarity. 

On Friday, October 14, 2016 at 3:15:44 PM UTC-4, Jeffrey Sarnoff wrote:
>
> Just clarifying: For a two part package name that begins with an acronym 
> and ends in a word   
>   
> the present guidance:   
>  the acronym is to be uppercased and the second word is to be 
> capitalized, no separator.  
>  so: CSSScripts, HTMLLinks  
>
> the desired guidance (from 24hrs of feedback):   
>  the acronym is to be titlecased and the second word is to be 
> capitalized, no separator.   
>  so: CssScripts, HtmlLinks
>
> What is behind the present guidance?
>
>
> On Saturday, October 8, 2016 at 8:42:05 AM UTC-4, Jeffrey Sarnoff wrote:
>>
>> I have created a new Organization on github: *JuliaPraxis.*
>> Everyone who has added to this thread will get an invitation to join, and 
>> so contribute.
>> I will set up the site and let you know how do include your wor(l)d views.
>>
>> Anyone else is welcome to post to this thread, and I will send an 
>> invitation.
>>
>>
>>
>> On Saturday, October 8, 2016 at 6:59:51 AM UTC-4, Chris Rackauckas wrote:
>>>
>>> Conventions would have to be arrived at before this is possible.
>>>
>>> On Saturday, October 8, 2016 at 3:39:55 AM UTC-7, Traktor Toni wrote:

 In my opinion the solutions to this are very clear, or would be:

 1. make a mandatory linter for all julia code
 2. julia IDEs should offer good intellisense

 Am Freitag, 7. Oktober 2016 17:35:46 UTC+2 schrieb Gabriel Gellner:
>
> Something that I have been noticing, as I convert more of my research 
> code over to Julia, is how the super easy to use package manager (which I 
> love), coupled with the talent base of the Julia community seems to have 
> a 
> detrimental effect on the API consistency of the many “micro” packages 
> that 
> cover what I would consider the de-facto standard library.
>
> What I mean is that whereas a commercial package like 
> Matlab/Mathematica etc., being written under one large umbrella, will 
> largely (clearly not always) choose consistent names for similar API 
> keyword arguments, and have similar calling conventions for master 
> function 
> like tools (`optimize` versus `lbfgs`, etc), which I am starting to 
> realize 
> is one of the great selling points of these packages as an end user. I 
> can 
> usually guess what a keyword will be in Mathematica, whereas even after a 
> year of using Julia almost exclusively I find I have to look at the 
> documentation (or the source code depending on the documentation ...) to 
> figure out the keyword names in many common packages.
>
> Similarly, in my experience with open source tools, due to the 
> complexity of the package management, we get large “batteries included” 
> distributions that cover a lot of the standard stuff for doing science, 
> like python’s numpy + scipy combination. Whereas in Julia the equivalent 
> of 
> scipy is split over many, separately developed packages (Base, Optim.jl, 
> NLopt.jl, Roots.jl, NLsolve.jl, ODE.jl/DifferentialEquations.jl). Many of 
> these packages are stupid awesome, but they can have dramatically 
> different 
> naming conventions and calling behavior, for essential equivalent 
> behavior. 
> Recently I noticed that tolerances, for example, are named as `atol/rtol` 
> versus `abstol/reltol` versus `abs_tol/rel_tol`, which means is extremely 
> easy to have a piece of scientific code that will need to use all three 
> conventions across different calls to seemingly similar libraries. 
>
> Having brought this up I find that the community is largely 
> sympathetic and, in general, would support a common convention, the issue 
> I 
> have slowly realized is that it is rarely that straightforward. In the 
> above example the abstol/reltol versus abs_tol/rel_tol seems like an easy 
> example of what can be tidied up, but the latter underscored name is 
> consistent with similar naming conventions from Optim.jl for other 
> tolerances, so that community is reluctant to change the convention. 
> Similarly, I think there would be little interest in changing 
> abstol/reltol 
> to the underscored version in packages like Base, ODE.jl etc as this 
> feels 
> consistent with each of these 

[julia-users] request many processes (addprocs()) simultaneously such that each can be used when obtained?

2016-10-24 Thread Ryan Gardner
I'm trying to write code for sun grid engine (sge) although I think the 
general idea applies to any addprocs.  I would like to be able to request a 
gazillion nodes, and start using each shortly after it becomes available.

An example of what I want is roughly this code:

   for j=1:100
  @async begin
 new_worker = addprocs_sge(1); #request to add one sun grid engine 
process
 worker_init(new_worker) #brings new worker into the work
   end
   end

The problem with this code is that addprocs (and thus addprocs_sge) seems 
to be something like one big critical section, so the @async is effectively 
non-existent, and the procs get added serially.  The big problem with this 
is that it might take a day before I get even the first worker (when 
addprocs_sge returns).  With this code, I would wait that day and only then 
would I start the request for the second worker, which might take 
approximately another day, and so on.  I want to get all my requests in the 
queue, right from the start, so once I get the first worker, I'm also next 
in line for the second, third, ...



The alternative code below effectively gets the request for all workers in 
the queue right from the start

   new_workers = addprocs(100)  #request to add 1,000,000 sun grid 
engine processes
   worker_init(new_workers)

but the problem with it is that I don't get any work done until all 
1,000,000 processes become available because the call to addprocs doesn't 
return until it has everything (even though nodes on sge start to become 
owned and blocked by me while it's trying to collect the whole million).

Is there a way around this?  (I'm using Julia 0.4.3.  I would love to 
upgrade, but I use a large amount of code that I don't control and isn't 
going to be updated any time soon.  At the same time, I'd be interested in 
solutions related to other versions regardless.)  Thanks.

Ryan



[julia-users] Re: using a module but with other name, similar to "import numpy as np" in python

2016-10-24 Thread Christoph Ortner
There is also an issue about this somewhere 

https://github.com/JuliaLang/julia/issues/1255




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

2016-10-24 Thread digxx
Hey,
Thx for ur reply. I tried both deleting all the files and run Pkg.build 
again...
It however did not work as are all the files present too :-(
Julia in cygwin is correct...


Re: [julia-users] Arrays with custom indices examples?

2016-10-24 Thread Isaiah Norton
>
> mg = zeros(Int,(0:4,0:4))


This isn't related to indexing -- it doesn't work with `1:4` either. Use:

  zeros(Int, 4, 4)

(See also the help entry: `?zeros`)

That said, be aware of the warnings in the referenced document: this
feature is still considered experimental, so if you hit other issues please
ping back here again, and folks may suggest to file a bug report.

On Mon, Oct 24, 2016 at 7:13 AM, Angel de Vicente <
angel.vicente.garr...@gmail.com> wrote:

> Hi,
>
> I'm trying to figure out how to use arrays with custom indices, and I've
> read http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/,
> but I don't seem to see how I could actually access array positions
> using arbitrary indices.
>
> A basic example of what I'd like to do would be something like:
> ,
> | m = rand(1:10,(3,3))
> | mg = zeros(Int,(0:4,0:4))
> | mg[1:3,1:3]=m
> `
>
> so that mg would be a copy of m but with a buffer zone around it, and
> when I need to access any value in mg, I can use the same indexing as
> for m (the buffer zone would represent ghost cells for PDEs).
>
> But I don't seem to get very far, as the creation of mg already is
> giving me troubles:
> ,
> | julia> mg = zeros(Int,(0:4,0:4))
> | ERROR: MethodError: Cannot `convert` an object of type
> Tuple{UnitRange{Int64},UnitRange{Int64}} to an object of type
> | Array{Int64,N}
> | This may have arisen from a call to the constructor Array{Int64,N}(...),
> | since type constructors fall back to convert methods.
> |  in Array{Int64,N}(::Tuple{UnitRange{Int64},UnitRange{Int64}}) at
> ./sysimg.jl:53
> |  in zeros(::Type{T}, ::Tuple{UnitRange{Int64},UnitRange{Int64}},
> ::Vararg{Tuple{UnitRange{Int64},UnitRange{Int64}},N}
> | ) at ./array.jl:169
> `
>
> I had a tough night, so perhaps the answer is clear from
> http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/, but I
> can't see whether what I'm trying to do is doable and if so, how. Any
> help appreciated.
>
> Thanks,
> --
> Ángel de Vicente
> http://www.iac.es/galeria/angelv/
>


Re: [julia-users] Named for loops?

2016-10-24 Thread Mauro
On Mon, 2016-10-24 at 15:49, Milan Bouchet-Valat  wrote:
> Le lundi 24 octobre 2016 à 08:05 -0400, Isaiah Norton a écrit:
>>
>>
>> On Monday, October 24, 2016, Angel de Vicente > gmail.com> wrote:
...
>> > Is it possible now (or in the near future) to have named nested
>> > loops in
>> > Julia?
>>
>> No, and I'm not aware of any plan to support this. But youcan create
>> customcontrol flow with '@goto', so itcould be probably bedone
>> with a macro.
> A way to get out of multiple loops has actually been discussed, and the
> consensus appears to be that it's a good idea:
> https://github.com/JuliaLang/julia/issues/5334
>
> Though it's not a high-priority feature since @goto works quite well.

Interesting. Also note the macro posted in the comment:
https://github.com/JuliaLang/julia/issues/5334#issuecomment-206508859

might be just what you need.


Re: [julia-users] Named for loops?

2016-10-24 Thread Milan Bouchet-Valat
Le lundi 24 octobre 2016 à 08:05 -0400, Isaiah Norton a écrit :
> 
> 
> On Monday, October 24, 2016, Angel de Vicente  gmail.com> wrote:
> > Hi,
> > 
> > I don't see it in the documentation, but I'm wondering if there is
> > a way
> > to have named nested loops, so that one can specify those names to
> > break
> > and continue, in order to have more control.
> > 
> > In the following examples, continue always skips the remaining loop
> > for
> > j, while break terminates the j loop in the first example and
> > terminates
> > the single outer loop in the second (I guess it can be a bit
> > confusing
> > at first, but I can understand the design).
> > 
> > ,
> > | println("nested")
> > | for i in 1:3
> > |     for j in 1:6
> > |         if 2 < j < 4 continue end
> > |         if j > 5 break end
> > |         @printf("i: %i j: %i \n",i,j)
> > |     end
> > | end
> > |
> > | println("single outer loop")
> > | for i in 1:3, j in 1:6
> > |     if 2 < j < 4 continue end
> > |     if j > 5 break end
> > |     @printf("i: %i j: %i \n",i,j)
> > | end
> > `
> > 
> > But I'm used to Fortran, where one can do things like this (CYCLE
> > ==
> > continue ; EXIT == break), and you specify the loop that the
> > instruction
> > applies to.
> > 
> > ,
> > |   INA: DO a = 1,1000
> > |     INB: DO b=a+1,1000
> > |         IF (a+b .GT. 1000) CYCLE INA
> > |         INC: DO c=b+1,1000
> > |            IF (a+b+c .GT. 1000) CYCLE INB
> > |            IF (a+b+c .EQ. 1000 .AND. a**2 + b**2 .EQ. c**2) THEN
> > |               PRINT*, a*b*c
> > |               EXIT INA
> > |            END IF
> > |         END DO INC
> > |      END DO INB
> > |   END DO INA
> > `
> > 
> > 
> > Is it possible now (or in the near future) to have named nested
> > loops in
> > Julia?
> 
> No, and I'm not aware of any plan to support this. But you can create
> custom control flow with '@goto', so it could be probably be done
> with a macro.
A way to get out of multiple loops has actually been discussed, and the
consensus appears to be that it's a good idea:
https://github.com/JuliaLang/julia/issues/5334

Though it's not a high-priority feature since @goto works quite well.


Regards

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


[julia-users] Re: stricter parsing of integers

2016-10-24 Thread Krisztián Pintér
validate with regex prior to converting?

On Monday, October 24, 2016 at 3:30:08 PM UTC+2, Tamas Papp wrote:
>
> Is there a way to make 
>
> parse(Int, " - 42 ") 
>
> throw an error, or substitute with a different function that does this? 
>


Re: [julia-users] Re: Problem with julia-0.5 on Gentoo

2016-10-24 Thread 'Bill Hart' via julia-users
I can confirm that the Julia nightly is now working on our Gentoo systems. 
Will there be a Julia-0.5 binary provided with the same fix?

Bill.

On Thursday, 29 September 2016 22:50:35 UTC+2, Tony Kelman wrote:
>
> Okay, the buildbot that was down was running centos which is failing some 
> of the tests due to this very change. We need to come up with a good fix 
> for the certificates location lookup issue on non-debian-based 
> distributions (https://github.com/JuliaLang/julia/issues/18693) before 
> new nightlies will get published.
>
>
> On Thursday, September 29, 2016 at 12:11:18 PM UTC-7, Tony Kelman wrote:
>>
>> nighties were a few days behind, I needed to log in and reconnect a few 
>> of the buildbots. Check in a few hours if the nightlies are dated with 
>> commits from today.
>
>

Re: [julia-users] Named for loops?

2016-10-24 Thread Angel de Vicente
Hi,

Isaiah Norton  writes:
> Is it possible now (or in the near future) to have named nested loops in
> Julia?
>
> No, and I'm not aware of any plan to support this. But you can create custom
> control flow with '@goto', so it could be probably be done with a macro.

Just learning Julia, so I didn't go through the macros yet. Good
motivation to keep going forward. 

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


Re: [julia-users] stricter parsing of integers

2016-10-24 Thread Stefan Karpinski
You could check that there's no whitespace first. Otherwise, this isn't
terribly hard to write a parser for, especially if you don't want any fancy
features.

On Mon, Oct 24, 2016 at 9:29 AM, Tamas Papp  wrote:

> Is there a way to make
>
> parse(Int, " - 42 ")
>
> throw an error, or substitute with a different function that does this?
>
> Note that I am not advocating that this should be invalid syntax, just
> want to have a "strict" version for reading a dataset that throws an
> error unless the integer is not of the "optional sign followed by
> digits", without reimplementing Base.parse if possible.
>


Re: [julia-users] using a module but with other name, similar to "import numpy as np" in python

2016-10-24 Thread Tamas Papp
import DataFrames
const DF = DataFrames
DF.@data ... etc

On Mon, Oct 24 2016, novatena2...@gmail.com wrote:

> Hello,
>
> is there an official way to using a module but with different name (not the 
> name of the module), like "import numpy as np".
>
> Currently, I can do that with a hack, like the following hack. But I don't 
> know if it really prevent method collision or not.
>
> ```
> module DF
> using DataFrames
> end
>
> dv = DF.@data([NA, 3, 2, 5, 4])
> mean(DF.dropna(dv))
> ```



[julia-users] stricter parsing of integers

2016-10-24 Thread Tamas Papp
Is there a way to make

parse(Int, " - 42 ")

throw an error, or substitute with a different function that does this?

Note that I am not advocating that this should be invalid syntax, just
want to have a "strict" version for reading a dataset that throws an
error unless the integer is not of the "optional sign followed by
digits", without reimplementing Base.parse if possible.


[julia-users] using a module but with other name, similar to "import numpy as np" in python

2016-10-24 Thread novatena2015
Hello,

is there an official way to using a module but with different name (not the 
name of the module), like "import numpy as np".

Currently, I can do that with a hack, like the following hack. But I don't 
know if it really prevent method collision or not.

```
module DF
using DataFrames
end

dv = DF.@data([NA, 3, 2, 5, 4])
mean(DF.dropna(dv))
```


Re: [julia-users] Named for loops?

2016-10-24 Thread Isaiah Norton
On Monday, October 24, 2016, Angel de Vicente <
angel.vicente.garr...@gmail.com> wrote:

> Hi,
>
> I don't see it in the documentation, but I'm wondering if there is a way
> to have named nested loops, so that one can specify those names to break
> and continue, in order to have more control.
>
> In the following examples, continue always skips the remaining loop for
> j, while break terminates the j loop in the first example and terminates
> the single outer loop in the second (I guess it can be a bit confusing
> at first, but I can understand the design).
>
> ,
> | println("nested")
> | for i in 1:3
> | for j in 1:6
> | if 2 < j < 4 continue end
> | if j > 5 break end
> | @printf("i: %i j: %i \n",i,j)
> | end
> | end
> |
> | println("single outer loop")
> | for i in 1:3, j in 1:6
> | if 2 < j < 4 continue end
> | if j > 5 break end
> | @printf("i: %i j: %i \n",i,j)
> | end
> `
>
> But I'm used to Fortran, where one can do things like this (CYCLE ==
> continue ; EXIT == break), and you specify the loop that the instruction
> applies to.
>
> ,
> |   INA: DO a = 1,1000
> | INB: DO b=a+1,1000
> | IF (a+b .GT. 1000) CYCLE INA
> | INC: DO c=b+1,1000
> |IF (a+b+c .GT. 1000) CYCLE INB
> |IF (a+b+c .EQ. 1000 .AND. a**2 + b**2 .EQ. c**2) THEN
> |   PRINT*, a*b*c
> |   EXIT INA
> |END IF
> | END DO INC
> |  END DO INB
> |   END DO INA
> `
>
>
> Is it possible now (or in the near future) to have named nested loops in
> Julia?


No, and I'm not aware of any plan to support this. But you can create
custom control flow with '@goto', so it could be probably be done with a
macro.


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


[julia-users] Arrays with custom indices examples?

2016-10-24 Thread Angel de Vicente
Hi,

I'm trying to figure out how to use arrays with custom indices, and I've
read http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/,
but I don't seem to see how I could actually access array positions
using arbitrary indices.

A basic example of what I'd like to do would be something like:
,
| m = rand(1:10,(3,3))
| mg = zeros(Int,(0:4,0:4))
| mg[1:3,1:3]=m
`

so that mg would be a copy of m but with a buffer zone around it, and
when I need to access any value in mg, I can use the same indexing as
for m (the buffer zone would represent ghost cells for PDEs).

But I don't seem to get very far, as the creation of mg already is
giving me troubles:
,
| julia> mg = zeros(Int,(0:4,0:4))
| ERROR: MethodError: Cannot `convert` an object of type 
Tuple{UnitRange{Int64},UnitRange{Int64}} to an object of type 
| Array{Int64,N}
  
| This may have arisen from a call to the constructor Array{Int64,N}(...),
| since type constructors fall back to convert methods.
|  in Array{Int64,N}(::Tuple{UnitRange{Int64},UnitRange{Int64}}) at 
./sysimg.jl:53
|  in zeros(::Type{T}, ::Tuple{UnitRange{Int64},UnitRange{Int64}}, 
::Vararg{Tuple{UnitRange{Int64},UnitRange{Int64}},N}
| ) at ./array.jl:169   
  
`

I had a tough night, so perhaps the answer is clear from
http://docs.julialang.org/en/release-0.5/devdocs/offset-arrays/, but I
can't see whether what I'm trying to do is doable and if so, how. Any
help appreciated.

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


[julia-users] Named for loops?

2016-10-24 Thread Angel de Vicente
Hi,

I don't see it in the documentation, but I'm wondering if there is a way
to have named nested loops, so that one can specify those names to break
and continue, in order to have more control. 

In the following examples, continue always skips the remaining loop for
j, while break terminates the j loop in the first example and terminates
the single outer loop in the second (I guess it can be a bit confusing
at first, but I can understand the design).

,
| println("nested")
| for i in 1:3
| for j in 1:6
| if 2 < j < 4 continue end
| if j > 5 break end
| @printf("i: %i j: %i \n",i,j)
| end
| end
|
| println("single outer loop")
| for i in 1:3, j in 1:6
| if 2 < j < 4 continue end
| if j > 5 break end
| @printf("i: %i j: %i \n",i,j)
| end
`

But I'm used to Fortran, where one can do things like this (CYCLE ==
continue ; EXIT == break), and you specify the loop that the instruction
applies to.
 
,
|   INA: DO a = 1,1000
| INB: DO b=a+1,1000
| IF (a+b .GT. 1000) CYCLE INA
| INC: DO c=b+1,1000
|IF (a+b+c .GT. 1000) CYCLE INB
|IF (a+b+c .EQ. 1000 .AND. a**2 + b**2 .EQ. c**2) THEN
|   PRINT*, a*b*c
|   EXIT INA
|END IF
| END DO INC
|  END DO INB
|   END DO INA
`


Is it possible now (or in the near future) to have named nested loops in
Julia?

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


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

2016-10-24 Thread Mauro
Maybe something like this:

file pre.jl:

if !isdefined(:proc)
proc = false
end

module A

macro pre(ex)
if Main.proc
return ex
else
:(println("doing nothing"))
end
end

function f(x)
@pre sort!(x)
x
end

end

v = rand(5)
A.f(v)
@show v


Then use it with:

$ julia
   _
   _   _ _(_)_ |  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)
 _/ |\__'_|_|_|\__'_|  |
|__/   |  x86_64-pc-linux-gnu

julia> include("/tmp/pre.jl")
doing nothing
v = [0.538799,0.962246,0.791487,0.275642,0.00649348]
5-element Array{Float64,1}:
 0.538799
 0.962246
 0.791487
 0.275642
 0.00649348


$ julia
   _
   _   _ _(_)_ |  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)
 _/ |\__'_|_|_|\__'_|  |
|__/   |  x86_64-pc-linux-gnu

julia> proc = true  # <-- flip the switch
true

julia> include("/tmp/pre.jl")
v = [0.174159,0.334383,0.758589,0.845893,0.858845]
5-element Array{Float64,1}:
 0.174159
 0.334383
 0.758589
 0.845893
 0.858845


On Mon, 2016-10-24 at 11:47, Florian Oswald  wrote:
> Ok. any suggestions how to get close to the C preprocessor behaviour though?
>
> On Monday, 24 October 2016 11:13:18 UTC+2, Mauro wrote:
>>
>> On Mon, 2016-10-24 at 10:37, Florian Oswald > > wrote:
>> > I have something that this in C++ I would write like
>> >
>> > double f(double x){
>> >  // do something with x
>> > #ifdef MACROVAR
>> >  // do something else with x
>> > #endif
>> >  return(x)
>> > }
>> >
>> > I was trying to understand how i could use julia macro's to achieve
>> > something similar. I have seen how the Logging.jl uses macros to this
>> end,
>> > at least that's how I understand
>> > it:
>> https://github.com/kmsquire/Logging.jl/blob/master/src/logging_macros.jl
>> > . However I'm a bit unclear as to how to use this in my case. in my
>> case,
>> > the condition of whether or not to insert a piece of code is stored in a
>> > custom type. Here is what I tried:
>> >
>> > # simplified type:
>> > type Param
>> > nD_rent :: Int
>> > end
>> >
>> > # macro:
>> > macro add_buy(p::Param)
>> > quote
>> > if $(esc(p.nD_rent)) > 4
>> > # insert some additional code
>> > println("here comes additional code")
>> > println(typeof(p))
>> >
>> > else
>> > println(typeof(p))
>> > :nothing
>> > end
>> > end
>> > end
>>
>> No, a macro receives the AST.  Check this
>>
>> macro tmp(p)
>> println(p)
>> println(typeof(p))
>> end
>>
>> So your signature should probably just read:
>>
>> macro add_buy(p)
>> ...
>> end
>>
>> > *julia> **bk.@add_buy(p)*
>> >
>> > *ERROR: MethodError: no method matching @add_buy(::Symbol)*
>> >
>> > Closest candidates are:
>> >
>> >   @add_buy(*::bk.Param*) at
>> > /Users/florian.oswald/git/bk/bk.jl/src/solver.jl:641
>> >
>> >
>> > so, I have a type `Param`, and depending on the value in field nD_rent,
>> I
>> > would like to insert that code or not. thanks for any suggestions.
>>
>> That is not what your above macro does.  And that is not what macros
>> should do (ideally), they should be syntax transformations independent
>> of the values.  You can eval in a macro but that is *strongly*
>> discouraged.
>>


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

2016-10-24 Thread Florian Oswald
Ok. any suggestions how to get close to the C preprocessor behaviour though?

On Monday, 24 October 2016 11:13:18 UTC+2, Mauro wrote:
>
> On Mon, 2016-10-24 at 10:37, Florian Oswald  > wrote: 
> > I have something that this in C++ I would write like 
> > 
> > double f(double x){ 
> >  // do something with x 
> > #ifdef MACROVAR 
> >  // do something else with x 
> > #endif 
> >  return(x) 
> > } 
> > 
> > I was trying to understand how i could use julia macro's to achieve 
> > something similar. I have seen how the Logging.jl uses macros to this 
> end, 
> > at least that's how I understand 
> > it: 
> https://github.com/kmsquire/Logging.jl/blob/master/src/logging_macros.jl 
> > . However I'm a bit unclear as to how to use this in my case. in my 
> case, 
> > the condition of whether or not to insert a piece of code is stored in a 
> > custom type. Here is what I tried: 
> > 
> > # simplified type: 
> > type Param 
> > nD_rent :: Int 
> > end 
> > 
> > # macro: 
> > macro add_buy(p::Param) 
> > quote 
> > if $(esc(p.nD_rent)) > 4 
> > # insert some additional code 
> > println("here comes additional code") 
> > println(typeof(p)) 
> > 
> > else 
> > println(typeof(p)) 
> > :nothing 
> > end 
> > end 
> > end 
>
> No, a macro receives the AST.  Check this 
>
> macro tmp(p) 
> println(p) 
> println(typeof(p)) 
> end 
>
> So your signature should probably just read: 
>
> macro add_buy(p) 
> ... 
> end 
>
> > *julia> **bk.@add_buy(p)* 
> > 
> > *ERROR: MethodError: no method matching @add_buy(::Symbol)* 
> > 
> > Closest candidates are: 
> > 
> >   @add_buy(*::bk.Param*) at 
> > /Users/florian.oswald/git/bk/bk.jl/src/solver.jl:641 
> > 
> > 
> > so, I have a type `Param`, and depending on the value in field nD_rent, 
> I 
> > would like to insert that code or not. thanks for any suggestions. 
>
> That is not what your above macro does.  And that is not what macros 
> should do (ideally), they should be syntax transformations independent 
> of the values.  You can eval in a macro but that is *strongly* 
> discouraged. 
>


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

2016-10-24 Thread Mauro
On Mon, 2016-10-24 at 10:37, Florian Oswald  wrote:
> I have something that this in C++ I would write like
>
> double f(double x){
>  // do something with x
> #ifdef MACROVAR
>  // do something else with x
> #endif
>  return(x)
> }
>
> I was trying to understand how i could use julia macro's to achieve
> something similar. I have seen how the Logging.jl uses macros to this end,
> at least that's how I understand
> it: https://github.com/kmsquire/Logging.jl/blob/master/src/logging_macros.jl
> . However I'm a bit unclear as to how to use this in my case. in my case,
> the condition of whether or not to insert a piece of code is stored in a
> custom type. Here is what I tried:
>
> # simplified type:
> type Param
> nD_rent :: Int
> end
>
> # macro:
> macro add_buy(p::Param)
> quote
> if $(esc(p.nD_rent)) > 4
> # insert some additional code
> println("here comes additional code")
> println(typeof(p))
>
> else
> println(typeof(p))
> :nothing
> end
> end
> end

No, a macro receives the AST.  Check this

macro tmp(p)
println(p)
println(typeof(p))
end

So your signature should probably just read:

macro add_buy(p)
...
end

> *julia> **bk.@add_buy(p)*
>
> *ERROR: MethodError: no method matching @add_buy(::Symbol)*
>
> Closest candidates are:
>
>   @add_buy(*::bk.Param*) at
> /Users/florian.oswald/git/bk/bk.jl/src/solver.jl:641
>
>
> so, I have a type `Param`, and depending on the value in field nD_rent, I
> would like to insert that code or not. thanks for any suggestions.

That is not what your above macro does.  And that is not what macros
should do (ideally), they should be syntax transformations independent
of the values.  You can eval in a macro but that is *strongly*
discouraged.


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

2016-10-24 Thread Florian Oswald
I have something that this in C++ I would write like

double f(double x){
 // do something with x
#ifdef MACROVAR
 // do something else with x
#endif
 return(x)
}   

I was trying to understand how i could use julia macro's to achieve 
something similar. I have seen how the Logging.jl uses macros to this end, 
at least that's how I understand 
it: https://github.com/kmsquire/Logging.jl/blob/master/src/logging_macros.jl 
. However I'm a bit unclear as to how to use this in my case. in my case, 
the condition of whether or not to insert a piece of code is stored in a 
custom type. Here is what I tried:

# simplified type:
type Param
nD_rent :: Int
end

# macro:
macro add_buy(p::Param)
quote
if $(esc(p.nD_rent)) > 4 
# insert some additional code
println("here comes additional code")
println(typeof(p))

else
println(typeof(p))
:nothing
end
end
end

*julia> **bk.@add_buy(p)*

*ERROR: MethodError: no method matching @add_buy(::Symbol)*

Closest candidates are:

  @add_buy(*::bk.Param*) at 
/Users/florian.oswald/git/bk/bk.jl/src/solver.jl:641


so, I have a type `Param`, and depending on the value in field nD_rent, I 
would like to insert that code or not. thanks for any suggestions.


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

2016-10-24 Thread Tommy Hofmann
Sorry, I meant arb and not pari. Something is off with the libraries. You 
can try the following:

1. Remove all files in .julia\v0.5\Nemo\local\lib and then do a 
Pkg.build("Nemo") again.

2. If 1. doesn't help, check if the following files are in Nemo\local\lib: 
"libwinpthread-1.dll", "libgmp-16.dll", "libmpfr-4.dll", "libflint.dll", 
"libflint-13.dll", "libarb.dll", "libpari.dll"
(Note that there must be two libflint* files).

Looking at your path names, I wonder if you are running julia in cygwin?


Re: [julia-users] How to save an object of a defined type

2016-10-24 Thread Michele Zaffalon
Can you post a bit more of the code? From the error message, it looks like
you are trying to open an already opened file...

On Sat, Oct 22, 2016 at 7:42 PM,  wrote:

> I have a module defined as module *Core* within which I have defined
> several types (*Node*, *Edge*, *Res*). Now what I intend to do is that I
> want to save the output of a function which is an object (*res1*) of type
> *Res* onto a JLD file so that I can retrieve it later on. I am calling
> the function iteratively and hence at each iteration, I would like to store
> the object in the JLD file. I'm not sure how the syntax of this snippet is
> but here is my attempt at it
>
> using HDF5, JLD
>>> z = jldopen("sample.jld", "w")
>>> write(z, "res1", res1)
>>>
>>>
>>>
> Can you please correct my code? I tried the code on the terminal but I get
> an error for the very first line saying
>
> HDF5-DIAG: Error detected in HDF5 (1.8.11) thread 140049981197376:
>   #000: ../../../src/H5F.c line 1504 in H5Fcreate(): unable to create file
> major: File accessibilty
> minor: Unable to open file
>   #001: ../../../src/H5F.c line 1307 in H5F_open(): unable to truncate a
> file which is already open
> major: File accessibilty
> minor: Unable to open file
>
>
>