-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ProcessBuilder #22
Comments
OOP design patterns are obsolete in Julia and can't be directly used. However, multiple dispatch might be useful in processing:
with types |
Create and dispatch on a Node variable, analog to ProcessBuilder: # Build process graph using julia AST eval
import Base: convert, promote, promote_rule
import Base: +, -, *, /, cos, sqrt
struct Node
op
children::Vector
end
Node(x::Node) = x
Node(x) = Node("create", [x])
"Create Placeholder node e.g. for user defined functions in reducers and apply functions"
Node() = Node("create", [nothing])
convert(::Type{Node}, x) = Node(x)
convert(::Type{Node}, x::Node) = Node(x)
promote_rule(::Type{Node}, ::Type{T}) where {T<:Any} = Node
cos(x::Node) = Node("cos", [x])
sqrt(x::Node) = Node("sqrt", [x])
+(x::Node, y::Node) = Node("add", [x, y])
*(x::Node, y::Node) = Node("multiply", [x, y])
+(x::Node, y) = +(promote(x, y)...)
*(x::Node, y) = *(promote(x, y)...)
+(x, y::Node) = +(promote(x, y)...)
*(x, y::Node) = *(promote(x, y)...) resulting in
|
For functional processing patterns I think it would be nice to also rather overload Julias base functions as an alternative to the rather OOP-ish step2 = map(x -> x / 255, step1)
step3 = sum(step2, dims="t") |
Simple arithmetic is added in 8d21293 and branch danlooo/issue22. There was no need for promotion. Instead, the type DataCube was introduced with functions e.g. |
The python client of openEO allows to use normal Python operators resulting in clean and concise code:
The Operators (+,-,/) are implemented in the class
ProcessBuilder
.This is based on the builder design pattern in OOP that is helpful in abstract type conversions.
Can we use this in the Julia client?
The text was updated successfully, but these errors were encountered: