[julia-users] Re: Running Julia in Ubuntu

2016-09-01 Thread Josh Langsfeld
This link is only to an archive of the source code; you would still have to build julia after downloading this. Ideally what you want is an ARM binary that's version 0.4 instead of a nightly build but I don't see anywhere obvious where that can be downloaded. RobotOS will start working on 0.5

[julia-users] Re: Arrays of user defined types, indexing and copying.

2016-08-12 Thread Josh Langsfeld
For your second question, I would have expected just doing deepcopy(MyType_Vec[[1,3,1]]) would have created a new array with a new object allocated for each element. Instead, it puts the same object (which is a copy) in the first and third positions and you get the same behavior. Maybe this

Re: [julia-users] use of parse and eval to create programmatically anonymous function

2016-04-29 Thread Josh Langsfeld
jects, it will just work and > do the right thing, even for expressions which have no possible string > representation. > > > On Thu, Apr 28, 2016 at 10:21 PM, Yichao Yu <yyc...@gmail.com > > wrote: > >> On Thu, Apr 28, 2016 at 6:05 PM, Josh Langsfeld <jdl...@gmail.com >

Re: [julia-users] use of parse and eval to create programmatically anonymous function

2016-04-28 Thread Josh Langsfeld
That's quite a strong statement to say never use parse. Could you explain? I think manipulating strings is typically much easier than Expr objects. On Thursday, April 28, 2016 at 8:38:27 AM UTC-4, Yichao Yu wrote: > > > On Apr 28, 2016 7:15 AM, "Ben Lauwens" > wrote: > > >

[julia-users] Re: Evaluation of boolean expression fails

2016-04-26 Thread Josh Langsfeld
that all the anonymous functions return Bools. On Tuesday, April 26, 2016 at 2:24:18 PM UTC-4, Ali Rezaee wrote: > > Reading the rules from a file, how can I convert the strings to such > anonymous functions? > > On Tuesday, April 26, 2016 at 6:48:21 PM UTC+2, Josh Langsfeld w

[julia-users] Re: Evaluation of boolean expression fails

2016-04-26 Thread Josh Langsfeld
Maybe a better design would be to store the rules as anonymous functions rather than code strings? Something like: ``` rules = [(x -> x[1] && x[2]), (x -> x[3] || x[4])] #parentheses not required result = [rule(boolList) for rule in rules] ``` On Tuesday, April 26, 2016 at 12:09:33 PM UTC-4,

Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread Josh Langsfeld
This is noted in the docs. See a few paragraphs down, "When a type is applied like a function..." http://docs.julialang.org/en/release-0.4/manual/types/#composite-types On Tuesday, April 5, 2016 at 10:19:05 AM UTC-4, FANG Colin wrote: > > methods(TT) > > call(::Type{TT}, x::Float64,

Re: [julia-users] MethodError: '+' has no method matching +(::DateTime, ::Int64)

2016-04-04 Thread Josh Langsfeld
Shouldn’t Dates.day(1) be the MethodError here? It calls what appears to be an internal calculation method that happens to have the same name as the exported and documented method. On Monday, April 4, 2016 at 11:21:47 AM UTC-4, Jacob Quinn wrote: Dates.day is the accessor funciton, returning

[julia-users] Re: Pkg.submit() not working on Julia v0.5

2016-03-07 Thread Josh Langsfeld
Hello Ayush, Note that you are using julia 0.5 but are using the 0.4 documentation. You want to be on this page instead: http://docs.julialang.org/en/latest/manual/packages/ There's a little widget in the bottom right corner of the page that lets you select the documentation version so you

[julia-users] Re: Loading a module without loading its submodules

2016-02-25 Thread Josh Langsfeld
Maybe a solution to this kind of design problem would be to allow multiple top-level modules per package, with syntax to let you load the particular one you want/need. On Thursday, February 25, 2016 at 1:10:28 AM UTC-5, John Myles White wrote: > > I don't think Julia is really amenable to this

Re: [julia-users] Is this a 0.5 bug?

2016-02-17 Thread Josh Langsfeld
Whoops, sorry Yichao, I missed you had already given the suggested change. On Wednesday, February 17, 2016 at 10:30:54 AM UTC-5, Yichao Yu wrote: > > On Wed, Feb 17, 2016 at 10:22 AM, J Luis > wrote: > > Hi, see > > > > function ttt() > > t1 =

Re: [julia-users] Is this a 0.5 bug?

2016-02-17 Thread Josh Langsfeld
To get a two-dimensional output array (i.e., row vector), you can use a non-scalar indexing expression such as t1[[1],:] or t1[1:1,:]. You probably knew this already, but just making a note for any others reading who might not. On Wednesday, February 17, 2016 at 10:51:04 AM UTC-5, J Luis

[julia-users] Re: Iterate through rows/columns

2016-02-10 Thread Josh Langsfeld
Exactly two years later seems like a good-enough time to bring this back up. Has the situation changed here at all, maybe in a package? I've experimented a bit and the code for doing row and column iteration at least is absurdly simple. If multiple people would make use of it, where would be a

[julia-users] Computing a related concrete type

2016-02-10 Thread Josh Langsfeld
Is there any straightforward way to define this function? : onedimless{T}(A::AbstractArray{T,2}) I would like it to return almost the same concrete type as typeof(A), but with an AbstractArray dimension type parameter of 1 instead of 2. E.g., onedimless(zeros(3,3)) == Array{Float64,1}.

[julia-users] Re: Computing a related concrete type

2016-02-10 Thread Josh Langsfeld
For Array, sure, but I was hoping for something that would work for various subtypes of AbstractArray. On Wednesday, February 10, 2016 at 12:36:00 PM UTC-5, Lutfullah Tomak wrote: Do yo mean something like > > onedimless{T,N}(A::Array{T,N}) = Array{T,N-1} > ? > ​

[julia-users] Re: Computing a related concrete type

2016-02-10 Thread Josh Langsfeld
Yeah, it does seem ill-posed in general. Still, it would nice if I could do this for at least some subtypes that use the same type parameter pattern, even if the behavior was undefined when it doesn't use the same pattern. Is there any method of dynamically computing a new type by changing one

Re: [julia-users] Re: Computing a related concrete type

2016-02-10 Thread Josh Langsfeld
Ok, but how does one actually create a new type object given a new set of parameters? On Wednesday, February 10, 2016 at 2:20:27 PM UTC-5, Yichao Yu wrote: > > On Wed, Feb 10, 2016 at 2:13 PM, Josh Langsfeld <jdl...@gmail.com > > wrote: > > Yeah, it does seem ill-po

Re: [julia-users] Re: Computing a related concrete type

2016-02-10 Thread Josh Langsfeld
given source array. > ``` > > Note that this puts the burden onto the creator of the type. > > On Wed, 2016-02-10 at 20:20, Yichao Yu <yyc...@gmail.com > > wrote: > > On Wed, Feb 10, 2016 at 2:13 PM, Josh Langsfeld <jdl...@gmail.com > > wrote: > >>

Re: [julia-users] Parametric Types with Incomplete Initialization

2016-02-04 Thread Josh Langsfeld
I may be mistaken, but I think setting the type parameter to be abstract is indeed the same as setting the field itself to be abstract. This snippet is my evidence: julia> abstract ABC julia> immutable A <: ABC a::Float32 end julia> type B{T<:ABC} a::T end

Re: [julia-users] Parametric Types with Incomplete Initialization

2016-02-04 Thread Josh Langsfeld
8: > > abstract ABC > > immutable A2 <: ABC > a::Float64 > end > > julia> bA2, bABC2 = B{A2}(A2(1)), B{ABC}(A2(2)) > (B{A2}(A2(1.0)),B{ABC}(A2(2.0))) > > julia> sizeof(bA2), sizeof(bABC2) > (8,8) > > > > > > On Thursday, February 4, 2016 at 2:

[julia-users] Re: Adding another function to Cairo.jl

2016-01-25 Thread Josh Langsfeld
You should test it and decide what to put in it by modifying your own forked copy of Cairo.jl. This is what's great about open-source; you get to exactly see and control what impact the changes you want will have before they get added to the official software. On Monday, January 25, 2016 at

[julia-users] Re: Variable scope in a function

2016-01-13 Thread Josh Langsfeld
The tipoff is that you had to quote 'awards' to become a symbol. That's an indicator that you're only referring to the variable name and not to any value it might have coming out of the xpath function. On Wednesday, January 13, 2016 at 4:14:18 PM UTC-5, Brandon Booth wrote: > > Thank you, I

Re: [julia-users] How to define methods of rearranged arguments

2016-01-08 Thread Josh Langsfeld
Here's an idea for a more general and scalable approach rather than checking each argument's type with an if-statement: function f(args...) argdict = Dict(zip(map(typeof, args), args)) f(argdict[A], argdict[B]) #etc... end Note that it won't work if any of your A,B,etc are abstract types

Re: [julia-users] can I load specific lines of a script file into REPL without copy/paste?

2016-01-06 Thread Josh Langsfeld
Just a quick note; it's quite limiting to put a type annotation of 'AbstractVector{Int64}' on 'lines', with nothing gained. This is a perfect example of a time when the programmer should just leave off the annotation and allow any expression that's valid for indexing to be used, including a

Re: [julia-users] can I load specific lines of a script file into REPL without copy/paste?

2016-01-06 Thread Josh Langsfeld
to signal the user that the > entries of lines has some restriction for getindex to work. > > How about the type annotation for path? That seems reasonable to me too, > but maybe I’m mistaken? > > On Wednesday, January 6, 2016 at 3:53:09 PM UTC-8, Josh Langsfeld wrote: > > Jus

[julia-users] Re: How to display in string?

2015-12-26 Thread Josh Langsfeld
As Yichao is hinting, you may find a macro to be a cleaner way of making your functions instead of constructing and parsing a string. macro return_fcn(N) xexprs = Expr[:($(symbol(:x,i)) = X[$i]) for i=1:N] return esc(:( function $(symbol(:f,N))(X::Vector) $(xexprs...)

[julia-users] Re: advent of code -- day 3

2015-12-16 Thread Josh Langsfeld
On Tuesday, December 15, 2015 at 1:09:54 PM UTC-8, Kristoffer Carlsson > wrote: >> >> The set is built as a number of key-value pairs of the hash and the >> object. When you modify the object the key that contains the hash does not >> get updated. A good reason not to pu

[julia-users] Re: advent of code -- day 3

2015-12-15 Thread Josh Langsfeld
t from the outside s = Set([[10,2,3]]) julia> push!(s, [10,2,3]) Set([[10,2,3],[10,2,3]]) julia> length(s) 2 julia> els = collect(s); els[1] == els[2] true Is something buggy going on here? On Tuesday, December 15, 2015 at 10:57:31 AM UTC-5, Josh Langsfeld wrote: > > It's not arr

[julia-users] Re: advent of code -- day 3

2015-12-15 Thread Josh Langsfeld
It's not array equality that's the issue here. Arrays with the same elements are '==' (but not '==='). If you manually test pushing the same array to a Set you'll see it works fine. Jan, what happened is that your 'santa' function modifies and returns the same array that was passed in instead

Re: [julia-users] Re: using statement with for loop inside if statement

2015-12-09 Thread Josh Langsfeld
g. > https://github.com/JuliaLang/julia/issues/2586 > https://github.com/JuliaLang/julia/issues/4893 > > On Wed, Dec 9, 2015 at 10:50 AM, Josh Langsfeld <jdl...@gmail.com > > wrote: > >> But an if statement does not introduce new scope, correct? >> >> Somethin

[julia-users] Re: using statement with for loop inside if statement

2015-12-09 Thread Josh Langsfeld
But an if statement does not introduce new scope, correct? Something weird/unexpected does seem to be going on here: julia> VERSION v"0.5.0-dev+1491" julia> if true using Compat println("Using") foreach(println, 1:3) end Using 1 2 3 julia> if true

Re: [julia-users] Re: `findmin` with arbitrary comparison operator?

2015-12-02 Thread Josh Langsfeld
s trivial. However, in the end I want not only the minimum > value, but also the additional tuple elements, which would be stripped off > by the score_func. > > -erik > > On Tue, Dec 1, 2015 at 12:38 PM, Josh Langsfeld <jdl...@gmail.com > > wrote: > >> Doesn't 'min'

Re: [julia-users] Re: `findmin` with arbitrary comparison operator?

2015-12-01 Thread Josh Langsfeld
Doesn't 'min' imply/require the usage of '<' ? A whole lot of methods would need the extra argument added for consistency, including min, minimum, maximum, etc... Could a workable solution be to define a function that maps a tuple to a real number instead of a comparison function and do

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread Josh Langsfeld
Should also mention that even when ["1", ["1","2","3"]] returns a two element Vector{Any}, the inner array will still get inferred to be Vector{ASCIIString} unless you add the Any prefix. On Wednesday, November 18, 2015 at 12:30:28 PM UTC-5, Josh Langsfe

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread Josh Langsfeld
Your conclusion is correct. The final switch should happen pretty soon on 0.5 master. Until then, the work-around is to prefix all your brackets with 'Any', including the inner arrays. On Wednesday, November 18, 2015 at 12:20:15 PM UTC-5, vis...@stanford.edu wrote: > > Hi everyone, > > Julia

Re: [julia-users] linspace-like range generators and keyword ordering

2015-11-16 Thread Josh Langsfeld
On Saturday, November 14, 2015 at 10:59:26 AM UTC-5, MA Laforge wrote: > > >> - `immutable KD{Symbol} end` does not force the type parameter to be a >> symbol. It does the same thing as the more typical 'T' (which could be >> :tfund, Int, Array{Symbol,2}, or anything else). >> > Hmm... I

Re: [julia-users] linspace-like range generators and keyword ordering

2015-11-13 Thread Josh Langsfeld
This looks like overengineering of what should be a simple problem. Why do you want turn the keywords into arguments for dispatch? Dispatch is best when you need different behavior for different types but here all your input and output types are fixed. You may have already known, but you can

[julia-users] Re: julia style to resize array with initialization?

2015-10-26 Thread Josh Langsfeld
You could do 'append!(vec, zeros(i-n))'. On Monday, October 26, 2015 at 3:32:56 PM UTC-4, Cameron McBride wrote: > > Hi All, > > What's the best julian way to do the following: > > function vecadd!(vec, i, v) > n = length(vec) > if n < i > resize!(vec, i) > vec[n+1:i] =

[julia-users] Re: non-modifying push (and unshift, etc.)

2015-10-19 Thread Josh Langsfeld
[a; b] / vcat(...) is type stable. It may produce different output depending on the types of a and b but it won't change behavior depending on their values. On Monday, October 19, 2015 at 10:20:06 AM UTC-4, Andras Niedermayer wrote: > > In light of the recent discussions ( >

[julia-users] Re: Function push! adds objects where it should not

2015-10-14 Thread Josh Langsfeld
There must have been some other subtle change you made when converting to 0.4. I see the same fill! behavior in 0.3. julia> VERSION v"0.3.11" julia> X = Array(Vector{Int},5); fill!(X, Int[]); julia> push!(X[1], 11); @show X; X => [[11],[11],[11],[11],[11]] On Tuesday, October 13, 2015 at

Re: [julia-users] Method fieldnames not defined

2015-10-14 Thread Josh Langsfeld
Actually Compat doesn't rewrite the code to call 'names' but just defines 'fieldnames' directly. So either import Compat Compat.fieldnames(x) or using Compat fieldnames(x) is sufficient. On Wednesday, October 14, 2015 at 4:47:36 PM UTC-4, Milan Bouchet-Valat wrote: > > Le mercredi 14

[julia-users] Re: Dispatch on arbitrary wrapper types

2015-09-17 Thread Josh Langsfeld
Essentially, it would really cool to be able to do something like 'type SubString{T<: AbstractString} <:T ...' for dispatch purposes. 'SubString{ASCIIString} <: ASCIIString' would still return false in general. On Thursday, September 17, 2015 at 1:47:24 PM UTC-4, Josh Langsfeld wro

[julia-users] Dispatch on arbitrary wrapper types

2015-09-17 Thread Josh Langsfeld
I recently was stumped when I wanted to write a function that dispatched on 'ASCIIString' versus 'UTF8String' but then had to deal with a 'SubString{ASCIIString}'. It made me think that given Julia's prolific use of wrapper types, it would be very nice to be able to dispatch on a type T and

Re: [julia-users] Re: Dispatch on arbitrary wrapper types

2015-09-17 Thread Josh Langsfeld
king them part of the core language eventually, but in the meantime, > check out https://github.com/mauro3/Traits.jl > > On Thu, Sep 17, 2015 at 2:16 PM, Josh Langsfeld <jdl...@gmail.com > > wrote: > >> Essentially, it would really cool to be able to do something like 't

[julia-users] Re: Getting type parameters from a parameterized types?

2015-09-11 Thread Josh Langsfeld
You can access the 'parameters' field of a type instance object. But the standard Julian way to get type parameters is to just define a helper function: typeparams{A,B}(::Type{T{A,B}}) = A,B On Friday, September 11, 2015 at 3:20:17 PM UTC-4, Erik Schnetter wrote: > > Is there a function in

[julia-users] Re: How to best define an EulerAngles type

2015-08-26 Thread Josh Langsfeld
You can always just make the arguments give all the parameters: type EulerAngles{T : Number, Seq} angles::Vector{T} end EulerAngles{T}(seq, angles::Vector{T}) = EulerAngles{T,seq}(angles) julia EulerAngles(321, [pi,pi/2,0])

Re: [julia-users] Re: Which Packages Should be Registered?

2015-07-14 Thread Josh Langsfeld
Christoph and David, If you want your package to be useful to the world, how should new users in your domain find it? With a Google search? I'm of the same opinion of Jeffrey that anything that could be helpful to others should be registered in some capacity. Besides making it easier to

[julia-users] Re: collect(a:b) vs. [a:b;] in v0.4

2015-07-10 Thread Josh Langsfeld
You can see the discussion about changing the deprecation suggestion here: https://github.com/JuliaLang/julia/pull/11369 I think people liked it because it's a bit of an abuse of terminology to call the [a:b;] form 'concatenation' when there is only one object being put into the array. The

Re: [julia-users] Re: Efficient way to compute X' diag(w) Y

2015-07-08 Thread Josh Langsfeld
andreasnoackjen...@gmail.com wrote: You could, but unless the matrices are small, it would be slower because it wouldn't use optimized matrix multiplication. 2015-07-08 10:36 GMT-04:00 Josh Langsfeld jdla...@gmail.com: Maybe I'm missing something obvious, but couldn't you easily write your

[julia-users] Re: Efficient way to compute X' diag(w) Y

2015-07-08 Thread Josh Langsfeld
Maybe I'm missing something obvious, but couldn't you easily write your own 'cross' function that uses a couple nested for-loops to do the arithmetic without any intermediate allocations at all? On Tuesday, July 7, 2015 at 6:24:34 PM UTC-4, Matthieu wrote: Thanks, this is what I currently do

Re: [julia-users] What's the best way to implement multiple methods with similar arguments?

2015-06-28 Thread Josh Langsfeld
The philosophy I try to follow is to use multiple dispatch when you don't care at the calling site what the types of your arguments are and therefore which method will be called. For example, consider the case when you receive some output from a library function and you either don't know or

Re: [julia-users] Re: Getting the length of a tuple type

2015-06-25 Thread Josh Langsfeld
tony.hf.f...@gmail.com wrote: I have just put out an update to the Lint.jl master which should have some examples of what you need. Hopefully this would fix the tuple length issue for you. On Wednesday, June 24, 2015 at 2:54:03 PM UTC-4, Josh Langsfeld wrote: Thanks, Matt. I hope your stuff does

[julia-users] Re: Getting the length of a tuple type

2015-06-24 Thread Josh Langsfeld
way to do this. You could take a look at my Tuples package[1], which is an attempt at hashing out the API before trying to get this functionality into base. Your feedback would be very welcome! 1: https://github.com/mbauman/Tuples.jl On Wednesday, June 24, 2015 at 1:14:41 PM UTC-4, Josh

Re: [julia-users] Performances: vectorised operator, for loop and comprehension

2015-06-19 Thread Josh Langsfeld
My results don't show a significant performance advantage of the comprehension. Averaging over 1000 runs of a million-element array, I got: f1 (vectorized): 10.32 ms f2 (loop): 2.07 ms f3 (comprehension): 2.05 ms f4 (map): 38.09 ms Also, as you can see here

Re: [julia-users] map() vs list comprehension - any preference?

2015-06-18 Thread Josh Langsfeld
wrote: Gah. I'm sorry. I can't reproduce my original results! I don't know why, but the same tests I ran two days ago are not giving me the same timing. I need to go back to the drawing board here. On Wednesday, June 17, 2015 at 11:37:52 AM UTC-5, Josh Langsfeld wrote: For me, map is 100x

[julia-users] Re: Is there a reason any(p, c) isn't lazy?

2015-06-18 Thread Josh Langsfeld
/JuliaLang/julia/issues/11750. On Thursday, June 18, 2015 at 11:04:29 AM UTC-5, Josh Langsfeld wrote: It seems 'any' calls 'mapreduce' which calls 'mapfoldl' which has a specialization that will stop computing in the case of searching for a single true or false value. However, it seems

[julia-users] Re: Is there a reason any(p, c) isn't lazy?

2015-06-18 Thread Josh Langsfeld
It seems 'any' calls 'mapreduce' which calls 'mapfoldl' which has a specialization that will stop computing in the case of searching for a single true or false value. However, it seems the call to mapreduce instead goes to a more specific method that doesn't implement this shortcut. If 'any'

Re: [julia-users] map() vs list comprehension - any preference?

2015-06-17 Thread Josh Langsfeld
For me, map is 100x slower: julia function f1(g,a) [Pair(x,g) for x in a] end f1 (generic function with 1 method) julia function f2(g,a) map(x-Pair(x,g), a) end f2 (generic function with 1 method) julia @time f1(2,ones(1_000_000)); 25.158 milliseconds (28491

Re: [julia-users] Macros generating Functions

2015-06-01 Thread Josh Langsfeld
On Monday, 1 June 2015 02:35:28 UTC+10, Josh Langsfeld wrote: I don't think this is correct actually. With Julia's metaprogramming abilities, all macros could be handled by runtime functions. The rule I follow is that macros should be used when some processing needs to be done at compile time

Re: [julia-users] Re: Construct range with custom type

2015-05-21 Thread Josh Langsfeld
AM UTC-10, Josh Langsfeld wrote: That particular error was just because the = operator was implemented and there was no fallback method to give an informative error. I sent in a PR to fix that: #11372 https://github.com/JuliaLang/julia/pull/11372. Beyond that, I managed to get it working

[julia-users] Re: Selective dispatching on an Int

2015-05-21 Thread Josh Langsfeld
. Mai 2015 23:28:26 UTC+2 schrieb Josh Langsfeld: I want to implement some functionality in multiple methods and have the dispatch controlled by an Int variable N. The trick is I want one method to be called if N == 0 and another one to be called for all other values of N. Is there a way I can

[julia-users] Selective dispatching on an Int

2015-05-20 Thread Josh Langsfeld
I want to implement some functionality in multiple methods and have the dispatch controlled by an Int variable N. The trick is I want one method to be called if N == 0 and another one to be called for all other values of N. Is there a way I can do this with Val{N} without making the method

Re: [julia-users] Re: Construct range with custom type

2015-05-20 Thread Josh Langsfeld
(float64(a))) nextfloat(a::JDate,b::Int64) = JDate(nextfloat(float64(a),b)) Then, julia [j1:.5:j2] ERROR: stack overflow in = at promotion.jl:170 (repeats 8 times) Any insight into why this is happening? Thanks, Chris On Thursday, May 14, 2015 at 3:48:48 AM UTC-10, Josh Langsfeld wrote

[julia-users] Re: Selective dispatching on an Int

2015-05-20 Thread Josh Langsfeld
Ideally, I would like to write func{N::Int}(::Type{Val{N}) = N and get no-method errors if N is a float, symbol, etc... Has there been previous discussion on this topic? On Wednesday, May 20, 2015 at 5:28:26 PM UTC-4, Josh Langsfeld wrote: I want to implement some functionality in multiple

Re: [julia-users] Re: Construct range with custom type

2015-05-14 Thread Josh Langsfeld
. Thanks for your help. Chris On Wednesday, May 13, 2015 at 2:30:53 PM UTC-4, Josh Langsfeld wrote: Yeah, I missed that you were subtyping FloatingPoint before. It still worked ok for me though once I also defined colon methods suggested by the ambiguity warnings. in my case it was: colon

[julia-users] Re: Construct range with custom type

2015-05-13 Thread Josh Langsfeld
, define colon(JDate,JDate,JDate) before the new definition. Then, when I test this, I still get a Array{Float64,1}. Thanks, Chris On Wednesday, May 13, 2015 at 12:05:19 PM UTC-4, Josh Langsfeld wrote: I believe you only need to add a method to Base.colon of the form 'colon(start

[julia-users] Re: verbs for immutable collections

2015-05-13 Thread Josh Langsfeld
Is your concern that some other package might also export non-mutating setindex and delete, thereby conflicting with yours? Or just that they should exist in Base? On Wednesday, May 13, 2015 at 2:35:44 PM UTC-4, Michael Francis wrote: I added methods to NamedTuples.jl to support merge, set

[julia-users] Re: Construct range with custom type

2015-05-13 Thread Josh Langsfeld
I believe you only need to add a method to Base.colon of the form 'colon(start::JDate, step::Real, stop::JDate)' I just tested it and that was the only thing needed to make the the [J1:s:J2] syntax work. On Wednesday, May 13, 2015 at 11:13:53 AM UTC-4, Chris wrote: I have a simple custom

[julia-users] Re: how to compute the maximum value of an object's attribute

2015-05-07 Thread Josh Langsfeld
Or: maximum([t.tau_max for t in TUnitS]) On Thursday, May 7, 2015 at 12:02:09 PM UTC-4, Darwin Darakananda wrote: How about : mapreduce(t - t.tau_max, max, TUnitS) On Thursday, May 7, 2015 at 8:49:49 AM UTC-7, Michela Di Lullo wrote: Hello everyone, I have to compute the maximum

Re: [julia-users] Re: how to dispatch on an instance being a datatype

2015-05-01 Thread Josh Langsfeld
What's the motivation for wanting to restrict calling repack on non-composite types? 'fieldnames' works fine on them too. If you want to do a different operation on non-composites, wouldn't you have to define specialized methods for different type families anyway since they would all have

Re: [julia-users] Re: how to dispatch on an instance being a datatype

2015-05-01 Thread Josh Langsfeld
I vaguely remember Jeff saying after the tuple update something along the lines of 'typeof(typeof(x)) == DataType for all x now'. So as Tom mentioned, there won't be any cases when the not-a-datatype method will be called. On Friday, May 1, 2015 at 9:24:59 AM UTC-4, Tamas Papp wrote: Not

[julia-users] Re: idiom for range + offset

2015-04-29 Thread Josh Langsfeld
An inferior solution to range() is '(1:N) .+ i'. [without the parens, it's parsed as 1:(N .+ i) ] On Wednesday, April 29, 2015 at 10:22:23 AM UTC-4, Sebastian Good wrote: I find myself creating ranges of the form i:i+num-1. That is, the ith thing, and num more. Whenever I see a +1 or -1 I

Re: [julia-users] Yet Another String Concatenation Thread (was: Re: Naming convention)

2015-04-28 Thread Josh Langsfeld
I don't know why it hasn't been mentioned (it was hinted at by Tamas) but it seems to me the clear solution is for most of Base to actually be moved into submodules like 'LinAlg'. Then to use those names, people need to call 'using LinAlg' or 'using Sparse', etc... Somebody mentioned how

Re: [julia-users] Yet Another String Concatenation Thread (was: Re: Naming convention)

2015-04-28 Thread Josh Langsfeld
Turning named functions into methods of a generic function is definitely something Julia should take maximum advantage of. It does look like it should work well in the case of 'factorize'. But I think it's a bit unrelated from the naming convention issue. Most, if not the large majority, of

[julia-users] Re: Custom println with field name

2015-04-20 Thread Josh Langsfeld
To get custom printing of a user-defined type, you only have to overload the show method: julia type Pt x::Int y::Int end julia Pt(1,2) Pt(1,2) julia Base.show(io::IO, p::Pt) = print(io, Pt: x=$(p.x), y=$(p.y)) show (generic function with 86 methods) julia Pt(1,2) Pt:

[julia-users] Re: simultaneous minima of a set of function

2015-04-09 Thread Josh Langsfeld
Do you know apriori that the minima of f and g are at the same value of (x,y)? If so, then you can just minimize h(x,y) = f(x,y) + g(x,y). If the two minimums are located in different points, the problem does not seem sufficiently well-posed. On Thursday, April 9, 2015 at 4:19:31 PM UTC-4,

[julia-users] Re: Declaring a function taking a type not yet declared as argument.

2015-03-07 Thread Josh Langsfeld
It should be noted that this is an issue with circular dependencies and isn't specific to Julia at all. Sam's suggestions apply to software engineering in general, and not just this particular scenario. On Friday, March 6, 2015 at 5:30:13 PM UTC-5, Kristoffer Carlsson wrote: If I have a

[julia-users] Re: Using ModX: Can scope avoid collisions improve readability?

2015-03-06 Thread Josh Langsfeld
. Compilation is actually a separate step from using and import On Tuesday, March 3, 2015 at 11:48:53 AM UTC-5, Josh Langsfeld wrote: I'm curious about that workaround suggested in the FAQ, where you wrap the function inside its own module. What is happening under the hood there? Does

[julia-users] PyPlot figures

2015-03-04 Thread Josh Langsfeld
In PyPlot.jl, is there a way to create my figures and render them without a figure window getting created? My window manager is interfering with the size hint in the figure() function so it would be nice if I can go straight to a file. Thanks, Josh

[julia-users] Re: PyPlot figures

2015-03-04 Thread Josh Langsfeld
. Any idea how I can fix this? On Wednesday, March 4, 2015 at 11:32:01 AM UTC-5, Josh Langsfeld wrote: In PyPlot.jl, is there a way to create my figures and render them without a figure window getting created? My window manager is interfering with the size hint in the figure() function so

[julia-users] Re: PyPlot figures

2015-03-04 Thread Josh Langsfeld
Ok, I got it working by doing pygui(:qt) or pygui(:gtk) before the 'using PyPlot' call and mentioned in your docs. I'm not totally clear what 'non-interactive' means for the backend. Working directly in the REPL, is that not a default setting? And is that what I ended up changing with either

[julia-users] Re: General question about composite types

2015-03-03 Thread Josh Langsfeld
I believe if all your type fields are concrete (which they are in the case of Float64), the performance should be the same as using Vector{Float64}. This is really nice since you get to use code that is much more understandable like state.x instead of state[1] for no penalty. And if your state

[julia-users] Re: Using ModX: Can scope avoid collisions improve readability?

2015-03-03 Thread Josh Langsfeld
UTC+10, Josh Langsfeld wrote: It's discussed in the FAQ so there must be a good reason for it, though no rationale is mentioned. http://docs.julialang.org/en/latest/manual/faq/#can-i-use-using-or-import-inside-a-function On Monday, March 2, 2015 at 3:00:21 PM UTC-5, Patrick O'Leary wrote

[julia-users] Re: Using ModX: Can scope avoid collisions improve readability?

2015-03-02 Thread Josh Langsfeld
It's discussed in the FAQ so there must be a good reason for it, though no rationale is mentioned. http://docs.julialang.org/en/latest/manual/faq/#can-i-use-using-or-import-inside-a-function On Monday, March 2, 2015 at 3:00:21 PM UTC-5, Patrick O'Leary wrote: On Saturday, February 28, 2015 at

[julia-users] Re: Is string in Julia extendable?

2015-02-26 Thread Josh Langsfeld
It's equivalent to str = str * def. I believe that's the case for all +=, *=, etc operators and all types. On Thursday, February 26, 2015 at 9:23:19 AM UTC-5, Jerry Xiong wrote: Considering below code: str=abc str*=def Is the new string def just be appended after the memory space of abc,

Re: [julia-users] Re: Whats the deal with concatenation in 0.4!?

2015-02-25 Thread Josh Langsfeld
FYI, transposing currently doesn't work even on built-in arrays because it also calls transpose on each element as well. So it converts them all to Array{T,2} and then can't fit them back into a Array{Array{T,1},1}. On Wednesday, February 25, 2015 at 5:24:29 PM UTC-5, Jeff Bezanson wrote:

Re: [julia-users] Re: Whats the deal with concatenation in 0.4!?

2015-02-25 Thread Josh Langsfeld
Assuming transposing works, you could do [[a,a,a]' ; [a,a,a]'] which isn't entirely horrible On Wednesday, February 25, 2015 at 5:50:04 PM UTC-5, Simon Danisch wrote: Okay... So how do I realize: a = vec3(...) [ a a a ; a a a] Well, all I think is, that arrays of arrays get treated like

Re: [julia-users] Re: Whats the deal with concatenation in 0.4!?

2015-02-25 Thread Josh Langsfeld
something concatenates or just constructs. In this case, [b ; b] does indeed always have type Array{eltype(b)} and not Array{typeof(b)} (unless typeof(b) == Number). 2015-02-26 0:10 GMT+01:00 Josh Langsfeld jdla...@gmail.com: Assuming transposing works, you could do

[julia-users] Re: splice! function. Instead of removing a single item, remove a collection of items stored in an array.

2015-02-23 Thread Josh Langsfeld
(errors) splice!(data,errors[x]) end On Monday, February 23, 2015 at 8:17:29 AM UTC, Josh Langsfeld wrote: corrected_data = deleteat!(x, errors) should be what you're looking for. Alternately, a more functionally pure way to do it is to compute the good indices and then just do

[julia-users] Re: splice! function. Instead of removing a single item, remove a collection of items stored in an array.

2015-02-23 Thread Josh Langsfeld
corrected_data = deleteat!(x, errors) should be what you're looking for. Alternately, a more functionally pure way to do it is to compute the good indices and then just do corrected_data = x[good_idx], though this will make a copy of those elements of x. On Sunday, February 22, 2015 at 3:14:11

[julia-users] Re: Function that takes an abstract type and calls function depending on the concrete type passed.

2015-02-21 Thread Josh Langsfeld
If your initial knn function has logic that depends on the concrete type of tree being input, it's a sign you should refactor that logic into separate methods which are dispatched on by the concrete type. The simplest case of this would be to just pass that argument during setup to every _knn

[julia-users] Re: Numerical precision of simple mathematical operations

2015-02-12 Thread Josh Langsfeld
I don't see why you are only concerned about the value being negative. The number itself is completely meaningless since your calculation basically does the floating-point equivalent of divide zero by infinity. Anything that comes out can't be remotely trusted. I think you will need to

[julia-users] Re: Numerical precision of simple mathematical operations

2015-02-12 Thread Josh Langsfeld
of dividing s3 by d. On Thursday, February 12, 2015 at 10:13:42 AM UTC-5, Josh Langsfeld wrote: I don't see why you are only concerned about the value being negative. The number itself is completely meaningless since your calculation basically does the floating-point equivalent of divide zero

[julia-users] Re: Scanning the optional arguments of a function

2015-02-10 Thread Josh Langsfeld
that iterating over variables using symbols would be the thing to do, but maybe not. Cheers! On Monday, February 9, 2015 at 3:27:46 PM UTC-5, Josh Langsfeld wrote: Here's a macro that just has the effect of combining the code that would check each variable's length into a short form. It refers

[julia-users] Re: Scanning the optional arguments of a function

2015-02-09 Thread Josh Langsfeld
Here's a macro that just has the effect of combining the code that would check each variable's length into a short form. It refers to the input variables both by name and value. macro lencheck(l,vars...) exprs = Expr[] for v in vars sym = string(v) push!(exprs,:(if

[julia-users] Re: Scanning the optional arguments of a function

2015-02-08 Thread Josh Langsfeld
)* to *@eval $(myarg)*, the call prints *10*. On Sunday, February 8, 2015 at 10:57:43 PM UTC-5, Josh Langsfeld wrote: At least for why is doesn't work, the eval runs in the scope of the current module, not in the local scope of the function: julia myarg = a string a string julia f(myarg::Int

[julia-users] Re: Scanning the optional arguments of a function

2015-02-08 Thread Josh Langsfeld
At least for why is doesn't work, the eval runs in the scope of the current module, not in the local scope of the function: julia myarg = a string a string julia f(myarg::Int) = println(eval(:myarg)) f (generic function with 1 method) julia f(10) a string I don't know if there is a way to

[julia-users] Re: Type Annotations and Overloading Question

2015-02-04 Thread Josh Langsfeld
For me, option 1 looks the most Julian. Maybe the clunkiness is arising because the calc object shouldn't be a field of Atoms? Fields are just suppose to store data, not logic or methods. If a certain subtype of AbstractAtoms always uses the same calc object, then dispatching just on the atoms

[julia-users] Re: Type Annotations and Overloading Question

2015-02-04 Thread Josh Langsfeld
Sorry, disregard that last sentence which was supposed to have been edited out. On Wednesday, February 4, 2015 at 11:46:09 AM UTC-5, Josh Langsfeld wrote: For me, option 1 looks the most Julian. Maybe the clunkiness is arising because the calc object shouldn't be a field of Atoms? Fields

Re: [julia-users] Re: Type Annotations and Overloading Question

2015-02-04 Thread Josh Langsfeld
On Wed, Feb 4, 2015 at 2:29 PM, Christoph Ortner christophortn...@gmail.com wrote: If I read this correctly, then what you are saying is that I am allowed to assume that my concrete abstract subtypes will contain certain fields, and if they don't then too bad for them, they need to go and

  1   2   >