Re: [julia-users] Best method for inputting logic as a variable in a function

2015-12-02 Thread Tomas Lycken
Martin Fowler published a (rather long) blog post on the topic of refactoring code into data, which I think is a nice addition in this thread even though you already have a working solution: http://martinfowler.com/articles/refactoring-adaptive-model.html His solution to this problem would

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-12-01 Thread NotSoRecentConvert
It worked quite well. Here is the latest version. function qcl_valve_plot(Dr::AbstractString,mindate::DateTime,maxdate:: DateTime,dt::Dates.Period,col::Symbol,valveLogic::Function) ... # Valve Zones f4 = [] f4 = find(valveLogic(statuses) .== true) One of the valveLogic examples, "(V3 & !(V1 &

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread Tim Holy
You can use functions as variables, and that's far better than eval'ing a string. For example: julia> filter(x->x>0, [1,2,-3,5]) 3-element Array{Int64,1}: 1 2 5 See the manual section on "anonymous functions." --Tim On Monday, November 30, 2015 06:35:59 AM NotSoRecentConvert wrote: > I

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread Milan Bouchet-Valat
Le lundi 30 novembre 2015 à 07:25 -0800, NotSoRecentConvert a écrit : > D = [1:10;] > statusesValve1 = > [false;false;true;true;true;false;true;true;true;false] > valveLogic = "V1 == true" > > # Valve Zones > f4 = [] > valveLogic = replace(valveLogic," =="," .==") > valveLogic =

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread NotSoRecentConvert
D = [1:10;] statusesValve1 = [false;false;true;true;true;false;true;true;true;false] valveLogic = "V1 == true" # Valve Zones f4 = [] valveLogic = replace(valveLogic," =="," .==") valveLogic = replace(valveLogic,"V","statusesValve") valveLogic = "find(" * valveLogic * ")" f4 =

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread NotSoRecentConvert
@Tim Holy, I thought about that but wasn't sure how I'd deal with variable inputs. It should be able to use any of four valves (statuses.Valve1, statuses.Valve2, etc.) in any combination and number. I'll take another look.

[julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread NotSoRecentConvert
I've written a function which loads a bunch of data and plots individual periods where valves are in a certain configuration. My function works but I am curious about best methods. function qcl_valve_plot(Dr::AbstractString,mindate::DateTime,maxdate::

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread Milan Bouchet-Valat
Le lundi 30 novembre 2015 à 04:20 -0800, NotSoRecentConvert a écrit : > I've written a function which loads a bunch of data and plots > individual periods where valves are in a certain configuration. My > function works but I am curious about best methods. > > function >

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread NotSoRecentConvert
I need to plot data (D::DataFrame) during certain valve configurations. Each row of data has a corresponding status value for each valve (statuses.Valve#). First I have to find the periods of time where the valves were in that configuration. Then I can plot the chosen column of data

Re: [julia-users] Best method for inputting logic as a variable in a function

2015-11-30 Thread Milan Bouchet-Valat
Le lundi 30 novembre 2015 à 06:35 -0800, NotSoRecentConvert a écrit : > I need to plot data (D::DataFrame) during certain valve > configurations. Each row of data has a corresponding status value for > each valve (statuses.Valve#). First I have to find the periods of > time where the valves were