Re: [julia-users] Re: Nullable{Date}
missed a paren above (for the people that are going to past the code into a shell and try it out) - something that I am not doing. Still, this is closer: # wishful thinking... using Dates; leapDay = isleapyear(yr) ? Date(yr,2,29) : nothing if ! leapDay doy = dayofyear( leapDay ) ... clean and concise (thought that was the point), but we get leapDay = isleapyear (yr)? Nullable {Date} (Date (yr, 2:29)): Nullable {Date} () if ! isnull( leapDay ) doy = dayofyear( get(leapDay) ) On Tue, Feb 9, 2016 at 8:22 PM, Michael Landis <darkskyanar...@gmail.com> wrote: > # wishful thinking... > using Dates; > leapDay = isleapyear(yr) ? Date(yr,2,29) : nothing > if ! leapDay > dow = dayofyear( leapDay ) > ... clean and concise (thought that was the point), but we get > > leapDay = isleapyear(yr) ? Nullable{Date}( Date(yr,2,29) : Nullable{Date}() > if ! isnull( leapDay ) > dow = dayofyear( get(leapDay) ) > ... > > If I am dumb enough to forget to check for a null date, I deserve the > exception - the code would be wrong. Making me type two or three times as > many characters, obscuring what is actually going on, ... all to eliminate > NullPointerExceptions? I have to write exception free code anyway, so all > I have 'gained' is a lot of superfluous verbosity. I'm going to side with > salience over verbosity every time. The type safe argument just doesn't > sell me, sorry. >
Re: [julia-users] Re: Nullable{Date}
# wishful thinking... using Dates; leapDay = isleapyear(yr) ? Date(yr,2,29) : nothing if ! leapDay dow = dayofyear( leapDay ) ... clean and concise (thought that was the point), but we get leapDay = isleapyear(yr) ? Nullable{Date}( Date(yr,2,29) : Nullable{Date}() if ! isnull( leapDay ) dow = dayofyear( get(leapDay) ) ... If I am dumb enough to forget to check for a null date, I deserve the exception - the code would be wrong. Making me type two or three times as many characters, obscuring what is actually going on, ... all to eliminate NullPointerExceptions? I have to write exception free code anyway, so all I have 'gained' is a lot of superfluous verbosity. I'm going to side with salience over verbosity every time. The type safe argument just doesn't sell me, sorry.
[julia-users] Nullable{Date}
I'm so confused I thought this would be cool: isLeapYr(yr::Int64) = yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0) LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}() lp15 = LeapDay(2015) --> Nullable{Date}() lp16 = LeapDay(2016) --> 2016-02-29 no surprises there, but when I test the return values ... isnull( lp15 ) --> true isnull( lp16 ) --> MethodError: `isnull` has no method matching isnull( ::Date ) What IS the secret Nullable{Date} formulation?
Re: [julia-users] Re: Nullable{Date}
Why can't there be a base type upon which all others are based (perhaps by default)? The base class could handle the Nullable situation and everything else would magically inherit that capability. Making a union of a NULL and the actual type is pretty painful for the programmer. Weren't we going for a smart compiler that would make life easier on the programmer? What we have now is programmers going out of their way to make life easy for the compiler. That seems back-assward to me.
Re: [julia-users] Nullable{Date}
Thanks Erik. Much appreciated... On Mon, Feb 8, 2016 at 7:11 PM, Erik Schnetter <schnet...@gmail.com> wrote: > You need to write > > LeapDay(yr) = isLeapYr(yr) ? Nullable(Date(yr,2,29)) : Nullable{Date}() > > so that the return value is always a Nullable{Date}. > > -erik > > On Mon, Feb 8, 2016 at 10:08 PM, Michael Landis > <darkskyanar...@gmail.com> wrote: > > I'm so confused > > > > I thought this would be cool: > > isLeapYr(yr::Int64) = yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0) > > LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}() > > > > lp15 = LeapDay(2015) --> Nullable{Date}() > > lp16 = LeapDay(2016) --> 2016-02-29 > > > > no surprises there, but when I test the return values ... > > > > isnull( lp15 ) --> true > > isnull( lp16 ) --> MethodError: `isnull` has no method matching isnull( > > ::Date ) > > > > What IS the secret Nullable{Date} formulation? > > > > -- > Erik Schnetter <schnet...@gmail.com> > http://www.perimeterinstitute.ca/personal/eschnetter/ >
Re: [julia-users] Nullable{Date}
I know there's a language theorist out there that thinks having typed Nullables confers some sort of linguistic purity, but I think it's a royal pain. Every function needs to know whether Nullable is possible from all of it's callers? What you gain in semantic purity, you pay for in the configuration back end. I thought the whole point of the language was write what you mean. Typed Nullables seem counter to that strategic objective. On Mon, Feb 8, 2016 at 7:11 PM, Erik Schnetter <schnet...@gmail.com> wrote: > You need to write > > LeapDay(yr) = isLeapYr(yr) ? Nullable(Date(yr,2,29)) : Nullable{Date}() > > so that the return value is always a Nullable{Date}. > > -erik > > On Mon, Feb 8, 2016 at 10:08 PM, Michael Landis > <darkskyanar...@gmail.com> wrote: > > I'm so confused > > > > I thought this would be cool: > > isLeapYr(yr::Int64) = yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0) > > LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}() > > > > lp15 = LeapDay(2015) --> Nullable{Date}() > > lp16 = LeapDay(2016) --> 2016-02-29 > > > > no surprises there, but when I test the return values ... > > > > isnull( lp15 ) --> true > > isnull( lp16 ) --> MethodError: `isnull` has no method matching isnull( > > ::Date ) > > > > What IS the secret Nullable{Date} formulation? > > > > -- > Erik Schnetter <schnet...@gmail.com> > http://www.perimeterinstitute.ca/personal/eschnetter/ >
Re: [julia-users] Re: Nullable{Date}
ah, cool. Missed that. Thanks. The pain in returning a Nullable{Date} is that now I have to unpack it for things like dayofyear(). Nullable introduces a rat's nest of unnecessary complications. On Mon, Feb 8, 2016 at 7:35 PM, Christopher Alexander <uvapa...@gmail.com> wrote: > For a null date, I usually just use Date() (Dates.Date()), which returns > Jan 1, 0001. Also, you know that there is already a method to check > whether or not a year is a leap year right? > > Dates.isleapyear(y), returns a Bool. > http://docs.julialang.org/en/release-0.4/manual/dates/ > > > On Monday, February 8, 2016 at 10:08:25 PM UTC-5, Michael Landis wrote: >> >> I'm so confused >> >> I thought this would be cool: >> isLeapYr(yr::Int64) = yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0) >> LeapDay(yr) = isLeapYr(yr) ? Date(yr,2,29) : Nullable{Date}() >> >> lp15 = LeapDay(2015) --> Nullable{Date}() >> lp16 = LeapDay(2016) --> 2016-02-29 >> >> no surprises there, but when I test the return values ... >> >> isnull( lp15 ) --> true >> isnull( lp16 ) --> MethodError: `isnull` has no method matching isnull( >> ::Date ) >> >> What IS the secret Nullable{Date} formulation? >> >
Re: [julia-users] Queue{ByteString} acting strangely
ah, Queue's don't need to be typed, the type is a parameter to the constructor. Parens, not braces. So, why are Vectors defined as Vector{ByteString}(vecLength)? Where is the syntactical consistency? On Thursday, February 4, 2016 at 2:47:52 PM UTC-8, Yichao Yu wrote: > > On Thu, Feb 4, 2016 at 5:43 PM, Michael Landis <darksky...@gmail.com > > wrote: > > so ... what's the syntax for creating an empty Queue{ByteString}? > > > > qbs = Queue{ByteString}([])# also produces convert errors > > I think the document tells you exactly that. > https://github.com/JuliaLang/DataStructures.jl#stack-and-queue > > Queue(ByteString) seems to work. > > > > > > >> > > >
[julia-users] Queue{ByteString} acting strangely
DataStructures.Queue is doing strange things for me. Can someone please post proper syntax for forward declarations of an empty Queue{ByteString} and maybe an in-line instantiation (if different) so I can be sure that I am getting the declarations right? When I do: using DataStructures; qbs = Queue{ByteString}() # --> convert errors qbs = Queue{ByteString}(0)# --> convert errors qbs = Queue{ByteString}("") # --> no errors, so ok? typeof(qbs) # --> DataStructures.Queue{ByteString} (so far, so good) length(qbs) # --> 0 (hmmm) # which seems ok, but ... qbs = Queue{ByteString}("1234") # ok typeof(qbs) # --> DataStructures.Queue{ByteString} length(qbs) # --> 4 ??? why not 1? enqueue!(qbs, "xyz") # --> MethodError: `push!` has no method matching push!(::ASCIIString, ::ASCIIString ) in queue.jl:17 x = dequeue!( qbs ) # --> MethodError: `shift!` has no method matching shift!(::ASCIIString) in ... dequeue! at queue.jl:21 so... I am growing increasingly mystified. How can the type be right when you ask for it, but wrong when you use it? Maybe I'm declaring it wrong? Any insight or suggestions would be appreciated.
Re: [julia-users] Queue{ByteString} acting strangely
assuming that you know more than I do (a likely circumstance), how do you explain... qbs = Queue{ByteString}("1234") # ok typeof(qbs) # --> DataStructures.Queue{ByteString} length(qbs) # --> 4, presumably the result of enqueuing "1", "2", "3", "4" as you suggest # then, why does the following... dequque!(qbs) # fails with MethodError: `shift!` has no method matching shift!(::ASCIIString) # why not just produce "1" (or "4")? On Thursday, February 4, 2016 at 1:52:51 PM UTC-8, Stefan Karpinski wrote: > > The Queue constructor (like all collection constructors) takes a > collection which it iterates over and converts each value it gets to the > expected element type – in this case ByteString. If you iterate over "1234" > you get '1' then '2' then '3' then '4' – each of which is converted to a > string and then inserted into your queue. > >
Re: [julia-users] Re: how to undefine variable in composite types
They would be invalid too. I know... no garbage collector, so it would be necessary to find the inbound references. Smart pointers maybe? Yet another performance hit. On Thursday, February 4, 2016 at 1:54:24 PM UTC-8, Stefan Karpinski wrote: > > How does one "release" an object? What happens to other objects that > retain references to those objects? > > On Thu, Feb 4, 2016 at 4:35 PM, Michael Landis <darksky...@gmail.com > > wrote: > >> if you added a field, the existing objects could still be valid. If you >> killed an attribute, they are invalid and can be released. >> >> On Thursday, February 4, 2016 at 10:55:25 AM UTC-8, Stefan Karpinski >> wrote: >>> >>> What happens to existing objects of a type when you redefine the type? >>> >>> On Thu, Feb 4, 2016 at 1:46 PM, Michael Landis <darksky...@gmail.com> >>> wrote: >>> >>>> I think it would be nice to be able to undefine a type, so restarting >>>> the environment is not required when adding or deleting an attribute from >>>> a >>>> type description. Not being able to update a type definition without >>>> restarting the environment is a royal pain in the ass. >>>> >>>> >>>> On Saturday, March 8, 2014 at 9:55:37 AM UTC-8, Freddy Chua wrote: >>>>> >>>>> Suppose I have a Type >>>>> >>>>> type Foo >>>>> a >>>>> b >>>>> end >>>>> >>>>> f = Foo(1,2) >>>>> f.a = 1 >>>>> f.b = 2 >>>>> >>>>> how do I test whether f.a is defined >>>>> I do this isdefined(f, 1) but isdefined(f, 'a') does not work >>>>> >>>>> another question >>>>> how do i undefine f.a such that isdefined(f,1) now returns false >>>>> >>>> >>> >
Re: [julia-users] Re: how to undefine variable in composite types
if you added a field, the existing objects could still be valid. If you killed an attribute, they are invalid and can be released. On Thursday, February 4, 2016 at 10:55:25 AM UTC-8, Stefan Karpinski wrote: > > What happens to existing objects of a type when you redefine the type? > > On Thu, Feb 4, 2016 at 1:46 PM, Michael Landis <darksky...@gmail.com > > wrote: > >> I think it would be nice to be able to undefine a type, so restarting the >> environment is not required when adding or deleting an attribute from a >> type description. Not being able to update a type definition without >> restarting the environment is a royal pain in the ass. >> >> >> On Saturday, March 8, 2014 at 9:55:37 AM UTC-8, Freddy Chua wrote: >>> >>> Suppose I have a Type >>> >>> type Foo >>> a >>> b >>> end >>> >>> f = Foo(1,2) >>> f.a = 1 >>> f.b = 2 >>> >>> how do I test whether f.a is defined >>> I do this isdefined(f, 1) but isdefined(f, 'a') does not work >>> >>> another question >>> how do i undefine f.a such that isdefined(f,1) now returns false >>> >> >
Re: [julia-users] Queue{ByteString} acting strangely
so ... what's the syntax for creating an empty Queue{ByteString}? qbs = Queue{ByteString}([])# also produces convert errors >
Re: [julia-users] Queue{ByteString} acting strangely
Thanks for the clarifications... Good to know which code is scheduled for an update later too. On Thursday, February 4, 2016 at 3:22:00 PM UTC-8, Stefan Karpinski wrote: > > The Queue constructors seem to be lagging the newer convention in Julia. > In older versions of Julia it was not possible to do Queue{ByteString}() or > Vector{ByteString}(). > > On Thu, Feb 4, 2016 at 5:56 PM, Michael Landis <darksky...@gmail.com > > wrote: > >> ah, Queue's don't need to be typed, the type is a parameter to the >> constructor. Parens, not braces. So, why are Vectors defined as >> Vector{ByteString}(vecLength)? Where is the syntactical consistency? >> >> On Thursday, February 4, 2016 at 2:47:52 PM UTC-8, Yichao Yu wrote: >>> >>> On Thu, Feb 4, 2016 at 5:43 PM, Michael Landis <darksky...@gmail.com> >>> wrote: >>> > so ... what's the syntax for creating an empty Queue{ByteString}? >>> > >>> > qbs = Queue{ByteString}([])# also produces convert errors >>> >>> I think the document tells you exactly that. >>> https://github.com/JuliaLang/DataStructures.jl#stack-and-queue >>> >>> Queue(ByteString) seems to work. >>> >>> > >>> > >>> >> >>> > >>> >> >
[julia-users] Re: how to undefine variable in composite types
I think it would be nice to be able to undefine a type, so restarting the environment is not required when adding or deleting an attribute from a type description. Not being able to update a type definition without restarting the environment is a royal pain in the ass. On Saturday, March 8, 2014 at 9:55:37 AM UTC-8, Freddy Chua wrote: > > Suppose I have a Type > > type Foo > a > b > end > > f = Foo(1,2) > f.a = 1 > f.b = 2 > > how do I test whether f.a is defined > I do this isdefined(f, 1) but isdefined(f, 'a') does not work > > another question > how do i undefine f.a such that isdefined(f,1) now returns false >
Re: [julia-users] Re: recommended graphics packages for multiple curves on a single canvas
I would appreciate suggestions on which back-end might best facilitate visualizing and manipulating a six dimensional model, maybe using three dimensional projections where the user can select (via check box?) any three dimensions and subsequently rotate/zoom the resulting 3D projection. On Monday, February 1, 2016 at 6:45:46 AM UTC-8, Tom Breloff wrote: > > Michael: If you have a specific plot-type in mind let me know... I'm > usually pretty quick to whip up an example or point you in the right > direction. Not all features are documented well (yet) so it might be > faster to ask for help. > > On Mon, Feb 1, 2016 at 4:48 AM, Michael Landis <darksky...@gmail.com > > wrote: > >> Gadfly already working. I will look at Breloff's Plots too. Thanks. >> >> >> >
[julia-users] Re: recommended graphics packages for multiple curves on a single canvas
Gadfly already working. I will look at Breloff's Plots too. Thanks.
[julia-users] recommended graphics packages for multiple curves on a single canvas
Can anyone recommend a graphics capable of plotting multiple curves on a single canvas. Python's pyplot/matplotlib multi-curve capabilities appear to be unavailable within Julia (maybe I'm doing it wrong).
[julia-users] unix timestamp to DateTime & divexact errors
Is there a language convention for converting/comparing unix timestamps (e.g. file modify dates) and DateTimes? When I do: fs = stat( "X.csv" ); ms = now() - fs.mtime; typeof(ms) --> Base.Dates.Millisecond, even though now() is a DateTime # you would think that creating a DateTime, would make them comparable, but dt = DateTime( fs.mtime ); # still has fractional seconds in it, so computations with dt and constructed DateTimes produce divexact errors What's the best stylistic workaround for that?
[julia-users] Re: unix timestamp to DateTime & divexact errors
# Even after dt = trunc(dt,Second); I am still seeing divexact errors... On Friday, January 29, 2016 at 12:44:35 PM UTC-8, Michael Landis wrote: > > Is there a language convention for converting/comparing unix timestamps > (e.g. file modify dates) and DateTimes? > > When I do: > fs = stat( "X.csv" ); > ms = now() - fs.mtime; > typeof(ms) --> Base.Dates.Millisecond, even though now() is a DateTime > > # you would think that creating a DateTime, would make them comparable, but > dt = DateTime( fs.mtime ); > # still has fractional seconds in it, so computations with dt and > constructed DateTimes produce divexact errors > > What's the best stylistic workaround for that? > > >
[julia-users] Re: DateTime business days, Wall Street days, ...
Wow, I will give that a try. Thank you! On Thursday, January 28, 2016 at 6:52:38 AM UTC-8, Michael Landis wrote: > > Maybe I'm missing something, but the one thing I want from DateTime is the > ability to determine whether a day has elapsed since a file modify date, > but not just a calendar day... at least a business day (i.e. Saturdays and > Sundays don't count), but even better if a calendar could skip past > government and/or business holidays too, so elapsed days are only the > meaningful ones, weekends and business holidays would not increment a > business days elapsed counter. > > For example, if you have downloaded daily closing stock prices at 8PM on > Friday the 29th of January, there's no point in downloading them again > until after the close of trading Monday, February 1st, but if you > originally downloaded them at 2PM on Friday the 29th of January, you will > get one more result by downloading them again at 8PM that same day. It > gets even more interesting when you throw time zone into the mix. The > markets are still actively trading at 6:30 PM Pacific Time. Need DateTime > functions that will aid in making those decisions. Is this being > considered for Julia and if not, should it be? >
[julia-users] Re: Julia Vector declare/load confusion
Both zeros(Float32,nFullYears) and Vector(Float32,nFullYears) work. Thanks! I overwrite any contents, so unitialized is fine. There are rarely as many as forty of these (though there are four such vectors per issue), so it does add up, so I the performance analysis is much appreciated too. On Wednesday, January 27, 2016 at 10:26:09 PM UTC-8, Michael Landis wrote: > > I am trying to compute some historical means and volatilities with Julia, > but I've been having some difficulty getting the declarations and/or > assignments right... > > When I try a declaration, like either of these: > adjCloseMuVec::Vector{Float32}; # or... > adjCloseMuVec::Vector{Float32,nFullYears}; > I get: UndefVarError: adjCloseMuVec not defined > > When I try: > adjCloseMuVec = Vector{Float32}; # and later try: > reshape(adjCloseMuVec,nFullYears); > I get: MethodError: `reshape` has no method matching > reshape(::Type{Array{Float32,1}}, ::Int32) > > When I try: > adjCloseMuVec = Vector{Float32,nFullYears}; > I get: too many parameters for type typealias > > So, the only acceptable path would seem to be: > adjCloseMuVec = Vector{Float32}; > but when I later try: > adjCloseMuVec[curYr] = Float32(adjCloseMu); # or... > setindex!(adjCloseMuVec, Float32(adjCloseMu), curYr); > I get: MethodError: `setIndex!` has no method matching > setindex!(::Type{Array{Float32,1}}, ::Float32, ::Int64) > > So, I'm mystified as to the correct syntax. Any suggestions on an > acceptable way to declare a Vector of Int32 and load values into it? >
Re: [julia-users] Re: DateTime business days, Wall Street days, ...
My first impression on BusinessDays is that it's a brute force, first cut solution. For a small range of days it's probably just fine, but over several years performance is going to take a hit because every day in the range gets evaluated and every evaluation considers the entire set of holidays for a computational complexity of O(days-in-range*holidays-in-set). Days in range is bound to be a much larger set than the set of holidays in that same range, so it could be improved by chopping the range into three parts, the from-week, the to-week, and everything in between. The in-between set automatically has two non-business days per week that you don't have to enumerate day by day. Then you address the business days in the endpoint weeks and subtract the holidays in the range. Likewise, every full year will have a set of holidays that are guaranteed to land on a weekday (by fiat), so those are automatically out. Conditional ones, like New Years Day (which don't result in a holiday when it occurs on the weekend still have to be enumerated, but if you're covering a really large span of years, you can count on the fact that (I think) there are only 28 unique years, so you if you are covering a span of centuries, you can execute a middle and endpoint strategy there too, though it's quite a bit messier than figuring New Years Days holidays. On Thursday, January 28, 2016 at 8:19:41 AM UTC-8, Tom Breloff wrote: > > Also check out Ito.jl and TimeZones.jl. It seems that both Ito.jl and > BusinessDays.jl are geared towards bond trading, so I'm not sure how well > they work for general queries. If you find you have opinions about the > strengths/weaknesses of any of these packages, please post here! > > On Thu, Jan 28, 2016 at 10:16 AM, Michael Landis <darksky...@gmail.com > > wrote: > >> Wow, I will give that a try. Thank you! >> >> On Thursday, January 28, 2016 at 6:52:38 AM UTC-8, Michael Landis wrote: >>> >>> Maybe I'm missing something, but the one thing I want from DateTime is >>> the ability to determine whether a day has elapsed since a file modify >>> date, but not just a calendar day... at least a business day (i.e. >>> Saturdays and Sundays don't count), but even better if a calendar could >>> skip past government and/or business holidays too, so elapsed days are only >>> the meaningful ones, weekends and business holidays would not increment a >>> business days elapsed counter. >>> >>> For example, if you have downloaded daily closing stock prices at 8PM on >>> Friday the 29th of January, there's no point in downloading them again >>> until after the close of trading Monday, February 1st, but if you >>> originally downloaded them at 2PM on Friday the 29th of January, you will >>> get one more result by downloading them again at 8PM that same day. It >>> gets even more interesting when you throw time zone into the mix. The >>> markets are still actively trading at 6:30 PM Pacific Time. Need DateTime >>> functions that will aid in making those decisions. Is this being >>> considered for Julia and if not, should it be? >>> >> >
[julia-users] DateTime business days, Wall Street days, ...
Maybe I'm missing something, but the one thing I want from DateTime is the ability to determine whether a day has elapsed since a file modify date, but not just a calendar day... at least a business day (i.e. Saturdays and Sundays don't count), but even better if a calendar could skip past government and/or business holidays too, so elapsed days are only the meaningful ones, weekends and business holidays would not increment a business days elapsed counter. For example, if you have downloaded daily closing stock prices at 8PM on Friday the 29th of January, there's no point in downloading them again until after the close of trading Monday, February 1st, but if you originally downloaded them at 2PM on Friday the 29th of January, you will get one more result by downloading them again at 8PM that same day. It gets even more interesting when you throw time zone into the mix. The markets are still actively trading at 6:30 PM Pacific Time. Need DateTime functions that will aid in making those decisions. Is this being considered for Julia and if not, should it be?
[julia-users] Julia Vector declare/load confusion
I am trying to compute some historical means and volatilities with Julia, but I've been having some difficulty getting the declarations and/or assignments right... When I try a declaration, like either of these: adjCloseMuVec::Vector{Float32}; # or... adjCloseMuVec::Vector{Float32,nFullYears}; I get: UndefVarError: adjCloseMuVec not defined When I try: adjCloseMuVec = Vector{Float32}; # and later try: reshape(adjCloseMuVec,nFullYears); I get: MethodError: `reshape` has no method matching reshape(::Type{Array{Float32,1}}, ::Int32) When I try: adjCloseMuVec = Vector{Float32,nFullYears}; I get: too many parameters for type typealias So, the only acceptable path would seem to be: adjCloseMuVec = Vector{Float32}; but when I later try: adjCloseMuVec[curYr] = Float32(adjCloseMu); # or... setindex!(adjCloseMuVec, Float32(adjCloseMu), curYr); I get: MethodError: `setIndex!` has no method matching setindex!(::Type{Array{Float32,1}}, ::Float32, ::Int64) So, I'm mystified as to the correct syntax. Any suggestions on an acceptable way to declare a Vector of Int32 and load values into it?
[julia-users] Re: Julia Vector declare/load confusion
Correction: a fixed size Vector of Float32 On Wednesday, January 27, 2016 at 10:26:09 PM UTC-8, Michael Landis wrote: > > I am trying to compute some historical means and volatilities with Julia, > but I've been having some difficulty getting the declarations and/or > assignments right... > > When I try a declaration, like either of these: > adjCloseMuVec::Vector{Float32}; # or... > adjCloseMuVec::Vector{Float32,nFullYears}; > I get: UndefVarError: adjCloseMuVec not defined > > When I try: > adjCloseMuVec = Vector{Float32}; # and later try: > reshape(adjCloseMuVec,nFullYears); > I get: MethodError: `reshape` has no method matching > reshape(::Type{Array{Float32,1}}, ::Int32) > > When I try: > adjCloseMuVec = Vector{Float32,nFullYears}; > I get: too many parameters for type typealias > > So, the only acceptable path would seem to be: > adjCloseMuVec = Vector{Float32}; > but when I later try: > adjCloseMuVec[curYr] = Float32(adjCloseMu); # or... > setindex!(adjCloseMuVec, Float32(adjCloseMu), curYr); > I get: MethodError: `setIndex!` has no method matching > setindex!(::Type{Array{Float32,1}}, ::Float32, ::Int64) > > So, I'm mystified as to the correct syntax. Any suggestions on an > acceptable way to declare a Vector of Int32 and load values into it? >
[julia-users] why does in(x,y) not follow the usual syntax of built-ins?
Most Julia built-ins are defined so that the first argument is the (Smalltalk style) message receiver, but in(x,y) reverses the apparent standard, testing whether x is in y (the message receiver). append(x,y) appends y to x (the message receiver); push(x,y) pushes y onto x (the message receiver); in(x,y) should test whether y is in x, not the syntactic reverse. IMO, defeating syntactic orthogonality is a mistake. What's the justification for 'in()' violating the usual message receiver syntax?
[julia-users] why does in(x,y) not follow the usual semantics of built-ins?
Most Julia built-ins are defined so that the first argument is the (Smalltalk style) message receiver, but in(x,y) reverses the apparent standard, testing whether x is in y (the message receiver). append(x,y) appends y to x (the message receiver); push(x,y) pushes y onto x (the message receiver); in(x,y) should test whether y is in x, not the reverse. IMO, defeating orthogonality is a mistake. What's the justification for 'in()' violating the usual message receiver semantics?
[julia-users] Re: why does in(x,y) not follow the usual semantics of built-ins?
if the Julia syntax was actually x in y, I'd have less of an objection, but while it looks like a function call, the message receiver should be the first argument. On Sunday, January 11, 2015 at 1:10:28 PM UTC-8, Jake Bolewski wrote: `in` is most often used with infix notation (ex. 1 in [1,2,3])? On Sunday, January 11, 2015 at 4:00:37 PM UTC-5, Michael Landis wrote: Most Julia built-ins are defined so that the first argument is the (Smalltalk style) message receiver, but in(x,y) reverses the apparent standard, testing whether x is in y (the message receiver). append(x,y) appends y to x (the message receiver); push(x,y) pushes y onto x (the message receiver); in(x,y) should test whether y is in x, not the reverse. IMO, defeating orthogonality is a mistake. What's the justification for 'in()' violating the usual message receiver semantics?