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
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 &
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
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 =
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 =
@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.
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::
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
>
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
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
10 matches
Mail list logo