Skip to content

Commit

Permalink
feat(stdlib): add xod/core/arity-level, xod/core/average nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenykochetkov committed Mar 4, 2021
1 parent f8e0c0b commit b17f125
Show file tree
Hide file tree
Showing 8 changed files with 508 additions and 0 deletions.
6 changes: 6 additions & 0 deletions workspace/__lib__/xod/core/arity-level-internal/patch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

node {
void evaluate(Context ctx) {
emitValue<output_OUT>(ctx, getValue<input_IN1>(ctx) + 1);
}
}
58 changes: 58 additions & 0 deletions workspace/__lib__/xod/core/arity-level-internal/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"nodes": [
{
"id": "HJk7Ze2M_",
"position": {
"units": "slots",
"x": 4,
"y": 1
},
"type": "xod/patch-nodes/variadic-1"
},
{
"id": "BJBQbx3Md",
"position": {
"units": "slots",
"x": 1,
"y": 1
},
"type": "xod/patch-nodes/not-implemented-in-xod"
},
{
"id": "ry9mWx3fd",
"position": {
"units": "slots",
"x": 2,
"y": 0
},
"type": "xod/patch-nodes/input-t1"
},
{
"id": "S1gVWl2Md",
"position": {
"units": "slots",
"x": 1,
"y": 0
},
"type": "xod/patch-nodes/input-number"
},
{
"id": "SkLNbxnfO",
"position": {
"units": "slots",
"x": 1,
"y": 2
},
"type": "xod/patch-nodes/output-number"
},
{
"id": "SJj4Ze3zO",
"position": {
"units": "slots",
"x": 5,
"y": 1
},
"type": "xod/patch-nodes/utility"
}
]
}
65 changes: 65 additions & 0 deletions workspace/__lib__/xod/core/arity-level/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"description": "When connected to a variadic-pass input, outputs arity level of parent node",
"links": [
{
"id": "ry2DSx3G_",
"input": {
"nodeId": "rkKPBe2G_",
"pinKey": "ry9mWx3fd"
},
"output": {
"nodeId": "B1DIHlhzu",
"pinKey": "__out__"
}
},
{
"id": "r16wrx3fO",
"input": {
"nodeId": "HJTUBe3f_",
"pinKey": "__in__"
},
"output": {
"nodeId": "rkKPBe2G_",
"pinKey": "SkLNbxnfO"
}
}
],
"nodes": [
{
"id": "HyCrHxnzO",
"position": {
"units": "slots",
"x": 3,
"y": 1
},
"type": "xod/patch-nodes/variadic-pass-1"
},
{
"id": "B1DIHlhzu",
"position": {
"units": "slots",
"x": 1,
"y": 0
},
"type": "xod/patch-nodes/input-t1"
},
{
"id": "HJTUBe3f_",
"position": {
"units": "slots",
"x": 0,
"y": 2
},
"type": "xod/patch-nodes/output-number"
},
{
"id": "rkKPBe2G_",
"position": {
"units": "slots",
"x": 0,
"y": 1
},
"type": "@/arity-level-internal"
}
]
}
116 changes: 116 additions & 0 deletions workspace/__lib__/xod/core/average/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"description": "Adds the input values together and divides by the number of values",
"links": [
{
"id": "Bk4hHl3Gd",
"input": {
"nodeId": "ByG2rlnfu",
"pinKey": "HkqmLAOrD1W"
},
"output": {
"nodeId": "rJG5SlhGu",
"pinKey": "__out__"
}
},
{
"id": "HJv3SxnMd",
"input": {
"nodeId": "S10jrlhG_",
"pinKey": "B1DIHlhzu"
},
"output": {
"nodeId": "rJG5SlhGu",
"pinKey": "__out__"
}
},
{
"id": "rks2Bl2Mu",
"input": {
"nodeId": "Sytnrx3Mu",
"pinKey": "SkdIRuBD1b"
},
"output": {
"nodeId": "ByG2rlnfu",
"pinKey": "SyomIRurDJ-"
}
},
{
"id": "SJhhSe2Gd",
"input": {
"nodeId": "Sytnrx3Mu",
"pinKey": "BytUCdHD1-"
},
"output": {
"nodeId": "S10jrlhG_",
"pinKey": "HJTUBe3f_"
}
},
{
"id": "BJ62He2f_",
"input": {
"nodeId": "BJgjHe3Mu",
"pinKey": "__in__"
},
"output": {
"nodeId": "Sytnrx3Mu",
"pinKey": "BkqLCOSw1W"
}
}
],
"nodes": [
{
"id": "rJG5SlhGu",
"position": {
"units": "slots",
"x": 1,
"y": 0
},
"type": "xod/patch-nodes/input-number"
},
{
"id": "S1wcrgnfu",
"position": {
"units": "slots",
"x": 5,
"y": 1
},
"type": "xod/patch-nodes/variadic-pass-1"
},
{
"id": "BJgjHe3Mu",
"position": {
"units": "slots",
"x": 1,
"y": 3
},
"type": "xod/patch-nodes/output-number"
},
{
"id": "S10jrlhG_",
"position": {
"units": "slots",
"x": 3,
"y": 1
},
"type": "@/arity-level"
},
{
"id": "ByG2rlnfu",
"position": {
"units": "slots",
"x": 0,
"y": 1
},
"type": "@/add"
},
{
"id": "Sytnrx3Mu",
"position": {
"units": "slots",
"x": 1,
"y": 2
},
"type": "@/divide"
}
]
}
2 changes: 2 additions & 0 deletions workspace/test/test-core/test-arity-level/patch.test.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OUT1 OUT2 OUT3
1 2 6
113 changes: 113 additions & 0 deletions workspace/test/test-core/test-arity-level/patch.xodp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"links": [
{
"id": "BJ5oSGTzO",
"input": {
"nodeId": "SytiSzTGO",
"pinKey": "__in__"
},
"output": {
"nodeId": "HyziHf6Md",
"pinKey": "HJTUBe3f_"
}
},
{
"id": "HyZa3rGazO",
"input": {
"nodeId": "SJeanBM6GO",
"pinKey": "__in__"
},
"output": {
"nodeId": "HJT2SfTf_",
"pinKey": "HJTUBe3f_"
}
},
{
"id": "BJ-fArM6MO",
"input": {
"nodeId": "H1xf0rf6zd",
"pinKey": "__in__"
},
"output": {
"nodeId": "SyG0BMTzd",
"pinKey": "HJTUBe3f_"
}
}
],
"nodes": [
{
"boundLiterals": {
"B1DIHlhzu": "\"foo\""
},
"id": "HyziHf6Md",
"position": {
"units": "slots",
"x": 1,
"y": 1
},
"type": "xod/core/arity-level"
},
{
"id": "SytiSzTGO",
"position": {
"units": "slots",
"x": 1,
"y": 2
},
"type": "xod/patch-nodes/output-number"
},
{
"arityLevel": 2,
"boundLiterals": {
"B1DIHlhzu": "0"
},
"id": "HJT2SfTf_",
"position": {
"units": "slots",
"x": 4,
"y": 1
},
"type": "xod/core/arity-level"
},
{
"id": "SJeanBM6GO",
"position": {
"units": "slots",
"x": 4,
"y": 2
},
"type": "xod/patch-nodes/output-number"
},
{
"arityLevel": 6,
"boundLiterals": {
"B1DIHlhzu": "True"
},
"id": "SyG0BMTzd",
"position": {
"units": "slots",
"x": 8,
"y": 1
},
"type": "xod/core/arity-level"
},
{
"id": "H1xf0rf6zd",
"position": {
"units": "slots",
"x": 8,
"y": 2
},
"type": "xod/patch-nodes/output-number"
},
{
"id": "B1MbIzTzd",
"position": {
"units": "slots",
"x": 16,
"y": 1
},
"type": "xod/patch-nodes/tabtest"
}
]
}
3 changes: 3 additions & 0 deletions workspace/test/test-core/test-average/patch.test.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IN1 IN2 IN3 IN4 IN5 OUT
1 2 3 4 5 3
10000 1000 100 10 1 2222.2
Loading

0 comments on commit b17f125

Please sign in to comment.