diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..7bacae399e --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/docstring.txt @@ -0,0 +1,14 @@ +The ACCURACY node takes two dataframes with the true and predicted labels from a classification task, + and indicates whether the prediction was correct or not. These dataframes should both be single columns. + + Parameters + ---------- + true_label: optional str + true label users can select from original data + predicted_label: optional str + resulting predicted label users can select + Returns + ------- + DataFrame + The input predictions dataframe, with an extra boolean column "prediction_correct". + diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..0757e9f657 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/a1-[autogen]/python_code.txt @@ -0,0 +1,30 @@ +from flojoy import flojoy, DataFrame +from typing import Optional + + +@flojoy +def ACCURACY( + true_data: DataFrame, + predicted_data: DataFrame, + true_label: Optional[str] = None, + predicted_label: Optional[str] = None, +) -> DataFrame: + + + true_df = true_data.m + predicted_df = predicted_data.m + + # if users prov + if true_label: + true_label = true_df[true_label] + else: + true_label = true_df.iloc[:, 0] + + if predicted_label: + predicted_label = predicted_df[predicted_label] + else: + predicted_label = predicted_df.iloc[:, 0] + + predicted_df["prediction_correct"] = true_label == predicted_label + + return DataFrame(df=predicted_df) diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/examples/EX1/app.txt new file mode 100644 index 0000000000..925ff9b5d2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ACCURACY/examples/EX1/app.txt @@ -0,0 +1,548 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38f", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38f", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "./PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/assets/iris_train.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 809.671020177502, + "y": 222.07629603230282 + }, + "selected": false, + "positionAbsolute": { + "x": 809.671020177502, + "y": 222.07629603230282 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6", + "label": "READ CSV 1", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "./PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/assets/iris_test.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 804.9503287192058, + "y": 628.7258310071566 + }, + "selected": false, + "positionAbsolute": { + "x": 804.9503287192058, + "y": 628.7258310071566 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0c", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0c", + "label": "EXTRACT COLUMNS", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "sepal_length,sepal_width,petal_length,petal_width" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 1263.9384521195566, + "y": 121.29660973664375 + }, + "selected": false, + "positionAbsolute": { + "x": 1263.9384521195566, + "y": 121.29660973664375 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fc", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fc", + "label": "EXTRACT COLUMNS 1", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "variety" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 1271.165545753499, + "y": 397.54647293978513 + }, + "selected": false, + "positionAbsolute": { + "x": 1271.165545753499, + "y": 397.54647293978513 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0", + "label": "EXTRACT COLUMNS 2", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "sepal_length,sepal_width,petal_length,petal_width" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 1277.7363475814786, + "y": 601.6703032521995 + }, + "selected": false, + "positionAbsolute": { + "x": 1277.7363475814786, + "y": 601.6703032521995 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800", + "label": "EXTRACT COLUMNS 3", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "variety" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 1286.2656908175936, + "y": 789.356865414031 + }, + "selected": false, + "positionAbsolute": { + "x": 1286.2656908175936, + "y": 789.356865414031 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "type": "AI_ML", + "data": { + "id": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "label": "SUPPORT VECTOR MACHINE", + "func": "SUPPORT_VECTOR_MACHINE", + "type": "AI_ML", + "ctrls": { + "kernel": { + "type": "select", + "default": "linear", + "options": [ + "linear", + "poly", + "rbf", + "sigmoid", + "precomputed" + ], + "functionName": "SUPPORT_VECTOR_MACHINE", + "param": "kernel", + "value": "linear" + } + }, + "inputs": [ + { + "name": "train_feature", + "id": "train_feature", + "type": "DataFrame|Matrix", + "multiple": false + }, + { + "name": "train_label", + "id": "train_label", + "type": "DataFrame|Matrix", + "multiple": false + }, + { + "name": "input_data", + "id": "input_data", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "scikit-learn", + "v": "1.2.2" + } + ], + "path": "PYTHON/nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/SUPPORT_VECTOR_MACHINE.py", + "selected": false + }, + "position": { + "x": 1896.9382856994248, + "y": 282.7469238906283 + }, + "selected": false, + "positionAbsolute": { + "x": 1896.9382856994248, + "y": 282.7469238906283 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4", + "type": "AI_ML", + "data": { + "id": "ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4", + "label": "ACCURACY", + "func": "ACCURACY", + "type": "AI_ML", + "ctrls": { + "true_label": { + "type": "str", + "default": null, + "functionName": "ACCURACY", + "param": "true_label", + "value": "" + }, + "predicted_label": { + "type": "str", + "default": null, + "functionName": "ACCURACY", + "param": "predicted_label", + "value": "" + } + }, + "inputs": [ + { + "name": "true_data", + "id": "true_data", + "type": "DataFrame", + "multiple": false + }, + { + "name": "predicted_data", + "id": "predicted_data", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/CLASSIFICATION/ACCURACY/ACCURACY.py", + "selected": false + }, + "position": { + "x": 2253.472526811098, + "y": 362.2715825149083 + }, + "selected": false, + "positionAbsolute": { + "x": 2253.472526811098, + "y": 362.2715825149083 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-22193775-285f-4b58-93b5-9a8260454424", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-22193775-285f-4b58-93b5-9a8260454424", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 2649.9417965837397, + "y": 316.6433733865691 + }, + "selected": false, + "positionAbsolute": { + "x": 2649.9417965837397, + "y": 316.6433733865691 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38f", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0c", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38fdefault-EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0cdefault" + }, + { + "source": "READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38f", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fc", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-efb0cda7-2730-4aa9-ad47-153aabbab38fdefault-EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fcdefault" + }, + { + "source": "READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6default-EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0default" + }, + { + "source": "READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-d92e3586-c0c0-4ebd-9713-02916b36e7b6default-EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800default" + }, + { + "source": "EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0c", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "targetHandle": "train_feature", + "id": "reactflow__edge-EXTRACT_COLUMNS-957fd785-5d26-4a46-8f38-3060768f5e0cdefault-SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4train_feature" + }, + { + "source": "EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fc", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "targetHandle": "train_label", + "id": "reactflow__edge-EXTRACT_COLUMNS-a11a9de2-476a-40d1-99e2-5abd3d1f38fcdefault-SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4train_label" + }, + { + "source": "EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "targetHandle": "input_data", + "id": "reactflow__edge-EXTRACT_COLUMNS-65b1438d-f76e-4151-90cc-6b0a0c2698b0default-SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4input_data" + }, + { + "source": "EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800", + "sourceHandle": "default", + "target": "ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4", + "targetHandle": "predicted_data", + "id": "reactflow__edge-EXTRACT_COLUMNS-8ff329af-40f4-4efc-bb12-5d10a7fde800default-ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4predicted_data" + }, + { + "source": "SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4", + "sourceHandle": "default", + "target": "ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4", + "targetHandle": "true_data", + "id": "reactflow__edge-SUPPORT_VECTOR_MACHINE-6d59b4fc-d2d2-4dbc-956e-6818cec198d4default-ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4true_data" + }, + { + "source": "ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4", + "sourceHandle": "default", + "target": "TABLE-22193775-285f-4b58-93b5-9a8260454424", + "targetHandle": "default", + "id": "reactflow__edge-ACCURACY-b375ef9d-2c74-4f73-88d8-717c020422e4default-TABLE-22193775-285f-4b58-93b5-9a8260454424default" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e1bb0b00f4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The ONE_HOT_ENCODING node creates a one hot encoding from a dataframe and columns dataframe containing categorical features. + +Returns +------- +DataFrame + The one hot encoding of the input features. diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..48529e14e3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/a1-[autogen]/python_code.txt @@ -0,0 +1,21 @@ +from flojoy import flojoy, DataFrame +from typing import Optional +import pandas as pd + + +@flojoy +def ONE_HOT_ENCODING( + data: DataFrame, + feature_col: Optional[DataFrame] = None, +) -> DataFrame: + + + df = data.m + if feature_col: + encoded = pd.get_dummies(df, columns=feature_col.m.columns.to_list()) + + else: + cat_df = df.select_dtypes(include=["object", "category"]).columns.to_list() + encoded = pd.get_dummies(df, columns=cat_df) + + return DataFrame(df=encoded) diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/examples/EX1/app.txt new file mode 100644 index 0000000000..6158c0b280 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/examples/EX1/app.txt @@ -0,0 +1,245 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cf", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cf", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "tips" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": 225.17466971279896, + "y": 33.26430366645344 + }, + "selected": false, + "positionAbsolute": { + "x": 225.17466971279896, + "y": 33.26430366645344 + } + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779", + "label": "EXTRACT COLUMNS", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "smoker,day" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 479.4724139818194, + "y": 227.22426944242306 + }, + "selected": false, + "positionAbsolute": { + "x": 479.4724139818194, + "y": 227.22426944242306 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822", + "type": "AI_ML", + "data": { + "id": "ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822", + "label": "ONE HOT ENCODING", + "func": "ONE_HOT_ENCODING", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "data", + "id": "data", + "type": "DataFrame", + "multiple": false + }, + { + "name": "feature_col", + "id": "feature_col", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING/ONE_HOT_ENCODING.py", + "selected": false + }, + "position": { + "x": 747.6834197435038, + "y": 52.737263025393986 + }, + "selected": false, + "positionAbsolute": { + "x": 747.6834197435038, + "y": 52.737263025393986 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-e6aab77d-927f-4eeb-be3f-afdd469df2ae", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-e6aab77d-927f-4eeb-be3f-afdd469df2ae", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1061.7767903212753, + "y": 13.83665125511368 + }, + "selected": false, + "positionAbsolute": { + "x": 1061.7767903212753, + "y": 13.83665125511368 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cf", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cfdefault-EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779default" + }, + { + "source": "PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cf", + "sourceHandle": "default", + "target": "ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822", + "targetHandle": "data", + "id": "reactflow__edge-PLOTLY_DATASET-905b1a9b-05ef-4ae4-b51a-8574359571cfdefault-ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822data" + }, + { + "source": "EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779", + "sourceHandle": "default", + "target": "ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822", + "targetHandle": "feature_col", + "id": "reactflow__edge-EXTRACT_COLUMNS-c8e238a7-337c-479f-a2c6-bf607cb52779default-ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822feature_col" + }, + { + "source": "ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822", + "sourceHandle": "default", + "target": "TABLE-e6aab77d-927f-4eeb-be3f-afdd469df2ae", + "targetHandle": "default", + "id": "reactflow__edge-ONE_HOT_ENCODING-eef29534-7bf7-4d54-aff9-8fc25081c822default-TABLE-e6aab77d-927f-4eeb-be3f-afdd469df2aedefault" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..27955f28ba --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + +The SUPPORT_VECTOR_MACHINE node is used to train a support vector machine model for classification tasks. +It takes two dataframes of label and feature from labelled training data and a dataframe of unlabelled input data. + +Parameters +---------- +kernel : 'linear' | 'poly' | 'rbf' | 'sigmoid' | 'precomputed' + Specifies the kernel type to be used in the algorithm. + For detailed information about kernel types: + https://scikit-learn.org/stable/modules/svm.html#kernel-functions + +Returns +------- +DataFrame + The predictions for the input data. diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..385dc8fb32 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/a1-[autogen]/python_code.txt @@ -0,0 +1,43 @@ +from flojoy import flojoy, DataFrame, Matrix +import pandas as pd +import numpy as np +from sklearn import svm, preprocessing +from typing import Literal + + +@flojoy(deps={"scikit-learn": "1.2.2"}) +def SUPPORT_VECTOR_MACHINE( + train_feature: DataFrame | Matrix, + train_label: DataFrame | Matrix, + input_data: DataFrame | Matrix, + kernel: Literal["linear", "poly", "rbf", "sigmoid", "precomputed"] = "linear", +) -> DataFrame: + + + le = preprocessing.LabelEncoder() + + if isinstance(train_feature, DataFrame): + train = train_feature.m.to_numpy() + col = train_label.m.to_numpy() + target_name = train_label.m.columns.values[0] + + else: + train = train_feature.m + col = train_label.m + target_name = "target" + + X = train + Y = le.fit_transform(col) + + clf = svm.SVC(kernel=kernel) + clf.fit(X, Y) + + if isinstance(input_data, DataFrame): + input_arr = input_data.m.to_numpy() + else: + input_arr = input_data.m + + prediction = clf.predict(input_arr) + prediction = le.inverse_transform(prediction) + prediction = pd.DataFrame({target_name: prediction}) + return DataFrame(df=prediction) diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/examples/EX1/app.txt new file mode 100644 index 0000000000..7f94512f28 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/examples/EX1/app.txt @@ -0,0 +1,363 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "./PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/assets/iris_train.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 654.4111754934514, + "y": 510.5069042246754 + }, + "selected": false, + "positionAbsolute": { + "x": 654.4111754934514, + "y": 510.5069042246754 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "READ_CSV-90526963-cd8b-4b79-bf22-12138be6d2c7", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-90526963-cd8b-4b79-bf22-12138be6d2c7", + "label": "READ CSV 1", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "./PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/assets/iris_test_no_label.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 656.2323843615078, + "y": 772.1477992127109 + }, + "selected": false, + "positionAbsolute": { + "x": 656.2323843615078, + "y": 772.1477992127109 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-500d4621-276f-4b84-a114-1e4498781381", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-500d4621-276f-4b84-a114-1e4498781381", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1496.5324809006217, + "y": 648.6028296725746 + }, + "selected": false, + "positionAbsolute": { + "x": 1496.5324809006217, + "y": 648.6028296725746 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "type": "AI_ML", + "data": { + "id": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "label": "SUPPORT VECTOR MACHINE", + "func": "SUPPORT_VECTOR_MACHINE", + "type": "AI_ML", + "ctrls": { + "kernel": { + "type": "select", + "default": "linear", + "options": [ + "linear", + "poly", + "rbf", + "sigmoid", + "precomputed" + ], + "functionName": "SUPPORT_VECTOR_MACHINE", + "param": "kernel", + "value": "linear" + } + }, + "inputs": [ + { + "name": "train_feature", + "id": "train_feature", + "type": "DataFrame|Matrix", + "multiple": false + }, + { + "name": "train_label", + "id": "train_label", + "type": "DataFrame|Matrix", + "multiple": false + }, + { + "name": "input_data", + "id": "input_data", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "scikit-learn", + "v": "1.2.2" + } + ], + "path": "PYTHON/nodes/AI_ML/CLASSIFICATION/SUPPORT_VECTOR_MACHINE/SUPPORT_VECTOR_MACHINE.py", + "selected": false + }, + "position": { + "x": 1210.9973012192495, + "y": 688.4577952218613 + }, + "selected": false, + "positionAbsolute": { + "x": 1210.9973012192495, + "y": 688.4577952218613 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7", + "label": "EXTRACT COLUMNS", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "sepal_length,sepal_width,petal_length,petal_width" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 925.4528113568123, + "y": 408.74992717383236 + }, + "selected": false, + "positionAbsolute": { + "x": 925.4528113568123, + "y": 408.74992717383236 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0", + "label": "EXTRACT COLUMNS 1", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "variety" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 921.9762546726099, + "y": 588.0217108217173 + }, + "selected": false, + "positionAbsolute": { + "x": 921.9762546726099, + "y": 588.0217108217173 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845default-EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7default" + }, + { + "source": "READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-59c660d6-c37c-48e6-9e32-11490ebba845default-EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0default" + }, + { + "source": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "sourceHandle": "default", + "target": "TABLE-500d4621-276f-4b84-a114-1e4498781381", + "targetHandle": "default", + "id": "reactflow__edge-SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44bdefault-TABLE-500d4621-276f-4b84-a114-1e4498781381default" + }, + { + "source": "EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "targetHandle": "train_feature", + "id": "reactflow__edge-EXTRACT_COLUMNS-afb1e4ac-a149-400c-b795-0f3fd78ab5f7default-SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44btrain_feature" + }, + { + "source": "EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "targetHandle": "train_label", + "id": "reactflow__edge-EXTRACT_COLUMNS-394a3bea-c4b0-4e54-821b-8392c1bcaac0default-SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44btrain_label" + }, + { + "source": "READ_CSV-90526963-cd8b-4b79-bf22-12138be6d2c7", + "sourceHandle": "default", + "target": "SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44b", + "targetHandle": "input_data", + "id": "reactflow__edge-READ_CSV-90526963-cd8b-4b79-bf22-12138be6d2c7default-SUPPORT_VECTOR_MACHINE-111df792-52d2-41ac-9662-1066da12d44binput_data" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3ecbc06d81 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/docstring.txt @@ -0,0 +1,14 @@ + +The TRAIN_TEST_SPLIT node is used to split the data into test and training according to a size specified before any ML tasks. + +Parameters +---------- +test_size : float + The size of testing data specified. + +Returns +------- +train: DataFrame + A dataframe of training data. +test: DataFrame + A dataframe of test data. diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..195ed7f880 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/a1-[autogen]/python_code.txt @@ -0,0 +1,19 @@ +from typing import TypedDict +from flojoy import flojoy, DataFrame +from sklearn.model_selection import train_test_split + + +class TrainTestSplitOutput(TypedDict): + train: DataFrame + test: DataFrame + + +@flojoy(deps={"scikit-learn": "1.2.2"}) +def TRAIN_TEST_SPLIT( + default: DataFrame, test_size: float = 0.2 +) -> TrainTestSplitOutput: + + + df = default.m + train, test = train_test_split(df, test_size=test_size) + return TrainTestSplitOutput(train=DataFrame(df=train), test=DataFrame(df=test)) diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/examples/EX1/app.txt new file mode 100644 index 0000000000..5fe4c3e400 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/examples/EX1/app.txt @@ -0,0 +1,232 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "READ_CSV-387daa06-4a0d-4a9c-b2f3-604318bdf972", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-387daa06-4a0d-4a9c-b2f3-604318bdf972", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 533.4945401380736, + "y": 529.0100974568767 + }, + "selected": false, + "positionAbsolute": { + "x": 533.4945401380736, + "y": 529.0100974568767 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231b", + "type": "AI_ML", + "data": { + "id": "TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231b", + "label": "TRAIN TEST SPLIT", + "func": "TRAIN_TEST_SPLIT", + "type": "AI_ML", + "ctrls": { + "test_size": { + "type": "float", + "default": 0.2, + "functionName": "TRAIN_TEST_SPLIT", + "param": "test_size", + "value": 0.2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "train", + "id": "train", + "type": "DataFrame" + }, + { + "name": "test", + "id": "test", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "scikit-learn", + "v": "1.2.2" + } + ], + "path": "PYTHON/nodes/AI_ML/CLASSIFICATION/TRAIN_TEST_SPLIT/TRAIN_TEST_SPLIT.py", + "selected": false + }, + "position": { + "x": 871.7089964434033, + "y": 527.8962387443567 + }, + "selected": false, + "positionAbsolute": { + "x": 871.7089964434033, + "y": 527.8962387443567 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-7c7e2534-d55a-48d0-9e5c-9fececfaf78a", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-7c7e2534-d55a-48d0-9e5c-9fececfaf78a", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1216.4388361339998, + "y": 222.00775012169743 + }, + "selected": false, + "positionAbsolute": { + "x": 1216.4388361339998, + "y": 222.00775012169743 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-9a6fa967-be36-4f5d-93c8-dd6a5b5b349a", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-9a6fa967-be36-4f5d-93c8-dd6a5b5b349a", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1224.7251303690232, + "y": 688.907639667992 + }, + "selected": false, + "positionAbsolute": { + "x": 1224.7251303690232, + "y": 688.907639667992 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-387daa06-4a0d-4a9c-b2f3-604318bdf972", + "sourceHandle": "default", + "target": "TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231b", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-387daa06-4a0d-4a9c-b2f3-604318bdf972default-TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231bdefault" + }, + { + "source": "TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231b", + "sourceHandle": "train", + "target": "TABLE-7c7e2534-d55a-48d0-9e5c-9fececfaf78a", + "targetHandle": "default", + "id": "reactflow__edge-TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231btrain-TABLE-7c7e2534-d55a-48d0-9e5c-9fececfaf78adefault" + }, + { + "source": "TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231b", + "sourceHandle": "test", + "target": "TABLE-9a6fa967-be36-4f5d-93c8-dd6a5b5b349a", + "targetHandle": "default", + "id": "reactflow__edge-TRAIN_TEST_SPLIT-dd597d43-f67f-4cd8-9444-3782f083231btest-TABLE-9a6fa967-be36-4f5d-93c8-dd6a5b5b349adefault" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..8c7d60ae56 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The NLP_CONNECT_VIT_GPT2 node captions an input image and produces an output string wrapped in a dataframe. + +Returns +------- +DataFrame + DataFrame containing the caption column and a single row. diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..6a94acf642 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/a1-[autogen]/python_code.txt @@ -0,0 +1,48 @@ +from flojoy import flojoy, run_in_venv, DataFrame, Image + + +@flojoy +@run_in_venv( + pip_dependencies=[ + "transformers==4.30.2", + "torch==1.13.0", + "torchvision==0.14.0", + ] +) +def NLP_CONNECT_VIT_GPT2(default: Image) -> DataFrame: + + + import numpy as np + import pandas as pd + + import transformers + import torch + import torchvision.transforms.functional as TF + from flojoy import DataFrame, snapshot_download + + r, g, b, a = default.r, default.g, default.b, default.a + nparray = ( + np.stack((r, g, b, a), axis=2) if a is not None else np.stack((r, g, b), axis=2) + ) + image = TF.to_pil_image(nparray).convert("RGB") + + # Download repo to local flojoy cache + local_repo_path = snapshot_download( + repo_id="nlpconnect/vit-gpt2-image-captioning", + revision="dc68f91c06a1ba6f15268e5b9c13ae7a7c514084", + local_dir_use_symlinks=False, + ) + # Load model objects + model = transformers.VisionEncoderDecoderModel.from_pretrained(local_repo_path) + feature_extractor = transformers.ViTImageProcessor.from_pretrained(local_repo_path) + tokenizer = transformers.AutoTokenizer.from_pretrained(local_repo_path) + + with torch.inference_mode(): + pixel_values = feature_extractor(images=[image], return_tensors="pt").pixel_values # type: ignore + output_ids = model.generate(pixel_values, max_length=16, num_beams=4) # type: ignore + preds = tokenizer.batch_decode(output_ids, skip_special_tokens=True) # type: ignore + pred = preds[0].strip() + + df_pred = pd.DataFrame.from_records([(pred,)], columns=["caption"]) + + return DataFrame(df=df_pred) diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/examples/EX1/app.txt new file mode 100644 index 0000000000..97f4dc2a97 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/examples/EX1/app.txt @@ -0,0 +1,237 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "./PYTHON/nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/assets/President_Barack_Obama.jpg" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 898.0767495241247, + "y": 258.007532127312 + }, + "selected": false, + "positionAbsolute": { + "x": 898.0767495241247, + "y": 258.007532127312 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1", + "type": "AI_ML", + "data": { + "id": "NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1", + "label": "NLP CONNECT VIT GPT2", + "func": "NLP_CONNECT_VIT_GPT2", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/IMAGE_CAPTIONING/NLP_CONNECT_VIT_GPT2/NLP_CONNECT_VIT_GPT2.py", + "selected": false + }, + "position": { + "x": 1283.1918647825164, + "y": 265.4714674215452 + }, + "selected": false, + "positionAbsolute": { + "x": 1283.1918647825164, + "y": 265.4714674215452 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-15ab5a91-a962-4f8e-ba9c-8a159d576dbb", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-15ab5a91-a962-4f8e-ba9c-8a159d576dbb", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1651.5185251577254, + "y": 220.55760502577914 + }, + "selected": false, + "positionAbsolute": { + "x": 1651.5185251577254, + "y": 220.55760502577914 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-ec76f3cf-6397-45cf-a1e0-ce43c89a9327", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-ec76f3cf-6397-45cf-a1e0-ce43c89a9327", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1246.1380299479968, + "y": 519.1209987191089 + }, + "selected": false, + "positionAbsolute": { + "x": 1246.1380299479968, + "y": 519.1209987191089 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6", + "sourceHandle": "default", + "target": "NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6default-NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1default" + }, + { + "source": "NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1", + "sourceHandle": "default", + "target": "TABLE-15ab5a91-a962-4f8e-ba9c-8a159d576dbb", + "targetHandle": "default", + "id": "reactflow__edge-NLP_CONNECT_VIT_GPT2-f4c9d884-68df-45a4-a06a-9c56750ff1c1default-TABLE-15ab5a91-a962-4f8e-ba9c-8a159d576dbbdefault" + }, + { + "source": "LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6", + "sourceHandle": "default", + "target": "IMAGE-ec76f3cf-6397-45cf-a1e0-ce43c89a9327", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-37e74f08-bfb2-49d1-bec2-d962fda0f0a6default-IMAGE-ec76f3cf-6397-45cf-a1e0-ce43c89a9327default" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 75.99194886435214, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..f44858ce90 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The COUNT_VECTORIZER node receives a collection (matrix, vector or dataframe) of +text documents to a matrix of token counts. + +Returns +------- +tokens: DataFrame + holds all the unique tokens observed from the input. +word_count_vector: Vector + contains the occurences of these tokens from each sentence. diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..39b0fdad68 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from typing import TypedDict +from sklearn.feature_extraction.text import CountVectorizer +from flojoy import flojoy, DataFrame, Matrix, Vector +import pandas as pd + + +class CountVectorizerOutput(TypedDict): + tokens: DataFrame + word_count_vector: Vector + + +@flojoy(deps={"scikit-learn": "1.2.2"}) +def COUNT_VECTORIZER(default: DataFrame | Matrix | Vector) -> CountVectorizerOutput: + + + if isinstance(default, DataFrame): + data = default.m.values + elif isinstance(default, Vector): + data = default.v + else: + data = default.m + + vectorizer = CountVectorizer() + X = vectorizer.fit_transform(data.flatten()) + + x = pd.DataFrame({"tokens": vectorizer.get_feature_names_out()}) + y = X.toarray() # type: ignore + + return CountVectorizerOutput(tokens=DataFrame(df=x), word_count_vector=Vector(v=y)) diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/examples/EX1/app.txt new file mode 100644 index 0000000000..2c51e4e4e6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/NLP/COUNT_VECTORIZER/examples/EX1/app.txt @@ -0,0 +1,282 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 160, + "height": 160, + "id": "READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589f", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589f", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "desc": "File path to the CSV file or an URL of CSV file", + "functionName": "READ_CSV", + "param": "file_path", + "value": "PYTHON/nodes/AI_ML/NLP/COUNT_VECTORIZER/assets/text.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": -110.98427597492659, + "y": -10.73536422316019 + }, + "selected": false, + "positionAbsolute": { + "x": -110.98427597492659, + "y": -10.73536422316019 + }, + "dragging": true + }, + { + "width": 208, + "height": 132, + "id": "COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7e", + "type": "AI_ML", + "data": { + "id": "COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7e", + "label": "COUNT VECTORIZER", + "func": "COUNT_VECTORIZER", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "tokens", + "id": "tokens", + "type": "DataFrame", + "desc": null + }, + { + "name": "word_count_vector", + "id": "word_count_vector", + "type": "Vector", + "desc": null + } + ], + "pip_dependencies": [ + { + "name": "scikit-learn", + "v": "1.2.2" + } + ], + "path": "PYTHON/nodes/AI_ML/NLP/COUNT_VECTORIZER/COUNT_VECTORIZER.py", + "selected": false + }, + "position": { + "x": 131.34474766051025, + "y": -0.556428681455003 + }, + "selected": false, + "positionAbsolute": { + "x": 131.34474766051025, + "y": -0.556428681455003 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-30ea1761-9951-4e88-a338-4d9dadfaa109", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-30ea1761-9951-4e88-a338-4d9dadfaa109", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 113.44753341488456, + "y": -281.98557347667753 + }, + "selected": false, + "positionAbsolute": { + "x": 113.44753341488456, + "y": -281.98557347667753 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-0bae26a8-e528-4b2c-839c-5422dcf88a81", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-0bae26a8-e528-4b2c-839c-5422dcf88a81", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 450.19382383028744, + "y": 60.65139178762516 + }, + "selected": false, + "positionAbsolute": { + "x": 450.19382383028744, + "y": 60.65139178762516 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-080bcffe-4b33-4849-b4e8-7a26a826f4ee", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-080bcffe-4b33-4849-b4e8-7a26a826f4ee", + "label": "TABLE 2", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 444.978957837495, + "y": -256.5186696950019 + }, + "selected": false, + "positionAbsolute": { + "x": 444.978957837495, + "y": -256.5186696950019 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589f", + "sourceHandle": "default", + "target": "COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7e", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589fdefault-COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7edefault" + }, + { + "source": "COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7e", + "sourceHandle": "tokens", + "target": "TABLE-080bcffe-4b33-4849-b4e8-7a26a826f4ee", + "targetHandle": "default", + "id": "reactflow__edge-COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7etokens-TABLE-080bcffe-4b33-4849-b4e8-7a26a826f4eedefault" + }, + { + "source": "COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7e", + "sourceHandle": "word_count_vector", + "target": "TABLE-0bae26a8-e528-4b2c-839c-5422dcf88a81", + "targetHandle": "default", + "id": "reactflow__edge-COUNT_VECTORIZER-cbdccd55-5dee-413e-9180-57e18005dd7eword_count_vector-TABLE-0bae26a8-e528-4b2c-839c-5422dcf88a81default" + }, + { + "source": "READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589f", + "sourceHandle": "default", + "target": "TABLE-30ea1761-9951-4e88-a338-4d9dadfaa109", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-c1741573-62fc-4e56-9d67-96e2d057589fdefault-TABLE-30ea1761-9951-4e88-a338-4d9dadfaa109default" + } + ], + "viewport": { + "x": 502.7009774274077, + "y": 219.59679745587334, + "zoom": 0.8486425101826552 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..83debb5373 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The OBJECT_DETECTION node detects objects in the input image, and returns an 'image' DataContainer with those objects highlighted. + +Inputs +------ +default : Image + +Returns +------- +Image diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a23505138c --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/a1-[autogen]/python_code.txt @@ -0,0 +1,47 @@ +import traceback +from flojoy import flojoy, Image +import numpy as np +import os +import requests + +from utils.object_detection.object_detection import detect_object + + +@flojoy +def OBJECT_DETECTION(default: Image) -> Image: + + r = default.r + g = default.g + b = default.b + a = default.a + + path = os.path.join( + os.path.abspath(os.getcwd()), "PYTHON/utils/object_detection/yolov3.weights" + ) + exists = os.path.exists(path) + + if not exists: + print("Downloading yolov3 weights for object detection.") + print("Download may take up to a minute.") + url = "https://pjreddie.com/media/files/yolov3.weights" + r = requests.get(url, allow_redirects=True) + open(path, "wb").write(r.content) + + if a is not None: + nparr = np.stack((r, g, b, a), axis=2) + else: + nparr = np.stack((r, g, b), axis=2) + try: + img_array = detect_object(nparr) + red_channel = img_array[:, :, 0] + green_channel = img_array[:, :, 1] + blue_channel = img_array[:, :, 2] + if img_array.shape[2] == 4: + alpha_channel = img_array[:, :, 3] + else: + alpha_channel = None + return Image(r=red_channel, g=green_channel, b=blue_channel, a=alpha_channel) + + except Exception: + print(traceback.format_exc()) + raise diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/examples/EX1/app.txt new file mode 100644 index 0000000000..3c7c4aa074 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/examples/EX1/app.txt @@ -0,0 +1,246 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 160, + "height": 160, + "id": "LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "desc": "path to the file to be loaded.", + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "PYTHON/nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/assets/obama_image.jpg" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "desc": "type of file to load, default: image.", + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame", + "desc": null + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 24.809619940370197, + "y": -128.2164625572575 + }, + "selected": false, + "positionAbsolute": { + "x": 24.809619940370197, + "y": -128.2164625572575 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-769c4e27-7d34-45ac-a2b3-b74dbf96dd4f", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-769c4e27-7d34-45ac-a2b3-b74dbf96dd4f", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 572.2067448111293, + "y": -166.80421635329245 + }, + "selected": false, + "positionAbsolute": { + "x": 572.2067448111293, + "y": -166.80421635329245 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-f28f6f34-e3dd-4840-a48e-28efc7b1ae45", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-f28f6f34-e3dd-4840-a48e-28efc7b1ae45", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 272.1848200697342, + "y": -363.6544609307003 + }, + "selected": false, + "positionAbsolute": { + "x": 272.1848200697342, + "y": -363.6544609307003 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5", + "type": "AI_ML", + "data": { + "id": "OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5", + "label": "OBJECT DETECTION", + "func": "OBJECT_DETECTION", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "desc": null + } + ], + "path": "PYTHON/nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/OBJECT_DETECTION.py", + "selected": false + }, + "position": { + "x": 260.3471692016421, + "y": -89.58575634203677 + }, + "selected": false, + "positionAbsolute": { + "x": 260.3471692016421, + "y": -89.58575634203677 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987", + "sourceHandle": "default", + "target": "OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987default-OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5default" + }, + { + "source": "OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5", + "sourceHandle": "default", + "target": "IMAGE-769c4e27-7d34-45ac-a2b3-b74dbf96dd4f", + "targetHandle": "default", + "id": "reactflow__edge-OBJECT_DETECTION-3ce0a6ee-8056-40f6-b99d-19e8358e54f5default-IMAGE-769c4e27-7d34-45ac-a2b3-b74dbf96dd4fdefault" + }, + { + "source": "LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987", + "sourceHandle": "default", + "target": "IMAGE-f28f6f34-e3dd-4840-a48e-28efc7b1ae45", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-6c5165f8-abe1-4d41-854b-c662b5d2a987default-IMAGE-f28f6f34-e3dd-4840-a48e-28efc7b1ae45default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d53b6eef5c --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/docstring.txt @@ -0,0 +1,44 @@ + +The PROPHET_PREDICT node rains a Prophet model on the incoming dataframe. + +The DataContainer input type must be a dataframe, and the first column (or index) of dataframe must be of a datetime type. + +This node always returns a DataContainer of a dataframe type. It will also always return an "extra" field with a key "prophet" of which the value is the JSONified Prophet model. +This model can be loaded as follows: + ```python + from prophet.serialize import model_from_json + + model = model_from_json(dc_inputs.extra["prophet"]) + ``` + +Parameters +---------- +run_forecast : bool + If True (default case), the dataframe of the returning DataContainer + ("m" parameter of the DataContainer) will be the forecasted dataframe. + It will also have an "extra" field with the key "original", which is + the original dataframe passed in. + + If False, the returning dataframe will be the original data. + + This node will also always have an "extra" field, run_forecast, which + matches that of the parameters passed in. This is for future nodes + to know if a forecast has already been run. + + Default = True + +periods : int + The number of periods to predict out. Only used if run_forecast is True. + Default = 365 + +Returns +------- +DataFrame + With parameter as df. + Indicates either the original df passed in, or the forecasted df + (depending on if run_forecast is True). + +DataContainer + With parameter as "extra". + Contains keys run_forecast which correspond to the input parameter, + and potentially "original" in the event that run_forecast is True. diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..460406c3c3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/a1-[autogen]/python_code.txt @@ -0,0 +1,96 @@ +from flojoy import flojoy, run_in_venv, DataFrame, DataContainer +from typing import TypedDict + + +class ProphetPredictOutput(TypedDict): + dataframe: DataFrame + prophet_data: DataContainer + + +@flojoy(deps={"prophet": "1.1.4", "holidays": "0.26", "pystan": "2.19.1.1"}) +@run_in_venv( + pip_dependencies=[ + "prophet==1.1.4", + ] +) +def PROPHET_PREDICT( + default: DataFrame, run_forecast: bool = True, periods: int = 365 +) -> ProphetPredictOutput: + + + import os + import sys + import pandas as pd + import numpy as np + + import prophet + from prophet.serialize import model_to_json + + def _make_dummy_dataframe_for_prophet(): + Generate random time series data to test if prophet works + start_date = pd.Timestamp("2023-01-01") + end_date = pd.Timestamp("2023-07-20") + num_days = (end_date - start_date).days + 1 + timestamps = pd.date_range(start=start_date, end=end_date, freq="D") + data = np.random.randn(num_days) # Random data points + df = pd.DataFrame({"ds": timestamps, "ys": data}) + df.rename( + columns={df.columns[0]: "ds", df.columns[1]: "y"}, inplace=True + ) # PROPHET model expects first column to be `ds` and second to be `y` + return df + + def _apply_macos_prophet_hotfix(): + This is a hotfix for MacOS. See https://github.com/facebook/prophet/issues/2250#issuecomment-1559516328 for more detail + + if not sys.platform == "darwin": + return + + # Test if prophet works (i.e. if the hotfix had already been applied) + try: + _dummy_df = _make_dummy_dataframe_for_prophet() + prophet.Prophet().fit(_dummy_df) + except RuntimeError as e: + print(f"Could not run prophet, applying hotfix...") + else: + return + + prophet_dir = prophet.__path__[0] # type: ignore + # Get stan dir + stan_dir = os.path.join(prophet_dir, "stan_model") + # Find cmdstan-xxxxx dir + cmdstan_basename = [x for x in os.listdir(stan_dir) if x.startswith("cmdstan")] + assert len(cmdstan_basename) == 1, "Could not find cmdstan dir" + cmdstan_basename = cmdstan_basename[0] + # Run (from stan_dir) : install_name_tool -add_rpath @executable_path//stan/lib/stan_math/lib/tbb prophet_model.bin + cmd = f"install_name_tool -add_rpath @executable_path/{cmdstan_basename}/stan/lib/stan_math/lib/tbb prophet_model.bin" + cwd = os.getcwd() + os.chdir(stan_dir) + return_code = os.system(cmd) + os.chdir(cwd) + if return_code != 0: + raise RuntimeError("Could not apply hotfix") + + _apply_macos_prophet_hotfix() + + df = default.m + first_col = df.iloc[:, 0] + if not pd.api.types.is_datetime64_any_dtype(first_col): + raise ValueError( + "First column must be of datetime type data for PROPHET_PREDICT!" + ) + df.rename( + columns={df.columns[0]: "ds", df.columns[1]: "y"}, inplace=True + ) # PROPHET model expects first column to be `ds` and second to be `y` + model = prophet.Prophet() + model.fit(df) + extra = {"prophet": model_to_json(model), "run_forecast": run_forecast} + # If run_forecast, the return df is the forecast, otherwise the original + return_df = df.copy() + if run_forecast: + future = model.make_future_dataframe(periods) + forecast = model.predict(future) + extra["original"] = df + return_df = forecast + return ProphetPredictOutput( + dataframe=DataFrame(df=return_df), prophet_data=DataContainer(extra=extra) + ) diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/examples/EX1/app.txt new file mode 100644 index 0000000000..3445a61a43 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/examples/EX1/app.txt @@ -0,0 +1,246 @@ +{ + "rfInstance": { + "nodes": [ + { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "type": "AI_ML", + "data": { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "label": "PROPHET PREDICT", + "func": "PROPHET_PREDICT", + "type": "AI_ML", + "ctrls": { + "run_forecast": { + "type": "bool", + "default": true, + "functionName": "PROPHET_PREDICT", + "param": "run_forecast", + "value": true + }, + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PREDICT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/PROPHET_PREDICT.py", + "selected": false + }, + "position": { + "x": 44.19991981803559, + "y": 49.45240668102545 + }, + "width": 150, + "height": 150, + "selected": false + }, + { + "width": 130, + "height": 130, + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TIMESERIES/TIMESERIES.py", + "selected": false + }, + "position": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "selected": false, + "positionAbsolute": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "label": "PROPHET COMPONENTS", + "func": "PROPHET_COMPONENTS", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_COMPONENTS", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/PROPHET_COMPONENTS.py", + "selected": false + }, + "position": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "selected": false, + "positionAbsolute": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "label": "PROPHET PLOT", + "func": "PROPHET_PLOT", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PLOT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/PROPHET_PLOT.py", + "selected": false + }, + "position": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "selected": false, + "positionAbsolute": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "sourceHandle": "default", + "target": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2default-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3default" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60default" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 103.38141914149585, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3e7c6bfedc --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The LEAST_SQUARE node computes the coefficients that minimizes the distance between the inputs 'Matrix' or 'OrderedPair' class and the regression. + +Returns +------- +OrderedPair + x: input matrix (data points) + y: fitted line computed with returned regression weights +Matrix + m : fitted matrix computed with returned regression weights diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..facb4c1f1e --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/a1-[autogen]/python_code.txt @@ -0,0 +1,56 @@ +import numpy as np +from typing import Optional +from flojoy import flojoy, OrderedPair, Matrix + + +@flojoy +def LEAST_SQUARES( + a: OrderedPair | Matrix, b: Optional[OrderedPair | Matrix] = None +) -> Matrix | OrderedPair: + + + if b is None and isinstance(a, OrderedPair): + x = a.x + y = a.y + try: + a = np.vstack([x, np.ones(len(x))]).T + p = np.linalg.lstsq(a, y, rcond=None)[0] + except np.linalg.LinAlgError: + raise ValueError("Least Square Computation failed.") + + slope, intercept = p[0:-1], p[-1] + res = slope * x + intercept + + return OrderedPair(x=x, y=res) + + if isinstance(a, OrderedPair) and isinstance(b, OrderedPair): + x = a.y + y = b.y + + try: + a = np.vstack([x, np.ones(len(x))]).T + p = np.linalg.lstsq(a, y, rcond=None)[0] + except np.linalg.LinAlgError: + raise ValueError("Least Square Computation failed.") + + slope, intercept = p[0:-1], p[-1] + print("=============== This is slope: ", slope) + print("=============== This is intercept: ", intercept) + res = slope * x + intercept + + return OrderedPair(x=x, y=res) + + elif isinstance(a, Matrix) and isinstance(b, Matrix): + x = a.m + y = b.m + + try: + a = np.vstack([x, np.ones(len(x))]).T + p = np.linalg.lstsq(a, y, rcond=None)[0] + except np.linalg.LinAlgError: + raise ValueError("Least Square Computation failed.") + + slope, intercept = p[0:-1], p[-1] + res = slope * x + intercept + + return Matrix(m=res) diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/examples/EX1/app.txt new file mode 100644 index 0000000000..e9573a354c --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/REGRESSION/LEAST_SQUARES/examples/EX1/app.txt @@ -0,0 +1,529 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 180, + "id": "LINSPACE-83e1b3b0-29ca-4f42-9776-6c73652e2b71", + "type": "default", + "data": { + "id": "LINSPACE-83e1b3b0-29ca-4f42-9776-6c73652e2b71", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "desc": null, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "desc": null, + "functionName": "LINSPACE", + "param": "end", + "value": "7" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "LINSPACE", + "param": "step", + "value": "300" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 148.49805390493464, + "y": 216.82264265774717 + }, + "selected": false, + "positionAbsolute": { + "x": 148.49805390493464, + "y": 216.82264265774717 + }, + "dragging": true + }, + { + "width": 208, + "height": 100, + "id": "CONSTANT-57b24533-1823-42bd-b02a-c055c4e8e406", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-57b24533-1823-42bd-b02a-c055c4e8e406", + "label": "2", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": "2" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": "300" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/CONSTANT/CONSTANT.py", + "selected": false + }, + "position": { + "x": 105.04913536132531, + "y": 63.181137897664996 + }, + "selected": false, + "positionAbsolute": { + "x": 105.04913536132531, + "y": 63.181137897664996 + }, + "dragging": true + }, + { + "width": 72, + "height": 72, + "id": "ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326", + "type": "ARITHMETIC", + "data": { + "id": "ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Scalar|Vector", + "multiple": false, + "desc": null + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Scalar|Vector", + "multiple": true, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar|Vector", + "desc": null + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 374.3382850463804, + "y": 214.12796593726893 + }, + "selected": false, + "positionAbsolute": { + "x": 374.3382850463804, + "y": 214.12796593726893 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "LINSPACE-4d57606b-5efd-4fab-8742-a6ac2e7f3b67", + "type": "default", + "data": { + "id": "LINSPACE-4d57606b-5efd-4fab-8742-a6ac2e7f3b67", + "label": "LINSPACE 1", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "desc": null, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "desc": null, + "functionName": "LINSPACE", + "param": "end", + "value": "7" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "LINSPACE", + "param": "step", + "value": "300" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 138.61587327634447, + "y": 434.28381343983517 + }, + "selected": false, + "positionAbsolute": { + "x": 138.61587327634447, + "y": 434.28381343983517 + }, + "dragging": true + }, + { + "width": 208, + "height": 100, + "id": "RAND-c737081e-0937-47ef-9a87-44915e6806d3", + "type": "GENERATORS", + "data": { + "id": "RAND-c737081e-0937-47ef-9a87-44915e6806d3", + "label": "RAND", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "desc": "the distribution over the random samples", + "functionName": "RAND", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "desc": "the lower bound of the output interval", + "functionName": "RAND", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "desc": "the upper bound of the output interval", + "functionName": "RAND", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "desc": "the mean or \"center\" of the normal distribution", + "functionName": "RAND", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "desc": "the spread or \"width\" of the normal distribution", + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "desc": "the expected number of events occurring in a fixed time-interval when distribution is poisson", + "functionName": "RAND", + "param": "poisson_events", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false, + "desc": "Optional input to use as the x-axis for the random samples" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "desc": "OrderedPair if there's an input\nx: the x-axis of the input\ny: the random samples\n\nScalar if there is no input\nc: the random number" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": 353.9160159658098, + "y": 495.1155185740378 + }, + "selected": false, + "positionAbsolute": { + "x": 353.9160159658098, + "y": 495.1155185740378 + }, + "dragging": true + }, + { + "width": 208, + "height": 132, + "id": "LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819de", + "type": "AI_ML", + "data": { + "id": "LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819de", + "label": "LEAST SQUARES", + "func": "LEAST_SQUARES", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Matrix", + "multiple": false, + "desc": null + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix|OrderedPair", + "desc": "x: input matrix (data points)\ny: fitted line computed with returned regression weights" + } + ], + "path": "PYTHON/nodes/AI_ML/REGRESSION/LEAST_SQUARES/LEAST_SQUARES.py", + "selected": false + }, + "position": { + "x": 482.7806320200681, + "y": 276.35382064920515 + }, + "selected": false, + "positionAbsolute": { + "x": 482.7806320200681, + "y": 276.35382064920515 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726f", + "type": "VISUALIZERS", + "data": { + "id": "COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726f", + "label": "COMPOSITE", + "func": "COMPOSITE", + "type": "VISUALIZERS", + "ctrls": { + "first_figure": { + "type": "select", + "default": "scatter", + "options": [ + "bar", + "line", + "histogram", + "scatter" + ], + "desc": null, + "functionName": "COMPOSITE", + "param": "first_figure", + "value": "line" + }, + "second_figure": { + "type": "select", + "default": "scatter", + "options": [ + "bar", + "line", + "histogram", + "scatter" + ], + "desc": null, + "functionName": "COMPOSITE", + "param": "second_figure", + "value": "scatter" + } + }, + "inputs": [ + { + "name": "primary_trace", + "id": "primary_trace", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + }, + { + "name": "secondary_trace", + "id": "secondary_trace", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/COMPOSITE/COMPOSITE.py", + "selected": false + }, + "position": { + "x": 778.2995679422427, + "y": 266.2522931189161 + }, + "selected": false, + "positionAbsolute": { + "x": 778.2995679422427, + "y": 266.2522931189161 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-4d57606b-5efd-4fab-8742-a6ac2e7f3b67", + "sourceHandle": "default", + "target": "RAND-c737081e-0937-47ef-9a87-44915e6806d3", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-4d57606b-5efd-4fab-8742-a6ac2e7f3b67default-RAND-c737081e-0937-47ef-9a87-44915e6806d3default" + }, + { + "source": "ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326", + "sourceHandle": "default", + "target": "LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819de", + "targetHandle": "a", + "id": "reactflow__edge-ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326default-LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819dea", + "selected": false + }, + { + "source": "RAND-c737081e-0937-47ef-9a87-44915e6806d3", + "sourceHandle": "default", + "target": "LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819de", + "targetHandle": "b", + "id": "reactflow__edge-RAND-c737081e-0937-47ef-9a87-44915e6806d3default-LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819deb" + }, + { + "source": "CONSTANT-57b24533-1823-42bd-b02a-c055c4e8e406", + "sourceHandle": "default", + "target": "ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326", + "targetHandle": "a", + "id": "reactflow__edge-CONSTANT-57b24533-1823-42bd-b02a-c055c4e8e406default-ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326a" + }, + { + "source": "LINSPACE-83e1b3b0-29ca-4f42-9776-6c73652e2b71", + "sourceHandle": "default", + "target": "ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326", + "targetHandle": "b", + "id": "reactflow__edge-LINSPACE-83e1b3b0-29ca-4f42-9776-6c73652e2b71default-ADD-8f70cff2-2317-4178-9927-0b1d1c5ce326b" + }, + { + "source": "LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819de", + "sourceHandle": "default", + "target": "COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726f", + "targetHandle": "primary_trace", + "id": "reactflow__edge-LEAST_SQUARES-0e288cda-db90-4fa7-b842-4ed4a43819dedefault-COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726fprimary_trace" + }, + { + "source": "RAND-c737081e-0937-47ef-9a87-44915e6806d3", + "sourceHandle": "default", + "target": "COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726f", + "targetHandle": "secondary_trace", + "id": "reactflow__edge-RAND-c737081e-0937-47ef-9a87-44915e6806d3default-COMPOSITE-5d51fd86-f875-4c1e-b8c5-0d67d6c6726fsecondary_trace" + } + ], + "viewport": { + "x": 555.284939185504, + "y": 240.2714794602041, + "zoom": 0.9407196048144776 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..4f5e323082 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The DEEPLAB_V3 node returns a segmentation mask from an input image in a dataframe. + +The input image is expected to be a DataContainer of an "image" type. + +The output is a DataContainer of an "image" type with the same dimensions as the input image, but with the red, green, and blue channels replaced with the segmentation mask. + +Returns +------- +Image diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..fec9e7156e --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/a1-[autogen]/python_code.txt @@ -0,0 +1,71 @@ +from flojoy import flojoy, run_in_venv, Image + + +@flojoy +@run_in_venv( + pip_dependencies=[ + "torch==2.0.1", + "torchvision==0.15.2", + "Pillow==9.5.0", + "numpy==1.24.3", + ] +) +def DEEPLAB_V3(default: Image) -> Image: + + + import os + import numpy as np + import PIL.Image + import torch + from torchvision import transforms + import torchvision.transforms.functional as TF + from flojoy import Image + from flojoy.utils import FLOJOY_CACHE_DIR + + # Parse input image + input_image = default + r, g, b, a = input_image.r, input_image.g, input_image.b, input_image.a + nparray = ( + np.stack((r, g, b, a), axis=2) if a is not None else np.stack((r, g, b), axis=2) + ) + # Convert input image + input_image = TF.to_pil_image(nparray).convert("RGB") + # Set torch hub cache directory + torch.hub.set_dir(os.path.join(FLOJOY_CACHE_DIR, "cache", "torch_hub")) + model = torch.hub.load( + "pytorch/vision:v0.15.2", + "deeplabv3_resnet50", + pretrained=True, + skip_validation=True, + ) + model.eval() + # Preprocessing + preprocess_transform = transforms.Compose( + [ + transforms.ToTensor(), + transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), + ] + ) + # Feed the input image to the model + input_tensor = preprocess_transform(input_image) + input_batch = input_tensor.unsqueeze(0) + with torch.inference_mode(): + output = model(input_batch)["out"][0] + # Fetch the output + output_predictions = output.argmax(0) + palette = torch.tensor([2**25 - 1, 2**15 - 1, 2**21 - 1]) + colors = torch.as_tensor([i for i in range(21)])[:, None] * palette + colors = (colors % 255).numpy().astype("uint8") + # plot the semantic segmentation predictions of 21 classes in each color + r = PIL.Image.fromarray(output_predictions.byte().cpu().numpy()).resize( + input_image.size + ) + r.putpalette(colors) + out_img = np.array(r.convert("RGB")) + # Build the output image + return Image( + r=out_img[:, :, 0], + g=out_img[:, :, 1], + b=out_img[:, :, 2], + a=None, + ) diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/examples/EX1/app.txt new file mode 100644 index 0000000000..3e91a3e481 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/examples/EX1/app.txt @@ -0,0 +1,237 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ec", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ec", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "./PYTHON/nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/assets/obama_image.jpg" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 321.61799971188316, + "y": 651.583895198448 + }, + "selected": false, + "positionAbsolute": { + "x": 321.61799971188316, + "y": 651.583895198448 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504", + "type": "AI_ML", + "data": { + "id": "DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504", + "label": "DEEPLAB V3", + "func": "DEEPLAB_V3", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/AI_ML/SEGMENTATION/DEEPLAB_V3/DEEPLAB_V3.py", + "selected": false + }, + "position": { + "x": 854.15096460019, + "y": 672.1244411503056 + }, + "selected": false, + "positionAbsolute": { + "x": 854.15096460019, + "y": 672.1244411503056 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-4f7be017-7bb2-4650-b357-536574caaef9", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-4f7be017-7bb2-4650-b357-536574caaef9", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1358.296287493712, + "y": 620.4805276906546 + }, + "selected": false, + "positionAbsolute": { + "x": 1358.296287493712, + "y": 620.4805276906546 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-587cc53c-8da9-4bd5-a525-44386424da4b", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-587cc53c-8da9-4bd5-a525-44386424da4b", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 850.1563653366388, + "y": 223.0733492297885 + }, + "selected": false, + "positionAbsolute": { + "x": 850.1563653366388, + "y": 223.0733492297885 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ec", + "sourceHandle": "default", + "target": "DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ecdefault-DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504default" + }, + { + "source": "DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504", + "sourceHandle": "default", + "target": "IMAGE-4f7be017-7bb2-4650-b357-536574caaef9", + "targetHandle": "default", + "id": "reactflow__edge-DEEPLAB_V3-d48ad00f-5f1d-4abc-b6e9-5dbca49c6504default-IMAGE-4f7be017-7bb2-4650-b357-536574caaef9default" + }, + { + "source": "LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ec", + "sourceHandle": "default", + "target": "IMAGE-587cc53c-8da9-4bd5-a525-44386424da4b", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-ea2690c7-1b37-40c0-9d02-b000a553c3ecdefault-IMAGE-587cc53c-8da9-4bd5-a525-44386424da4bdefault" + } + ], + "viewport": { + "x": -501.95459935516146, + "y": 197.98083177807212, + "zoom": 1.4811524052100216 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1be1ea1ed9 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/docstring.txt @@ -0,0 +1,9 @@ + +The BART_LARGE_CNN node takes an input dataframe with multiple rows and a single column, and produces a dataframe with a single "summary_text" column. + +The "summary_text" column contains a summary of the text in the corresponding row of the input dataframe. + +Returns +------- +DataFrame + dataframe containing the summary text in the "summary_text" column diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..cec0319c75 --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/a1-[autogen]/python_code.txt @@ -0,0 +1,78 @@ +from flojoy import flojoy, run_in_venv, DataFrame + + +@flojoy +@run_in_venv( + pip_dependencies=[ + "transformers==4.30.2", + "torch==2.0.1", + "torchvision==0.15.2", + "pandas==1.5.3", + ] +) +def BART_LARGE_CNN(default: DataFrame) -> DataFrame: + + + import torch + from flojoy import snapshot_download + from transformers import BartTokenizer, BartForConditionalGeneration + import pandas as pd + + input_df = default.m + + assert ( + len(input_df.columns.tolist()) == 1 + ), "Can only take a single-column dataframe as input" + + # Load the repo from either the local cache or from the web, and get the local path + local_path = snapshot_download( + repo_id="facebook/bart-large-cnn", revision="3d22493" + ) + + # Load the pre-trained BART model + model = BartForConditionalGeneration.from_pretrained(local_path) + tokenizer = BartTokenizer.from_pretrained(local_path) + + def _chunk_text(text): + inputs_no_trunc = tokenizer( + text, max_length=None, return_tensors="pt", truncation=False + ) + chunks = [] + step = 1024 + # step = tokenizer.model_max_length - 1 + for i in range(0, len(inputs_no_trunc["input_ids"][0]), step): + chunk = inputs_no_trunc["input_ids"][0][i : i + step] + chunks.append(torch.unsqueeze(chunk, 0)) + return chunks + + def _summarize_text(text): + chunks = _chunk_text(text) + summary_ids = [ + model.generate( + chunk, + num_beams=4, + max_length=1024 // 2, + early_stopping=True, + ) + for chunk in chunks + ] + summaries = [ + "\n".join( + [ + tokenizer.decode( + g, skip_special_tokens=True, clean_up_tokenization_spaces=False + ) + for g in id + ] + ) + for id in summary_ids + ] + return "\n".join(summaries) + + column = input_df.columns[0] + + with torch.inference_mode(): + output_df = pd.DataFrame( + input_df[column].apply(_summarize_text).rename("summary_text") + ) + return DataFrame(df=output_df) diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/hardware.md b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/media.md b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/notes.md b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/examples/EX1/app.txt new file mode 100644 index 0000000000..97cf9e2fba --- /dev/null +++ b/docs/nodes/flojoy_nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/examples/EX1/app.txt @@ -0,0 +1,221 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 180, + "id": "READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "desc": "File path to the CSV file or an URL of CSV file", + "functionName": "READ_CSV", + "param": "file_path", + "value": "PYTHON/nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/assets/story.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": -193.61455765591296, + "y": 22.506262839810688 + }, + "selected": false, + "positionAbsolute": { + "x": -193.61455765591296, + "y": 22.506262839810688 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6", + "type": "AI_ML", + "data": { + "id": "BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6", + "label": "BART LARGE CNN", + "func": "BART_LARGE_CNN", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes/AI_ML/TEXT_SUMMARIZATION/BART_LARGE_CNN/BART_LARGE_CNN.py", + "selected": false + }, + "position": { + "x": 28.275977938396807, + "y": 23.26432657684532 + }, + "selected": false, + "positionAbsolute": { + "x": 28.275977938396807, + "y": 23.26432657684532 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-d835eca9-2954-43ea-9970-2345933e2629", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-d835eca9-2954-43ea-9970-2345933e2629", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 265.7401587466265, + "y": -1.1595788699638092 + }, + "selected": false, + "positionAbsolute": { + "x": 265.7401587466265, + "y": -1.1595788699638092 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-aa682847-ab68-4ef8-a3fa-bc0ad1c4f002", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-aa682847-ab68-4ef8-a3fa-bc0ad1c4f002", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": -8.474838373483692, + "y": -232.87989856523 + }, + "selected": false, + "positionAbsolute": { + "x": -8.474838373483692, + "y": -232.87989856523 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0", + "sourceHandle": "default", + "target": "BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0default-BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6default" + }, + { + "source": "READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0", + "sourceHandle": "default", + "target": "TABLE-aa682847-ab68-4ef8-a3fa-bc0ad1c4f002", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-c6754ffa-7213-485b-a8b5-0a0f7b5bebe0default-TABLE-aa682847-ab68-4ef8-a3fa-bc0ad1c4f002default" + }, + { + "source": "BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6", + "sourceHandle": "default", + "target": "TABLE-d835eca9-2954-43ea-9970-2345933e2629", + "targetHandle": "default", + "id": "reactflow__edge-BART_LARGE_CNN-cfe29f1d-4632-4270-af07-2eb6b5848cd6default-TABLE-d835eca9-2954-43ea-9970-2345933e2629default" + } + ], + "viewport": { + "x": 671.2662705290845, + "y": 234.65628139815956, + "zoom": 0.9964993552221201 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..5e46bb3fd0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/docstring.txt @@ -0,0 +1,17 @@ + +The EXTRACT_COLUMNS node takes an input dataframe/matrix and returns a dataframe/matrix with only the specified columns. + +Inputs +------ +default : DataFrame|Matrix + Input to use as the table for column extraction + +Parameters +---------- +columns : list of str or list of int + The columns to extract from the input dataframe + +Returns +------- +DataFrame|Matrix + DataFrame or Matrix with only the specified columns diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..cdc20a5492 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/a1-[autogen]/python_code.txt @@ -0,0 +1,16 @@ +from flojoy import flojoy, DataFrame, Matrix, Array +import numpy as np + + +@flojoy +def EXTRACT_COLUMNS(default: DataFrame | Matrix, columns: Array) -> DataFrame: + + if isinstance(default, DataFrame): + df = default.m + new_df = df[columns.unwrap()] if columns else df + return DataFrame(df=new_df) + else: + matrix = default.m + indices = np.array(columns.unwrap(), dtype=int) + new_matrix = matrix[:, indices] if columns else matrix + return Matrix(m=new_matrix) diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/hardware.md b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/media.md b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/notes.md b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/examples/EX1/app.txt new file mode 100644 index 0000000000..5a7db60d80 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/DATAFRAME/EXTRACT_COLUMNS/examples/EX1/app.txt @@ -0,0 +1,288 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "tips" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": 246.6265685991994, + "y": 514.6410134767791 + }, + "selected": false, + "positionAbsolute": { + "x": 246.6265685991994, + "y": 514.6410134767791 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018", + "label": "EXTRACT COLUMNS", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "tip, time" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 586.4576631006794, + "y": 385.19678110303124 + }, + "selected": false, + "positionAbsolute": { + "x": 586.4576631006794, + "y": 385.19678110303124 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444", + "type": "EXTRACTORS", + "data": { + "id": "EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444", + "label": "EXTRACT COLUMNS 1", + "func": "EXTRACT_COLUMNS", + "type": "EXTRACTORS", + "ctrls": { + "columns": { + "type": "Array", + "default": null, + "functionName": "EXTRACT_COLUMNS", + "param": "columns", + "value": "total_bill" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/EXTRACT_COLUMNS/EXTRACT_COLUMNS/EXTRACT_COLUMNS.py", + "selected": false + }, + "position": { + "x": 583.6116199640052, + "y": 638.6433365798632 + }, + "selected": false, + "positionAbsolute": { + "x": 583.6116199640052, + "y": 638.6433365798632 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-54f2efe9-ff96-4337-a557-5b04987361a1", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-54f2efe9-ff96-4337-a557-5b04987361a1", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 860.9858764800861, + "y": 316.2359989426046 + }, + "selected": false, + "positionAbsolute": { + "x": 860.9858764800861, + "y": 316.2359989426046 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-78464c37-c0ed-4eeb-ac3a-0d13b241e24a", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-78464c37-c0ed-4eeb-ac3a-0d13b241e24a", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 868.488229602283, + "y": 655.3282103193458 + }, + "selected": false, + "positionAbsolute": { + "x": 868.488229602283, + "y": 655.3282103193458 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816default-EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018default" + }, + { + "source": "PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816", + "sourceHandle": "default", + "target": "EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-d91971aa-7143-46d8-82a7-5ec15eba9816default-EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444default" + }, + { + "source": "EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018", + "sourceHandle": "default", + "target": "TABLE-54f2efe9-ff96-4337-a557-5b04987361a1", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_COLUMNS-e8f40b9e-1d83-478f-b43a-e0a53829e018default-TABLE-54f2efe9-ff96-4337-a557-5b04987361a1default" + }, + { + "source": "EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444", + "sourceHandle": "default", + "target": "TABLE-78464c37-c0ed-4eeb-ac3a-0d13b241e24a", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_COLUMNS-19b5a943-df28-49dd-b030-f48cd6fc0444default-TABLE-78464c37-c0ed-4eeb-ac3a-0d13b241e24adefault" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c6d15f45fa --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The OPEN_IMAGE node loads an image file from disk and returns an image type DataContainer object. + +Inputs +------ +default: None + +Parameters +---------- +file_path : str + path to the file to be loaded + +Returns +------- +Image + Image loaded from specified file path diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a6fdc8b8fd --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/a1-[autogen]/python_code.txt @@ -0,0 +1,30 @@ +from os import path +from flojoy import flojoy, Image +from matplotlib import image +from numpy import asarray + + +@flojoy +def OPEN_IMAGE(file_path: str = "") -> Image: + + + if not path.exists(file_path): + raise ValueError("File path does not exist!") + read_image = image.imread(file_path) + data = asarray(read_image) + + red_channel = data[:, :, 0] + green_channel = data[:, :, 1] + blue_channel = data[:, :, 2] + + if data.shape[2] == 4: + alpha_channel = data[:, :, 3] + else: + alpha_channel = None + + return Image( + r=red_channel, + g=green_channel, + b=blue_channel, + a=alpha_channel, + ) diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/hardware.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/media.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/notes.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/examples/EX1/app.txt new file mode 100644 index 0000000000..c87778339a --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_IMAGE/examples/EX1/app.txt @@ -0,0 +1,119 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "OPEN_IMAGE-2bfde548-fc1a-46ae-bab1-1352eea39ae9", + "type": "EXTRACTORS", + "data": { + "id": "OPEN_IMAGE-2bfde548-fc1a-46ae-bab1-1352eea39ae9", + "label": "OPEN IMAGE", + "func": "OPEN_IMAGE", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "", + "functionName": "OPEN_IMAGE", + "param": "file_path", + "value": "./PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/assets/astronaut.png" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/OPEN_IMAGE/OPEN_IMAGE.py", + "selected": false + }, + "position": { + "x": 858.9345817189944, + "y": 387.14456168656636 + }, + "selected": false, + "positionAbsolute": { + "x": 858.9345817189944, + "y": 387.14456168656636 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-1f5192a8-cc27-4d99-beeb-a6632586b6d3", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-1f5192a8-cc27-4d99-beeb-a6632586b6d3", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1410.405681319957, + "y": 349.2352236827468 + }, + "selected": false, + "positionAbsolute": { + "x": 1410.405681319957, + "y": 349.2352236827468 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "OPEN_IMAGE-2bfde548-fc1a-46ae-bab1-1352eea39ae9", + "sourceHandle": "default", + "target": "IMAGE-1f5192a8-cc27-4d99-beeb-a6632586b6d3", + "targetHandle": "default", + "id": "reactflow__edge-OPEN_IMAGE-2bfde548-fc1a-46ae-bab1-1352eea39ae9default-IMAGE-1f5192a8-cc27-4d99-beeb-a6632586b6d3default" + } + ], + "viewport": { + "x": -501.95459935516146, + "y": 197.98083177807212, + "zoom": 1.4811524052100216 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1ea53a05fe --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The OPEN_PARQUET node loads a local file of the .parquet file format. It then returns the file as a pandas.Dataframe type. + +Inputs +------ +default: None + +Parameters +---------- +file_path : str + File path to the .parquet file or an URL of a .parquet file. + +Returns +------- +DataFrame + DataFrame loaded from .parquet file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..b13c6ccc38 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/a1-[autogen]/python_code.txt @@ -0,0 +1,18 @@ +from os import path +from flojoy import flojoy, DataFrame +import pandas as pd + + +@flojoy(deps={"pyarrow": "12.0.1", "fastparquet": "2023.7.0"}) +def OPEN_PARQUET(file_path: str = "") -> DataFrame: + + + if file_path[-8:] != ".parquet": + raise ValueError(f"File type {file_path[-8:]} unsupported.") + + if not path.exists(file_path): + raise ValueError("File path does not exist!") + + read_parquet = pd.read_parquet(file_path) + + return DataFrame(df=read_parquet) diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/hardware.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/media.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/notes.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/examples/EX1/app.txt new file mode 100644 index 0000000000..68b082c1c0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/OPEN_PARQUET/examples/EX1/app.txt @@ -0,0 +1,129 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "OPEN_PARQUET-196993ec-f559-44c6-8d7d-14360ed20ce7", + "type": "EXTRACTORS", + "data": { + "id": "OPEN_PARQUET-196993ec-f559-44c6-8d7d-14360ed20ce7", + "label": "OPEN PARQUET", + "func": "OPEN_PARQUET", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "", + "functionName": "OPEN_PARQUET", + "param": "file_path", + "value": "./PYTHON/nodes/EXTRACTORS/FILE/OPEN_PARQUET/assets/userdata1.parquet" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "pyarrow", + "v": "12.0.1" + }, + { + "name": "fastparquet", + "v": "2023.7.0" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/OPEN_PARQUET/OPEN_PARQUET.py", + "selected": false + }, + "position": { + "x": 138.68874411360315, + "y": 189.74714000262355 + }, + "selected": false, + "positionAbsolute": { + "x": 138.68874411360315, + "y": 189.74714000262355 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-af6328dd-0379-4824-898f-d0d3b677b664", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-af6328dd-0379-4824-898f-d0d3b677b664", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 520.163885181978, + "y": 149.0810155005708 + }, + "selected": false, + "positionAbsolute": { + "x": 520.163885181978, + "y": 149.0810155005708 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "OPEN_PARQUET-196993ec-f559-44c6-8d7d-14360ed20ce7", + "sourceHandle": "default", + "target": "TABLE-af6328dd-0379-4824-898f-d0d3b677b664", + "targetHandle": "default", + "id": "reactflow__edge-OPEN_PARQUET-196993ec-f559-44c6-8d7d-14360ed20ce7default-TABLE-af6328dd-0379-4824-898f-d0d3b677b664default" + } + ], + "viewport": { + "x": -456.37712173371256, + "y": 259.03077225262325, + "zoom": 1.3466637668169514 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1112336657 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The READ_CSV node reads a .csv file from disk or a URL, and then returns a dataframe. + +Parameters +---------- +file_path : str + File path to the .csv file or an URL of a .csv file. + +Returns +------- +DataFrame + DataFrame loaded from .csv file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..f16ff47fe6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/a1-[autogen]/python_code.txt @@ -0,0 +1,11 @@ +from flojoy import flojoy, DataFrame +import pandas as pd + + +@flojoy +def READ_CSV( + file_path: str = "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", +) -> DataFrame: + + df = pd.read_csv(file_path) # type: ignore + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/hardware.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/media.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/notes.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/examples/EX1/app.txt new file mode 100644 index 0000000000..81db078534 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_CSV/examples/EX1/app.txt @@ -0,0 +1,119 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "READ_CSV-8b04aea4-84df-4d71-ae8c-356334a25be2", + "type": "EXTRACTORS", + "data": { + "id": "READ_CSV-8b04aea4-84df-4d71-ae8c-356334a25be2", + "label": "READ CSV", + "func": "READ_CSV", + "type": "EXTRACTORS", + "ctrls": { + "file_path": { + "type": "str", + "default": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv", + "functionName": "READ_CSV", + "param": "file_path", + "value": "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_CSV/READ_CSV.py", + "selected": false + }, + "position": { + "x": 432.8381403735173, + "y": 231.4266921283094 + }, + "selected": false, + "positionAbsolute": { + "x": 432.8381403735173, + "y": 231.4266921283094 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-de9611d6-a05a-4679-afe3-a7fa7f49f8a4", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-de9611d6-a05a-4679-afe3-a7fa7f49f8a4", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 960.2573915409084, + "y": 186.96473062581748 + }, + "selected": false, + "positionAbsolute": { + "x": 960.2573915409084, + "y": 186.96473062581748 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_CSV-8b04aea4-84df-4d71-ae8c-356334a25be2", + "sourceHandle": "default", + "target": "TABLE-de9611d6-a05a-4679-afe3-a7fa7f49f8a4", + "targetHandle": "default", + "id": "reactflow__edge-READ_CSV-8b04aea4-84df-4d71-ae8c-356334a25be2default-TABLE-de9611d6-a05a-4679-afe3-a7fa7f49f8a4default" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 75.99194886435214, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1cea04d2eb --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/docstring.txt @@ -0,0 +1,21 @@ + +The READ_S3 node takes a S3_key name, S3 bucket name, and file name as input, and extracts the file from the specified bucket using the S3_key that was saved. + +Inputs +------ +default: None + +Parameters +---------- +s3_name : str + name of the key that the user used to save access and secret access key +bucket_name : str + AWS S3 bucket name that they are trying to access +file_name : str + name of the file that they want to extract + +Returns +------- +DataFrame + DataFrame loaded from file in the specfied bucket + diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..2a03b5f98d --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/a1-[autogen]/python_code.txt @@ -0,0 +1,32 @@ +import pandas as pd +import io +import boto3 +import keyring +from flojoy import flojoy, DataFrame + + +@flojoy +def READ_S3( + s3_name: str = "", + bucket_name: str = "", + file_name: str = "", +) -> DataFrame: + + if s3_name == "": + raise ValueError("Provide a name that was used to set AWS S3 key") + + try: + accessKey = keyring.get_password("system", f"{s3_name}_ACCESSKEY") + secretKey = keyring.get_password("system", f"{s3_name}_SECRETKEY") + s3 = boto3.resource( + "s3", aws_access_key_id=accessKey, aws_secret_access_key=secretKey + ) + object = s3.Object(bucket_name, file_name) + buffer = io.BytesIO() + object.download_fileobj(buffer) + df = pd.read_parquet(buffer) + + return DataFrame(df=df) + + except Exception as e: + print(e) diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/hardware.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/media.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/notes.md b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/examples/EX1/app.txt new file mode 100644 index 0000000000..228e0dc4e3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/EXTRACTORS/FILE/READ_S3/examples/EX1/app.txt @@ -0,0 +1,139 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 180, + "id": "READ_S3-a7ae5adf-3873-46e1-b0f1-89abfb885ae6", + "type": "EXTRACTORS", + "data": { + "id": "READ_S3-a7ae5adf-3873-46e1-b0f1-89abfb885ae6", + "label": "READ S3", + "func": "READ_S3", + "type": "EXTRACTORS", + "ctrls": { + "s3_name": { + "type": "str", + "default": "", + "desc": "name of the key that the user used to save access and secret access key", + "functionName": "READ_S3", + "param": "s3_name", + "value": "FLOJOY" + }, + "bucket_name": { + "type": "str", + "default": "", + "desc": "AWS S3 bucket name that they are trying to access", + "functionName": "READ_S3", + "param": "bucket_name", + "value": "flojoy-test" + }, + "file_name": { + "type": "str", + "default": "", + "desc": "name of the file that they want to extract", + "functionName": "READ_S3", + "param": "file_name", + "value": "userdata1.parquet" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes/EXTRACTORS/FILE/READ_S3/READ_S3.py", + "selected": false + }, + "position": { + "x": -30.844856544489318, + "y": -70.41830920648297 + }, + "selected": false, + "positionAbsolute": { + "x": -30.844856544489318, + "y": -70.41830920648297 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-0f7daf14-fbf4-46c1-8d75-124ce212b38e", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-0f7daf14-fbf4-46c1-8d75-124ce212b38e", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 325.5749490958755, + "y": -89.02125782914803 + }, + "selected": false, + "positionAbsolute": { + "x": 325.5749490958755, + "y": -89.02125782914803 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "READ_S3-a7ae5adf-3873-46e1-b0f1-89abfb885ae6", + "sourceHandle": "default", + "target": "TABLE-0f7daf14-fbf4-46c1-8d75-124ce212b38e", + "targetHandle": "default", + "id": "reactflow__edge-READ_S3-a7ae5adf-3873-46e1-b0f1-89abfb885ae6default-TABLE-0f7daf14-fbf4-46c1-8d75-124ce212b38edefault" + } + ], + "viewport": { + "x": 510.21439896404956, + "y": 541.3693344933569, + "zoom": 0.8648007408335578 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..a9d14f1d22 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The PLOTLY_DATASET node retrieves a pandas DataFrame from a Plotly built-in dataset using the provided dataset_key parameter and returns it wrapped in a Flojoy DataFrame class. + +Parameters +---------- +dataset_key : str + +Returns +------- +DataFrame diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..3c53051461 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/a1-[autogen]/python_code.txt @@ -0,0 +1,24 @@ +from flojoy import flojoy, DataFrame +from plotly.express import data +from typing import Literal + + +@flojoy +def PLOTLY_DATASET( + dataset_key: Literal[ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks", + ] = "wind" +) -> DataFrame: + + df = getattr(data, dataset_key)() + + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/examples/EX1/app.txt new file mode 100644 index 0000000000..d37975774e --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/examples/EX1/app.txt @@ -0,0 +1,131 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-18ff6bc0-bc2c-4a83-8d32-e0017d63b86a", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-18ff6bc0-bc2c-4a83-8d32-e0017d63b86a", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "wind" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": 642.5684228036087, + "y": 144.85787227656903 + }, + "selected": false, + "positionAbsolute": { + "x": 642.5684228036087, + "y": 144.85787227656903 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-074b186e-cc6b-43d4-910e-63c2a8e3650a", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-074b186e-cc6b-43d4-910e-63c2a8e3650a", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\TABLE\\TABLE.py", + "selected": false + }, + "position": { + "x": 1069.1596600416776, + "y": 111.92430876780708 + }, + "selected": false, + "positionAbsolute": { + "x": 1069.1596600416776, + "y": 111.92430876780708 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-18ff6bc0-bc2c-4a83-8d32-e0017d63b86a", + "sourceHandle": "default", + "target": "TABLE-074b186e-cc6b-43d4-910e-63c2a8e3650a", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-18ff6bc0-bc2c-4a83-8d32-e0017d63b86adefault-TABLE-074b186e-cc6b-43d4-910e-63c2a8e3650adefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..48d2243d34 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/docstring.txt @@ -0,0 +1,11 @@ + +The R_DATASET node retrieves a pandas DataFrame from rdatasets using the provided dataset_key parameter and returns it wrapped in a DataContainer. + +Parameters +---------- +dataset_key : str + +Returns +------- +DataFrame + A DataContainer object containing the retrieved pandas DataFrame. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..6ac494eec7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/a1-[autogen]/python_code.txt @@ -0,0 +1,100 @@ +from flojoy import flojoy, DataFrame +from rdatasets import data +from typing import Literal + + +@flojoy(deps={"rdatasets": "0.1.0"}) +def R_DATASET( + dataset_key: Literal[ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage", + ] = "iris" +) -> DataFrame: + + + df = data(dataset_key) + + if df is None: + raise ValueError(f"Failed to retrieve '{dataset_key}' from rdatasets package!") + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/examples/EX1/app.txt new file mode 100644 index 0000000000..18a471c2ec --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/examples/EX1/app.txt @@ -0,0 +1,208 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "R_DATASET-52b424e0-d868-40e9-90c2-992ff9c78e0e", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-52b424e0-d868-40e9-90c2-992ff9c78e0e", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\R_DATASET\\R_DATASET.py", + "selected": false + }, + "position": { + "x": 128.51593747608803, + "y": 199.87310163004685 + }, + "selected": false, + "positionAbsolute": { + "x": 128.51593747608803, + "y": 199.87310163004685 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-09b6e8ee-fa4a-43d0-b7d8-4ea7f6678fcd", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-09b6e8ee-fa4a-43d0-b7d8-4ea7f6678fcd", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\TABLE\\TABLE.py", + "selected": false + }, + "position": { + "x": 539.9445089046594, + "y": 128.4445302014754 + }, + "selected": false, + "positionAbsolute": { + "x": 539.9445089046594, + "y": 128.4445302014754 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "R_DATASET-52b424e0-d868-40e9-90c2-992ff9c78e0e", + "sourceHandle": "default", + "target": "TABLE-09b6e8ee-fa4a-43d0-b7d8-4ea7f6678fcd", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-52b424e0-d868-40e9-90c2-992ff9c78e0edefault-TABLE-09b6e8ee-fa4a-43d0-b7d8-4ea7f6678fcddefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..34feccc0da --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/docstring.txt @@ -0,0 +1,37 @@ +The TEXT_DATASET node loads the 20 newsgroups dataset from scikit-learn. + The data is returned as a dataframe with one column containing the text + and the other containing the category. + + Parameters + ---------- + subset: "train" | "test" | "all", default="train" + Select the dataset to load: "train" for the training set, "test" for the test set, "all" for both. + categories: list of str, optional + Select the categories to load. By default, all categories are loaded. + The list of all categories is: + 'alt.atheism', + 'comp.graphics', + 'comp.os.ms-windows.misc', + 'comp.sys.ibm.pc.hardware', + 'comp.sys.mac.hardware', + 'comp.windows.x', + 'misc.forsale', + 'rec.autos', + 'rec.motorcycles', + 'rec.sport.baseball', + 'rec.sport.hockey', + 'sci.crypt', + 'sci.electronics', + 'sci.med', + 'sci.space', + 'soc.religion.christian', + 'talk.politics.guns', + 'talk.politics.mideast', + 'talk.politics.misc', + 'talk.religion.misc' + remove_headers: boolean, default=false + Remove the headers from the data. + remove_footers: boolean, default=false + Remove the footers from the data. + remove_quotes: boolean, default=false + Remove the quotes from the data. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..86ee6b3f55 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/a1-[autogen]/python_code.txt @@ -0,0 +1,36 @@ +from flojoy import flojoy, DataFrame, Array +from sklearn.datasets import fetch_20newsgroups +from sklearn.utils import Bunch +import pandas as pd +from typing import cast, Literal, Optional + + +# TODO: Add more datasets to this node. +@flojoy +def TEXT_DATASET( + subset: Literal["train", "test", "all"] = "train", + categories: Optional[Array] = None, + remove_headers: bool = False, + remove_footers: bool = False, + remove_quotes: bool = False, +) -> DataFrame: + + + to_remove = tuple( + ["headers" for remove_headers in [remove_headers] if remove_headers] + + ["footers" for remove_footers in [remove_footers] if remove_footers] + + ["quotes" for remove_quotes in [remove_quotes] if remove_quotes] + ) + + newsgroups = fetch_20newsgroups( + subset=subset, + categories=categories.unwrap() if categories else None, + remove=to_remove, + ) + + newsgroups = cast(Bunch, newsgroups) + data = newsgroups.data + labels = [newsgroups.target_names[i] for i in newsgroups.target] + + df = pd.DataFrame({"Text": data, "Label": labels}) + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/examples/EX1/app.txt new file mode 100644 index 0000000000..a1c2d4f76b --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_DATASETS/TEXT_DATASET/examples/EX1/app.txt @@ -0,0 +1,158 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 225, + "height": 226, + "id": "TABLE-6a242d62-814f-406e-94de-d5c6908dce5e", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-6a242d62-814f-406e-94de-d5c6908dce5e", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1170.5289863217536, + "y": 441.8699692511366 + }, + "selected": false, + "positionAbsolute": { + "x": 1170.5289863217536, + "y": 441.8699692511366 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "TEXT_DATASET-4a227c84-7852-41a2-acdf-248e97fbae85", + "type": "GENERATORS", + "data": { + "id": "TEXT_DATASET-4a227c84-7852-41a2-acdf-248e97fbae85", + "label": "TEXT DATASET", + "func": "TEXT_DATASET", + "type": "GENERATORS", + "ctrls": { + "subset": { + "type": "select", + "default": "train", + "options": [ + "train", + "test", + "all" + ], + "desc": "Select the dataset to load: \"train\" for the training set, \"test\" for the test set, \"all\" for both.", + "functionName": "TEXT_DATASET", + "param": "subset", + "value": "train" + }, + "categories": { + "type": "Array", + "default": null, + "desc": "Select the categories to load. By default, all categories are loaded.\nThe list of all categories is:\n'alt.atheism',\n'comp.graphics',\n'comp.os.ms-windows.misc',\n'comp.sys.ibm.pc.hardware',\n'comp.sys.mac.hardware',\n'comp.windows.x',\n'misc.forsale',\n'rec.autos',\n'rec.motorcycles',\n'rec.sport.baseball',\n'rec.sport.hockey',\n'sci.crypt',\n'sci.electronics',\n'sci.med',\n'sci.space',\n'soc.religion.christian',\n'talk.politics.guns',\n'talk.politics.mideast',\n'talk.politics.misc',\n'talk.religion.misc'", + "functionName": "TEXT_DATASET", + "param": "categories", + "value": "comp.graphics,alt.atheism" + }, + "remove_headers": { + "type": "bool", + "default": false, + "desc": "Remove the headers from the data.", + "functionName": "TEXT_DATASET", + "param": "remove_headers", + "value": true + }, + "remove_footers": { + "type": "bool", + "default": false, + "desc": "Remove the footers from the data.", + "functionName": "TEXT_DATASET", + "param": "remove_footers", + "value": true + }, + "remove_quotes": { + "type": "bool", + "default": false, + "desc": "Remove the quotes from the data.", + "functionName": "TEXT_DATASET", + "param": "remove_quotes", + "value": true + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\TEXT_DATASET\\TEXT_DATASET.py", + "selected": false + }, + "position": { + "x": 829.2140671536599, + "y": 506.1845630079231 + }, + "selected": false, + "positionAbsolute": { + "x": 829.2140671536599, + "y": 506.1845630079231 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TEXT_DATASET-4a227c84-7852-41a2-acdf-248e97fbae85", + "sourceHandle": "default", + "target": "TABLE-6a242d62-814f-406e-94de-d5c6908dce5e", + "targetHandle": "default", + "id": "reactflow__edge-TEXT_DATASET-4a227c84-7852-41a2-acdf-248e97fbae85default-TABLE-6a242d62-814f-406e-94de-d5c6908dce5edefault" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..61aa8d505a --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The SKLEARNIMAGE node is designed to load example images from scikit-image. + +Examples can be found here: +https://scikit-image.org/docs/stable/auto_examples/index.html + +Parameters +---------- +img_key : str + The name of the image to be loader from scikit-image. + +Outputs +------- +Image + DataContainer containing image loaded from scikit-image. + diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4e2e0ce36b --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/a1-[autogen]/python_code.txt @@ -0,0 +1,83 @@ +from flojoy import flojoy, Image +from skimage import data +from typing import Literal + + +@flojoy(deps={"scikit-image": "0.21.0"}) +def SKLEARNIMAGE( + img_key: Literal[ + "astronaut", + "binary_blobs", + "brain", + "brick", + "camera", + "cat", + "cell", + "cells3d", + "checkerboard", + "chelsea", + "clock", + "coffee", + "coins", + "colorwheel", + "create_image_fetcher", + "data_dir", + "download_all", + "eagle", + "file_hash", + "grass", + "gravel", + "horse", + "hubble_deep_field", + "human_mitosis", + "image_fetcher", + "immunohistochemistry", + "kidney", + "lbp_frontal_face_cascade_filename", + "lfw_subset", + "lily", + "logo", + "microaneurysms", + "moon", + "nickel_solidification", + "page", + "protein_transport", + "retina", + "rocket", + "shepp_logan_phantom", + "skin", + "stereo_motorcycle", + "text", + "vortex", + ] = "astronaut" +) -> Image: + + + img_array = getattr(data, img_key)() + + if len(img_array.shape) == 2: + red = green = blue = img_array + alpha = None + elif len(img_array.shape) == 3: + # Color image + if img_array.shape[2] == 3: + red, green, blue = ( + img_array[:, :, 0], + img_array[:, :, 1], + img_array[:, :, 2], + ) + alpha = None + elif img_array.shape[2] == 4: + red, green, blue, alpha = ( + img_array[:, :, 0], + img_array[:, :, 1], + img_array[:, :, 2], + img_array[:, :, 3], + ) + + return Image( + r=red, + g=green, + b=blue, + a=alpha, + ) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/examples/EX1/app.txt new file mode 100644 index 0000000000..3a332f46f3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/examples/EX1/app.txt @@ -0,0 +1,257 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8", + "type": "default", + "data": { + "id": "SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8", + "label": "SKLEARNIMAGE", + "func": "SKLEARNIMAGE", + "type": "default", + "ctrls": { + "img_key": { + "type": "select", + "default": null, + "options": [ + "astronaut", + "binary_blobs", + "brain", + "brick", + "camera", + "cat", + "cell", + "cells3d", + "checkerboard", + "chelsea", + "clock", + "coffee", + "coins", + "colorwheel", + "create_image_fetcher", + "data_dir", + "download_all", + "eagle", + "file_hash", + "grass", + "gravel", + "horse", + "hubble_deep_field", + "human_mitosis", + "image_fetcher", + "immunohistochemistry", + "kidney", + "lbp_frontal_face_cascade_filename", + "lfw_subset", + "lily", + "logo", + "microaneurysms", + "moon", + "nickel_solidification", + "page", + "protein_transport", + "retina", + "rocket", + "shepp_logan_phantom", + "skin", + "stereo_motorcycle", + "text", + "vortex" + ], + "functionName": "SKLEARNIMAGE", + "param": "img_key", + "value": "astronaut" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_IMAGES/SKLEARNIMAGE/SKLEARNIMAGE.py", + "selected": false + }, + "position": { + "x": 210.34307729224753, + "y": 18.719023756686905 + }, + "selected": false, + "positionAbsolute": { + "x": 210.34307729224753, + "y": 18.719023756686905 + } + }, + { + "width": 150, + "height": 150, + "id": "OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062", + "type": "AI_ML", + "data": { + "id": "OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062", + "label": "OBJECT DETECTION", + "func": "OBJECT_DETECTION", + "type": "AI_ML", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION/OBJECT_DETECTION.py", + "selected": false + }, + "position": { + "x": 672.8186360339052, + "y": 5.372907505069605 + }, + "selected": false, + "positionAbsolute": { + "x": 672.8186360339052, + "y": 5.372907505069605 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 940.0318111970437, + "y": 255.64889946924262 + }, + "selected": false, + "positionAbsolute": { + "x": 940.0318111970437, + "y": 255.64889946924262 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 463.2797046471253, + "y": 253.34979215719778 + }, + "selected": false, + "positionAbsolute": { + "x": 463.2797046471253, + "y": 253.34979215719778 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8", + "sourceHandle": "default", + "target": "OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062", + "targetHandle": "default", + "id": "reactflow__edge-SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8default-OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062default" + }, + { + "source": "SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8", + "sourceHandle": "default", + "target": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "targetHandle": "default", + "id": "reactflow__edge-SKLEARNIMAGE-874fdd2b-fea5-4dc6-8898-2905d070aca8default-IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406default" + }, + { + "source": "OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062", + "sourceHandle": "default", + "target": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "targetHandle": "default", + "id": "reactflow__edge-OBJECT_DETECTION-4ba045ca-f490-4f8b-853c-9c38e1297062default-IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427cdefault" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..bc0619426b --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/docstring.txt @@ -0,0 +1,27 @@ + +The BASIC_OSCILLATOR node is a combination of the LINSPACE and SINE nodes. + +It offers a more straightforward way to generate signals, with sample rate and the time in seconds as parameters, along with all the parameters in the SINE node. + +Parameters +---------- +sample_rate : float + How many samples are taken in a second. +time : float + The total amount of time of the signal. +waveform : select + The waveform type of the wave. +amplitude : float + The amplitude of the wave. +frequency : float + The wave frequency in radians/2pi. +offset : float + The y axis offset of the function. +phase : float + The x axis offset of the function. + +Returns +------- +OrderedPair + x: time domain + y: generated signal diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..e6df43aa74 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/a1-[autogen]/python_code.txt @@ -0,0 +1,30 @@ +import numpy as np +from flojoy import flojoy, OrderedPair +from scipy import signal +from typing import Literal + + +@flojoy(node_type="default") +def BASIC_OSCILLATOR( + sample_rate: int = 100, + time: int = 10, + waveform: Literal["sine", "square", "triangle", "sawtooth"] = "sine", + amplitude: float = 1, + frequency: float = 1, + offset: float = 0, + phase: float = 0, +) -> OrderedPair: + + samples = sample_rate * time + x = np.linspace(0, time, samples) + + if waveform == "sine": + y = offset + amplitude * np.sin(2 * np.pi * frequency * x + phase) + elif waveform == "square": + y = offset + amplitude * signal.square(2 * np.pi * frequency * x + phase) + elif waveform == "triangle": + y = offset + amplitude * signal.sawtooth(2 * np.pi * frequency * x + phase, 0.5) + else: # Sawtooth + y = offset + amplitude * signal.sawtooth(2 * np.pi * frequency * x + phase) + + return OrderedPair(x=x, y=y) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/examples/EX1/app.txt new file mode 100644 index 0000000000..9580ecd6ea --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/examples/EX1/app.txt @@ -0,0 +1,358 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-e5431bde-534f-49ca-a5e2-20c9c1f7fe08", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-e5431bde-534f-49ca-a5e2-20c9c1f7fe08", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "40" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": 10 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": "3" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "1" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 1227.4032746661196, + "y": 161.28781474974653 + }, + "selected": false, + "positionAbsolute": { + "x": 1227.4032746661196, + "y": 161.28781474974653 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-a1b62de0-c53a-44d8-8980-66221aaa2fdd", + "type": "default", + "data": { + "id": "LINSPACE-a1b62de0-c53a-44d8-8980-66221aaa2fdd", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "10" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "400" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 1224.7583149254278, + "y": 440.94212795790025 + }, + "selected": false, + "positionAbsolute": { + "x": 1224.7583149254278, + "y": 440.94212795790025 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0e", + "type": "GENERATORS", + "data": { + "id": "SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0e", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": "3" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": "1" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 1513.5508358185066, + "y": 460.3660821818519 + }, + "selected": false, + "positionAbsolute": { + "x": 1513.5508358185066, + "y": 460.3660821818519 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-6e4cafcb-cabe-4fb8-8a29-9272f541955f", + "type": "VISUALIZERS", + "data": { + "id": "LINE-6e4cafcb-cabe-4fb8-8a29-9272f541955f", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1774.1165516383596, + "y": 438.4713323950528 + }, + "selected": false, + "positionAbsolute": { + "x": 1774.1165516383596, + "y": 438.4713323950528 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-2d820744-6626-4ad9-8560-6b61fc8f2cab", + "type": "VISUALIZERS", + "data": { + "id": "LINE-2d820744-6626-4ad9-8560-6b61fc8f2cab", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1720.3114213913743, + "y": 114.49352467764686 + }, + "selected": false, + "positionAbsolute": { + "x": 1720.3114213913743, + "y": 114.49352467764686 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-a1b62de0-c53a-44d8-8980-66221aaa2fdd", + "sourceHandle": "default", + "target": "SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0e", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-a1b62de0-c53a-44d8-8980-66221aaa2fdddefault-SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0edefault", + "selected": false + }, + { + "source": "BASIC_OSCILLATOR-e5431bde-534f-49ca-a5e2-20c9c1f7fe08", + "sourceHandle": "default", + "target": "LINE-2d820744-6626-4ad9-8560-6b61fc8f2cab", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-e5431bde-534f-49ca-a5e2-20c9c1f7fe08default-LINE-2d820744-6626-4ad9-8560-6b61fc8f2cabdefault" + }, + { + "source": "SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0e", + "sourceHandle": "default", + "target": "LINE-6e4cafcb-cabe-4fb8-8a29-9272f541955f", + "targetHandle": "default", + "id": "reactflow__edge-SINE-8aa9e195-26c1-4dd8-8e79-95a07e3b0f0edefault-LINE-6e4cafcb-cabe-4fb8-8a29-9272f541955fdefault" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3915fa1965 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/docstring.txt @@ -0,0 +1,20 @@ + +The CONSTANT node generates a single x-y vector of numeric (floating point) constants. + +Inputs +------ +default : OrderedPair|Vector + Optional input that defines the size of the output. + +Parameters +---------- +constant : float + The value of the y axis output +step : int + The size of the y and x axes. + +Returns +------- +OrderedPair + x: the x axis generated with size 'step' + y: the resulting constant with size 'step' diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..5a0531074a --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/a1-[autogen]/python_code.txt @@ -0,0 +1,23 @@ +import numpy as np +from flojoy import DCNpArrayType, flojoy, Vector, OrderedPair +from typing import Optional + + +@flojoy +def CONSTANT( + default: Optional[Vector | OrderedPair] = None, + constant: float = 3.0, + step: float = 1000, +) -> OrderedPair: + + x = np.arange(0, step, 1) + if default: + match default: + case OrderedPair(): + x = default.y + case Vector(): + x = default.v + + y = np.full(len(x), constant) + + return OrderedPair(x=x, y=y) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/examples/EX1/app.txt new file mode 100644 index 0000000000..c058ac1335 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/CONSTANT/examples/EX1/app.txt @@ -0,0 +1,173 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "CONSTANT-9bfa0626-7664-41a7-b5bc-ec8f62540e35", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-9bfa0626-7664-41a7-b5bc-ec8f62540e35", + "label": "3.0", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": 3 + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": 1000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": -130.83989138018498, + "y": 13.422546284269998 + }, + "selected": false, + "positionAbsolute": { + "x": -130.83989138018498, + "y": 13.422546284269998 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "BIG_NUMBER-23d35b1d-f436-4201-8aa1-69c93ff7ed99", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-23d35b1d-f436-4201-8aa1-69c93ff7ed99", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BIG_NUMBER\\BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 294.1748962833931, + "y": -62.1556648169163 + }, + "selected": false, + "positionAbsolute": { + "x": 294.1748962833931, + "y": -62.1556648169163 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONSTANT-9bfa0626-7664-41a7-b5bc-ec8f62540e35", + "sourceHandle": "default", + "target": "BIG_NUMBER-23d35b1d-f436-4201-8aa1-69c93ff7ed99", + "targetHandle": "default", + "id": "reactflow__edge-CONSTANT-9bfa0626-7664-41a7-b5bc-ec8f62540e35default-BIG_NUMBER-23d35b1d-f436-4201-8aa1-69c93ff7ed99default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..71990759c2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The FEEDBACK node captures the result of the specified node ID. If the result is not found, it passes the result of the parent node. + +Parameters +---------- +referred_node : str + The node ID to capture the result from. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..b051593a1e --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/a1-[autogen]/python_code.txt @@ -0,0 +1,11 @@ +from flojoy import flojoy, DataContainer, get_job_result, NodeReference + + +@flojoy +def FEEDBACK(default: DataContainer, referred_node: NodeReference) -> DataContainer: + + result = get_job_result(referred_node.ref) + if result: + return result + else: + return default diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/examples/EX1/app.txt new file mode 100644 index 0000000000..5048a321fd --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/FEEDBACK/examples/EX1/app.txt @@ -0,0 +1,415 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "BIG_NUMBER-e4942bf1-f23a-4344-80eb-c166dabb2dd2", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-e4942bf1-f23a-4344-80eb-c166dabb2dd2", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BIG_NUMBER\\BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 627.0045699600352, + "y": 110.02353935715365 + }, + "selected": false, + "positionAbsolute": { + "x": 627.0045699600352, + "y": 110.02353935715365 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "type": "GENERATORS", + "data": { + "id": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "label": "FEEDBACK", + "func": "FEEDBACK", + "type": "GENERATORS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": "", + "functionName": "FEEDBACK", + "param": "referred_node", + "value": "MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6a" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\FEEDBACK\\FEEDBACK.py", + "selected": false + }, + "position": { + "x": 341.09724320819623, + "y": 92.35595321700652 + }, + "selected": false, + "positionAbsolute": { + "x": 341.09724320819623, + "y": 92.35595321700652 + }, + "dragging": true + }, + { + "width": 96, + "height": 96, + "id": "LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2f", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2f", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "5" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOPS\\LOOP\\LOOP.py", + "selected": false + }, + "position": { + "x": -175.2242470174267, + "y": 223.309405138469 + }, + "selected": false, + "positionAbsolute": { + "x": -175.2242470174267, + "y": 223.309405138469 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89f", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89f", + "label": "2", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": "2" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": 1000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 50.92457046813533, + "y": 305.3771474020375 + }, + "selected": false, + "positionAbsolute": { + "x": 50.92457046813533, + "y": 305.3771474020375 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bb", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bb", + "label": "4", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": "4" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": 1000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 30.577110066478696, + "y": 130.70166876803648 + }, + "selected": false, + "positionAbsolute": { + "x": 30.577110066478696, + "y": 130.70166876803648 + }, + "dragging": true + }, + { + "width": 72, + "height": 72, + "id": "MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6a", + "type": "ARITHMETIC", + "data": { + "id": "MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6a", + "label": "MULTIPLY", + "func": "MULTIPLY", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Scalar|Vector", + "multiple": false, + "desc": null + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Scalar|Vector", + "multiple": true, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar|Vector", + "desc": null + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\ARITHMETIC\\MULTIPLY\\MULTIPLY.py", + "selected": false + }, + "position": { + "x": 475.6559607373604, + "y": 304.0731615929962 + }, + "selected": false, + "positionAbsolute": { + "x": 475.6559607373604, + "y": 304.0731615929962 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "sourceHandle": "default", + "target": "BIG_NUMBER-e4942bf1-f23a-4344-80eb-c166dabb2dd2", + "targetHandle": "default", + "id": "reactflow__edge-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault-BIG_NUMBER-e4942bf1-f23a-4344-80eb-c166dabb2dd2default" + }, + { + "source": "LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2f", + "sourceHandle": "body", + "target": "CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bb", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2fbody-CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bbdefault" + }, + { + "source": "LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2f", + "sourceHandle": "body", + "target": "CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89f", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-053d8521-fb3b-4c7d-85d0-9785230aeb2fbody-CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89fdefault" + }, + { + "source": "CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bb", + "sourceHandle": "default", + "target": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "targetHandle": "default", + "id": "reactflow__edge-CONSTANT-449b5a47-6d72-4f30-a239-8b3e2ba721bbdefault-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault" + }, + { + "source": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "sourceHandle": "default", + "target": "MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6a", + "targetHandle": "a", + "id": "reactflow__edge-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault-MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6aa" + }, + { + "source": "CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89f", + "sourceHandle": "default", + "target": "MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6a", + "targetHandle": "b", + "id": "reactflow__edge-CONSTANT-8abbba8b-424f-4b20-888f-1cca9b62f89fdefault-MULTIPLY-c463c154-d47a-4ed4-bc8d-ef5e6d237a6ab" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..9e42f9ac11 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The LINSPACE node generates data spaced evenly between two points. + +It uses the numpy function linspace. It is useful for generating an x axis for the ordered pair data type. + +Inputs +------ +default : OrderedPair + Optional input in case LINSPACE is used in a loop. Not used. + +Parameters +---------- +start : float + The start point of the data. +end : float + The end point of the data. +step : float + The number of points in the vector. + +Returns +------- +Vector + v: the vector between start and end with step number of points. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..3b2aeaa40a --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/a1-[autogen]/python_code.txt @@ -0,0 +1,16 @@ +import numpy as np +from flojoy import flojoy, Vector, OrderedPair +from typing import Optional + + +@flojoy(node_type="default") +def LINSPACE( + default: Optional[OrderedPair | Vector] = None, + start: float = 10, + end: float = 0, + step: int = 1000, +) -> Vector: + + + v = np.linspace(start, end, step) + return Vector(v=v) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/examples/EX1/app.txt new file mode 100644 index 0000000000..2db357aae0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/LINSPACE/examples/EX1/app.txt @@ -0,0 +1,133 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "type": "default", + "data": { + "id": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 1207.3462867113103, + "y": 296.9547453014071 + }, + "selected": false, + "positionAbsolute": { + "x": 1207.3462867113103, + "y": 296.9547453014071 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-3d3c8af8-5efd-4d15-af93-4703e1146018", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-3d3c8af8-5efd-4d15-af93-4703e1146018", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 1456.3282026710792, + "y": 263.2004437204553 + }, + "selected": false, + "positionAbsolute": { + "x": 1456.3282026710792, + "y": 263.2004437204553 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "sourceHandle": "default", + "target": "SCATTER-3d3c8af8-5efd-4d15-af93-4703e1146018", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6cdefault-SCATTER-3d3c8af8-5efd-4d15-af93-4703e1146018default" + } + ], + "viewport": { + "x": -454.16852149654983, + "y": 260.7534565927997, + "zoom": 1.3401466962340274 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..0a14bedc53 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The MATRIX node takes two arguments, row and col, as input. + +Based on these inputs, it generates a random matrix where the integers inside the matrix are between 0 and 19. + +Parameters +---------- +row : int + number of rows +column : int + number of columns + +Returns +------- +matrix + randomly generated matrix diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..38655ab7a0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/a1-[autogen]/python_code.txt @@ -0,0 +1,12 @@ +import numpy as np +from flojoy import flojoy, Matrix + + +@flojoy(node_type="default") +def MATRIX(row: int = 2, column: int = 2) -> Matrix: + + + np.random.seed() + mat = np.random.randint(20, size=(row, column)) + + return Matrix(m=mat) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/examples/EX1/app.txt new file mode 100644 index 0000000000..83474a70d9 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/MATRIX/examples/EX1/app.txt @@ -0,0 +1,126 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 130, + "height": 130, + "id": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "type": "GENERATORS", + "data": { + "id": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "8" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "8" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": 227.31148151690388, + "y": 171.0485680935967 + }, + "selected": false, + "positionAbsolute": { + "x": 227.31148151690388, + "y": 171.0485680935967 + }, + "dragging": true + }, + { + "width": 240, + "height": 260, + "id": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "label": "MATRIX VIEW", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\DATA_STRUCTURE\\MATRIX_VIEW\\MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 611.6471944648578, + "y": 95.620522779557 + }, + "selected": false, + "positionAbsolute": { + "x": 611.6471944648578, + "y": 95.620522779557 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "sourceHandle": "default", + "target": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-957da30a-8624-44d8-93fb-51ec90f92485default-MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498adefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..77fa907315 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt @@ -0,0 +1,32 @@ + +The RAND node generates a random number or a list of random numbers, depending on the distribution selected. + +Inputs +------ +default : OrderedPair|Vector + Optional input to use as the x-axis for the random samples. + +Parameters +---------- +distribution : select + the distribution over the random samples +lower_bound : float + the lower bound of the output interval +upper_bound : float + the upper bound of the output interval +normal_mean : float + the mean or "center" of the normal distribution +normal_standard_deviation : float + the spread or "width" of the normal distribution +poisson_events : float + the expected number of events occurring in a fixed time-interval when distribution is poisson + +Returns +------- +OrderedPair|Scalar + OrderedPair if there is an input. + x: the x-axis of the input + y: the random samples + + Scalar if there is no input. + c: the random number diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..97d72e89b9 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -0,0 +1,44 @@ +import random +import numpy as np +from flojoy import flojoy, OrderedPair, Scalar, Vector +from typing import Literal, Optional + + +@flojoy +def RAND( + default: Optional[OrderedPair | Vector] = None, + distribution: Literal["normal", "uniform", "poisson"] = "normal", + lower_bound: float = 0, + upper_bound: float = 1, + normal_mean: float = 0, + normal_standard_deviation: float = 1, + poisson_events: float = 1, +) -> OrderedPair | Scalar: + + if upper_bound < lower_bound: + upper_bound, lower_bound = lower_bound, upper_bound + + seed = random.randint(1, 10000) + my_generator = np.random.default_rng(seed) + + match default: + case OrderedPair(): + size = len(default.x) + x = default.x + case Vector(): + size = len(default.v) + x = default.v + case _: + size = 1 + + match distribution: + case "uniform": + y = my_generator.uniform(low=lower_bound, high=upper_bound, size=size) + case "normal": + y = my_generator.normal( + loc=normal_mean, scale=normal_standard_deviation, size=size + ) + case "poisson": + y = my_generator.poisson(lam=poisson_events, size=size) + + return OrderedPair(x=x, y=y) if default else Scalar(c=y) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.txt new file mode 100644 index 0000000000..cc4910b1e8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.txt @@ -0,0 +1,392 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", + "type": "default", + "data": { + "id": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "2000" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "2000" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 71.58328955005041, + "y": -121.19469825521614 + }, + "selected": false, + "positionAbsolute": { + "x": 71.58328955005041, + "y": -121.19469825521614 + }, + "dragging": true + }, + { + "width": 250, + "height": 159, + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "label": "HISTOGRAM", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/HISTOGRAM/HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 807.1730016964145, + "y": -111.45313449538975 + }, + "selected": false, + "positionAbsolute": { + "x": 807.1730016964145, + "y": -111.45313449538975 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "type": "GENERATORS", + "data": { + "id": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "label": "RAND", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "functionName": "RAND", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "lower_bound", + "value": "0" + }, + "upper_bound": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "upper_bound", + "value": "1" + }, + "normal_mean": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "normal_mean", + "value": "0" + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": "5" + }, + "poisson_events": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "poisson_events", + "value": "1" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": 454.43802731096747, + "y": -117.22102655068787 + }, + "selected": false, + "positionAbsolute": { + "x": 454.43802731096747, + "y": -117.22102655068787 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "type": "GENERATORS", + "data": { + "id": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "label": "RAND 1", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "functionName": "RAND", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "normal_mean", + "value": "30" + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": "50" + }, + "poisson_events": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "poisson_events", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": 385.163294287524, + "y": 328.61362457174704 + }, + "selected": false, + "positionAbsolute": { + "x": 385.163294287524, + "y": 328.61362457174704 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 818.3036219776461, + "y": 287.8342828015806 + }, + "selected": false, + "positionAbsolute": { + "x": 818.3036219776461, + "y": 287.8342828015806 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", + "sourceHandle": "default", + "target": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486default-RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60adefault" + }, + { + "source": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "sourceHandle": "default", + "target": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "targetHandle": "default", + "id": "reactflow__edge-RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60adefault-HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4default" + }, + { + "source": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "sourceHandle": "default", + "target": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", + "targetHandle": "default", + "id": "reactflow__edge-RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00default-BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266default" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..db762c8d3b --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ +The SECOND_ORDER_SYSTEM has a second order exponential function. + This node is designed to be used in a loop. + The data is appended as the loop progress and written to memory. + + Parameters + ---------- + d1: float + The first time constant. + d2: float + The second time constant. + + Returns + ------- + OrderedPair + The most recent value of the second order function. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7d903ef252 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/a1-[autogen]/python_code.txt @@ -0,0 +1,63 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, DefaultParams, SmallMemory, Vector + + +memory_key = "SECOND_ORDER_SYSTEM" + + +@flojoy(inject_node_metadata=True) +def SECOND_ORDER_SYSTEM( + default: OrderedPair | Vector, + default_params: DefaultParams, + d1: float = 250, + d2: float = 100, +) -> OrderedPair: + + + # Let's first define things that won't change over + # each iteration: time constants, etc ... + match default: + case OrderedPair(): + def_key = default.y + case Vector(): + def_key = default.v + + node_id = default_params.node_id + + # ... and now some helper functions + x1 = np.exp(-1.0 / d1) if d1 > 0 else 0.0 + x2 = np.exp(-1.0 / d2) if d2 > 0 else 0.0 + ac = (1.0 - x1) * (1.0 - x2) + bpd = x1 + x2 + bd = x1 * x2 + + # Now we require memory. The only thing we need in memory is the last two + # values the system had in this basic example. + data = SmallMemory().read_memory(node_id, memory_key) + if data is None: + initialize = True + elif type(data) == np.ndarray: + initialize = False + else: + raise TypeError(f"Error loading object from REDIS. Type: {type(data)}") + + # We're going to store and read the data in reverse order to + # how it is accessed here. We will write the functionality + # below to assume the most recent time step is the first + # index. However, for visualization and external access, + # it makes the most sense to have the first time step + # as the first index! + y_primes = np.zeros((2, 1)) if initialize else data[::-1] + + # Using input from controller as v[0].y ... + response = ac * def_key[-1] + bpd * y_primes[0] - bd * y_primes[1] + y_primes[1] = y_primes[0] + + # prepend the most recent result to the front of the histrory + y_primes = np.insert(y_primes, 0, response) + # We now write to memory, reversing the order ... + SmallMemory().write_to_memory(node_id, memory_key, y_primes[::-1]) + # ... and return the result! + return OrderedPair( + x=def_key, y=np.ones_like(def_key) * float(y_primes[0]) + ) # returns input output pair diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/examples/EX1/app.txt new file mode 100644 index 0000000000..2ebbfa25dd --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/examples/EX1/app.txt @@ -0,0 +1,492 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5", + "label": "100", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "100" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 233.2840998939468, + "y": 257.4687143861847 + }, + "selected": false, + "positionAbsolute": { + "x": 233.2840998939468, + "y": 257.4687143861847 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "type": "TRANSFORMERS", + "data": { + "id": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "label": "PID", + "func": "PID", + "type": "TRANSFORMERS", + "ctrls": { + "Kp": { + "type": "float", + "default": 5, + "functionName": "PID", + "param": "Kp", + "value": 5 + }, + "Ki": { + "type": "float", + "default": 0.0143, + "functionName": "PID", + "param": "Ki", + "value": 0.0143 + }, + "Kd": { + "type": "float", + "default": 356.25, + "functionName": "PID", + "param": "Kd", + "value": 356.25 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\SIGNAL_PROCESSING\\PID\\PID.py", + "selected": false + }, + "position": { + "x": 677.7645079422954, + "y": 81.60321798273725 + }, + "selected": false, + "positionAbsolute": { + "x": 677.7645079422954, + "y": 81.60321798273725 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "type": "GENERATORS", + "data": { + "id": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "label": "SECOND ORDER SYSTEM", + "func": "SECOND_ORDER_SYSTEM", + "type": "GENERATORS", + "ctrls": { + "d1": { + "type": "float", + "default": 250, + "functionName": "SECOND_ORDER_SYSTEM", + "param": "d1", + "value": 250 + }, + "d2": { + "type": "float", + "default": 100, + "functionName": "SECOND_ORDER_SYSTEM", + "param": "d2", + "value": 100 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\SECOND_ORDER_SYSTEM\\SECOND_ORDER_SYSTEM.py", + "selected": false + }, + "position": { + "x": 978.4912585306391, + "y": 87.6001248789845 + }, + "selected": false, + "positionAbsolute": { + "x": 978.4912585306391, + "y": 87.6001248789845 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "type": "GENERATORS", + "data": { + "id": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "label": "FEEDBACK", + "func": "FEEDBACK", + "type": "GENERATORS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": null, + "functionName": "FEEDBACK", + "param": "referred_node", + "value": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\FEEDBACK\\FEEDBACK.py", + "selected": false + }, + "position": { + "x": 232.12842821463732, + "y": -2.0336450690984975 + }, + "selected": false, + "positionAbsolute": { + "x": 232.12842821463732, + "y": -2.0336450690984975 + }, + "dragging": true + }, + { + "width": 72, + "height": 72, + "id": "SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1", + "type": "ARITHMETIC", + "data": { + "id": "SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1", + "label": "SUBTRACT", + "func": "SUBTRACT", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\ARITHMETIC\\SUBTRACT\\SUBTRACT.py", + "selected": false + }, + "position": { + "x": 462.9560157284769, + "y": 114.87540487187692 + }, + "selected": false, + "positionAbsolute": { + "x": 462.9560157284769, + "y": 114.87540487187692 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "type": "VISUALIZERS", + "data": { + "id": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 646.7443796856828, + "y": 431.78879240282043 + }, + "selected": false, + "positionAbsolute": { + "x": 646.7443796856828, + "y": 431.78879240282043 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "type": "LOADERS", + "data": { + "id": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "label": "DS LOAD", + "func": "DS_LOAD", + "type": "LOADERS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": null, + "functionName": "DS_LOAD", + "param": "referred_node", + "value": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 226.90231299211854, + "y": 460.341992432171 + }, + "selected": false, + "positionAbsolute": { + "x": 226.90231299211854, + "y": 460.341992432171 + }, + "dragging": true + }, + { + "width": 96, + "height": 96, + "id": "LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "15" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOPS\\LOOP\\LOOP.py", + "selected": false + }, + "position": { + "x": -69.14789865874168, + "y": 265.86960150811666 + }, + "selected": false, + "positionAbsolute": { + "x": -69.14789865874168, + "y": 265.86960150811666 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1", + "sourceHandle": "default", + "target": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "targetHandle": "default", + "id": "reactflow__edge-SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1default-PID-cee43c6b-237d-45f8-98d0-319f48acaebfdefault" + }, + { + "source": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "sourceHandle": "default", + "target": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "targetHandle": "default", + "id": "reactflow__edge-PID-cee43c6b-237d-45f8-98d0-319f48acaebfdefault-SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622default" + }, + { + "source": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "sourceHandle": "default", + "target": "SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1", + "targetHandle": "a", + "id": "reactflow__edge-FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718ddefault-SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1a" + }, + { + "source": "CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5", + "sourceHandle": "default", + "target": "SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1", + "targetHandle": "b", + "id": "reactflow__edge-CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5default-SUBTRACT-3a3c4ed2-1ec0-433a-b6d6-d9819a2a02c1b" + }, + { + "source": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "sourceHandle": "default", + "target": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "targetHandle": "default", + "id": "reactflow__edge-DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49default-LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9default" + }, + { + "source": "LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5", + "sourceHandle": "body", + "target": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5body-FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718ddefault" + }, + { + "source": "LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5", + "sourceHandle": "body", + "target": "CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5body-CONSTANT-763b863d-7a28-4264-8f33-3e02c65f85d5default" + }, + { + "source": "LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5", + "sourceHandle": "end", + "target": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-55a3deaf-9012-4d05-ad8a-b903d3e07ce5end-DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..5d04404a34 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/docstring.txt @@ -0,0 +1,27 @@ + +The SINE node generates a waveform function. With the shape being defined +by the input. + +Inputs +------ +default : OrderedPair|Vector + Input that defines the x axis values of the function and output. + +Parameters +---------- +waveform : select + The waveform type of the wave. +amplitude : float + The amplitude of the wave. +frequency : float + The wave frequency in radians/2pi. +offset : float + The y axis offset of the function. +phase : float + The x axis offset of the function. + +Returns +------- +OrderedPair + x: the input v or x values + y: the resulting sine function diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..75f28af21a --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Vector +from scipy import signal +from typing import Literal + + +@flojoy +def SINE( + default: OrderedPair | Vector, + amplitude: float = 1, + frequency: float = 1, + offset: float = 0, + phase: float = 0, + waveform: Literal["sine", "square", "triangle", "sawtooth"] = "sine", +) -> OrderedPair: + A = amplitude + F = frequency + Y0 = offset + + match default: + case OrderedPair(): + x = default.y + case _: + x = default.v + + if waveform == "sine": + y = Y0 + A * np.sin(2 * np.pi * F * x + phase) + elif waveform == "square": + y = Y0 + A * signal.square(2 * np.pi * F * x / 10 + phase) + elif waveform == "triangle": + y = Y0 + A * signal.sawtooth(2 * np.pi * F * x / 10 + phase, 0.5) + elif waveform == "sawtooth": + y = Y0 + A * signal.sawtooth(2 * np.pi * F / 10 * x + phase) + + return OrderedPair(x=x, y=y) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/examples/EX1/app.txt new file mode 100644 index 0000000000..a21039a97c --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/SINE/examples/EX1/app.txt @@ -0,0 +1,222 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "type": "default", + "data": { + "id": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 942.4353826333122, + "y": 331.5553531809823 + }, + "selected": false, + "positionAbsolute": { + "x": 942.4353826333122, + "y": 331.5553531809823 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-eea67eed-8065-40ba-9f28-3420f1f4a62a", + "type": "GENERATORS", + "data": { + "id": "SINE-eea67eed-8065-40ba-9f28-3420f1f4a62a", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 1282.4756382562118, + "y": 176.0477365617848 + }, + "selected": false, + "positionAbsolute": { + "x": 1282.4756382562118, + "y": 176.0477365617848 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-0966e710-b72c-4cf4-ade7-1c09a3b14b37", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-0966e710-b72c-4cf4-ade7-1c09a3b14b37", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 1608.9942008510418, + "y": 260.8163753487955 + }, + "selected": false, + "positionAbsolute": { + "x": 1608.9942008510418, + "y": 260.8163753487955 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6c", + "sourceHandle": "default", + "target": "SINE-eea67eed-8065-40ba-9f28-3420f1f4a62a", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-03f57daa-59f9-4a59-9fbd-7a15a4878b6cdefault-SINE-eea67eed-8065-40ba-9f28-3420f1f4a62adefault" + }, + { + "source": "SINE-eea67eed-8065-40ba-9f28-3420f1f4a62a", + "sourceHandle": "default", + "target": "SCATTER-0966e710-b72c-4cf4-ade7-1c09a3b14b37", + "targetHandle": "default", + "id": "reactflow__edge-SINE-eea67eed-8065-40ba-9f28-3420f1f4a62adefault-SCATTER-0966e710-b72c-4cf4-ade7-1c09a3b14b37default" + } + ], + "viewport": { + "x": -454.16852149654983, + "y": 260.7534565927997, + "zoom": 1.3401466962340274 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..0679362594 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + + +The TIMESERIES node generates a random timeseries vector (as a DataFrame). + +Parameters +---------- +start_date : str + The start date of the timeseries in the format YYYY:MM:DD. +end_date : str + The end date of the timeseries in the format YYYY:MM:DD. + +Returns +------- +DataFrame + m: the resulting timeseries diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..5e9f2440c9 --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +import numpy as np +from flojoy import flojoy, DataFrame +import pandas as pd +import traceback + + +@flojoy +def TIMESERIES( + start_date: str = "2023-01-01", end_date: str = "2023-07-20" +) -> DataFrame: + + + try: + # Set the random seed for reproducibility + np.random.seed(42) + + # Generate random time series data + start = pd.Timestamp(start_date) + end = pd.Timestamp(end_date) + num_days = (end - start).days + 1 + timestamps = pd.date_range(start=start, end=end, freq="D") + data = np.random.randn(num_days) # Random data points + + df = pd.DataFrame({"Timestamp": timestamps, "Data": data}) + + return DataFrame(df=df) + except Exception as e: + print(traceback.format_exc()) + raise e diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/examples/EX1/app.txt new file mode 100644 index 0000000000..dd68cf28ce --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/TIMESERIES/examples/EX1/app.txt @@ -0,0 +1,126 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 225, + "height": 226, + "id": "TABLE-e495f7ee-9936-41e5-8341-8532fbe7fc37", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-e495f7ee-9936-41e5-8341-8532fbe7fc37", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 1454.0240539163242, + "y": 449.24417024363777 + }, + "selected": false, + "positionAbsolute": { + "x": 1454.0240539163242, + "y": 449.24417024363777 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "TIMESERIES-32359924-1394-434a-a933-965680772cfb", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-32359924-1394-434a-a933-965680772cfb", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TIMESERIES/TIMESERIES.py", + "selected": false + }, + "position": { + "x": 1083.3085875570803, + "y": 496.01628490654286 + }, + "selected": false, + "positionAbsolute": { + "x": 1083.3085875570803, + "y": 496.01628490654286 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-32359924-1394-434a-a933-965680772cfb", + "sourceHandle": "default", + "target": "TABLE-e495f7ee-9936-41e5-8341-8532fbe7fc37", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-32359924-1394-434a-a933-965680772cfbdefault-TABLE-e495f7ee-9936-41e5-8341-8532fbe7fc37default" + } + ], + "viewport": { + "x": -388.5128599008947, + "y": 286.46416379622787, + "zoom": 1.1464119616325565 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..73d31294ff --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The WAVEPACKET node approximates the behaviour of a 1D Gaussian wavepacket in an infinite-well potential box. + +This example uses the Crank-Nicolson Method to solve the 1D Schrodinger equation. + +Further reading: +http://staff.ustc.edu.cn/~zqj/posts/Numerical_TDSE/ + +Parameters +---------- +L_box : float + The width of the box in Bohr lengths. +center : float + The center of the initial wavepacket. +momentum : float + The momentum of the initial wavepacket. +sigma : float + The width of the initial wavepacket. +dt : float + Time steps in atomic units, 1 a.u. = 24.188 as. + +Returns +------- +OrderedPair + The most recent wavepacket. diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..5d86eef0cb --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/a1-[autogen]/python_code.txt @@ -0,0 +1,85 @@ +import numpy as np +import scipy.sparse as spa +from scipy.sparse.linalg import splu +from flojoy import flojoy, OrderedPair, SmallMemory, DefaultParams +from typing import Optional + + +def gaussian_wavepacket(x, x0, k, sigma=0.1): + # One dimensional Gaussian wavepacket. + x = np.asarray(x) + g = np.sqrt(1 / np.sqrt(np.pi) / sigma) * np.exp(-((x - x0) ** 2) / 2 / sigma**2) + + return np.exp(1j * k * (x - x0)) * g + + +def CrankNicolson(psi, V, x, dt): + # Crank-Nicolson method for the 1D Schrodinger equation. + + # No. of spatial grid points + J = x.size - 1 + dx = x[1] - x[0] + + # the external potential + V_e = spa.diags(V) + # the kinetic operator + O_k = np.ones(J + 1) + T = (-1 / 2 / dx**2) * spa.spdiags([O_k, -2 * O_k, O_k], [-1, 0, 1], J + 1, J + 1) + + # the two unitary matrices + U2 = spa.eye(J + 1) + (1j * 0.5 * dt) * (T + V_e) + U1 = spa.eye(J + 1) - (1j * 0.5 * dt) * (T + V_e) + # splu requires CSC matrix format for efficient decomposition + U2 = U2.tocsc() + LU = splu(U2) + + b = U1.dot(psi) + PSI_t = LU.solve(b) + + return PSI_t + + +memory_key = "WAVEPACKET" + + +@flojoy(inject_node_metadata=True) +def WAVEPACKET( + default_params: DefaultParams, + default: Optional[OrderedPair] = None, + L_box: float = 20, + center: float = 0, + momentum: float = 5, + sigma: float = 1, + dt: float = 0.2, +) -> OrderedPair: + + + node_id = default_params.node_id + + psi_t = SmallMemory().read_memory(node_id, memory_key) + if psi_t is None: + initialize = True + elif isinstance(psi_t, np.ndarray): + initialize = False + else: + raise TypeError("Error loading object from SmallMemory.") + + # Box parameters. + xmin = -L_box / 2.0 # left boundary + J = 999 # No. of spatial grid points + x = np.linspace(xmin, xmin + L_box, J + 1, endpoint=True) + + # The gaussian wavepacket as the initial wavefunction. + psi0 = gaussian_wavepacket(x, x0=center, k=momentum, sigma=sigma) + V_e = np.zeros_like(x) # The externial potentials. + + # The time evolution of the Schrodinger equation. + if initialize: + PSI = CrankNicolson(psi0, V_e, x, dt) + elif not initialize: + PSI = CrankNicolson(psi_t, V_e, x, dt) + + SmallMemory().write_to_memory(node_id, memory_key, PSI) + y = np.abs(PSI) + + return OrderedPair(x=x, y=y) diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/hardware.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/media.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/notes.md b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/examples/EX1/app.txt new file mode 100644 index 0000000000..0585934c8f --- /dev/null +++ b/docs/nodes/flojoy_nodes/GENERATORS/SIMULATIONS/WAVEPACKET/examples/EX1/app.txt @@ -0,0 +1,228 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "LINE-04475ad6-db8e-485b-8169-a90dfb525a8f", + "type": "VISUALIZERS", + "data": { + "id": "LINE-04475ad6-db8e-485b-8169-a90dfb525a8f", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 327.14642964578854, + "y": 198.79482276769716 + }, + "selected": false, + "positionAbsolute": { + "x": 327.14642964578854, + "y": 198.79482276769716 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261", + "type": "GENERATORS", + "data": { + "id": "WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261", + "label": "WAVEPACKET", + "func": "WAVEPACKET", + "type": "GENERATORS", + "ctrls": { + "L_box": { + "type": "float", + "default": 20, + "desc": "The width of the box in Bohr lengths.", + "functionName": "WAVEPACKET", + "param": "L_box", + "value": 20 + }, + "center": { + "type": "float", + "default": 0, + "desc": "The center of the initial wavepacket.", + "functionName": "WAVEPACKET", + "param": "center", + "value": "5" + }, + "momentum": { + "type": "float", + "default": 5, + "desc": "The momentum of the initial wavepacket.", + "functionName": "WAVEPACKET", + "param": "momentum", + "value": 5 + }, + "sigma": { + "type": "float", + "default": 1, + "desc": "The width of the initial wavepacket.", + "functionName": "WAVEPACKET", + "param": "sigma", + "value": "1" + }, + "dt": { + "type": "float", + "default": 0.2, + "desc": "Time steps in atomic units, 1 a.u. = 24.188 as", + "functionName": "WAVEPACKET", + "param": "dt", + "value": "0.1" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "The most recent wavepacket." + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/WAVEPACKET/WAVEPACKET.py", + "selected": false + }, + "position": { + "x": -71.22529418711089, + "y": 231.12759430779778 + }, + "selected": false, + "positionAbsolute": { + "x": -71.22529418711089, + "y": 231.12759430779778 + }, + "dragging": true + }, + { + "width": 96, + "height": 96, + "id": "LOOP-4a9435b9-f3d9-42bb-ac6f-058b309d33f5", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-4a9435b9-f3d9-42bb-ac6f-058b309d33f5", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "20" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOPS\\LOOP\\LOOP.py", + "selected": false + }, + "position": { + "x": -398.0667272413819, + "y": 300.8094166726855 + }, + "selected": false, + "positionAbsolute": { + "x": -398.0667272413819, + "y": 300.8094166726855 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261", + "sourceHandle": "default", + "target": "LINE-04475ad6-db8e-485b-8169-a90dfb525a8f", + "targetHandle": "default", + "id": "reactflow__edge-WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261default-LINE-04475ad6-db8e-485b-8169-a90dfb525a8fdefault" + }, + { + "source": "LOOP-4a9435b9-f3d9-42bb-ac6f-058b309d33f5", + "sourceHandle": "body", + "target": "WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-4a9435b9-f3d9-42bb-ac6f-058b309d33f5body-WAVEPACKET-ee6f2fc1-8cef-400a-895c-abe0564b1261default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..faed22db75 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/docstring.txt @@ -0,0 +1,9 @@ + +The KEITHLEY2400 node takes a IV curve measurement with a Keithley 2400 source meter, send voltages, and measures currents. + +Parameters +----------- +comport : string + defines the serial communication port for the Keithley2400 source meter. +baudrate : float + specifies the baud rate for the serial communication between the Keithley2400 and the computer diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..9fe88c7ef2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/a1-[autogen]/python_code.txt @@ -0,0 +1,59 @@ +from flojoy import flojoy, OrderedPair, Vector +import serial + + +@flojoy(deps={"pyserial": "3.5"}) +def KEITHLEY2400( + default: OrderedPair | Vector, comport: str = "/dev/ttyUSB0", baudrate: float = 9600 +) -> OrderedPair: + + + # Start serial communication with the instrument + ser: serial = serial.Serial() + + # Specific parameters + ser.port = comport # Specify serial port for com + ser.baudrate = baudrate # Specify Baudrate + + # General parameters + ser.bytesize = serial.EIGHTBITS # Specify Bites number + ser.parity = serial.PARITY_NONE # Specify Parity + ser.stopbits = serial.STOPBITS_ONE # Specify Stop bites + ser.timeout = 1 + # Open Serial Com + ser.open() + + # Keithley 2400 Configuration + ser.write(b"*RST\n") # reinitialisation of the instrument + ser.write(b":SOUR:FUNC:MODE VOLT\n") # Sourcing tension + ser.write(b':SENS:FUNC "CURR"\n') # Measuring current + ser.write( + b":SENS:CURR:PROT 1.05\n" + ) # Current protection set at 1.05A (Keithley 2400) + + match default: + case OrderedPair(): + voltages = default.y + case Vector(): + voltages = default.v + + currents_neg: list[float] = [] # measured currents + + for voltage in voltages: + ser.write(b":SOUR:VOLT %f\n" % voltage) # Source Tension (V) + ser.write(b":OUTP ON\n") # Instrument output open + ser.write(b":INIT\n") # Start measuring + ser.write(b":FETC?\n") # Retrieve the measured values + + current_str: str = ( + ser.readline().decode("ascii").strip() + ) # Save answers in a string + voltage_current_values: str = current_str.split(",") # Split the string + currents_neg.append(-float(voltage_current_values[1])) + + ser.write(b":OUTP OFF\n") # Close output from Instrument + + # Close Serial Communication + ser.close() + + return OrderedPair(x=voltages, y=currents_neg) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/examples/EX1/app.txt new file mode 100644 index 0000000000..5fe64f22da --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/examples/EX1/app.txt @@ -0,0 +1,201 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063ab", + "type": "INSTRUMENTS", + "data": { + "id": "KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063ab", + "label": "KEITHLEY2400", + "func": "KEITHLEY2400", + "type": "INSTRUMENTS", + "ctrls": { + "comport": { + "type": "str", + "default": "/dev/ttyUSB0", + "functionName": "KEITHLEY2400", + "param": "comport", + "value": "/dev/ttyUSB0" + }, + "baudrate": { + "type": "float", + "default": 9600, + "functionName": "KEITHLEY2400", + "param": "baudrate", + "value": 9600 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "pyserial", + "v": "3.5" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/KEITHLEY/KEITHLEY2400/KEITHLEY2400.py", + "selected": false + }, + "position": { + "x": 200.68907961661031, + "y": 13.035882888633353 + }, + "selected": false, + "positionAbsolute": { + "x": 200.68907961661031, + "y": 13.035882888633353 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-c497dfe3-5697-43ea-89ae-49855ed1fd06", + "type": "VISUALIZERS", + "data": { + "id": "LINE-c497dfe3-5697-43ea-89ae-49855ed1fd06", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 551.1961381818137, + "y": -23.670798508066298 + }, + "selected": false, + "positionAbsolute": { + "x": 551.1961381818137, + "y": -23.670798508066298 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-9ef0bb07-00b7-4d2b-8cb3-bba95cdc6477", + "type": "default", + "data": { + "id": "LINSPACE-9ef0bb07-00b7-4d2b-8cb3-bba95cdc6477", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -152.73436905978036, + "y": 11.992374302794559 + }, + "selected": false, + "positionAbsolute": { + "x": -152.73436905978036, + "y": 11.992374302794559 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-9ef0bb07-00b7-4d2b-8cb3-bba95cdc6477", + "sourceHandle": "default", + "target": "KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063ab", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-9ef0bb07-00b7-4d2b-8cb3-bba95cdc6477default-KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063abdefault" + }, + { + "source": "KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063ab", + "sourceHandle": "default", + "target": "LINE-c497dfe3-5697-43ea-89ae-49855ed1fd06", + "targetHandle": "default", + "id": "reactflow__edge-KEITHLEY2400-06832353-c0e3-4b21-80f1-99f7827063abdefault-LINE-c497dfe3-5697-43ea-89ae-49855ed1fd06default" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..fdb650a08e --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The LABJACKU3 node allows you to record and returns temperature measurements with a LABJACK U3 device. + +Parameters +---------- +number : int + Defines the number of temperature sensors connected to the LabJack U3 device. diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..abef3fb7a7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import flojoy, OrderedPair +from typing import Optional +import u3 # Import the library from LabJackPython in order to use our U3-LV device + + +@flojoy(deps={"labjackpython": "2.1.0"}) +def LABJACKU3( + default: Optional[OrderedPair] = None, sensor_number: int = 1 +) -> OrderedPair: + + + voltages: list[float] = [] + temperatures: list[float] = [] + temperatures_celsius: list[float] = [] + sensor_num: list[int] = [] + + # Create an instance of U3 class + d = u3.U3() + # Config the U3 for daq from temperature sensors + d.configIO(FIOAnalog=255, EIOAnalog=0) + + for i in range(0, sensor_number): + sensor_num.append(i + 1) + # Loop on the LabJack pins + voltage: float = d.getAIN(i) + # Convert Voltage into temperature in Celsius : + temperature: float = voltage * 100.0 + temperature_celsius: float = (temperature - 32) / 1.8 + voltages.append(voltage) + temperatures.append(temperature) + temperatures_celsius.append(temperature_celsius) + + return OrderedPair(x=sensor_num, y=temperatures_celsius) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/examples/EX1/app.txt new file mode 100644 index 0000000000..a93d2c3a7c --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/LABJACK/LABJACKU3/examples/EX1/app.txt @@ -0,0 +1,193 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85f", + "type": "INSTRUMENTS", + "data": { + "id": "LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85f", + "label": "LABJACKU3", + "func": "LABJACKU3", + "type": "INSTRUMENTS", + "ctrls": { + "sensor_number": { + "type": "int", + "default": 1, + "functionName": "LABJACKU3", + "param": "sensor_number", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "labjackpython", + "v": "2.1.0" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/LABJACK/LABJACKU3/LABJACKU3.py", + "selected": false + }, + "position": { + "x": 140.74505642489382, + "y": 105.51677834620148 + }, + "selected": false, + "positionAbsolute": { + "x": 140.74505642489382, + "y": 105.51677834620148 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LOOP-744fed19-65b1-47c3-ad99-28db2e906bde", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-744fed19-65b1-47c3-ad99-28db2e906bde", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "functionName": "LOOP", + "param": "num_loops", + "value": -1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any" + }, + { + "name": "end", + "id": "end", + "type": "Any" + } + ], + "path": "PYTHON/nodes/LOGIC_GATES/LOOPS/LOOP/LOOP.py", + "selected": false + }, + "position": { + "x": -306.3503683140443, + "y": 124.1652281565726 + }, + "selected": false, + "positionAbsolute": { + "x": -306.3503683140443, + "y": 124.1652281565726 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "BAR-d54011a8-5b19-471e-9aad-74ce3ca62914", + "type": "VISUALIZERS", + "data": { + "id": "BAR-d54011a8-5b19-471e-9aad-74ce3ca62914", + "label": "BAR", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BAR/BAR.py", + "selected": false + }, + "position": { + "x": 509.9694052032725, + "y": 64.67437309401998 + }, + "selected": false, + "positionAbsolute": { + "x": 509.9694052032725, + "y": 64.67437309401998 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOOP-744fed19-65b1-47c3-ad99-28db2e906bde", + "sourceHandle": "body", + "target": "LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85f", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-744fed19-65b1-47c3-ad99-28db2e906bdebody-LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85fdefault" + }, + { + "source": "LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85f", + "sourceHandle": "default", + "target": "BAR-d54011a8-5b19-471e-9aad-74ce3ca62914", + "targetHandle": "default", + "id": "reactflow__edge-LABJACKU3-8bb214ab-525a-490d-b539-7811b057d85fdefault-BAR-d54011a8-5b19-471e-9aad-74ce3ca62914default" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..493f6c6cf7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/docstring.txt @@ -0,0 +1,11 @@ + +The PHIDGET22 node allows you to record pressures from Flexiforce sensors using a Phidget InterfaceKit. + +Parameters +---------- +n_sensors : int + Defines the number of pressure sensors connected to the Phidget InterfaceKit. +calibration1 : float + Calibration parameters to convert voltage into pressure. +calibration2 : float + Calibration parameters to convert voltage into pressure. diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..c9bc331e37 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/a1-[autogen]/python_code.txt @@ -0,0 +1,44 @@ +from flojoy import flojoy, OrderedPair +from typing import Optional +from Phidget22.Devices.VoltageRatioInput import VoltageRatioInput + + +def onVoltageRatioChange(self, voltageRatio): + # Declaration of the Event handler, print Voltage variation for a channel. + print("VoltageRatio [" + str(self.getChannel()) + "]: " + str(voltageRatio)) + + +@flojoy(deps={"Phidget22": "1.14.20230331"}) +def PHIDGET22( + default: Optional[OrderedPair] = None, + n_sensors: int = 1, + calibration1: float = 0.015, + calibration2: float = 0.06, +) -> OrderedPair: + + + voltage: list[float] = [] + pressions: list[float] = [] + sensor_num: list[int] = [] + + for i in range(0, n_sensors): + sensor_num.append(i + 1) + # Creation of an instance of the VoltageRationInput class + voltage_ratio_input = VoltageRatioInput() + # Set Channel for Communication with the Phidget Interface Kit : + voltage_ratio_input.setChannel(i) + # Assign the handler that will be called when the event occurs : + voltage_ratio_input.setOnVoltageRatioChangeHandler(onVoltageRatioChange) + # Open the Channel after event handler is set : + voltage_ratio_input.openWaitForAttachment(5000) + + volt_i: float = ( + voltage_ratio_input.getVoltageRatio() + ) # Measure Voltage from the sensor + voltage.append(volt_i) # Add Voltage to the list of measurements + + # Example of a Calibration to convert Voltage into pressions : + pression_i: float = (volt_i - calibration1) / calibration2 + pressions.append(pression_i) + + return OrderedPair(x=sensor_num, y=pressions) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/examples/EX1/app.txt new file mode 100644 index 0000000000..644e55a154 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/PHIDGET/PHIDGET22/examples/EX1/app.txt @@ -0,0 +1,147 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PHIDGET22-c6e0fa47-17f1-4642-ae9e-f52453b7c526", + "type": "INSTRUMENTS", + "data": { + "id": "PHIDGET22-c6e0fa47-17f1-4642-ae9e-f52453b7c526", + "label": "PHIDGET22", + "func": "PHIDGET22", + "type": "INSTRUMENTS", + "ctrls": { + "n_sensors": { + "type": "int", + "default": 1, + "functionName": "PHIDGET22", + "param": "n_sensors", + "value": "4" + }, + "calibration1": { + "type": "float", + "default": 0.015, + "functionName": "PHIDGET22", + "param": "calibration1", + "value": 0.015 + }, + "calibration2": { + "type": "float", + "default": 0.06, + "functionName": "PHIDGET22", + "param": "calibration2", + "value": 0.06 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "Phidget22", + "v": "1.14.20230331" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/PHIDGET/PHIDGET22/PHIDGET22.py", + "selected": false + }, + "position": { + "x": 104.17972518130836, + "y": -46.665726762869554 + }, + "selected": false, + "positionAbsolute": { + "x": 104.17972518130836, + "y": -46.665726762869554 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "BAR-8788c5f3-d566-4c58-85dc-59af4e81d36c", + "type": "VISUALIZERS", + "data": { + "id": "BAR-8788c5f3-d566-4c58-85dc-59af4e81d36c", + "label": "BAR", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BAR/BAR.py", + "selected": false + }, + "position": { + "x": 513.6546307707831, + "y": -80.58167838030928 + }, + "selected": false, + "positionAbsolute": { + "x": 513.6546307707831, + "y": -80.58167838030928 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PHIDGET22-c6e0fa47-17f1-4642-ae9e-f52453b7c526", + "sourceHandle": "default", + "target": "BAR-8788c5f3-d566-4c58-85dc-59af4e81d36c", + "targetHandle": "default", + "id": "reactflow__edge-PHIDGET22-c6e0fa47-17f1-4642-ae9e-f52453b7c526default-BAR-8788c5f3-d566-4c58-85dc-59af4e81d36cdefault" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..f46a812e15 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/docstring.txt @@ -0,0 +1,9 @@ + +The SERIAL_SINGLE_MEASUREMENT node takes a single reading of data from an Ardunio or a similar serial device. + +Parameters +---------- +baudrate : int + Baud rate for the serial communication. +comport : string + Defines the comunication port on which the serial device is connected. diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7bb19b0d24 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/a1-[autogen]/python_code.txt @@ -0,0 +1,25 @@ +from flojoy import flojoy, OrderedPair +from typing import Optional +import serial +import numpy as np + + +@flojoy(deps={"pyserial": "3.5"}) +def SERIAL_SINGLE_MEASUREMENT( + default: Optional[OrderedPair] = None, + comport: str = "/dev/ttyUSB0", + baudrate: int = 9600, +) -> OrderedPair: + + + ser = serial.Serial(comport, timeout=1, baudrate=baudrate) + s = "" + while s == "": + s = ser.readline().decode() + + reading = s[:-2].split(",") + reading = np.array(reading) # Create an array + reading = reading.astype("float64") # Convert the array to float + x = np.arange(0, reading.size) # Create a second array + + return OrderedPair(x=x, y=reading) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/examples/EX1/app.txt new file mode 100644 index 0000000000..6830c2f250 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/examples/EX1/app.txt @@ -0,0 +1,140 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 225, + "height": 226, + "id": "BAR-a5dad7fa-f6be-4814-9b64-a5c67318c653", + "type": "VISUALIZERS", + "data": { + "id": "BAR-a5dad7fa-f6be-4814-9b64-a5c67318c653", + "label": "BAR", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BAR/BAR.py", + "selected": false + }, + "position": { + "x": 618.6142511100182, + "y": -115.37358126811186 + }, + "selected": false, + "positionAbsolute": { + "x": 618.6142511100182, + "y": -115.37358126811186 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "SERIAL_SINGLE_MEASUREMENT-e2db0dcb-93ee-4548-babe-27a69ed71b1b", + "type": "INSTRUMENTS", + "data": { + "id": "SERIAL_SINGLE_MEASUREMENT-e2db0dcb-93ee-4548-babe-27a69ed71b1b", + "label": "SERIAL SINGLE MEASUREMENT", + "func": "SERIAL_SINGLE_MEASUREMENT", + "type": "INSTRUMENTS", + "ctrls": { + "comport": { + "type": "str", + "default": "/dev/ttyUSB0", + "functionName": "SERIAL_SINGLE_MEASUREMENT", + "param": "comport", + "value": "/dev/ttyUSB0" + }, + "baudrate": { + "type": "int", + "default": 9600, + "functionName": "SERIAL_SINGLE_MEASUREMENT", + "param": "baudrate", + "value": 9600 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "pyserial", + "v": "3.5" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/SERIAL/SERIAL_SINGLE_MEASUREMENT/SERIAL_SINGLE_MEASUREMENT.py", + "selected": false + }, + "position": { + "x": 263.25526904013145, + "y": -71.99475564115923 + }, + "selected": false, + "positionAbsolute": { + "x": 263.25526904013145, + "y": -71.99475564115923 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "SERIAL_SINGLE_MEASUREMENT-e2db0dcb-93ee-4548-babe-27a69ed71b1b", + "sourceHandle": "default", + "target": "BAR-a5dad7fa-f6be-4814-9b64-a5c67318c653", + "targetHandle": "default", + "id": "reactflow__edge-SERIAL_SINGLE_MEASUREMENT-e2db0dcb-93ee-4548-babe-27a69ed71b1bdefault-BAR-a5dad7fa-f6be-4814-9b64-a5c67318c653default" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3dd5f4b705 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The SERIAL_TIMESERIES node extracts simple time-dependent 1D data from an Ardunio or a similar serial device. + +Parameters +---------- +num_readings : int + Number of points to record. +record_period : float + Length between two recordings in seconds. +baudrate : int + Baud rate for the serial device. +comport : string + COM port of the serial device. + +num_readings * record_period : + Is roughly the run length in seconds. diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a28e906caf --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/a1-[autogen]/python_code.txt @@ -0,0 +1,59 @@ +from flojoy import flojoy, OrderedPair +from time import sleep +from typing import Optional +import serial +import numpy as np +from datetime import datetime + + +@flojoy(deps={"pyserial": "3.5"}) +def SERIAL_TIMESERIES( + default: Optional[OrderedPair] = None, + comport: str = "/dev/ttyUSB0", + baudrate: int = 9600, + num_readings: int = 100, + record_period: int = 1, +) -> OrderedPair: + + ser = serial.Serial(comport, timeout=1, baudrate=baudrate) + readings = [] + times = [] + # The first reading is commonly empty. + s = ser.readline().decode() + + for i in range(num_readings): + ts = datetime.now() + s = ser.readline().decode() + # Some readings may be empty. + if s != "": + reading = s[:-2].split(",") + if len(reading) == 1: + reading = reading[0] + readings.append(reading) + + ts = datetime.now() + seconds = float( + ts.hour * 3600 + ts.minute * 60 + ts.second + ts.microsecond / 10**6 + ) + + times.append(seconds) + + if len(times) > 0: + time1 = seconds - times[i] + else: + # Estimate execution time. + time1 = 0.1 + + if time1 < record_period: + sleep(record_period - time1) + + times = np.array(times) + try: + times -= times[0] + except IndexError: + raise IndexError("No data detected from the Arduino") + + readings = np.array(readings) + readings = readings.astype("float64") + + return OrderedPair(x=times, y=readings) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/examples/EX1/app.txt new file mode 100644 index 0000000000..dee623195b --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/examples/EX1/app.txt @@ -0,0 +1,154 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "SERIAL_TIMESERIES-d9520c8e-120d-488b-a042-dac8b39b294c", + "type": "INSTRUMENTS", + "data": { + "id": "SERIAL_TIMESERIES-d9520c8e-120d-488b-a042-dac8b39b294c", + "label": "SERIAL TIMESERIES", + "func": "SERIAL_TIMESERIES", + "type": "INSTRUMENTS", + "ctrls": { + "comport": { + "type": "str", + "default": "/dev/ttyUSB0", + "functionName": "SERIAL_TIMESERIES", + "param": "comport", + "value": "/dev/ttyUSB0" + }, + "baudrate": { + "type": "int", + "default": 9600, + "functionName": "SERIAL_TIMESERIES", + "param": "baudrate", + "value": 9600 + }, + "num_readings": { + "type": "int", + "default": 100, + "functionName": "SERIAL_TIMESERIES", + "param": "num_readings", + "value": 100 + }, + "record_period": { + "type": "int", + "default": 1, + "functionName": "SERIAL_TIMESERIES", + "param": "record_period", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "pyserial", + "v": "3.5" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/SERIAL/SERIAL_TIMESERIES/SERIAL_TIMESERIES.py", + "selected": false + }, + "position": { + "x": 353.0843053074072, + "y": 1.629899261204912 + }, + "selected": false, + "positionAbsolute": { + "x": 353.0843053074072, + "y": 1.629899261204912 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-e0ba3b06-fcc8-40a5-bb12-14370fe009e9", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-e0ba3b06-fcc8-40a5-bb12-14370fe009e9", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 815.4592095712483, + "y": -29.91266050320587 + }, + "selected": false, + "positionAbsolute": { + "x": 815.4592095712483, + "y": -29.91266050320587 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "SERIAL_TIMESERIES-d9520c8e-120d-488b-a042-dac8b39b294c", + "sourceHandle": "default", + "target": "TABLE-e0ba3b06-fcc8-40a5-bb12-14370fe009e9", + "targetHandle": "default", + "id": "reactflow__edge-SERIAL_TIMESERIES-d9520c8e-120d-488b-a042-dac8b39b294cdefault-TABLE-e0ba3b06-fcc8-40a5-bb12-14370fe009e9default" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..bc642900e8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + +The STEPPER_DRIVER_TIC node controls a stepper motor movement with a TIC driver. + +The user defines the speed and the sleep time between movements. + +(To choose the position, use the STEPPER_DRIVER_TIC_KNOB.) + +Parameters +---------- +current_limit : int + Defines the current limitation that the stepper motor will receive. +sleep_time : int + Defines the sleep time after moving to each position. +speed : int + Defines the speed of the motor movement (between 0 and 200000). diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ff4d2805cd --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/a1-[autogen]/python_code.txt @@ -0,0 +1,36 @@ +from flojoy import flojoy, OrderedPair +from typing import Optional +from ticlib import ( + TicUSB, +) # Import the TicUSB library to send command to Tic drivers with USB connection +from time import sleep + + +@flojoy(deps={"ticlib": "0.2.2"}) +def STEPPER_DRIVER_TIC( + default: Optional[OrderedPair] = None, + current_limit: int = 30, + sleep_time: int = 2, + speed: int = 100000, +) -> OrderedPair: + + # Setting default positions + positions: list[int] = [50, 100, 150, 200] + + # Declaration of the stepper driver + tic: TicUSB = TicUSB() + tic.halt_and_set_position(0) # Set the position to 0 + # Set the current limit of the TIC driver + tic.set_current_limit(current_limit) + tic.energize() # Turn on the driver + tic.exit_safe_start() # The driver is now ready to receive commands + + for i in range(0, len(positions)): + tic.set_max_speed(speed) # Set motor speed + tic.set_target_position(positions[i]) # Set target positions + sleep(sleep_time) + + tic.deenergize() + tic.enter_safe_start() + + return OrderedPair(x=positions, y=positions) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/examples/EX1/app.txt new file mode 100644 index 0000000000..4afb8bd038 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/examples/EX1/app.txt @@ -0,0 +1,99 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "STEPPER_DRIVER_TIC-deb4fca7-fc18-443d-bd70-f1455a749eff", + "type": "INSTRUMENTS", + "data": { + "id": "STEPPER_DRIVER_TIC-deb4fca7-fc18-443d-bd70-f1455a749eff", + "label": "STEPPER DRIVER TIC", + "func": "STEPPER_DRIVER_TIC", + "type": "INSTRUMENTS", + "ctrls": { + "current_limit": { + "type": "int", + "default": 30, + "functionName": "STEPPER_DRIVER_TIC", + "param": "current_limit", + "value": 30 + }, + "sleep_time": { + "type": "int", + "default": 2, + "functionName": "STEPPER_DRIVER_TIC", + "param": "sleep_time", + "value": 2 + }, + "speed": { + "type": "int", + "default": 100000, + "functionName": "STEPPER_DRIVER_TIC", + "param": "speed", + "value": 100000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "ticlib", + "v": "0.2.2" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC/STEPPER_DRIVER_TIC.py", + "selected": false + }, + "position": { + "x": 883.1245033729516, + "y": -2.309719518942927 + }, + "selected": false, + "positionAbsolute": { + "x": 883.1245033729516, + "y": -2.309719518942927 + }, + "dragging": true + } + ], + "edges": [], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..40ebff8783 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + +The STEPPER_DRIVER_TIC_KNOB controls a stepper motor movement with a TIC driver. + +The user controls the motor rotation with the knob position in the node's parameters. + +Parameters +---------- +knob_value : int + Defines the position of the motor (rotational movement). +current_limit : int + Defines the current limitation that the stepper motor will receive. +sleep_time : int + Defines the sleep time after moving to each position. +speed : int + Defines the speed of the motor movement (between 0 and 200000). diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4674192e43 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/a1-[autogen]/python_code.txt @@ -0,0 +1,40 @@ +from flojoy import flojoy, OrderedPair +from typing import Optional + +# Import the TicUSB library to send command to Tic drivers with USB connection +from ticlib import TicUSB +from time import sleep + + +@flojoy(deps={"ticlib": "0.2.2"}) +def STEPPER_DRIVER_TIC_KNOB( + default: Optional[OrderedPair] = None, + knob_value: int = 0, + current_limit: int = 30, + sleep_time: int = 2, + speed: int = 200000, +) -> OrderedPair: + + # Converting the knob value into a position + knob_position: int = 2 * knob_value + + # Declaration of the stepper driver (You can add serial number to specify the driver) + tic: TicUSB = TicUSB() + # Set the current limit for the driver TIC + tic.set_current_limit(current_limit) + tic.energize() # Turn on the driver + tic.exit_safe_start() # The driver is now ready to receive commands + # Set maximum speed for the motor during first movement. + tic.set_max_speed(speed) + + tic.halt_and_set_position(0) # Set initial position to origin + sleep(sleep_time) + + # Set target position for the first movement + tic.set_target_position(knob_position) + sleep(sleep_time) + + tic.deenergize() + tic.enter_safe_start() + + return OrderedPair(x=knob_position, y=speed) diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/examples/EX1/app.txt new file mode 100644 index 0000000000..e0a12da8f6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/examples/EX1/app.txt @@ -0,0 +1,106 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "STEPPER_DRIVER_TIC_KNOB-3b234e79-4648-4661-a8e8-3e14b3d0e72b", + "type": "INSTRUMENTS", + "data": { + "id": "STEPPER_DRIVER_TIC_KNOB-3b234e79-4648-4661-a8e8-3e14b3d0e72b", + "label": "STEPPER DRIVER TIC KNOB", + "func": "STEPPER_DRIVER_TIC_KNOB", + "type": "INSTRUMENTS", + "ctrls": { + "knob_value": { + "type": "int", + "default": 0, + "functionName": "STEPPER_DRIVER_TIC_KNOB", + "param": "knob_value", + "value": 0 + }, + "current_limit": { + "type": "int", + "default": 30, + "functionName": "STEPPER_DRIVER_TIC_KNOB", + "param": "current_limit", + "value": 30 + }, + "sleep_time": { + "type": "int", + "default": 2, + "functionName": "STEPPER_DRIVER_TIC_KNOB", + "param": "sleep_time", + "value": 2 + }, + "speed": { + "type": "int", + "default": 200000, + "functionName": "STEPPER_DRIVER_TIC_KNOB", + "param": "speed", + "value": 200000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "pip_dependencies": [ + { + "name": "ticlib", + "v": "0.2.2" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/STEPPER_MOTOR/STEPPER_DRIVER_TIC_KNOB/STEPPER_DRIVER_TIC_KNOB.py", + "selected": false + }, + "position": { + "x": 934.1949826356821, + "y": -1.452956731347598 + }, + "selected": false, + "positionAbsolute": { + "x": 934.1949826356821, + "y": -1.452956731347598 + }, + "dragging": true + } + ], + "edges": [], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..cc868f4d9a --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + +The CAMERA node acquires an image using the selected camera. + +If no camera is detected, an error would be shown. + +Parameters +---------- +camera_ind : int + Camera index (i.e. camera identifier). +resolution : select + Camera resolution. Choose from a few options. + +Returns +------- +Image diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..542f4cc702 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/a1-[autogen]/python_code.txt @@ -0,0 +1,63 @@ +import cv2 +import os +from flojoy import flojoy, DataContainer +from typing import Optional, Literal +from PIL import Image +import numpy as np + + +@flojoy(deps={"opencv-python-headless": "4.7.0.72"}) +def CAMERA( + default: Optional[DataContainer] = None, + camera_ind: int = -1, + resolution: Literal[ + "default", "640x360", "640x480", "1280x720", "1920x1080" + ] = "default", +) -> DataContainer: + + + try: + camera = cv2.VideoCapture(camera_ind) + if resolution != "default": + resolution = resolution.split("x") + try: + camera.set(cv2.CAP_PROP_FRAME_WIDTH, int(resolution[0])) + camera.set(cv2.CAP_PROP_FRAME_HEIGHT, int(resolution[1])) + except cv2.error as camera_error: + print(f"Invalid resolution ({resolution}). Try a lower value.") + raise camera_error + + if not camera.isOpened(): + raise cv2.error("Failed to open camera") + + result, BGR_img = camera.read() + + if not result: + raise cv2.error("Failed to capture image") + camera.release() + del camera + + RGB_img = cv2.cvtColor(BGR_img, cv2.COLOR_BGR2RGB) + + # Split the image channels + red_channel = RGB_img[:, :, 0] + green_channel = RGB_img[:, :, 1] + blue_channel = RGB_img[:, :, 2] + + if RGB_img.shape[2] == 4: + alpha_channel = RGB_img[:, :, 3] + else: + alpha_channel = None + + camera_image = DataContainer( + type="Image", + r=red_channel, + g=green_channel, + b=blue_channel, + a=alpha_channel, + ) + + return camera_image + + except cv2.error as camera_error: + raise camera_error diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/hardware.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/media.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/notes.md b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/examples/EX1/app.txt new file mode 100644 index 0000000000..b0da688128 --- /dev/null +++ b/docs/nodes/flojoy_nodes/INSTRUMENTS/WEB_CAM/CAMERA/examples/EX1/app.txt @@ -0,0 +1,147 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "CAMERA-29dc2b2f-b87c-46a3-9ddc-11e685de3206", + "type": "INSTRUMENTS", + "data": { + "id": "CAMERA-29dc2b2f-b87c-46a3-9ddc-11e685de3206", + "label": "CAMERA", + "func": "CAMERA", + "type": "INSTRUMENTS", + "ctrls": { + "camera_ind": { + "type": "int", + "default": -1, + "functionName": "CAMERA", + "param": "camera_ind", + "value": -1 + }, + "resolution": { + "type": "select", + "default": "default", + "options": [ + "default", + "640x360", + "640x480", + "1280x720", + "1920x1080" + ], + "functionName": "CAMERA", + "param": "resolution", + "value": "default" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "pip_dependencies": [ + { + "name": "opencv-python-headless", + "v": "4.7.0.72" + } + ], + "path": "PYTHON/nodes/INSTRUMENTS/WEB_CAM/CAMERA/CAMERA.py", + "selected": false + }, + "position": { + "x": 934.4795759482945, + "y": -38.568710835013746 + }, + "selected": false, + "positionAbsolute": { + "x": 934.4795759482945, + "y": -38.568710835013746 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-cd503f68-87fd-478a-b577-baa959f3df08", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-cd503f68-87fd-478a-b577-baa959f3df08", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1261.9152508247892, + "y": -78.58047260527047 + }, + "selected": false, + "positionAbsolute": { + "x": 1261.9152508247892, + "y": -78.58047260527047 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CAMERA-29dc2b2f-b87c-46a3-9ddc-11e685de3206", + "sourceHandle": "default", + "target": "IMAGE-cd503f68-87fd-478a-b577-baa959f3df08", + "targetHandle": "default", + "id": "reactflow__edge-CAMERA-29dc2b2f-b87c-46a3-9ddc-11e685de3206default-IMAGE-cd503f68-87fd-478a-b577-baa959f3df08default" + } + ], + "viewport": { + "x": -358.59636577932724, + "y": 99.85117439980638, + "zoom": 1.0581352782820395 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..0ee8125669 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/a1-[autogen]/python_code.txt @@ -0,0 +1,67 @@ +import json +import os +from typing import Optional +import requests +from flojoy import DataContainer, flojoy, get_env_var +from flojoy.utils import PlotlyJSONEncoder + + +FRONTIER_URI: str = os.environ.get("FRONTIER_URI") or "https://cloud.flojoy.ai" + + +@flojoy +def LOADER( + default: DataContainer, + measurement_id: Optional[str] = None, + dc_id: Optional[str] = None, +) -> DataContainer: + api_key = get_env_var("FLOJOY_CLOUD_API_KEY") + + if api_key is None: + raise KeyError("Frontier API key is not found!") + + if default: + # This will stream the data to the cloud + resp: requests.Response + if measurement_id is None: + resp = requests.post( + f"{FRONTIER_URI}/api/v1/measurements/{measurement_id}", + headers={"api_key": api_key}, + json={ + "measurement": json.dumps(default, cls=PlotlyJSONEncoder), + }, + ) + + else: + resp = requests.post( + f"{FRONTIER_URI}/api/v1/dcs", + headers={"api_key": api_key}, + json={ + "measurement_id": measurement_id, + "measurement": json.dumps(default, cls=PlotlyJSONEncoder), + }, + ) + + if not (resp.status_code >= 200 and resp.status_code < 300): + raise Exception(str(resp.json()["error"])) + + return default + + else: + # If there is nothing connected to the node, then it will download from cloud + if dc_id is None: + raise Exception("A data container ID is required for downstreaming") + + resp = requests.get( + f"{FRONTIER_URI}/api/v1/dcs/{dc_id}", + headers={"api_key": api_key}, + ) + print(resp.json()) + # TODO: now it only supports x and y + if not (resp.status_code == 200 or resp.status_code == 201): + raise Exception(resp.json()["error"]) + + return DataContainer( + x=resp.json()["data"][0]["dataContainer"]["x"], + y=resp.json()["data"][0]["dataContainer"]["y"], + ) diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/media.md b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/notes.md b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/examples/EX1/app.txt new file mode 100644 index 0000000000..3f35aead07 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/CLOUD_DATABASE/LOADER/examples/EX1/app.txt @@ -0,0 +1,391 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 181, + "id": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "type": "default", + "position": { + "x": 199.83204415740659, + "y": 241.1242907400127 + }, + "data": { + "id": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "label": "loop", + "func": "LOOP", + "type": "LOOP", + "ctrls": { + "num_loops": { + "functionName": "LOOP", + "param": "num_loops", + "value": "2" + } + }, + "inputs": [ + { + "name": "end", + "id": "end", + "type": "source" + }, + { + "name": "body", + "id": "body", + "type": "source" + } + ], + "selected": false + }, + "selected": false, + "positionAbsolute": { + "x": 199.83204415740659, + "y": 241.1242907400127 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138", + "label": "12", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "functionName": "CONSTANT", + "param": "constant", + "value": 12 + } + }, + "selected": false + }, + "position": { + "x": 466.19543125380744, + "y": 197.28696880898065 + }, + "selected": false, + "positionAbsolute": { + "x": 466.19543125380744, + "y": 197.28696880898065 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "type": "ARITHMETIC", + "data": { + "id": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "label": "add", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "y", + "id": "add_y", + "type": "target" + } + ], + "selected": false + }, + "position": { + "x": 887.654481217497, + "y": 355.72438638328936 + }, + "selected": false, + "positionAbsolute": { + "x": 887.654481217497, + "y": 355.72438638328936 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0", + "type": "GENERATORS", + "data": { + "id": "FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0", + "label": "FeedBack", + "func": "FEEDBACK", + "type": "GENERATORS", + "ctrls": { + "referred_node": { + "functionName": "FEEDBACK", + "param": "referred_node", + "value": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04" + } + }, + "selected": false + }, + "position": { + "x": 665.8033807606249, + "y": 228.40739343961675 + }, + "selected": false, + "positionAbsolute": { + "x": 665.8033807606249, + "y": 228.40739343961675 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LOADER-0ade6235-d420-468c-89af-bc408aee3a24", + "type": "LOADERS", + "data": { + "id": "LOADER-0ade6235-d420-468c-89af-bc408aee3a24", + "label": "LOADER", + "func": "LOADER", + "type": "LOADERS", + "ctrls": { + "measurement_uuid": { + "functionName": "LOADER", + "param": "measurement_uuid", + "value": "" + } + }, + "selected": false + }, + "position": { + "x": 1064.7147147719838, + "y": 328.56187855063024 + }, + "selected": false, + "positionAbsolute": { + "x": 1064.7147147719838, + "y": 328.56187855063024 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1a", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1a", + "label": "-1", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "functionName": "CONSTANT", + "param": "constant", + "value": "-1" + } + }, + "selected": false + }, + "position": { + "x": 553.0459523002967, + "y": 451.13717806476825 + }, + "selected": false, + "positionAbsolute": { + "x": 553.0459523002967, + "y": 451.13717806476825 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-dae9c5e6-fa8a-4f2c-8d56-f77445749237", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-dae9c5e6-fa8a-4f2c-8d56-f77445749237", + "label": "42", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "functionName": "CONSTANT", + "param": "constant", + "value": "42" + } + }, + "selected": false + }, + "position": { + "x": -49.550885095089185, + "y": 265.2171743774056 + }, + "selected": false, + "positionAbsolute": { + "x": -49.550885095089185, + "y": 265.2171743774056 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "sourceHandle": "body", + "target": "CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138", + "targetHandle": "CONSTANT", + "id": "reactflow__edge-LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fbbody-CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138CONSTANT" + }, + { + "source": "CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138", + "sourceHandle": "main", + "target": "FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0", + "targetHandle": "FEEDBACK", + "id": "reactflow__edge-CONSTANT-ee40698d-60e6-4eb4-88b5-4d19e0c41138main-FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0FEEDBACK" + }, + { + "source": "FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0", + "sourceHandle": "main", + "target": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "targetHandle": "ADD", + "id": "reactflow__edge-FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0main-ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04ADD" + }, + { + "source": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "sourceHandle": "main", + "target": "LOADER-0ade6235-d420-468c-89af-bc408aee3a24", + "targetHandle": "LOADER", + "id": "reactflow__edge-ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04main-LOADER-0ade6235-d420-468c-89af-bc408aee3a24LOADER" + }, + { + "source": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "sourceHandle": "body", + "target": "CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1a", + "targetHandle": "CONSTANT", + "id": "reactflow__edge-LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fbbody-CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1aCONSTANT" + }, + { + "source": "CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1a", + "sourceHandle": "main", + "target": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "targetHandle": "add_y", + "id": "reactflow__edge-CONSTANT-a17e1542-74ca-4999-985f-e69f71750b1amain-ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04add_y" + }, + { + "source": "CONSTANT-dae9c5e6-fa8a-4f2c-8d56-f77445749237", + "sourceHandle": "main", + "target": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "targetHandle": "LOOP", + "id": "reactflow__edge-CONSTANT-dae9c5e6-fa8a-4f2c-8d56-f77445749237main-LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fbLOOP" + } + ], + "viewport": { + "x": 226.6796457828928, + "y": 31.056018042519327, + "zoom": 0.6853504029717089 + } + }, + "ctrlsManifest": [ + { + "type": "output", + "name": "Seven Segment Display", + "minWidth": 2, + "minHeight": 3, + "id": "ctrl-4b484ce1-533a-4be6-a395-c9b96104d9e9", + "hidden": false, + "param": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "val": 0, + "layout": { + "w": 2, + "h": 3, + "x": 4, + "y": 0, + "i": "ctrl-4b484ce1-533a-4be6-a395-c9b96104d9e9", + "minW": 2, + "minH": 3, + "moved": false, + "static": false + } + }, + { + "type": "input", + "name": "Text Input", + "minWidth": 1, + "minHeight": 1, + "id": "ctrl-3280c18b-84d7-4f72-a6ab-5b4721123c92", + "hidden": false, + "param": { + "id": "CONDITIONAL_CONDITIONAL_operator_type", + "functionName": "CONDITIONAL", + "param": "operator_type", + "nodeId": "CONDITIONAL-2e565212-13e4-497c-89ca-2440fb98f68c", + "inputId": "ctrl-3280c18b-84d7-4f72-a6ab-5b4721123c92" + }, + "val": "<=", + "layout": { + "w": 2, + "h": 2, + "x": 0, + "y": 0, + "i": "ctrl-3280c18b-84d7-4f72-a6ab-5b4721123c92", + "minW": 1, + "minH": 1, + "moved": false, + "static": false + } + }, + { + "type": "input", + "name": "Node Reference", + "minWidth": 2, + "minHeight": 2, + "id": "ctrl-420defe9-c2d0-4eeb-bfa1-a512cb5cd599", + "hidden": false, + "param": { + "id": "FEEDBACK_FeedBack_referred_node", + "functionName": "FEEDBACK", + "param": "referred_node", + "nodeId": "FEEDBACK-bce3a2a9-20e8-4841-8404-1d91fcfac4f0", + "inputId": "ctrl-420defe9-c2d0-4eeb-bfa1-a512cb5cd599", + "type": "node_reference" + }, + "val": "ADD-0758c6a8-52b4-4b5b-9c46-2a83bdef2a04", + "layout": { + "w": 2, + "h": 2, + "x": 2, + "y": 0, + "i": "ctrl-420defe9-c2d0-4eeb-bfa1-a512cb5cd599", + "minW": 2, + "minH": 2, + "moved": false, + "static": false + } + }, + { + "type": "input", + "name": "Slider", + "minWidth": 2, + "minHeight": 1, + "id": "ctrl-528f60c6-3795-4f10-ab34-2e22914d632f", + "hidden": false, + "param": { + "id": "num_loops", + "functionName": "LOOP", + "param": "num_loops", + "nodeId": "LOOP-faed7bdc-f766-4742-b48f-d31a7b8083fb", + "inputId": "ctrl-528f60c6-3795-4f10-ab34-2e22914d632f", + "type": "int" + }, + "val": "2", + "layout": { + "w": 2, + "h": 2, + "x": 0, + "y": 2, + "i": "ctrl-528f60c6-3795-4f10-ab34-2e22914d632f", + "minW": 2, + "minH": 1, + "moved": false, + "static": false + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..a58d623d6d --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ +The DS_LOAD node loads data directly from in-memory data storage. + + Parameters + ---------- + referred_node: str + The ID of the node to retrieve the result from. + + Returns + ------- + OrderedPair diff --git a/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..e37cbdf482 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/a1-[autogen]/python_code.txt @@ -0,0 +1,26 @@ +from flojoy import flojoy, NodeReference, OrderedPair, SmallMemory +import numpy as np + + +@flojoy +def DS_LOAD(default: OrderedPair, referred_node: NodeReference) -> OrderedPair: + + x = default.y + if referred_node.unwrap() != "": + referred_node_key = referred_node.unwrap().split("-")[0] + y = SmallMemory().read_memory(referred_node.unwrap(), referred_node_key) + if y is None: + y = x + print( + "-" * 72 + + "\n" * 5 + + f"{y.size-1} iterations" + + f" for {referred_node_key} , " + + str([i for i in y]) + + "\n" * 5 + + "-" * 72 + ) + return OrderedPair(x=np.arange(0, len(y), 1), y=y) + + else: + return default diff --git a/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/media.md b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/notes.md b/docs/nodes/flojoy_nodes/LOADERS/INTERNAL_MEMORY/DS_LOAD/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..50f25be046 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/docstring.txt @@ -0,0 +1,15 @@ + +The LOCAL_FILE node loads a local file of a different type and converts it to a DataContainer class. + +Parameters +---------- +file_type : str + type of file to load, default = image +file_path : str + path to the file to be loaded + +Returns +------- +Image|DataFrame + Image for file_type 'image' + DataFrame for file_type 'json', 'csv', 'excel', 'xml' diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..fbd7ae781d --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/a1-[autogen]/python_code.txt @@ -0,0 +1,61 @@ +from flojoy import flojoy, Image, DataFrame +from typing import Literal +import numpy as np +from PIL import Image as PIL_Image +from os import path +import pandas as pd + + +def get_file_path(file_path: str, default_path: str | None = None): + f_path = path.abspath(file_path) if file_path != "" else default_path + if not f_path: + raise ValueError("File path is missing for file_path parameter!") + print(f"file will be loaded from {f_path}") + return f_path + + +@flojoy(deps={"xlrd": "2.0.1", "lxml": "4.9.2", "openpyxl": "3.0.10"}) +def LOCAL_FILE( + file_path: str, + file_type: Literal["Image", "JSON", "CSV", "Excel", "XML"] = "Image", +) -> Image | DataFrame: + + match file_type: + case "Image": + default_image_path = path.join( + path.dirname(path.abspath(__file__)), + "assets", + "astronaut.png", + ) + file_path = get_file_path(file_path, default_image_path) + f = PIL_Image.open(file_path) + img_array = np.array(f.convert("RGBA")) + red_channel = img_array[:, :, 0] + green_channel = img_array[:, :, 1] + blue_channel = img_array[:, :, 2] + if img_array.shape[2] == 4: + alpha_channel = img_array[:, :, 3] + else: + alpha_channel = None + return Image( + r=red_channel, + g=green_channel, + b=blue_channel, + a=alpha_channel, + ) + case "CSV": + file_path = get_file_path(file_path) + df = pd.read_csv(file_path) + return DataFrame(df=df) + case "JSON": + file_path = get_file_path(file_path) + df = pd.read_json(file_path) + return DataFrame(df=df) + case "XML": + file_path = get_file_path(file_path) + df = pd.read_xml(file_path) + return DataFrame(df=df) + case "Excel": + file_path = get_file_path(file_path) + df = pd.read_excel(file_path) + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/media.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/notes.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/examples/EX1/app.txt new file mode 100644 index 0000000000..ca89aa46e4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/examples/EX1/app.txt @@ -0,0 +1,143 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes\\LOADERS\\LOCAL_FILE_SYSTEM\\LOCAL_FILE\\LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 149.9445089046593, + "y": 154.15881591576107 + }, + "selected": false, + "positionAbsolute": { + "x": 149.9445089046593, + "y": 154.15881591576107 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\IMAGE\\IMAGE.py", + "selected": false + }, + "position": { + "x": 528.5159374760879, + "y": 79.87310163004685 + }, + "selected": false, + "positionAbsolute": { + "x": 528.5159374760879, + "y": 79.87310163004685 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "sourceHandle": "default", + "target": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6ddefault-IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..03095c49bb --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/docstring.txt @@ -0,0 +1,14 @@ + +The OPEN_MATLAB node loads a local file of the .mat file format. + +Note that if multiple 'tabs' of data are used, the number of rows must match in order to stack the arrays. + +Parameters +---------- +file_path : str + path to the file to be loaded + +Returns +------- +DataFrame + DataFrame loaded from the .mat file diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d1a5230329 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/a1-[autogen]/python_code.txt @@ -0,0 +1,32 @@ +from flojoy import DataFrame, flojoy +import numpy as np +from scipy.io import loadmat +from os import path +import pandas as pd + + +@flojoy +def OPEN_MATLAB(file_path: str = "") -> DataFrame: + + + if file_path == "": + file_path = path.join( + path.dirname(path.abspath(__file__)), + "assets", + "default.mat", + ) + + if file_path[-4:] != ".mat": + raise ValueError(f"File type {file_path[-4:]} unsupported.") + + if not path.exists(file_path): + raise ValueError("File path does not exist!") + + mat = loadmat(file_path) + key = list(mat.keys())[3:] + X = mat[key[0]] + Y = mat[key[1]] + + df = pd.DataFrame(np.hstack((X, Y))) + + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/media.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/notes.md b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/examples/EX1/app.txt new file mode 100644 index 0000000000..9e707cd660 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/examples/EX1/app.txt @@ -0,0 +1,118 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "OPEN_MATLAB-ca242c1a-4bfc-4c1c-bf96-a1b556428e0d", + "type": "LOADERS", + "data": { + "id": "OPEN_MATLAB-ca242c1a-4bfc-4c1c-bf96-a1b556428e0d", + "label": "OPEN MATLAB", + "func": "OPEN_MATLAB", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": "", + "functionName": "OPEN_MATLAB", + "param": "file_path", + "value": "" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/OPEN_MATLAB/OPEN_MATLAB.py", + "selected": false + }, + "position": { + "x": 758.8641288851292, + "y": 369.1099187192696 + }, + "selected": false, + "positionAbsolute": { + "x": 758.8641288851292, + "y": 369.1099187192696 + } + }, + { + "width": 240, + "height": 260, + "id": "ARRAY_VIEW-ae48effe-f242-41ee-8822-93fb92679ecd", + "type": "VISUALIZERS", + "data": { + "id": "ARRAY_VIEW-ae48effe-f242-41ee-8822-93fb92679ecd", + "label": "ARRAY VIEW", + "func": "ARRAY_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix|DataFrame|Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/ARRAY_VIEW.py", + "selected": false + }, + "position": { + "x": 1133.8697763624045, + "y": 335.0194036085589 + }, + "selected": false, + "positionAbsolute": { + "x": 1133.8697763624045, + "y": 335.0194036085589 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "OPEN_MATLAB-ca242c1a-4bfc-4c1c-bf96-a1b556428e0d", + "sourceHandle": "default", + "target": "ARRAY_VIEW-ae48effe-f242-41ee-8822-93fb92679ecd", + "targetHandle": "default", + "id": "reactflow__edge-OPEN_MATLAB-ca242c1a-4bfc-4c1c-bf96-a1b556428e0ddefault-ARRAY_VIEW-ae48effe-f242-41ee-8822-93fb92679ecddefault" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 77.38141914149585, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..a60c97b914 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/docstring.txt @@ -0,0 +1,9 @@ + +The CONDITIONAL node is a specialized node that compares two given DataContainer inputs. + +It then enqueues nodes connected with a "true" or "false" output based on the comparison result. + +Parameters +---------- +operator_type : select + Specifies the type of comparison to be performed between the two inputs. The default value is ">=". diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..9c2cc38298 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/a1-[autogen]/python_code.txt @@ -0,0 +1,58 @@ +from typing import Any, TypedDict, Literal +from flojoy import flojoy, JobResultBuilder, OrderedPair + + +class ConditionalOutput(TypedDict): + true: Any + false: Any + + +@flojoy +def CONDITIONAL( + x: OrderedPair, + y: OrderedPair, + operator_type: Literal["<=", ">", "<", ">=", "!=", "=="] = ">=", +) -> ConditionalOutput: + + + y_of_x = x.y + y_of_y = y.y + bool_ = compare_values(y_of_x[0], y_of_y[0], operator_type) + data = None + if operator_type in ["<=", "<"]: + if not bool_: + data = OrderedPair(x=x.x, y=y.y) + else: + data = OrderedPair(x=y.x, y=x.y) + elif bool_: + data = OrderedPair(x=x.x, y=y.y) + else: + data = OrderedPair(x=y.x, y=x.y) + next_direction = str(bool_).lower() + return ConditionalOutput( + true=JobResultBuilder() + .from_data(data) + .flow_to_directions([next_direction]) + .build(), + false=JobResultBuilder() + .from_data(data) + .flow_to_directions([next_direction]) + .build(), + ) + + +def compare_values(first_value: Any, second_value: Any, operator: str): + bool_: bool = False + if operator == "<=": + bool_ = first_value <= second_value + elif operator == ">": + bool_ = first_value > second_value + elif operator == "<": + bool_ = first_value < second_value + elif operator == ">=": + bool_ = first_value >= second_value + elif operator == "!=": + bool_ = first_value != second_value + else: + bool_ = first_value == second_value + return bool_ diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/media.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/notes.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/examples/EX1/app.txt new file mode 100644 index 0000000000..ab90846aa2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/CONDITIONALS/CONDITIONAL/examples/EX1/app.txt @@ -0,0 +1,303 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 210, + "height": 208, + "id": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "type": "CONDITIONALS", + "data": { + "id": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "label": "CONDITIONAL", + "func": "CONDITIONAL", + "type": "CONDITIONALS", + "ctrls": { + "operator_type": { + "type": "select", + "default": ">=", + "options": [ + "<=", + ">", + "<", + ">=", + "!=", + "==" + ], + "functionName": "CONDITIONAL", + "param": "operator_type", + "value": ">" + } + }, + "inputs": [ + { + "name": "x", + "id": "x", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "y", + "id": "y", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "true", + "id": "true", + "type": "Any" + }, + { + "name": "false", + "id": "false", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\CONDITIONALS\\CONDITIONAL\\CONDITIONAL.py", + "selected": false + }, + "position": { + "x": 259.2959843332327, + "y": 140.81176179304782 + }, + "selected": false, + "positionAbsolute": { + "x": 259.2959843332327, + "y": 140.81176179304782 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-3ab4671f-65c7-48d6-a2c2-d03c4cd4bd8f", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-3ab4671f-65c7-48d6-a2c2-d03c4cd4bd8f", + "label": "8", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "8" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": -17.83614094036632, + "y": 74.67650991195404 + }, + "selected": false, + "positionAbsolute": { + "x": -17.83614094036632, + "y": 74.67650991195404 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-8ac72ae0-8f52-47e4-a1c9-76167f0b0706", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-8ac72ae0-8f52-47e4-a1c9-76167f0b0706", + "label": "4", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "4" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": -9.281435332839152, + "y": 314.1934465450072 + }, + "selected": false, + "positionAbsolute": { + "x": -9.281435332839152, + "y": 314.1934465450072 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-3c753e5a-5d90-4d92-92f9-b955d32bd24e", + "type": "VISUALIZERS", + "data": { + "id": "LINE-3c753e5a-5d90-4d92-92f9-b955d32bd24e", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 652.9812004323767, + "y": -19.860651714669302 + }, + "selected": false, + "positionAbsolute": { + "x": 652.9812004323767, + "y": -19.860651714669302 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-6a05bf10-f19b-401d-b8e4-0a4d56d8f27c", + "type": "VISUALIZERS", + "data": { + "id": "LINE-6a05bf10-f19b-401d-b8e4-0a4d56d8f27c", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 673.0558583074628, + "y": 333.5593015742577 + }, + "selected": false, + "positionAbsolute": { + "x": 673.0558583074628, + "y": 333.5593015742577 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONSTANT-3ab4671f-65c7-48d6-a2c2-d03c4cd4bd8f", + "sourceHandle": "default", + "target": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "targetHandle": "x", + "id": "reactflow__edge-CONSTANT-3ab4671f-65c7-48d6-a2c2-d03c4cd4bd8fdefault-CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62cx" + }, + { + "source": "CONSTANT-8ac72ae0-8f52-47e4-a1c9-76167f0b0706", + "sourceHandle": "default", + "target": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "targetHandle": "y", + "id": "reactflow__edge-CONSTANT-8ac72ae0-8f52-47e4-a1c9-76167f0b0706default-CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62cy" + }, + { + "source": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "sourceHandle": "true", + "target": "LINE-3c753e5a-5d90-4d92-92f9-b955d32bd24e", + "targetHandle": "default", + "id": "reactflow__edge-CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62ctrue-LINE-3c753e5a-5d90-4d92-92f9-b955d32bd24edefault" + }, + { + "source": "CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62c", + "sourceHandle": "false", + "target": "LINE-6a05bf10-f19b-401d-b8e4-0a4d56d8f27c", + "targetHandle": "default", + "id": "reactflow__edge-CONDITIONAL-c44f8006-f1fb-41be-ab39-de40becaf62cfalse-LINE-6a05bf10-f19b-401d-b8e4-0a4d56d8f27cdefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..217151d4cd --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The APPEND node appends a single data point to an array. + +The large array must be passed to the bottom "array" connection. + +For ordered pair, the single point must have a shape of 1 (or (1,)). + +Returns +------- +OrderedPair, Matrix, DataFrame diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..63006e686e --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/a1-[autogen]/python_code.txt @@ -0,0 +1,44 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Matrix, DataFrame + + +@flojoy +def APPEND( + primary_dp: OrderedPair | Matrix | DataFrame, + secondary_dp: OrderedPair | Matrix | DataFrame, +) -> OrderedPair | Matrix | DataFrame: + + + if isinstance(primary_dp, OrderedPair) and isinstance(secondary_dp, OrderedPair): + x0 = primary_dp.x + y0 = primary_dp.y + + x1 = secondary_dp.x + y1 = secondary_dp.y + + if y1.shape[0] != 1: + raise ValueError( + ( + "To append, APPEND node the requires the non-array " + "input to have a single point. " + f"The data passed has a shape of: {y1.shape}" + ) + ) + + x = np.append(x0, x1) + y = np.append(y0, y1) + return OrderedPair(x=x, y=y) + + elif isinstance(primary_dp, Matrix) and isinstance(secondary_dp, Matrix): + m0 = primary_dp.m + m1 = secondary_dp.m + + m = np.append(m0, m1, axis=0) + return Matrix(m=m) + + else: + df0 = primary_dp.m + df1 = secondary_dp.m + + df = np.append(df0, df1, axis=0) + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/media.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/notes.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/examples/EX1/app.txt new file mode 100644 index 0000000000..287d30d6e6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/APPEND/examples/EX1/app.txt @@ -0,0 +1,500 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4", + "type": "LOGIC_GATES", + "data": { + "id": "APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4", + "label": "APPEND", + "func": "APPEND", + "type": "LOGIC_GATES", + "ctrls": {}, + "inputs": [ + { + "name": "primary_dp", + "id": "primary_dp", + "type": "OrderedPair|Matrix|DataFrame", + "multiple": false + }, + { + "name": "secondary_dp", + "id": "secondary_dp", + "type": "OrderedPair|Matrix|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix|DataFrame" + } + ], + "path": "PYTHON/nodes/LOGIC_GATES/LOOPS/APPEND/APPEND.py", + "selected": false + }, + "position": { + "x": 217.74230238952578, + "y": 103.06105984037367 + }, + "selected": false, + "positionAbsolute": { + "x": 217.74230238952578, + "y": 103.06105984037367 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586", + "type": "GENERATORS", + "data": { + "id": "RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586", + "label": "RAND", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "functionName": "RAND", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "poisson_events", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": -116.99910130481645, + "y": 31.67641795910953 + }, + "selected": false, + "positionAbsolute": { + "x": -116.99910130481645, + "y": 31.67641795910953 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-84e2f852-a28c-48bf-b9df-8aa5a0996511", + "type": "default", + "data": { + "id": "LINSPACE-84e2f852-a28c-48bf-b9df-8aa5a0996511", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "1" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "2" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -447.16047439695353, + "y": 11.970451908549023 + }, + "selected": false, + "positionAbsolute": { + "x": -447.16047439695353, + "y": 11.970451908549023 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-d44b3399-36af-4c49-aa54-bc58930977cd", + "type": "default", + "data": { + "id": "LINSPACE-d44b3399-36af-4c49-aa54-bc58930977cd", + "label": "LINSPACE 1", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "2" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "3" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "1" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -467.0723665226683, + "y": 319.26815254052497 + }, + "selected": false, + "positionAbsolute": { + "x": -467.0723665226683, + "y": 319.26815254052497 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "RAND-604d3223-83f7-4e62-851c-567cf7d10cfe", + "type": "GENERATORS", + "data": { + "id": "RAND-604d3223-83f7-4e62-851c-567cf7d10cfe", + "label": "RAND 1", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "functionName": "RAND", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "poisson_events", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": -64.24809691739924, + "y": 348.6561269746337 + }, + "selected": false, + "positionAbsolute": { + "x": -64.24809691739924, + "y": 348.6561269746337 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-fe4b85c2-0917-4786-a715-836201d919cf", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-fe4b85c2-0917-4786-a715-836201d919cf", + "label": "SCATTER 1", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 560.427035076177, + "y": 55.36121100525014 + }, + "selected": false, + "positionAbsolute": { + "x": 560.427035076177, + "y": 55.36121100525014 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-ee3d567b-33c6-4700-a8ff-dd4f091e2d27", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-ee3d567b-33c6-4700-a8ff-dd4f091e2d27", + "label": "SCATTER 1", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 223.6782344391588, + "y": -267.09799352606467 + }, + "selected": false, + "positionAbsolute": { + "x": 223.6782344391588, + "y": -267.09799352606467 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-84e2f852-a28c-48bf-b9df-8aa5a0996511", + "sourceHandle": "default", + "target": "RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-84e2f852-a28c-48bf-b9df-8aa5a0996511default-RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586default" + }, + { + "source": "RAND-604d3223-83f7-4e62-851c-567cf7d10cfe", + "sourceHandle": "default", + "target": "APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4", + "targetHandle": "secondary_dp", + "id": "reactflow__edge-RAND-604d3223-83f7-4e62-851c-567cf7d10cfedefault-APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4secondary_dp" + }, + { + "source": "LINSPACE-d44b3399-36af-4c49-aa54-bc58930977cd", + "sourceHandle": "default", + "target": "RAND-604d3223-83f7-4e62-851c-567cf7d10cfe", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-d44b3399-36af-4c49-aa54-bc58930977cddefault-RAND-604d3223-83f7-4e62-851c-567cf7d10cfedefault" + }, + { + "source": "RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586", + "sourceHandle": "default", + "target": "APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4", + "targetHandle": "primary_dp", + "id": "reactflow__edge-RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586default-APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4primary_dp" + }, + { + "source": "RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586", + "sourceHandle": "default", + "target": "SCATTER-ee3d567b-33c6-4700-a8ff-dd4f091e2d27", + "targetHandle": "default", + "id": "reactflow__edge-RAND-c7739b2a-89f6-46fd-ac17-b3fdbec8c586default-SCATTER-ee3d567b-33c6-4700-a8ff-dd4f091e2d27default" + }, + { + "source": "APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4", + "sourceHandle": "default", + "target": "SCATTER-fe4b85c2-0917-4786-a715-836201d919cf", + "targetHandle": "default", + "id": "reactflow__edge-APPEND-a2c9923a-6e0d-4eee-9075-b898669afef4default-SCATTER-fe4b85c2-0917-4786-a715-836201d919cfdefault" + } + ], + "viewport": { + "x": -501.95459935516146, + "y": 196.48083177807212, + "zoom": 1.4811524052100216 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..34054ccad4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The LOOP node is a specialized node that iterates through the body nodes for a given number of times. + +Parameters +---------- +num_loops : int + number of times to iterate through body nodes, default is "-1" meaning infinity. diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7d489f6a86 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/a1-[autogen]/python_code.txt @@ -0,0 +1,125 @@ +import json +from typing import TypedDict, Any, Optional +from flojoy import JobResultBuilder, DataContainer, flojoy, DefaultParams, SmallMemory + +memory_key = "loop-info" + + +class LoopOutput(TypedDict): + body: Any + end: Any + + +class LoopData: + def __init__( + self, + node_id: str, + num_loops: int = -1, + current_iteration: int = 0, + is_finished: bool = False, + ) -> None: + self.node_id = node_id + self.num_loops = int(num_loops) + self.current_iteration = int(current_iteration) + self.is_finished = bool(is_finished) + + def restart(self): + self.current_iteration = 0 + self.is_finished = False + + def step(self): + self.current_iteration += 1 + if self.current_iteration > self.num_loops: + self.is_finished = True + + def get_data(self): + return { + "node_id": self.node_id, + "num_loops": self.num_loops, + "current_iteration": self.current_iteration, + "is_finished": self.is_finished, + } + + @staticmethod + def from_data(node_id: str, data: dict[str, Any]): + loop_data = LoopData( + node_id, + num_loops=data.get("num_loops", -1), + current_iteration=data.get("current_iteration", 0), + is_finished=data.get("is_finished", False), + ) + return loop_data + + def print(self, prefix: str = ""): + print(f"{prefix}loop Data:", json.dumps(self.get_data(), indent=2)) + + +@flojoy(inject_node_metadata=True) +def LOOP( + default_params: DefaultParams, + default: Optional[DataContainer] = None, + num_loops: int = -1, +) -> LoopOutput: + + node_id = default_params.node_id + + print("\n\nstart loop:", node_id) + + # infinite loop + if num_loops == -1: + print("infinite loop") + return build_result(inputs=[default] if default else [], is_loop_finished=False) + + loop_data: LoopData = load_loop_data(node_id, num_loops) + loop_data.print("at start ") + + # loop was previously finished, but now re-executing, so restart + if loop_data.is_finished: + loop_data.restart() + else: + loop_data.step() + + if not loop_data.is_finished: + store_loop_data(node_id, loop_data) + else: + print("finished loop") + delete_loop_data(node_id) + + print("end loop\n\n") + + return build_result([default] if default else [], loop_data.is_finished) + + +def load_loop_data(node_id: str, default_num_loops: int) -> LoopData: + data: dict[str, Any] = SmallMemory().read_memory(node_id, memory_key) or {} + loop_data = LoopData.from_data( + node_id=node_id, data={"num_loops": default_num_loops, **data} + ) + return loop_data + + +def store_loop_data(node_id: str, loop_data: LoopData): + SmallMemory().write_to_memory(node_id, memory_key, loop_data.get_data()) + loop_data.print("store ") + + +def delete_loop_data(node_id: str): + SmallMemory().delete_object(node_id, memory_key) + print("delete loop data") + + +def build_result(inputs: list[DataContainer], is_loop_finished: bool): + return LoopOutput( + body=JobResultBuilder() + .from_inputs(inputs) + .flow_by_flag( + flag=is_loop_finished, false_direction=["body"], true_direction=["end"] + ) + .build(), + end=JobResultBuilder() + .from_inputs(inputs) + .flow_by_flag( + flag=is_loop_finished, false_direction=["body"], true_direction=["end"] + ) + .build(), + ) diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/media.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/notes.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/examples/EX1/app.txt new file mode 100644 index 0000000000..95f5d226ae --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOPS/LOOP/examples/EX1/app.txt @@ -0,0 +1,228 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 96, + "height": 96, + "id": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "100" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes/LOGIC_GATES/LOOPS/LOOP/LOOP.py", + "selected": false + }, + "position": { + "x": 153.08826345429478, + "y": 125.76028881809133 + }, + "selected": false, + "positionAbsolute": { + "x": 153.08826345429478, + "y": 125.76028881809133 + } + }, + { + "width": 380, + "height": 293, + "id": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 821.3726227277857, + "y": -56.51459992169677 + }, + "selected": false, + "positionAbsolute": { + "x": 821.3726227277857, + "y": -56.51459992169677 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "type": "default", + "data": { + "id": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "label": "LOOP INDEX", + "func": "LOOP_INDEX", + "type": "default", + "ctrls": { + "loop_node": { + "type": "NodeReference", + "default": null, + "desc": "The LOOP node to track the loop index from.", + "functionName": "LOOP_INDEX", + "param": "loop_node", + "value": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Scalar", + "desc": "The loop index in Scalar form." + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOP_TOOLS\\LOOP_INDEX\\LOOP_INDEX.py", + "selected": false + }, + "position": { + "x": 472.5656805220707, + "y": 3.5093485056772806 + }, + "selected": false, + "positionAbsolute": { + "x": 472.5656805220707, + "y": 3.5093485056772806 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "sourceHandle": "body", + "target": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7body-LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526adefault" + }, + { + "source": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "sourceHandle": "default", + "target": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "targetHandle": "default", + "id": "reactflow__edge-LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526adefault-BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851default" + } + ], + "viewport": { + "x": 555.0976680981258, + "y": 214.4419430555007, + "zoom": 0.8287213244976164 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..7b2c303ce7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ +The LOOP_INDEX node loads the loop index from the LOOP node. + A loop index in Flojoy starts at 1 and increases by 1 for each loop. + + Parameters + ---------- + loop_node: str + The LOOP node to track the loop index from. + + Returns + ------- + Scalar + The loop index in Scalar form. diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..35a7e7a12c --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/a1-[autogen]/python_code.txt @@ -0,0 +1,32 @@ +from flojoy import ( + flojoy, + Scalar, + OrderedPair, + SmallMemory, + NodeReference, +) +from typing import Optional + + +memory_key = "LOOP_INDEX" + + +@flojoy(node_type="default") +def LOOP_INDEX( + loop_node: NodeReference, + default: Optional[OrderedPair | Scalar] = None, +) -> Scalar: + + + ref_loop_node = loop_node.unwrap() + + if ref_loop_node == "" or "LOOP" not in ref_loop_node: + raise ValueError("A LOOP node id must be given.") + + loop_info = SmallMemory().read_memory(ref_loop_node, "loop-info") + if loop_info is None: + c = 1 + else: + c = loop_info.get("current_iteration") + + return Scalar(c=float(c)) diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/media.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/notes.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/examples/EX1/app.txt new file mode 100644 index 0000000000..95f5d226ae --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/LOOP_TOOLS/LOOP_INDEX/examples/EX1/app.txt @@ -0,0 +1,228 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 96, + "height": 96, + "id": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "100" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes/LOGIC_GATES/LOOPS/LOOP/LOOP.py", + "selected": false + }, + "position": { + "x": 153.08826345429478, + "y": 125.76028881809133 + }, + "selected": false, + "positionAbsolute": { + "x": 153.08826345429478, + "y": 125.76028881809133 + } + }, + { + "width": 380, + "height": 293, + "id": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 821.3726227277857, + "y": -56.51459992169677 + }, + "selected": false, + "positionAbsolute": { + "x": 821.3726227277857, + "y": -56.51459992169677 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "type": "default", + "data": { + "id": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "label": "LOOP INDEX", + "func": "LOOP_INDEX", + "type": "default", + "ctrls": { + "loop_node": { + "type": "NodeReference", + "default": null, + "desc": "The LOOP node to track the loop index from.", + "functionName": "LOOP_INDEX", + "param": "loop_node", + "value": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Scalar", + "desc": "The loop index in Scalar form." + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOP_TOOLS\\LOOP_INDEX\\LOOP_INDEX.py", + "selected": false + }, + "position": { + "x": 472.5656805220707, + "y": 3.5093485056772806 + }, + "selected": false, + "positionAbsolute": { + "x": 472.5656805220707, + "y": 3.5093485056772806 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7", + "sourceHandle": "body", + "target": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-e209afec-0fe8-41e1-a665-d055e0179cc7body-LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526adefault" + }, + { + "source": "LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526a", + "sourceHandle": "default", + "target": "BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851", + "targetHandle": "default", + "id": "reactflow__edge-LOOP_INDEX-908a6860-ae5a-4be7-bff4-bb92070f526adefault-BIG_NUMBER-ca0dc263-0e3f-4c7e-9a71-50dd014ec851default" + } + ], + "viewport": { + "x": 555.0976680981258, + "y": 214.4419430555007, + "zoom": 0.8287213244976164 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..7f7adcf4ae --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/docstring.txt @@ -0,0 +1,6 @@ +The TIMER node sleeps for a specified number of seconds. + + Parameters + ---------- + sleep_time: float + number of seconds to sleep diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..eed957bcde --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/a1-[autogen]/python_code.txt @@ -0,0 +1,56 @@ +from flojoy import flojoy, DataContainer, DefaultParams, send_to_socket +from flojoy.utils import PlotlyJSONEncoder +from flojoy.job_result_builder import JobResultBuilder +import plotly.graph_objects as go +import time +import json +from typing import Optional, cast + + +@flojoy(inject_node_metadata=True) +def TIMER( + default_params: DefaultParams, + default: Optional[DataContainer] = None, + sleep_time: float = 0, +) -> DataContainer: + + node_id = default_params.node_id + jobset_id = default_params.jobset_id + remaining_time = sleep_time + start_time = time.time() + current_time = start_time + + result = cast( + DataContainer, + JobResultBuilder().from_inputs([default] if default else []).build(), + ) + + while current_time - start_time < sleep_time: + fig = go.Figure( + data=go.Indicator( + mode="number", + value=int(remaining_time), + domain={"y": [0, 1], "x": [0, 1]}, + delta=None, + ) + ) + send_to_socket( + json.dumps( + { + "NODE_RESULTS": { + "cmd": "TIMER", + "id": node_id, + "result": {"plotly_fig": fig}, + }, + "proceed_to_next": False, + "jobsetId": jobset_id, + }, + cls=PlotlyJSONEncoder, + ), + ) + sleep_interval = min(1, remaining_time) + time.sleep(sleep_interval) + remaining_time = sleep_time - (current_time - start_time) + current_time = time.time() + + return result diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/hardware.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/media.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/notes.md b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/examples/EX1/app.txt new file mode 100644 index 0000000000..74020c08fc --- /dev/null +++ b/docs/nodes/flojoy_nodes/LOGIC_GATES/TIMERS/TIMER/examples/EX1/app.txt @@ -0,0 +1,228 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 96, + "height": 96, + "id": "TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31", + "type": "LOGIC_GATES", + "data": { + "id": "TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31", + "label": "TIMER", + "func": "TIMER", + "type": "LOGIC_GATES", + "ctrls": { + "sleep_time": { + "type": "float", + "default": 0, + "functionName": "TIMER", + "param": "sleep_time", + "value": "1.5" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\TIMERS\\TIMER\\TIMER.py", + "selected": false + }, + "position": { + "x": 248.76423256094694, + "y": 106.13709173968681 + }, + "selected": false, + "positionAbsolute": { + "x": 248.76423256094694, + "y": 106.13709173968681 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "BIG_NUMBER-65eb6fbe-2374-4cf8-ba51-c40c7eb017aa", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-65eb6fbe-2374-4cf8-ba51-c40c7eb017aa", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "desc": null, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BIG_NUMBER\\BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 518.2358414847172, + "y": 4.169096131465835 + }, + "selected": false, + "positionAbsolute": { + "x": 518.2358414847172, + "y": 4.169096131465835 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "CONSTANT-8797a1fe-b49f-469e-81a7-813fe7638a7e", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-8797a1fe-b49f-469e-81a7-813fe7638a7e", + "label": "3.0", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": 3 + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": 1000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": -125.44180464761385, + "y": 104.56416879553518 + }, + "selected": false, + "positionAbsolute": { + "x": -125.44180464761385, + "y": 104.56416879553518 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31", + "sourceHandle": "default", + "target": "BIG_NUMBER-65eb6fbe-2374-4cf8-ba51-c40c7eb017aa", + "targetHandle": "default", + "id": "reactflow__edge-TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31default-BIG_NUMBER-65eb6fbe-2374-4cf8-ba51-c40c7eb017aadefault" + }, + { + "source": "CONSTANT-8797a1fe-b49f-469e-81a7-813fe7638a7e", + "sourceHandle": "default", + "target": "TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31", + "targetHandle": "default", + "id": "reactflow__edge-CONSTANT-8797a1fe-b49f-469e-81a7-813fe7638a7edefault-TIMER-b85f2c5b-f7de-4485-953d-986177ab9d31default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3b262b5e27 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/docstring.txt @@ -0,0 +1,22 @@ + +The CHOLESKY node is based on a numpy or scipy function. + +The description of that function is as follows: + + Cholesky decomposition. + + Return the Cholesky decomposition, "L * L.H", of the square matrix "a", where "L" is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if "a" is real-valued). + + "a" must be Hermitian (symmetric if real-valued) and positive-definite. No checking is performed to verify whether "a" is Hermitian or not. + + In addition, only the lower-triangular and diagonal elements of "a" are used. Only "L" is actually returned. + +Parameters +---------- +a : (..., M, M) array_like + Hermitian (symmetric if all elements are real), positive-definite input matrix. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..f34169c30f --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def CHOLESKY( + default: Matrix, +) -> Matrix | Scalar: + + + result = numpy.linalg.cholesky( + a=default.m, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/CHOLESKY/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1feef34979 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The DET node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the determinant of an array. + +Parameters +---------- +a : (..., M, M) array_like + Input array to compute determinants. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..08c5f0aac6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def DET( + default: Matrix, +) -> Matrix | Scalar: + + + result = numpy.linalg.det( + a=default.m, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/DET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..a24160ea0a --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/docstring.txt @@ -0,0 +1,19 @@ + +The EIG node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the eigenvalues and right eigenvectors of a square array. + +Parameters +---------- +select_return : This function has returns for multiple objects ['w', 'v']. + Select the desired one to return. + See the respective function docs for descriptors. +a : (..., M, M) array + Matrices for which the eigenvalues and right eigenvectors will be computed. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..77a85086f2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def EIG( + default: Matrix, + select_return: Literal["w", "v"] = "w", +) -> Matrix | Scalar: + + + result = numpy.linalg.eig( + a=default.m, + ) + + return_list = ["w", "v"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIG/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..7de89623c8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/docstring.txt @@ -0,0 +1,11 @@ + +The EIGH node is based on a numpy or scipy function. + +The description of that function is as follows: + + Return the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..c468f8f310 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/a1-[autogen]/python_code.txt @@ -0,0 +1,41 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def EIGH( + default: Matrix, + UPLO: str = "L", + select_return: Literal["w", "v"] = "w", +) -> Matrix | Scalar: + + + result = numpy.linalg.eigh( + a=default.m, + UPLO=UPLO, + ) + + return_list = ["w", "v"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGH/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c4ecd8a1d1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The EIGVALS node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the eigenvalues of a general matrix. + +Main difference between `eigvals` and `eig`: the eigenvectors are not returned. + +Parameters +---------- +a : (..., M, M) array_like + A complex- or real-valued matrix whose eigenvalues will be computed. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7ab5f830dd --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def EIGVALS( + default: Matrix, +) -> Matrix | Scalar: + + + result = numpy.linalg.eigvals( + a=default.m, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..54facd8d1d --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The EIGVALSH node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the eigenvalues of a complex Hermitian or real symmetric matrix. + +Main difference from eigh: the eigenvectors are not computed. + +Parameters +---------- +a : (..., M, M) array_like + A complex- or real-valued matrix whose eigenvalues are to be computed. +UPLO : {'L', 'U'}, optional + Specifies whether the calculation is done with the lower triangular + part of 'a' ('L', default) or the upper triangular part ('U'). + Irrespective of this value, only the real parts of the diagonal will + be considered in the computation to preserve the notion of a Hermitian matrix. + It therefore follows that the imaginary part of the diagonal will always + be treated as zero. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..503afa1080 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def EIGVALSH( + default: Matrix, + UPLO: str = "L", +) -> Matrix | Scalar: + + + result = numpy.linalg.eigvalsh( + a=default.m, + UPLO=UPLO, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/EIGVALSH/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1c1d57392a --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The INV node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the (multiplicative) inverse of a matrix. + + Given a square matrix 'a', return the matrix 'ainv', satisfying "dot(a, ainv) = dot(ainv, a) = eye(a.shape[0])". + +Parameters +---------- +a : (..., M, M) array_like + Matrix to be inverted. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d277d554eb --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def INV( + default: Matrix, +) -> Matrix | Scalar: + + + result = numpy.linalg.inv( + a=default.m, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/INV/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..955df203b8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/docstring.txt @@ -0,0 +1,24 @@ + +The MATRIX_POWER node is based on a numpy or scipy function. + +The description of that function is as follows: + + Raise a square matrix to the (integer) power 'n'. + + For positive integers 'n', the power is computed by repeated matrix squarings and matrix multiplications. + + If "n == 0", the identity matrix of the same shape as M is returned. If "n < 0", the inverse is computed and then raised to "abs(n)". + +Note: Stacks of object matrices are not currently supported. + +Parameters +---------- +a : (..., M, M) array_like + Matrix to be "powered". +n : int + The exponent can be any integer or long integer, positive, negative, or zero. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7e8c7b082c --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def MATRIX_POWER( + default: Matrix, + n: int = 2, +) -> Matrix | Scalar: + + + result = numpy.linalg.matrix_power( + a=default.m, + n=n, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/MATRIX_POWER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1133c2f05a --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The PINV node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the (Moore-Penrose) pseudo-inverse of a matrix. + + Calculate the generalized inverse of a matrix using its singular-value decomposition (SVD) and including all *large* singular values. + +.. versionchanged:: 1.14 + Can now operate on stacks of matrices + +Parameters +---------- +a : (..., M, N) array_like + Matrix or stack of matrices to be pseudo-inverted. +rcond : (...) array_like of float + Cutoff for small singular values. + Singular values less than or equal to "rcond * largest_singular_value" are set to zero. + Broadcasts against the stack of matrices. +hermitian : bool, optional + If True, "a" is assumed to be Hermitian (symmetric if real-valued), enabling a more + efficient method for finding singular values. + Defaults to False. + +.. versionadded:: 1.17.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..162168177a --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def PINV( + default: Matrix, + rcond: float = 1e-15, + hermitian: bool = False, +) -> Matrix | Scalar: + + + result = numpy.linalg.pinv( + a=default.m, + rcond=rcond, + hermitian=hermitian, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/PINV/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c9b39e1935 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/docstring.txt @@ -0,0 +1,35 @@ + +The QR node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the qr factorization of a matrix. + + Factor the matrix 'a' as *qr*, where 'q' is orthonormal and 'r' is upper-triangular. + +Parameters +---------- +select_return : This function has returns for multiple objects ['q', 'r', '(h, tau)']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array_like, shape (..., M, N) + An array-like object with the dimensionality of at least 2. +mode : {'reduced', 'complete', 'r', 'raw'}, optional + If K = min(M, N), then: + 'reduced' : returns q, r with dimensions (..., M, K), (..., K, N) (default) + 'complete' : returns q, r with dimensions (..., M, M), (..., M, N) + 'r' : returns r only with dimensions (..., K, N) + 'raw' : returns h, tau with dimensions (..., N, M), (..., K,) + + The options 'reduced', 'complete, and 'raw' are new in numpy 1.8 (see the notes for more information). + The default is 'reduced', and to maintain backward compatibility with earlier versions of numpy, + both it and the old default 'full' can be omitted. + Note that array h returned in 'raw' mode is transposed for calling Fortran. + The 'economic' mode is deprecated. + The modes 'full' and 'economic' may be passed using only the first letter for backwards compatibility, + but all others must be spelled out (see the Notes for further explanation). + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d9491266f1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/a1-[autogen]/python_code.txt @@ -0,0 +1,41 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def QR( + default: Matrix, + mode: str = "reduced", + select_return: Literal["q", "r", "(h, tau)"] = "q", +) -> Matrix | Scalar: + + + result = numpy.linalg.qr( + a=default.m, + mode=mode, + ) + + return_list = ["q", "r", "(h, tau)"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/QR/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..ef28096635 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The SLOGDET node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the sign and (natural) logarithm of the determinant of an array. + + If an array has a very small or very large determinant, then a call to 'det' may overflow or underflow. + + This routine is more robust against such issues, because it computes the logarithm of the determinant rather than the determinant itself. + +Parameters +---------- +select_return : This function has returns multiple objects []'sign', 'logdet']. + Select the desired one to return. + See the respective function documents for descriptors. +a : (..., M, M) array_like + Input array, has to be a square 2-D array. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4f462df5f8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def SLOGDET( + default: Matrix, + select_return: Literal["sign", "logdet"] = "sign", +) -> Matrix | Scalar: + + + result = numpy.linalg.slogdet( + a=default.m, + ) + + return_list = ["sign", "logdet"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SLOGDET/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..92f714980e --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/docstring.txt @@ -0,0 +1,35 @@ + +The SVD node is based on a numpy or scipy function. + +The description of that function is as follows: + + Singular Value Decomposition. + + When 'a' is a 2D array, and "full_matrices=False", then it is factorized as "u @ np.diag(s) @ vh = (u * s) @ vh", + where 'u' and the Hermitian transpose of 'vh' are 2D arrays with orthonormal columns and 's' is a 1D array of 'a' singular values. + + When 'a' is higher-dimensional, SVD is applied in stacked mode as explained below. + +Parameters +---------- +select_return : This function has returns multiple objects ['u', 's', 'vh']. + Select the desired one to return. + See the respective function docs for descriptors. +a : (..., M, N) array_like + A real or complex array with "a.ndim >= 2". +full_matrices : bool, optional + If True (default), 'u' and 'vh' have the shapes "(..., M, M)" and "(..., N, N)", respectively. + Otherwise, the shapes are "(..., M, K)" and "(..., K, N)", respectively, where "K = min(M, N)". +compute_uv : bool, optional + Whether or not to compute 'u' and 'vh' in addition to 's'. + True by default. +hermitian : bool, optional + If True, 'a' is assumed to be Hermitian (symmetric if real-valued), enabling a more efficient method for finding singular values. + Defaults to False. + +.. versionadded:: 1.17.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..b2e72292de --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/a1-[autogen]/python_code.txt @@ -0,0 +1,45 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def SVD( + default: Matrix, + full_matrices: bool = True, + compute_uv: bool = True, + hermitian: bool = False, + select_return: Literal["u", "s", "vh"] = "u", +) -> Matrix | Scalar: + + + result = numpy.linalg.svd( + a=default.m, + full_matrices=full_matrices, + compute_uv=compute_uv, + hermitian=hermitian, + ) + + return_list = ["u", "s", "vh"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/SVD/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..b5562506cd --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The TENSORINV node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the 'inverse' of an N-dimensional array. + + The result is an inverse for 'a' relative to the tensordot operation "tensordot(a, b, ind)", + i.e. up to floating-point accuracy, "tensordot(tensorinv(a), a, ind)" is the "identity" tensor for the tensordot operation. + +Parameters +---------- +a : array_like + Tensor to 'invert'. + Its shape must be 'square', i.e. "prod(a.shape[:ind]) == prod(a.shape[ind:])". +ind : int, optional + Number of first indices that are involved in the inverse sum. + Must be a positive integer, default is 2. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..fde430f4de --- /dev/null +++ b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import numpy.linalg + + +@flojoy +def TENSORINV( + default: Matrix, + ind: int = 2, +) -> Matrix | Scalar: + + + result = numpy.linalg.tensorinv( + a=default.m, + ind=ind, + ) + + if isinstance(result, np.ndarray): + result = Matrix(m=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/hardware.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/media.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/notes.md b/docs/nodes/flojoy_nodes/NUMPY/LINALG/TENSORINV/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c7760fde48 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The ARGRELMAX node is based on a numpy or scipy function. + +The description of that function is as follows: + Calculate the relative maxima of `data`. + +Parameters +---------- +data : ndarray + Array in which to find the relative maxima. +axis : int, optional + Axis over which to select from 'data'. Default is 0. +order : int, optional + How many points on each side to use for the comparison + to consider "comparator(n, n+x)" to be True. +mode : str, optional + How the edges of the vector are treated. + Available options are 'wrap' (wrap around) or 'clip' (treat overflow + as the same as the last (or first) element). + Default 'clip'. See numpy.take. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..44bfe3febb --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/a1-[autogen]/python_code.txt @@ -0,0 +1,28 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def ARGRELMAX( + default: OrderedPair | Matrix, + axis: int = 0, + order: int = 1, + mode: str = "clip", +) -> OrderedPair | Matrix | Scalar: + + + result = OrderedPair( + x=default.x, + y=scipy.signal.argrelmax( + data=default.y, + axis=axis, + order=order, + mode=mode, + ), + ) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMAX/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..9bf0c6ce19 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/docstring.txt @@ -0,0 +1,26 @@ + +The ARGRELMIN node is based on a numpy or scipy function. + +The description of that function is as follows: + + Calculate the relative minima of 'data'. + +Parameters +---------- +data : ndarray + Array in which to find the relative minima. +axis : int, optional + Axis over which to select from 'data'. Default is 0. +order : int, optional + How many points on each side to use for the comparison + to consider "comparator(n, n+x)" to be True. +mode : str, optional + How the edges of the vector are treated. + Available options are 'wrap' (wrap around) or 'clip' (treat overflow + as the same as the last (or first) element). + Default 'clip'. See numpy.take. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..80f54f55ef --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/a1-[autogen]/python_code.txt @@ -0,0 +1,28 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def ARGRELMIN( + default: OrderedPair | Matrix, + axis: int = 0, + order: int = 1, + mode: str = "clip", +) -> OrderedPair | Matrix | Scalar: + + + result = OrderedPair( + x=default.x, + y=scipy.signal.argrelmin( + data=default.y, + axis=axis, + order=order, + mode=mode, + ), + ) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/ARGRELMIN/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..4aa707be71 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The BSPLINE node is based on a numpy or scipy function. + +The description of that function is as follows: + + B-spline basis function of order n. + +Parameters +---------- +x : array_like + A knot vector. +n : int + The order of the spline. Must be non-negative, i.e. n >= 0. + +Returns +---------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..87f2a30f4c --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def BSPLINE( + default: OrderedPair | Matrix, + n: int = 2, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.bspline( + x=default.y, + n=n, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/BSPLINE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..16cbc3ab97 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/docstring.txt @@ -0,0 +1,17 @@ + +The CUBIC node is based on a numpy or scipy function. + +The description of that function is as follows: + + A cubic B-spline. + This is a special case of 'bspline', and equivalent to "bspline(x, 3)". + +Parameters +---------- +x : array_like + a knot vector + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..58317b8c9b --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def CUBIC( + default: OrderedPair | Matrix, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.cubic( + x=default.y, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/CUBIC/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..b82a40f377 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/docstring.txt @@ -0,0 +1,36 @@ + +The DECIMATE node is based on a numpy or scipy function. + +The description of that function is as follows: + + Downsample the signal after applying an anti-aliasing filter. + + By default, an order 8 Chebyshev type I filter is used. A 30 point FIR filter with Hamming window is used if `ftype` is 'fir'. + +Parameters +---------- +x : array_like + The signal to be downsampled, as an N-dimensional array. +q : int + The downsampling factor. When using IIR downsampling, it is recommended + to call `decimate` multiple times for downsampling factors higher than 13. +n : int, optional + The order of the filter (1 less than the length for 'fir'). + Defaults to 8 for 'iir' and 20 times the downsampling factor for 'fir'. +ftype : str {'iir', 'fir'} or "dlti" instance, optional + If 'iir' or 'fir', specifies the type of lowpass filter. + If an instance of an "dlti" object, uses that object to filter before downsampling. +axis : int, optional + The axis along which to decimate. +zero_phase : bool, optional + Prevent phase shift by filtering with 'filtfilt' instead of 'lfilter' + when using an IIR filter, and shifting the outputs back by the filter's + group delay when using an FIR filter. The default value of 'True' is + recommended, since a phase shift is generally not desired. + +.. versionadded:: 0.18.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..c85438bbde --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/a1-[autogen]/python_code.txt @@ -0,0 +1,37 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def DECIMATE( + default: OrderedPair | Matrix, + q: int = 2, + n: int = 2, + ftype: str = "iir", + axis: int = -1, + zero_phase: bool = True, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.decimate( + x=default.y, + q=q, + n=n, + ftype=ftype, + axis=axis, + zero_phase=zero_phase, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DECIMATE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3a1f8f4024 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/docstring.txt @@ -0,0 +1,30 @@ + +The DETREND node is based on a numpy or scipy function. + +The description of that function is as follows: + + Remove linear trend along axis from data. + +Parameters +---------- +data : array_like + The input data. +axis : int, optional + The axis along which to detrend the data. By default this is the + last axis (-1). +type : {'linear', 'constant'}, optional + The type of detrending. If type == 'linear' (default), + the result of a linear least-squares fit to 'data' is subtracted from 'data'. + If type == 'constant', only the mean of 'data' is subtracted. +bp : array_like of ints, optional + A sequence of break points. If given, an individual linear fit is + performed for each part of 'data' between two break points. + Break points are specified as indices into 'data'. This parameter + only has an effect when type == 'linear'. +overwrite_data : bool, optional + If True, perform in place detrending and avoid a copy. Default is False. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7706cb42a4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def DETREND( + default: OrderedPair | Matrix, + axis: int = -1, + type: str = "linear", + bp: int = 0, + overwrite_data: bool = False, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.detrend( + data=default.y, + axis=axis, + type=type, + bp=bp, + overwrite_data=overwrite_data, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/DETREND/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..80f51461b3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The GAUSS_SPLINE node is based on a numpy or scipy function. + +The description of that function is as follows: + + Gaussian approximation to B-spline basis function of order n. + +Parameters +---------- +x : array_like + A knot vector. +n : int + The order of the spline. Must be non-negative, i.e. n >= 0. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..0a1af53793 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def GAUSS_SPLINE( + default: OrderedPair | Matrix, + n: int = 2, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.gauss_spline( + x=default.y, + n=n, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/GAUSS_SPLINE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..fe71c2e375 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/docstring.txt @@ -0,0 +1,22 @@ + +The HILBERT node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the analytic signal, using the Hilbert transform. + + The transformation is done along the last axis by default. + +Parameters +---------- +x : array_like + Signal data. Must be real. +N : int, optional + Number of Fourier components. Default: x.shape[axis]. +axis : int, optional + Axis along which to do the transformation. Default: -1. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..aa6798b0a2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def HILBERT( + default: OrderedPair | Matrix, + N: int = 2, + axis: int = -1, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.hilbert( + x=default.y, + N=N, + axis=axis, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/HILBERT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..8d47a68d31 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/docstring.txt @@ -0,0 +1,17 @@ + +The KAISER_BETA node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the Kaiser parameter 'beta', given the attenuation 'a'. + +Parameters +---------- +a : float + The desired attenuation in the stopband and maximum ripple in + the passband, in dB. This should be a *positive* number. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..307acdf009 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def KAISER_BETA( + default: OrderedPair | Matrix, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.kaiser_beta( + a=default.y, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/KAISER_BETA/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..6d6ef59f86 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/docstring.txt @@ -0,0 +1,48 @@ + +The PERIODOGRAM node is based on a numpy or scipy function. + +The description of that function is as follows: + + Estimate power spectral density using a periodogram. + +Parameters +---------- +select_return : This function has returns multiple objects ['f', 'Pxx']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Time series of measurement values. +fs : float, optional + Sampling frequency of the 'x' time series. Defaults to 1.0. +window : str or tuple or array_like, optional + Desired window to use. If 'window' is a string or tuple, it is + passed to 'get_window' to generate the window values, which are + DFT-even by default. See 'get_window' for a list of windows and + required parameters. If 'window' is array_like it will be used + directly as the window and its length must be nperseg. + Defaults to 'boxcar'. +nfft : int, optional + Length of the FFT used. If 'None' the length of 'x' will be used. +detrend : str or function or 'False', optional + Specifies how to detrend each segment. If 'detrend' is a + string, it is passed as the 'type' argument to the 'detrend' function. + If it is a function, it takes a segment and returns a + detrended segment. If 'detrend' is 'False', no detrending is done. + Defaults to 'constant'. +return_onesided : bool, optional + If 'True', return a one-sided spectrum for real data. + If 'False' return a two-sided spectrum. Defaults to 'True', but for + complex data, a two-sided spectrum is always returned. +scaling : { 'density', 'spectrum' }, optional + Selects between computing the power spectral density ('density') + where 'Pxx' has units of V**2/Hz and computing the power + spectrum ('spectrum') where 'Pxx' has units of V**2, if 'x' + is measured in V and 'fs' is measured in Hz. Defaults to 'density'. +axis : int, optional + Axis along which the periodogram is computed; the default is + over the last axis (i.e. axis=-1). + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..549b6647df --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/a1-[autogen]/python_code.txt @@ -0,0 +1,53 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy(node_type="default") +def PERIODOGRAM( + default: OrderedPair | Matrix, + fs: float = 1.0, + window: str = "boxcar", + nfft: int = 2, + detrend: str = "constant", + return_onesided: bool = True, + scaling: str = "density", + axis: int = -1, + select_return: Literal["f", "Pxx"] = "f", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.periodogram( + x=default.y, + fs=fs, + window=window, + nfft=nfft, + detrend=detrend, + return_onesided=return_onesided, + scaling=scaling, + axis=axis, + ) + + return_list = ["f", "Pxx"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/PERIODOGRAM/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..579fc43786 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The QUADRATIC node is based on a numpy or scipy function. + +The description of that function is as follows: + + A quadratic B-spline. + + This is a special case of 'bspline', and equivalent to 'bspline(x, 2)'. + +Parameters +---------- +x : array_like + a knot vector + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..5844f8aa8c --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/a1-[autogen]/python_code.txt @@ -0,0 +1,27 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def QUADRATIC( + default: OrderedPair | Matrix, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.quadratic( + x=default.y, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/QUADRATIC/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..fd7d28fb40 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/docstring.txt @@ -0,0 +1,48 @@ + +The SAVGOL_FILTER node is based on a numpy or scipy function. + +The description of that function is as follows: + + Apply a Savitzky-Golay filter to an array. + + This is a 1-D filter. If 'x' has dimension greater than 1, 'axis' determines the axis along which the filter is applied. + +Parameters +---------- +x : array_like + The data to be filtered. If 'x' is not a single or double precision + floating point array, it will be converted to type numpy.float64 before filtering. +window_length : int + The length of the filter window (i.e., the number of coefficients). + If 'mode' is 'interp', 'window_length' must be less than or equal to the size of 'x'. +polyorder : int + The order of the polynomial used to fit the samples. + 'polyorder' must be less than 'window_length'. +deriv : int, optional + The order of the derivative to compute. This must be a + nonnegative integer. The default is 0, which means to filter + the data without differentiating. +delta : float, optional + The spacing of the samples to which the filter will be applied. + This is only used if deriv > 0. Default is 1.0. +axis : int, optional + The axis of the array 'x' along which the filter is to be applied. + Default is -1. +mode : str, optional + Must be 'mirror', 'constant', 'nearest', 'wrap' or 'interp'. This + determines the type of extension to use for the padded signal to + which the filter is applied. When 'mode' is 'constant', the padding + value is given by 'cval'. See the Notes for more details on 'mirror', + 'constant', 'wrap', and 'nearest'. + When the 'interp' mode is selected (the default), no extension + is used. Instead, a degree 'polyorder' polynomial is fit to the + last 'window_length' values of the edges, and this polynomial is + used to evaluate the last 'window_length // 2' output values. +cval : scalar, optional + Value to fill past the edges of the input if 'mode' is 'constant'. + Default is 0.0. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a4a62c8009 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/a1-[autogen]/python_code.txt @@ -0,0 +1,41 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy +def SAVGOL_FILTER( + default: OrderedPair | Matrix, + window_length: int = 2, + polyorder: int = 1, + deriv: int = 0, + delta: float = 1.0, + axis: int = -1, + mode: str = "interp", + cval: float = 0.0, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.savgol_filter( + x=default.y, + window_length=window_length, + polyorder=polyorder, + deriv=deriv, + delta=delta, + axis=axis, + mode=mode, + cval=cval, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/SAVGOL_FILTER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..175101c634 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/docstring.txt @@ -0,0 +1,75 @@ + +The STFT node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the Short Time Fourier Transform (STFT). + + STFTs can be used as a way of quantifying the change of a nonstationary signal's frequency and phase content over time. + +Parameters +---------- +select_return : This function has returns multiple objects []'f', 't', 'Zxx']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Time series of measurement values +fs : float, optional + Sampling frequency of the 'x' time series. Defaults to 1.0. +window : str or tuple or array_like, optional + Desired window to use. If 'window' is a string or tuple, it is + passed to 'get_window' to generate the window values, which are + DFT-even by default. See 'get_window' for a list of windows and + required parameters. If 'window' is array_like it will be used + directly as the window and its length must be nperseg. Defaults + to a Hann window. +nperseg : int, optional + Length of each segment. Defaults to 256. +noverlap : int, optional + Number of points to overlap between segments. If 'None', + noverlap = nperseg // 2. Defaults to 'None'. When + specified, the COLA constraint must be met (see Notes below). +nfft : int, optional + Length of the FFT used, if a zero padded FFT is desired. If + 'None', the FFT length is 'nperseg'. Defaults to 'None'. +detrend : str or function or 'False', optional + Specifies how to detrend each segment. If 'detrend' is a + string, it is passed as the 'type' argument to the 'detrend' + function. If it is a function, it takes a segment and returns a + detrended segment. If 'detrend' is 'False', no detrending is + done. Defaults to 'False'. +return_onesided : bool, optional + If 'True', return a one-sided spectrum for real data. + If 'False' return a two-sided spectrum. Defaults to 'True', but for + complex data, a two-sided spectrum is always returned. +boundary : str or None, optional + Specifies whether the input signal is extended at both ends, and + how to generate the new values, in order to center the first + windowed segment on the first input point. This has the benefit + of enabling reconstruction of the first input point when the + employed window function starts at zero. Valid options are + ['even', 'odd', 'constant', 'zeros', None]. Defaults to + 'zeros', for zero padding extension. I.e. [1, 2, 3, 4] is + extended to [0, 1, 2, 3, 4, 0] for nperseg=3. +padded : bool, optional + Specifies whether the input signal is zero-padded at the end to + make the signal fit exactly into an integer number of window + segments, so that all of the signal is included in the output. + Defaults to 'True'. Padding occurs after boundary extension, if + 'boundary' is not 'None', and 'padded' is 'True', as is the + default. +axis : int, optional + Axis along which the STFT is computed; the default is over the + last axis (i.e. axis=-1). +scaling: {'spectrum', 'psd'} + The default 'spectrum' scaling allows each frequency line of 'Zxx' to + be interpreted as a magnitude spectrum. The 'psd' option scales each + line to a power spectral density - it allows to calculate the signal's + energy by numerically integrating over abs(Zxx)**2. + +.. versionadded:: 1.9.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..aa946727f5 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/a1-[autogen]/python_code.txt @@ -0,0 +1,61 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy(node_type="default") +def STFT( + default: OrderedPair | Matrix, + fs: float = 1.0, + window: str = "hann", + nperseg: int = 2, + noverlap: int = 1, + nfft: int = 2, + detrend: bool = False, + return_onesided: bool = True, + boundary: str = "zeros", + padded: bool = True, + axis: int = -1, + scaling: str = "spectrum", + select_return: Literal["f", "t", "Zxx"] = "f", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.stft( + x=default.y, + fs=fs, + window=window, + nperseg=nperseg, + noverlap=noverlap, + nfft=nfft, + detrend=detrend, + return_onesided=return_onesided, + boundary=boundary, + padded=padded, + axis=axis, + scaling=scaling, + ) + + return_list = ["f", "t", "Zxx"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/STFT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..ed84d832ca --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/docstring.txt @@ -0,0 +1,64 @@ + +The WELCH node is based on a numpy or scipy function. + +The description of that function is as follows: + + Estimate power spectral density using Welch's method. + + Welch's method [1]_ computes an estimate of the power spectral density by dividing the data into overlapping segments, + computing a modified periodogram for each segment, and averaging the periodograms. + +Parameters +---------- +select_return : This function has returns multiple objects ['f', 'Pxx']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Time series of measurement values +fs : float, optional + Sampling frequency of the 'x' time series. Defaults to 1.0. +window : str or tuple or array_like, optional + Desired window to use. If 'window' is a string or tuple, it is + passed to 'get_window' to generate the window values, which are + DFT-even by default. See 'get_window' for a list of windows and + required parameters. If 'window' is array_like it will be used + directly as the window and its length must be nperseg. Defaults + to a Hann window. +nperseg : int, optional + Length of each segment. Defaults to None, but if window is str or + tuple, is set to 256, and if window is array_like, is set to the + length of the window. +noverlap : int, optional + Number of points to overlap between segments. If 'None', + noverlap = nperseg // 2. Defaults to 'None'. +nfft : int, optional + Length of the FFT used, if a zero padded FFT is desired. + If 'None', the FFT length is 'nperseg'. Defaults to 'None'. +detrend : str or function or 'False', optional + Specifies how to detrend each segment. If 'detrend' is a + string, it is passed as the 'type' argument to the 'detrend' + function. If it is a function, it takes a segment and returns a + detrended segment. If 'detrend' is 'False', no detrending is + done. Defaults to 'constant'. +return_onesided : bool, optional + If 'True', return a one-sided spectrum for real data. If + 'False' return a two-sided spectrum. Defaults to 'True', but for + complex data, a two-sided spectrum is always returned. +scaling : { 'density', 'spectrum' }, optional + Selects between computing the power spectral density ('density') + where 'Pxx' has units of V**2/Hz and computing the power + spectrum ('spectrum') where 'Pxx' has units of V**2, if 'x' + is measured in V and 'fs' is measured in Hz. Defaults to + 'density' +axis : int, optional + Axis along which the periodogram is computed; the default is + over the last axis (i.e. axis=-1). +average : { 'mean', 'median' }, optional + Method to use when averaging periodograms. Defaults to 'mean'. + +.. versionadded:: 1.2.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..6ed0e3cdc0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/a1-[autogen]/python_code.txt @@ -0,0 +1,59 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.signal + + +@flojoy(node_type="default") +def WELCH( + default: OrderedPair | Matrix, + fs: float = 1.0, + window: str = "hann", + nperseg: int = 2, + noverlap: int = 1, + nfft: int = 2, + detrend: str = "constant", + return_onesided: bool = True, + scaling: str = "density", + axis: int = -1, + average: str = "mean", + select_return: Literal["f", "Pxx"] = "f", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.signal.welch( + x=default.y, + fs=fs, + window=window, + nperseg=nperseg, + noverlap=noverlap, + nfft=nfft, + detrend=detrend, + return_onesided=return_onesided, + scaling=scaling, + axis=axis, + average=average, + ) + + return_list = ["f", "Pxx"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/SIGNAL/WELCH/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..30b5287888 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/docstring.txt @@ -0,0 +1,26 @@ + +The ANDERSON node is based on a numpy or scipy function. + +The description of that function is as follows: + + Anderson-Darling test for data coming from a particular distribution. + + The Anderson-Darling test tests the null hypothesis that a sample is drawn from a population that follows a particular distribution. + For the Anderson-Darling test, the critical values depend on which distribution is being tested against. + This function works for normal, exponential, logistic, or Gumbel (Extreme Value Type I) distributions. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'critical_values', 'significance_level']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Array of sample data. +dist : {'norm', 'expon', 'logistic', 'gumbel', 'gumbel_l', 'gumbel_r', 'extreme1'}, optional + The type of distribution to test against. The default is 'norm'. + The names 'extreme1', 'gumbel_l' and 'gumbel' are synonyms for the same distribution. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..1214038aba --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/a1-[autogen]/python_code.txt @@ -0,0 +1,43 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def ANDERSON( + default: OrderedPair | Matrix, + dist: str = "norm", + select_return: Literal[ + "statistic", "critical_values", "significance_level" + ] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.anderson( + x=default.y, + dist=dist, + ) + + return_list = ["statistic", "critical_values", "significance_level"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ANDERSON/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..5b9781a43c --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/docstring.txt @@ -0,0 +1,19 @@ + +The BAYES_MVS node is based on a numpy or scipy function. + +The description of that function is as follows: + + Bayesian confidence intervals for the mean, var, and std. + +Parameters +---------- +data : array_like + Input data, if multi-dimensional it is flattened to 1-D by 'bayes_mvs'. + Requires 2 or more data points. +alpha : float, optional + Probability that the returned confidence interval contains the true parameter. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..74f4ed1d0e --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/a1-[autogen]/python_code.txt @@ -0,0 +1,24 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def BAYES_MVS( + default: OrderedPair | Matrix, + alpha: float = 0.9, +) -> OrderedPair | Matrix | Scalar: + + + result = OrderedPair( + x=default.x, + y=scipy.stats.bayes_mvs( + data=default.y, + alpha=alpha, + ), + ) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BAYES_MVS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..4554d20079 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/docstring.txt @@ -0,0 +1,30 @@ + +The BINOM_TEST node is based on a numpy or scipy function. + +The description of that function is as follows: + + Perform a test that the probability of success is p. + +Note: 'binom_test' is deprecated; it is recommended that 'binomtest' be used instead. + + This is an exact, two-sided test of the null hypothesis that the probability of success in a Bernoulli experiment is 'p'. + +Parameters +---------- +x : int or array_like + The number of successes, or if x has length 2, it is the + number of successes and the number of failures. +n : int + The number of trials. This is ignored if x gives both the + number of successes and failures. +p : float, optional + The hypothesized probability of success. 0 <= p <= 1. + The default value is p = 0.5. +alternative : {'two-sided', 'greater', 'less'}, optional + Indicates the alternative hypothesis. + The default value is 'two-sided'. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..1f72699c36 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def BINOM_TEST( + default: OrderedPair | Matrix, + n: int = 2, + p: float = 0.5, + alternative: str = "two-sided", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.binom_test( + x=default.y, + n=n, + p=p, + alternative=alternative, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/BINOM_TEST/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..faab7876d5 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/docstring.txt @@ -0,0 +1,32 @@ + +The DESCRIBE node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute several descriptive statistics of the passed array. + +Parameters +---------- +select_return : This function has returns multiple objects ['nobs', 'mean', 'variance', 'skewness', 'kurtosis']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array_like + Input data. +axis : int or None, optional + Axis along which statistics are calculated. Default is 0. + If None, compute over the whole array 'a'. +ddof : int, optional + Delta degrees of freedom (only for variance). Default is 1. +bias : bool, optional + If False, then the skewness and kurtosis calculations are corrected for statistical bias. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate': returns nan + 'raise': throws an error + 'omit': performs the calculations ignoring nan values + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..08aa841886 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/a1-[autogen]/python_code.txt @@ -0,0 +1,47 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def DESCRIBE( + default: OrderedPair | Matrix, + axis: int = 0, + ddof: int = 1, + bias: bool = True, + nan_policy: str = "propagate", + select_return: Literal["nobs", "mean", "variance", "skewness", "kurtosis"] = "nobs", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.describe( + a=default.y, + axis=axis, + ddof=ddof, + bias=bias, + nan_policy=nan_policy, + ) + + return_list = ["nobs", "mean", "variance", "skewness", "kurtosis"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/DESCRIBE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e8a45472af --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/docstring.txt @@ -0,0 +1,32 @@ + +The GSTD node is based on a numpy or scipy function. + +The description of that function is as follows: + + Calculate the geometric standard deviation of an array. + + The geometric standard deviation describes the spread of a set of numbers where the geometric mean is preferred. + It is a multiplicative factor, and so a dimensionless quantity. + + It is defined as the exponent of the standard deviation of log(a). + + Mathematically the population geometric standard deviation can be evaluated as:: + + gstd = exp(std(log(a))) + +.. versionadded:: 1.3.0 + +Parameters +---------- +a : array_like + An array like object containing the sample data. +axis : int, tuple or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +ddof : int, optional + Degree of freedom correction in the calculation of the geometric standard deviation. + Default is 1. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..9319395be0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def GSTD( + default: OrderedPair | Matrix, + axis: int = 0, + ddof: int = 1, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.gstd( + a=default.y, + axis=axis, + ddof=ddof, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GSTD/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..001d54a9e5 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/docstring.txt @@ -0,0 +1,36 @@ + +The GZSCORE node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the geometric standard score. + + Compute the geometric z score of each strictly positive value in the sample, relative to the geometric mean and standard deviation. + + Mathematically the geometric z score can be evaluated as:: + + gzscore = log(a/gmu) / log(gsigma) + + where ``gmu`` (resp. ``gsigma``) is the geometric mean (resp. standard + deviation). + +Parameters +---------- +a : array_like + Sample data. +axis : int or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +ddof : int, optional + Degrees of freedom correction in the calculation of the standard deviation. + Default is 0. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. 'propagate' returns nan, + 'raise' throws an error, 'omit' performs the calculations ignoring nan values. + Default is 'propagate'. Note that when the value is 'omit', + nans in the input also propagate to the output, but they do not affect + the geometric z scores computed for the non-nan values. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..8129c5085f --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def GZSCORE( + default: OrderedPair | Matrix, + axis: int = 0, + ddof: int = 0, + nan_policy: str = "propagate", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.gzscore( + a=default.y, + axis=axis, + ddof=ddof, + nan_policy=nan_policy, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/GZSCORE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..979d13f387 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The JARQUE_BERA node is based on a numpy or scipy function. + +The description of that function is as follows: + + Perform the Jarque-Bera goodness of fit test on sample data. + + The Jarque-Bera test tests whether the sample data has the skewness and kurtosis matching a normal distribution. + + Note that this test only works for a large enough number of data samples (>2000) as the test statistic asymptotically has a Chi-squared distribution with 2 degrees of freedom. + +Parameters +---------- +select_return : This function has returns multiple objects ['jb_value', 'p']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Observations of a random variable. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d095b76ca2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def JARQUE_BERA( + default: OrderedPair | Matrix, + select_return: Literal["jb_value", "p"] = "jb_value", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.jarque_bera( + x=default.y, + ) + + return_list = ["jb_value", "p"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/JARQUE_BERA/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..bb4c07c450 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/docstring.txt @@ -0,0 +1,45 @@ + +The KURTOSIS node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the kurtosis (Fisher or Pearson) of a dataset. + + Kurtosis is the fourth central moment divided by the square of the variance. + If Fisher's definition is used, then 3.0 is subtracted from the result to give 0.0 for a normal distribution. + + If bias is False then the kurtosis is calculated using k statistics to eliminate bias coming from biased moment estimators + + Use `kurtosistest` to see if result is close enough to normal. + +Parameters +---------- +a : array + Data for which the kurtosis is calculated. +axis : int or None, default: 0 + If an int, the axis of the input along which to compute the statistic. + The statistic of each axis-slice (e.g. row) of the input will appear in a + corresponding element of the output. + If None, the input will be raveled before computing the statistic. +fisher : bool, optional + If True, Fisher's definition is used (normal ==> 0.0). + If False, Pearson's definition is used (normal ==> 3.0). +bias : bool, optional + If False, then the calculations are corrected for statistical bias. +nan_policy : {'propagate', 'omit', 'raise'} + Defines how to handle input NaNs. + - propagate : if a NaN is present in the axis slice (e.g. row) along + which the statistic is computed, the corresponding entry of the output will be NaN. + - omit : NaNs will be omitted when performing the calculation. + If insufficient data remains in the axis slice along which the + statistic is computed, the corresponding entry of the output will be NaN. + - raise : if a NaN is present, a ValueError will be raised. +keepdims : bool, default: False + If this is set to True, the axes which are reduced are left + in the result as dimensions with size one. With this option, + the result will broadcast correctly against the input array. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..f3f6f3b099 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/a1-[autogen]/python_code.txt @@ -0,0 +1,37 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def KURTOSIS( + default: OrderedPair | Matrix, + axis: int = 0, + fisher: bool = True, + bias: bool = True, + nan_policy: str = "propagate", + keepdims: bool = False, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.kurtosis( + a=default.y, + axis=axis, + fisher=fisher, + bias=bias, + nan_policy=nan_policy, + keepdims=keepdims, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSIS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..91dd57261b --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/docstring.txt @@ -0,0 +1,38 @@ + +The KURTOSISTEST node is based on a numpy or scipy function. + +The description of that function is as follows: + + Test whether a dataset has normal kurtosis. + + This function tests the null hypothesis that the kurtosis of the population from which the sample was drawn is that of the normal distribution. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'pvalue']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array + Array of the sample data. +axis : int or None, optional + Axis along which to compute test. Default is 0. + If None, compute over the whole array 'a'. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values +alternative : {'two-sided', 'less', 'greater'}, optional + Defines the alternative hypothesis. + The following options are available (default is 'two-sided'): + 'two-sided' : the kurtosis of the distribution underlying the sample is different from that of the normal distribution + 'less' : the kurtosis of the distribution underlying the sample is less than that of the normal distribution + 'greater' : the kurtosis of the distribution underlying the sample is greater than that of the normal distribution + +.. versionadded:: 1.7.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4166ff1ba6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/a1-[autogen]/python_code.txt @@ -0,0 +1,45 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def KURTOSISTEST( + default: OrderedPair | Matrix, + axis: int = 0, + nan_policy: str = "propagate", + alternative: str = "two-sided", + select_return: Literal["statistic", "pvalue"] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.kurtosistest( + a=default.y, + axis=axis, + nan_policy=nan_policy, + alternative=alternative, + ) + + return_list = ["statistic", "pvalue"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/KURTOSISTEST/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c0b575b9e7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/docstring.txt @@ -0,0 +1,38 @@ + +The MOMENT node is based on a numpy or scipy function. + +The description of that function is as follows: + + Calculate the nth moment about the mean for a sample. + + A moment is a specific quantitative measure of the shape of a set of points. + It is often used to calculate coefficients of skewness and kurtosis due to its close relationship with them. + +Parameters +---------- +a : array_like + Input array. +moment : int or array_like of ints, optional + Order of central moment that is returned. Default is 1. +axis : int or None, default: 0 + If an int, the axis of the input along which to compute the statistic. + The statistic of each axis-slice (e.g. row) of the input will appear in a + corresponding element of the output. + If None, the input will be raveled before computing the statistic. +nan_policy : {'propagate', 'omit', 'raise'} + Defines how to handle input NaNs. + - propagate : if a NaN is present in the axis slice (e.g. row) along + which the statistic is computed, the corresponding entry of the output will be NaN. + - omit : NaNs will be omitted when performing the calculation. + If insufficient data remains in the axis slice along which the + statistic is computed, the corresponding entry of the output will be NaN. + - raise : if a NaN is present, a ValueError will be raised. +keepdims : bool, default: False + If this is set to True, the axes which are reduced are left + in the result as dimensions with size one. With this option, + the result will broadcast correctly against the input array. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..33b6fdaaf8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def MOMENT( + default: OrderedPair | Matrix, + moment: int = 1, + axis: int = 0, + nan_policy: str = "propagate", + keepdims: bool = False, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.moment( + a=default.y, + moment=moment, + axis=axis, + nan_policy=nan_policy, + keepdims=keepdims, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MOMENT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d3a7d2d4d0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/docstring.txt @@ -0,0 +1,20 @@ + +The MVSDIST node is based on a numpy or scipy function. + +The description of that function is as follows: + + 'Frozen' distributions for mean, variance, and standard deviation of data. + +Parameters +---------- +select_return : This function has returns multiple Objects ['mdist', 'vdist', 'sdist']. + Select the desired one to return. + See the respective function docs for descriptors. +data : array_like + Input array. Converted to 1-D using ravel. + Requires 2 or more data-points. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..85c65cab51 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/a1-[autogen]/python_code.txt @@ -0,0 +1,23 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def MVSDIST( + default: OrderedPair | Matrix, + select_return: Literal["mdist", "vdist", "sdist"] = "mdist", +) -> OrderedPair | Matrix | Scalar: + + + result = OrderedPair( + x=default.x, + y=scipy.stats.mvsdist( + data=default.y, + ), + ) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/MVSDIST/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..bcacd30ec3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The NORMALTEST node is based on a numpy or scipy function. + +The description of that function is as follows: + + Test whether a sample differs from a normal distribution. + + This function tests the null hypothesis that a sample comes from a normal distribution. + It is based on D'Agostino and Pearson's [1]_, [2]_ test that combines skew and kurtosis to produce an omnibus test of normality. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'pvalue']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array_like + The array containing the sample to be tested. +axis : int or None, optional + Axis along which to compute test. Default is 0. + If None, compute over the whole array 'a'. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ec439c6c43 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/a1-[autogen]/python_code.txt @@ -0,0 +1,43 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def NORMALTEST( + default: OrderedPair | Matrix, + axis: int = 0, + nan_policy: str = "propagate", + select_return: Literal["statistic", "pvalue"] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.normaltest( + a=default.y, + axis=axis, + nan_policy=nan_policy, + ) + + return_list = ["statistic", "pvalue"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/NORMALTEST/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..b77ffae5bc --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/docstring.txt @@ -0,0 +1,30 @@ + +The SEM node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute standard error of the mean. + + Calculate the standard error of the mean (or standard error of measurement) of the values in the input array. + +Parameters +---------- +a : array_like + An array containing the values for which the standard error is returned. +axis : int or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +ddof : int, optional + Delta degrees-of-freedom. How many degrees of freedom to adjust + for bias in limited samples relative to the population estimate of variance. + Defaults to 1. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..0f9e0be433 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def SEM( + default: OrderedPair | Matrix, + axis: int = 0, + ddof: int = 1, + nan_policy: str = "propagate", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.sem( + a=default.y, + axis=axis, + ddof=ddof, + nan_policy=nan_policy, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SEM/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d13d35cb19 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/docstring.txt @@ -0,0 +1,21 @@ + +The SHAPIRO node is based on a numpy or scipy function. + +The description of that function is as follows: + + Perform the Shapiro-Wilk test for normality. + + The Shapiro-Wilk test tests the null hypothesis that the data was drawn from a normal distribution. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'p-value']. + Select the desired one to return. + See the respective function docs for descriptors. +x : array_like + Array of sample data. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..04068fae84 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def SHAPIRO( + default: OrderedPair | Matrix, + select_return: Literal["statistic", "p-value"] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.shapiro( + x=default.y, + ) + + return_list = ["statistic", "p-value"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SHAPIRO/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d0c117e3b8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The SIGMACLIP node is based on a numpy or scipy function. + +The description of that function is as follows: + + Perform iterative sigma-clipping of array elements. + + Starting from the full sample, all elements outside the critical range are removed, + i.e. all elements of the input array 'c' that satisfy either of the following conditions:: + + c < mean(c) - std(c)*low + c > mean(c) + std(c)*high + + The iteration continues with the updated sample until no elements are outside the (updated) range. + +Parameters +---------- +select_return : This function has returns multiple objects ['clipped', 'lower', 'upper']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array_like + Data array, will be raveled if not 1-D. +low : float, optional + Lower bound factor of sigma clipping. Default is 4. +high : float, optional + Upper bound factor of sigma clipping. Default is 4. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..dbe9db8032 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/a1-[autogen]/python_code.txt @@ -0,0 +1,43 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def SIGMACLIP( + default: OrderedPair | Matrix, + low: float = 4.0, + high: float = 4.0, + select_return: Literal["clipped", "lower", "upper"] = "clipped", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.sigmaclip( + a=default.y, + low=low, + high=high, + ) + + return_list = ["clipped", "lower", "upper"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SIGMACLIP/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..51f99edc8e --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/docstring.txt @@ -0,0 +1,40 @@ + +The SKEW node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the sample skewness of a data set. + + For normally distributed data, the skewness should be about zero. + For unimodal continuous distributions, a skewness value greater than zero means that there is more weight in the right tail of the distribution. \ + The function 'skewtest' can be used to determine if the skewness value is close enough to zero, statistically speaking. + +Parameters +---------- +a : ndarray + Input array. +axis : int or None, default: 0 + If an int, the axis of the input along which to compute the statistic. + The statistic of each axis-slice (e.g. row) of the input will appear in a + corresponding element of the output. + If None, the input will be raveled before computing the statistic. +bias : bool, optional + If False, then the calculations are corrected for statistical bias. +nan_policy : {'propagate', 'omit', 'raise'} + Defines how to handle input NaNs. + - propagate : if a NaN is present in the axis slice (e.g. row) along + which the statistic is computed, the corresponding entry of the output + will be NaN. + - omit : NaNs will be omitted when performing the calculation. + If insufficient data remains in the axis slice along which the + statistic is computed, the corresponding entry of the output will be NaN. + - raise : if a NaN is present, a ValueError will be raised. +keepdims : bool, default: False + If this is set to True, the axes which are reduced are left + in the result as dimensions with size one. With this option, + the result will broadcast correctly against the input array. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..dffae74355 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def SKEW( + default: OrderedPair | Matrix, + axis: int = 0, + bias: bool = True, + nan_policy: str = "propagate", + keepdims: bool = False, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.skew( + a=default.y, + axis=axis, + bias=bias, + nan_policy=nan_policy, + keepdims=keepdims, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEW/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1697375b24 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/docstring.txt @@ -0,0 +1,41 @@ + +The SKEWTEST node is based on a numpy or scipy function. + +The description of that function is as follows: + + Test whether the skew is different from the normal distribution. + + This function tests the null hypothesis that the skewness of the population that the sample was drawn from is the same as that of a corresponding normal distribution. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'pvalue']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array + The data to be tested. +axis : int or None, optional + Axis along which statistics are calculated. Default is 0. + If None, compute over the whole array `a`. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values +alternative : {'two-sided', 'less', 'greater'}, optional + Defines the alternative hypothesis. Default is 'two-sided'. + The following options are available: + 'two-sided' : the skewness of the distribution underlying the sample + is different from that of the normal distribution (i.e. 0) + 'less' : the skewness of the distribution underlying the sample + is less than that of the normal distribution + 'greater' : the skewness of the distribution underlying the sample + is greater than that of the normal distribution + +.. versionadded:: 1.7.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..468284f09d --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/a1-[autogen]/python_code.txt @@ -0,0 +1,45 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def SKEWTEST( + default: OrderedPair | Matrix, + axis: int = 0, + nan_policy: str = "propagate", + alternative: str = "two-sided", + select_return: Literal["statistic", "pvalue"] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.skewtest( + a=default.y, + axis=axis, + nan_policy=nan_policy, + alternative=alternative, + ) + + return_list = ["statistic", "pvalue"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/SKEWTEST/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..800705386d --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/docstring.txt @@ -0,0 +1,32 @@ + +The TMAX node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the trimmed maximum. + + This function computes the maximum value of an array along a given axis, while ignoring values larger than a specified upper limit. + +Parameters +---------- +a : array_like + Array of values. +upperlimit : None or float, optional + Values in the input array greater than the given limit will be ignored. + When upperlimit is None, then all values are used. The default value is None. +axis : int or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +inclusive : {True, False}, optional + This flag determines whether values exactly equal to the upper limit are included. + The default value is True. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..89afee2fbd --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TMAX( + default: OrderedPair | Matrix, + upperlimit: float = 0.1, + axis: int = 0, + inclusive: bool = True, + nan_policy: str = "propagate", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.tmax( + a=default.y, + upperlimit=upperlimit, + axis=axis, + inclusive=inclusive, + nan_policy=nan_policy, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMAX/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..aaeda4015a --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/docstring.txt @@ -0,0 +1,32 @@ + +The TMIN node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the trimmed minimum. + + This function finds the miminum value of an array 'a' along the specified axis, but only considering values greater than a specified lower limit. + +Parameters +---------- +a : array_like + Array of values. +lowerlimit : None or float, optional + Values in the input array less than the given limit will be ignored. + When lowerlimit is None, then all values are used. The default value is None. +axis : int or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +inclusive : {True, False}, optional + This flag determines whether values exactly equal to the lower limit are included. + The default value is True. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..f284f419e5 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TMIN( + default: OrderedPair | Matrix, + lowerlimit: float = 0.1, + axis: int = 0, + inclusive: bool = True, + nan_policy: str = "propagate", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.tmin( + a=default.y, + lowerlimit=lowerlimit, + axis=axis, + inclusive=inclusive, + nan_policy=nan_policy, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TMIN/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..813478529a --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/docstring.txt @@ -0,0 +1,26 @@ + +The TRIM1 node is based on a numpy or scipy function. + +The description of that function is as follows: + + Slice off a proportion from ONE end of the passed array distribution. + + If 'proportiontocut' = 0.1, slices off 'leftmost' or 'rightmost' 10% of scores. + The lowest or highest values are trimmed (depending on the tail). + Slice off less if proportion results in a non-integer slice index (i.e. conservatively slices off 'proportiontocut'). + +Parameters +---------- +a : array_like + Input array. +proportiontocut : float + Fraction to cut off of 'left' or 'right' of distribution. +tail : {'left', 'right'}, optional + Defaults to 'right'. +axis : int or None, optional + Axis along which to trim data. Default is 0. If None, compute over the whole array 'a'. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..be35b1b52d --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TRIM1( + default: OrderedPair | Matrix, + proportiontocut: float = 0.1, + tail: str = "right", + axis: int = 0, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.trim1( + a=default.y, + proportiontocut=proportiontocut, + tail=tail, + axis=axis, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM1/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..efcc2ada8d --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The TRIMBOTH node is based on a numpy or scipy function. + +The description of that function is as follows: + + Slice off a proportion of items from both ends of an array. + + Slice off the passed proportion of items from both ends of the passed array + (i.e., with 'proportiontocut' = 0.1, slices leftmost 10% and rightmost 10% of scores). + The trimmed values are the lowest and highest ones. + Slice off less if proportion results in a non-integer slice index (i.e. conservatively slices off 'proportiontocut'). + +Parameters +---------- +a : array_like + Data to trim. +proportiontocut : float + Proportion (in range 0-1) of total data set to trim of each end. +axis : int or None, optional + Axis along which to trim data. Default is 0. If None, compute over the whole array 'a'. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..9e153b2daa --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TRIMBOTH( + default: OrderedPair | Matrix, + proportiontocut: float = 0.1, + axis: int = 0, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.trimboth( + a=default.y, + proportiontocut=proportiontocut, + axis=axis, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIMBOTH/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..29777b0504 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The TRIM_MEAN node is based on a numpy or scipy function. + +The description of that function is as follows: + + Return mean of array after trimming distribution from both tails. + + If `proportiontocut` = 0.1, slices off 'leftmost' and 'rightmost' 10% of scores. + The input is sorted before slicing. + Slices off less if proportion results in a non-integer slice index (i.e. conservatively slices off 'proportiontocut'). + +Parameters +---------- +a : array_like + Input array. +proportiontocut : float + Fraction to cut off of both tails of the distribution. +axis : int or None, optional + Axis along which the trimmed means are computed. Default is 0. + If None, compute over the whole array `a`. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..34393f34ce --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TRIM_MEAN( + default: OrderedPair | Matrix, + proportiontocut: float = 0.1, + axis: int = 0, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.trim_mean( + a=default.y, + proportiontocut=proportiontocut, + axis=axis, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TRIM_MEAN/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..630d5e45d4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/docstring.txt @@ -0,0 +1,43 @@ + +The TTEST_1SAMP node is based on a numpy or scipy function. + +The description of that function is as follows: + + Calculate the T-test for the mean of ONE group of scores. + + This is a test for the null hypothesis that the expected value (mean) of a sample of independent observations 'a' is equal to the given population mean, 'popmean'. + +Parameters +---------- +select_return : This function has returns multiple objects ['statistic', 'pvalue']. + Select the desired one to return. + See the respective function docs for descriptors. +a : array_like + Sample observation. +popmean : float or array_like + Expected value in null hypothesis. + If array_like, then it must have the same shape as 'a' excluding the axis dimension. +axis : int or None, optional + Axis along which to compute test; default is 0. If None, compute over the whole array 'a'. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. + The following options are available (default is 'propagate'): + 'propagate' : returns nan + 'raise' : throws an error + 'omit' : performs the calculations ignoring nan values +alternative : {'two-sided', 'less', 'greater'}, optional + Defines the alternative hypothesis. + The following options are available (default is 'two-sided'): + 'two-sided' : the mean of the underlying distribution of the sample + is different than the given population mean (`popmean`) + 'less' : the mean of the underlying distribution of the sample is + less than the given population mean (`popmean`) + 'greater' : the mean of the underlying distribution of the sample is + greater than the given population mean (`popmean`) + +.. versionadded:: 1.6.0 + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a8de56e52c --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/a1-[autogen]/python_code.txt @@ -0,0 +1,47 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def TTEST_1SAMP( + default: OrderedPair | Matrix, + popmean: float = 0.1, + axis: int = 0, + nan_policy: str = "propagate", + alternative: str = "two-sided", + select_return: Literal["statistic", "pvalue"] = "statistic", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.ttest_1samp( + a=default.y, + popmean=popmean, + axis=axis, + nan_policy=nan_policy, + alternative=alternative, + ) + + return_list = ["statistic", "pvalue"] + if isinstance(result, tuple): + res_dict = {} + num = min(len(result), len(return_list)) + for i in range(num): + res_dict[return_list[i]] = result[i] + result = res_dict[select_return] + else: + result = result._asdict() + result = result[select_return] + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/TTEST_1SAMP/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..62855db655 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/docstring.txt @@ -0,0 +1,51 @@ + +The VARIATION node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the coefficient of variation. + + The coefficient of variation is the standard deviation divided by the mean. + + This function is equivalent to:: + + np.std(x, axis=axis, ddof=ddof) / np.mean(x) + + The default for "ddof" is 0, but many definitions of the coefficient of variation + use the square root of the unbiased sample variance for the sample standard deviation, which corresponds to "ddof=1". + + The function does not take the absolute value of the mean of the data, so the return value is negative if the mean is negative. + +Parameters +---------- +a : array_like + Input array. +axis : int or None, optional + Axis along which to calculate the coefficient of variation. + Default is 0. If None, compute over the whole array 'a'. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains 'nan'. + The following options are available: + 'propagate' : return 'nan' + 'raise' : raise an exception + 'omit' : perform the calculation with 'nan' values omitted + The default is 'propagate'. +ddof : int, optional + Gives the "Delta Degrees Of Freedom" used when computing the + standard deviation. The divisor used in the calculation of the + standard deviation is 'N - ddof', where 'N' is the number of + elements. 'ddof' must be less than 'N'; if it isn't, the result + will be 'nan' or 'inf', depending on 'N' and the values in + the array. By default `ddof` is zero for backwards compatibility, + but it is recommended to use 'ddof=1' to ensure that the sample + standard deviation is computed as the square root of the unbiased + sample variance. +keepdims : bool, optional + If this is set to True, the axes which are reduced are left in the + result as dimensions with size one. With this option, the result + will broadcast correctly against the input array. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..79c23d4f5d --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def VARIATION( + default: OrderedPair | Matrix, + axis: int = 0, + nan_policy: str = "propagate", + ddof: int = 0, + keepdims: bool = False, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.variation( + a=default.y, + axis=axis, + nan_policy=nan_policy, + ddof=ddof, + keepdims=keepdims, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/VARIATION/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..5b90593650 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/docstring.txt @@ -0,0 +1,20 @@ + +The YEOJOHNSON node is based on a numpy or scipy function. + +The description of that function is as follows: + + Return a dataset transformed by a Yeo-Johnson power transformation. + +Parameters +---------- +x : ndarray + Input array. Should be 1-dimensional. +lmbda : float, optional + If 'lmbda' is 'None', find the lambda that maximizes the + log-likelihood function and return it as the second output argument. + Otherwise the transformation is done for the given value. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..2abc84e34e --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def YEOJOHNSON( + default: OrderedPair | Matrix, + lmbda: float = 0.1, +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.yeojohnson( + x=default.y, + lmbda=lmbda, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/YEOJOHNSON/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..20e8208ad4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/docstring.txt @@ -0,0 +1,29 @@ + +The ZSCORE node is based on a numpy or scipy function. + +The description of that function is as follows: + + Compute the z score. + + Compute the z score of each value in the sample, relative to the sample mean and standard deviation. + +Parameters +---------- +a : array_like + An array like object containing the sample data. +axis : int or None, optional + Axis along which to operate. Default is 0. If None, compute over the whole array 'a'. +ddof : int, optional + Degrees of freedom correction in the calculation of the standard deviation. + Default is 0. +nan_policy : {'propagate', 'raise', 'omit'}, optional + Defines how to handle when input contains nan. 'propagate' returns nan, + 'raise' throws an error, 'omit' performs the calculations ignoring nan + values. Default is 'propagate'. Note that when the value is 'omit', + nans in the input also propagate to the output, but they do not affect + the z-scores computed for the non-nan values. + +Returns +------- +DataContainer + type 'ordered pair', 'scalar', or 'matrix' diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..354780f558 --- /dev/null +++ b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/a1-[autogen]/python_code.txt @@ -0,0 +1,33 @@ +from flojoy import OrderedPair, flojoy, Matrix, Scalar +import numpy as np +from collections import namedtuple +from typing import Literal + +import scipy.stats + + +@flojoy +def ZSCORE( + default: OrderedPair | Matrix, + axis: int = 0, + ddof: int = 0, + nan_policy: str = "propagate", +) -> OrderedPair | Matrix | Scalar: + + + result = scipy.stats.zscore( + a=default.y, + axis=axis, + ddof=ddof, + nan_policy=nan_policy, + ) + + if isinstance(result, np.ndarray): + result = OrderedPair(x=default.x, y=result) + else: + assert isinstance( + result, np.number | float | int + ), f"Expected np.number, float or int for result, got {type(result)}" + result = Scalar(c=float(result)) + + return result diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/hardware.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/media.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/notes.md b/docs/nodes/flojoy_nodes/SCIPY/STATS/ZSCORE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..fea97aded6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/docstring.txt @@ -0,0 +1,2 @@ + +The ABS node returns an absolute value. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..a588646acf --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/a1-[autogen]/python_code.txt @@ -0,0 +1,19 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Vector, Scalar + + +@flojoy +def ABS(default: OrderedPair | Vector | Scalar) -> OrderedPair: + + match default: + case OrderedPair(): + x = default.x + y = np.abs(default.y) + case Scalar(): + x = default.c + y = np.abs(x) + case Vector(): + x = default.v + y = np.abs(x) + + return OrderedPair(x=x, y=y) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/examples/EX1/app.txt new file mode 100644 index 0000000000..e6da45d1ea --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ABS/examples/EX1/app.txt @@ -0,0 +1,180 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-de210d16-0daa-4899-8002-a804eda33095", + "type": "default", + "data": { + "id": "LINSPACE-de210d16-0daa-4899-8002-a804eda33095", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 37.431003943946735, + "y": 197.51767594877157 + }, + "selected": false, + "positionAbsolute": { + "x": 37.431003943946735, + "y": 197.51767594877157 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ABS-ad25f309-790f-41e6-961e-66a8d31804eb", + "type": "ARITHMETIC", + "data": { + "id": "ABS-ad25f309-790f-41e6-961e-66a8d31804eb", + "label": "ABS", + "func": "ABS", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ABS/ABS.py", + "selected": false + }, + "position": { + "x": 352.8011866270941, + "y": 185.2774624714072 + }, + "selected": false, + "positionAbsolute": { + "x": 352.8011866270941, + "y": 185.2774624714072 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-cf6d079b-1d2a-4e7f-b3eb-b1eb391237a9", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-cf6d079b-1d2a-4e7f-b3eb-b1eb391237a9", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 629.9834976862775, + "y": 131.4321975964789 + }, + "selected": false, + "positionAbsolute": { + "x": 629.9834976862775, + "y": 131.4321975964789 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-de210d16-0daa-4899-8002-a804eda33095", + "sourceHandle": "default", + "target": "ABS-ad25f309-790f-41e6-961e-66a8d31804eb", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-de210d16-0daa-4899-8002-a804eda33095default-ABS-ad25f309-790f-41e6-961e-66a8d31804ebdefault" + }, + { + "source": "ABS-ad25f309-790f-41e6-961e-66a8d31804eb", + "sourceHandle": "default", + "target": "SCATTER-cf6d079b-1d2a-4e7f-b3eb-b1eb391237a9", + "targetHandle": "default", + "id": "reactflow__edge-ABS-ad25f309-790f-41e6-961e-66a8d31804ebdefault-SCATTER-cf6d079b-1d2a-4e7f-b3eb-b1eb391237a9default" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..09d2e45443 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/docstring.txt @@ -0,0 +1,6 @@ + +The ADD node adds two or more numeric arrays, matrices, dataframes, or constants element-wise. + +When a constant is added to an array or matrix, each element in the array or matrix will be increased by the constant value. + +If two arrays or matrices of different sizes are added, the output will be the size of the larger array or matrix with only the overlapping elements changed. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..2fce009812 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/a1-[autogen]/python_code.txt @@ -0,0 +1,22 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Scalar, Vector +from flojoy_nodes.TRANSFORMERS.ARITHMETIC.utils.arithmetic_utils import get_val +from functools import reduce + + +@flojoy +def ADD( + a: OrderedPair | Scalar | Vector, b: list[OrderedPair | Scalar | Vector] +) -> OrderedPair | Scalar | Vector: + + initial = get_val(a) + seq = map(lambda dc: get_val(dc), b) + y = reduce(lambda u, v: np.add(u, v), seq, initial) + + match a: + case OrderedPair(): + return OrderedPair(x=a.x, y=y) + case Vector(): + return Vector(v=y) + case Scalar(): + return Scalar(c=y) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/examples/EX1/app.txt new file mode 100644 index 0000000000..7d299bae5e --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/ADD/examples/EX1/app.txt @@ -0,0 +1,450 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "type": "default", + "data": { + "id": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -113.18243194507767, + "y": 307.97092313530635 + }, + "selected": false, + "positionAbsolute": { + "x": -113.18243194507767, + "y": 307.97092313530635 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "type": "GENERATORS", + "data": { + "id": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 219.269165823263, + "y": 69.16103189945369 + }, + "selected": false, + "positionAbsolute": { + "x": 219.269165823263, + "y": 69.16103189945369 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "type": "GENERATORS", + "data": { + "id": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "label": "SINE 1", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 220.1178069273795, + "y": 275.2083910670039 + }, + "selected": false, + "positionAbsolute": { + "x": 220.1178069273795, + "y": 275.2083910670039 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "type": "ARITHMETIC", + "data": { + "id": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 507.8308272868701, + "y": 246.49992477584135 + }, + "selected": false, + "positionAbsolute": { + "x": 507.8308272868701, + "y": 246.49992477584135 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 758.3102246338292, + "y": 195.7025958753576 + }, + "selected": false, + "positionAbsolute": { + "x": 758.3102246338292, + "y": 195.7025958753576 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "type": "GENERATORS", + "data": { + "id": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "label": "SINE 2", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 219.88007739393487, + "y": 479.77865899708195 + }, + "selected": false, + "positionAbsolute": { + "x": 219.88007739393487, + "y": 479.77865899708195 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-990ddb8d-e21a-4365-b291-67758709e0fedefault" + }, + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509default" + }, + { + "source": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "sourceHandle": "default", + "target": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "targetHandle": "b", + "id": "reactflow__edge-SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509default-ADD-6913967c-6486-478d-91ec-e9db7d795e39b" + }, + { + "source": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "sourceHandle": "default", + "target": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "targetHandle": "a", + "id": "reactflow__edge-SINE-990ddb8d-e21a-4365-b291-67758709e0fedefault-ADD-6913967c-6486-478d-91ec-e9db7d795e39a", + "selected": false + }, + { + "source": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "sourceHandle": "default", + "target": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "targetHandle": "default", + "id": "reactflow__edge-ADD-6913967c-6486-478d-91ec-e9db7d795e39default-SCATTER-60ebf12f-24b1-4b81-81a2-320252811811default" + }, + { + "source": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "sourceHandle": "default", + "target": "ADD-6913967c-6486-478d-91ec-e9db7d795e39", + "targetHandle": "b", + "id": "reactflow__edge-SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ffdefault-ADD-6913967c-6486-478d-91ec-e9db7d795e39b" + }, + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ffdefault" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..34cda30e81 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/docstring.txt @@ -0,0 +1,4 @@ + +The DIVIDE node divides two or more numeric arrays, matrices, dataframes, or constants element-wise. + +When a constant is divided into an array or matrix, each element in the array or matrix will be increased by the constant value. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4548ce8d41 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/a1-[autogen]/python_code.txt @@ -0,0 +1,22 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Scalar, Vector +from flojoy_nodes.TRANSFORMERS.ARITHMETIC.utils.arithmetic_utils import get_val +from functools import reduce + + +@flojoy +def DIVIDE( + a: OrderedPair | Scalar | Vector, b: list[OrderedPair | Scalar | Vector] +) -> OrderedPair | Scalar | Vector: + + initial = get_val(a) + seq = map(lambda dc: get_val(dc), b) + y = reduce(lambda u, v: np.divide(u, v), seq, initial) + + match a: + case OrderedPair(): + return OrderedPair(x=a.x, y=y) + case Vector(): + return Vector(v=y) + case Scalar(): + return Scalar(c=y) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/examples/EX1/app.txt new file mode 100644 index 0000000000..c72222cb01 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/examples/EX1/app.txt @@ -0,0 +1,426 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-3c8676a0-d750-4ffb-9383-744e93cdc059", + "type": "default", + "data": { + "id": "LINSPACE-3c8676a0-d750-4ffb-9383-744e93cdc059", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\LINSPACE\\LINSPACE.py", + "selected": false + }, + "position": { + "x": 686.186058301981, + "y": 132.26550508327233 + }, + "selected": false, + "positionAbsolute": { + "x": 686.186058301981, + "y": 132.26550508327233 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-8dcb087a-7351-4d5f-bc30-19a48ab35724", + "type": "default", + "data": { + "id": "LINSPACE-8dcb087a-7351-4d5f-bc30-19a48ab35724", + "label": "LINSPACE 1", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\LINSPACE\\LINSPACE.py", + "selected": false + }, + "position": { + "x": 700.6928626297193, + "y": 377.1390831557569 + }, + "selected": false, + "positionAbsolute": { + "x": 700.6928626297193, + "y": 377.1390831557569 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878", + "type": "GENERATORS", + "data": { + "id": "SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\SINE\\SINE.py", + "selected": false + }, + "position": { + "x": 998.7966016158562, + "y": 140.7987916252648 + }, + "selected": false, + "positionAbsolute": { + "x": 998.7966016158562, + "y": 140.7987916252648 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-21704aae-9020-418b-af35-0ff9aa08e52d", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-21704aae-9020-418b-af35-0ff9aa08e52d", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 1563.318632561524, + "y": 181.0872967974346 + }, + "selected": false, + "positionAbsolute": { + "x": 1563.318632561524, + "y": 181.0872967974346 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509", + "type": "ARITHMETIC", + "data": { + "id": "DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509", + "label": "DIVIDE", + "func": "DIVIDE", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/DIVIDE/DIVIDE.py", + "selected": false + }, + "position": { + "x": 1304.7042785347214, + "y": 234.5247970818711 + }, + "selected": false, + "positionAbsolute": { + "x": 1304.7042785347214, + "y": 234.5247970818711 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40", + "type": "GENERATORS", + "data": { + "id": "SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40", + "label": "SINE 1", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 1016.8834763936775, + "y": 380.8721729409148 + }, + "selected": false, + "positionAbsolute": { + "x": 1016.8834763936775, + "y": 380.8721729409148 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-3c8676a0-d750-4ffb-9383-744e93cdc059", + "sourceHandle": "default", + "target": "SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-3c8676a0-d750-4ffb-9383-744e93cdc059default-SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878default" + }, + { + "source": "SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878", + "sourceHandle": "default", + "target": "DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509", + "targetHandle": "a", + "id": "reactflow__edge-SINE-0c1b9fec-3f11-46b6-87de-4d9d4bd25878default-DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509a" + }, + { + "source": "DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509", + "sourceHandle": "default", + "target": "SCATTER-21704aae-9020-418b-af35-0ff9aa08e52d", + "targetHandle": "default", + "id": "reactflow__edge-DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509default-SCATTER-21704aae-9020-418b-af35-0ff9aa08e52ddefault" + }, + { + "source": "LINSPACE-8dcb087a-7351-4d5f-bc30-19a48ab35724", + "sourceHandle": "default", + "target": "SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-8dcb087a-7351-4d5f-bc30-19a48ab35724default-SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40default" + }, + { + "source": "SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40", + "sourceHandle": "default", + "target": "DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509", + "targetHandle": "b", + "id": "reactflow__edge-SINE-9d81de2f-d788-4df9-86b0-70a1d9bebe40default-DIVIDE-85b43aa1-996c-49f7-aaaa-c2f5dc70b509b", + "selected": false + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..63987a4e51 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/docstring.txt @@ -0,0 +1,2 @@ + +The MULTIPLY node takes two input vectors, multiplies them, and returns the result. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..db4a3e60ce --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/a1-[autogen]/python_code.txt @@ -0,0 +1,22 @@ +import numpy as np +from flojoy import OrderedPair, flojoy, Scalar, Vector +from flojoy_nodes.TRANSFORMERS.ARITHMETIC.utils.arithmetic_utils import get_val +from functools import reduce + + +@flojoy +def MULTIPLY( + a: OrderedPair | Scalar | Vector, b: list[OrderedPair | Scalar | Vector] +) -> OrderedPair | Scalar | Vector: + + initial = get_val(a) + seq = map(lambda dc: get_val(dc), b) + y = reduce(lambda u, v: np.multiply(u, v), seq, initial) + + match a: + case OrderedPair(): + return OrderedPair(x=a.x, y=y) + case Vector(): + return Vector(v=y) + case Scalar(): + return Scalar(c=y) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/examples/EX1/app.txt new file mode 100644 index 0000000000..d394bed390 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/examples/EX1/app.txt @@ -0,0 +1,337 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 130, + "height": 130, + "id": "SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15d", + "type": "GENERATORS", + "data": { + "id": "SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15d", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 1247.3407184321943, + "y": 354.64573297681466 + }, + "selected": false, + "positionAbsolute": { + "x": 1247.3407184321943, + "y": 354.64573297681466 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-9927419b-29bb-4d10-bf5a-79ea28add9a9", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-9927419b-29bb-4d10-bf5a-79ea28add9a9", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 1837.687746366354, + "y": 421.041374298705 + }, + "selected": false, + "positionAbsolute": { + "x": 1837.687746366354, + "y": 421.041374298705 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fb", + "type": "ARITHMETIC", + "data": { + "id": "MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fb", + "label": "MULTIPLY", + "func": "MULTIPLY", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/MULTIPLY/MULTIPLY.py", + "selected": false + }, + "position": { + "x": 1582.866634724288, + "y": 470.91201134788423 + }, + "selected": false, + "positionAbsolute": { + "x": 1582.866634724288, + "y": 470.91201134788423 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9c", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9c", + "label": "2.0", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "2.0" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/CONSTANT/CONSTANT.py", + "selected": false + }, + "position": { + "x": 1248.4862978844392, + "y": 624.8962996676939 + }, + "selected": false, + "positionAbsolute": { + "x": 1248.4862978844392, + "y": 624.8962996676939 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8", + "type": "default", + "data": { + "id": "LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 970.118927622176, + "y": 474.2206729930675 + }, + "selected": false, + "positionAbsolute": { + "x": 970.118927622176, + "y": 474.2206729930675 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15d", + "sourceHandle": "default", + "target": "MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fb", + "targetHandle": "a", + "id": "reactflow__edge-SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15ddefault-MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fba" + }, + { + "source": "MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fb", + "sourceHandle": "default", + "target": "SCATTER-9927419b-29bb-4d10-bf5a-79ea28add9a9", + "targetHandle": "default", + "id": "reactflow__edge-MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fbdefault-SCATTER-9927419b-29bb-4d10-bf5a-79ea28add9a9default" + }, + { + "source": "CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9c", + "sourceHandle": "default", + "target": "MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fb", + "targetHandle": "b", + "id": "reactflow__edge-CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9cdefault-MULTIPLY-cf3c6079-3f31-4c33-b280-5ab1187e33fbb" + }, + { + "source": "LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8", + "sourceHandle": "default", + "target": "SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15d", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8default-SINE-2cc933b2-9d01-45bb-96a3-a8dceee7a15ddefault" + }, + { + "source": "LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8", + "sourceHandle": "default", + "target": "CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9c", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-772fbaa3-2429-47d3-8c07-a44b0c1eb1d8default-CONSTANT-352d5c77-f4c3-4b53-93b9-bdc31d39ad9cdefault" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..da3dc3122e --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/docstring.txt @@ -0,0 +1,2 @@ + +The SUBTRACT node subtracts two input vectors and returns the result. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..62c36c22cc --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/a1-[autogen]/python_code.txt @@ -0,0 +1,22 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Scalar, Vector +from flojoy_nodes.TRANSFORMERS.ARITHMETIC.utils.arithmetic_utils import get_val +from functools import reduce + + +@flojoy +def SUBTRACT( + a: OrderedPair | Scalar | Vector, b: list[OrderedPair | Scalar | Vector] +) -> OrderedPair | Scalar | Vector: + + initial = get_val(a) + seq = map(lambda dc: get_val(dc), b) + y = reduce(lambda u, v: np.subtract(u, v), seq, initial) + + match a: + case OrderedPair(): + return OrderedPair(x=a.x, y=y) + case Vector(): + return Vector(v=y) + case Scalar(): + return Scalar(c=y) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/examples/EX1/app.txt new file mode 100644 index 0000000000..52fb7218e3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/examples/EX1/app.txt @@ -0,0 +1,449 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "type": "default", + "data": { + "id": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -113.18243194507767, + "y": 307.97092313530635 + }, + "selected": false, + "positionAbsolute": { + "x": -113.18243194507767, + "y": 307.97092313530635 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "type": "GENERATORS", + "data": { + "id": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 207.3780552696801, + "y": 215.30806779437336 + }, + "selected": false, + "positionAbsolute": { + "x": 207.3780552696801, + "y": 215.30806779437336 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "type": "GENERATORS", + "data": { + "id": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "label": "SINE 1", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 210.17067349467703, + "y": 428.6483420685281 + }, + "selected": false, + "positionAbsolute": { + "x": 210.17067349467703, + "y": 428.6483420685281 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 762.6377995787557, + "y": 211.35853751644567 + }, + "selected": false, + "positionAbsolute": { + "x": 762.6377995787557, + "y": 211.35853751644567 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "type": "GENERATORS", + "data": { + "id": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "label": "SINE 2", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 207.72246986507633, + "y": 12.383639474099027 + }, + "selected": false, + "positionAbsolute": { + "x": 207.72246986507633, + "y": 12.383639474099027 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "type": "ARITHMETIC", + "data": { + "id": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "label": "SUBTRACT", + "func": "SUBTRACT", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\ARITHMETIC\\SUBTRACT\\SUBTRACT.py", + "selected": false + }, + "position": { + "x": 563.4886924488495, + "y": 244.0345256336979 + }, + "selected": false, + "positionAbsolute": { + "x": 563.4886924488495, + "y": 244.0345256336979 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-990ddb8d-e21a-4365-b291-67758709e0fedefault" + }, + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509default" + }, + { + "source": "LINSPACE-5141f39e-1fea-4266-9396-4663f566a676", + "sourceHandle": "default", + "target": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-5141f39e-1fea-4266-9396-4663f566a676default-SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ffdefault" + }, + { + "source": "SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ff", + "sourceHandle": "default", + "target": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "targetHandle": "a", + "id": "reactflow__edge-SINE-70c5c7c4-e2dc-4a9f-abd1-2ce8208eb2ffdefault-SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9a" + }, + { + "source": "SINE-990ddb8d-e21a-4365-b291-67758709e0fe", + "sourceHandle": "default", + "target": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "targetHandle": "b", + "id": "reactflow__edge-SINE-990ddb8d-e21a-4365-b291-67758709e0fedefault-SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9b" + }, + { + "source": "SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509", + "sourceHandle": "default", + "target": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "targetHandle": "b", + "id": "reactflow__edge-SINE-d52400c2-b5b4-49f1-a558-d0e6dd4ab509default-SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9b" + }, + { + "source": "SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9", + "sourceHandle": "default", + "target": "SCATTER-60ebf12f-24b1-4b81-81a2-320252811811", + "targetHandle": "default", + "id": "reactflow__edge-SUBTRACT-934c8a65-1eef-469d-aa30-1cae47d732c9default-SCATTER-60ebf12f-24b1-4b81-81a2-320252811811default" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..31362e829c --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/docstring.txt @@ -0,0 +1,9 @@ + +The DIFFERENTIATE node takes two lists, x and y, as input. + +It then computes the derivative of the array, y, with respect to x. + +Returns +------- +numpy array + Derivative of the array. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ec8e23f41e --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import flojoy, OrderedPair, Vector +import numpy as np + + +@flojoy +def DIFFERENTIATE(default: OrderedPair | Vector) -> OrderedPair: + + + match default: + case OrderedPair(): + input_x = default.x + input_y = default.y + + if len(input_x) != len(input_y): + raise ValueError( + f" X and Y keys must have the same length, got x of length {len(input_x)} and y {len(input_y)}" + ) + + differentiate = np.diff(input_y) / np.diff(input_x) + + return OrderedPair(x=input_x, y=differentiate) + case Vector(): + input_x = np.arange((len(default.v) - 1)) + differentiate = np.zeros_like(input_x) + + for i in range(0, len(input_x)): + differentiate[i] = default.v[i + 1] - default.v[i] + + return OrderedPair(x=input_x, y=differentiate) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/examples/EX1/app.txt new file mode 100644 index 0000000000..00c7304f04 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/examples/EX1/app.txt @@ -0,0 +1,227 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7", + "type": "default", + "data": { + "id": "LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "100" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "100" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -138.22531635320615, + "y": 187.4310138537213 + }, + "selected": false, + "positionAbsolute": { + "x": -138.22531635320615, + "y": 187.4310138537213 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102e", + "type": "TRANSFORMERS", + "data": { + "id": "DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102e", + "label": "DIFFERENTIATE", + "func": "DIFFERENTIATE", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/CALCULUS/DIFFERENTIATE/DIFFERENTIATE.py", + "selected": false + }, + "position": { + "x": 136.80141481754697, + "y": 17.364466758721278 + }, + "selected": false, + "positionAbsolute": { + "x": 136.80141481754697, + "y": 17.364466758721278 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-400a651b-783c-464e-966b-4b80afde8479", + "type": "VISUALIZERS", + "data": { + "id": "LINE-400a651b-783c-464e-966b-4b80afde8479", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 376.0764235825058, + "y": 256.69286737092807 + }, + "selected": false, + "positionAbsolute": { + "x": 376.0764235825058, + "y": 256.69286737092807 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-61d1c07f-3488-4e60-8516-590e91a676f8", + "type": "VISUALIZERS", + "data": { + "id": "LINE-61d1c07f-3488-4e60-8516-590e91a676f8", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 374.07413670141926, + "y": -26.018778406198976 + }, + "selected": false, + "positionAbsolute": { + "x": 374.07413670141926, + "y": -26.018778406198976 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7", + "sourceHandle": "default", + "target": "DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102e", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7default-DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102edefault" + }, + { + "source": "LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7", + "sourceHandle": "default", + "target": "LINE-400a651b-783c-464e-966b-4b80afde8479", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-77558e00-711d-4b01-8f71-6e7ba5a2f8e7default-LINE-400a651b-783c-464e-966b-4b80afde8479default" + }, + { + "source": "DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102e", + "sourceHandle": "default", + "target": "LINE-61d1c07f-3488-4e60-8516-590e91a676f8", + "targetHandle": "default", + "id": "reactflow__edge-DIFFERENTIATE-9fae03db-8157-4b96-9b18-9b52084d102edefault-LINE-61d1c07f-3488-4e60-8516-590e91a676f8default" + } + ], + "viewport": { + "x": -359.3994931382954, + "y": 128.67227555309967, + "zoom": 1.0605051221303754 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..8a471ccdea --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/docstring.txt @@ -0,0 +1,25 @@ + +The DEFINITE_INTEGRAL node takes a function, upper, and lower bounds as input. It then computes double integral of the given function. + +Proper Syntax for function input example: +2*x*y + +Improper Syntax for function input example: +2xy + +Parameters +---------- +function : str + function that we are integrating +upper_bound_x : float + upper bound for x +lower_bound_x : float + lower bound for x +upper_bound_y : float + upper bound for y +lower_bound_y : float + lower bound for y + +Returns +------- +Scalar diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..92929b897d --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/a1-[autogen]/python_code.txt @@ -0,0 +1,24 @@ +from flojoy import flojoy, Scalar +from scipy import integrate +from sympy import parse_expr, lambdify + + +@flojoy(deps={"sympy": "1.12"}) +def DOUBLE_DEFINITE_INTEGRAL( + function: str = "", + upper_bound_x: float = 0.0, + lower_bound_x: float = 0.0, + upper_bound_y: float = 0.0, + lower_bound_y: float = 0.0, +) -> Scalar: + + func = parse_expr(function) + symbols = tuple(func.free_symbols) + + f = lambdify(symbols, func) + + result = integrate.nquad( + f, [(lower_bound_x, upper_bound_x), (lower_bound_y, upper_bound_y)] + )[0] + + return Scalar(c=result) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/examples/EX1/app.txt new file mode 100644 index 0000000000..c74a4651bb --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/examples/EX1/app.txt @@ -0,0 +1,397 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "DOUBLE_DEFINITE_INTEGRAL-c215aaac-b66e-4117-b317-1533b8e94265", + "type": "TRANSFORMERS", + "data": { + "id": "DOUBLE_DEFINITE_INTEGRAL-c215aaac-b66e-4117-b317-1533b8e94265", + "label": "DOUBLE DEFINITE INTEGRAL", + "func": "DOUBLE_DEFINITE_INTEGRAL", + "type": "TRANSFORMERS", + "ctrls": { + "function": { + "type": "str", + "default": "", + "functionName": "DOUBLE_DEFINITE_INTEGRAL", + "param": "function", + "value": "x*y" + }, + "upper_bound_x": { + "type": "float", + "default": 0, + "functionName": "DOUBLE_DEFINITE_INTEGRAL", + "param": "upper_bound_x", + "value": "2" + }, + "lower_bound_x": { + "type": "float", + "default": 0, + "functionName": "DOUBLE_DEFINITE_INTEGRAL", + "param": "lower_bound_x", + "value": "0" + }, + "upper_bound_y": { + "type": "float", + "default": 0, + "functionName": "DOUBLE_DEFINITE_INTEGRAL", + "param": "upper_bound_y", + "value": "1" + }, + "lower_bound_y": { + "type": "float", + "default": 0, + "functionName": "DOUBLE_DEFINITE_INTEGRAL", + "param": "lower_bound_y", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Scalar" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/CALCULUS/DOUBLE_DEFINITE_INTEGRAL/DOUBLE_DEFINITE_INTEGRAL.py", + "selected": false + }, + "position": { + "x": -50.30808138121269, + "y": 239.74834859306333 + }, + "selected": false, + "positionAbsolute": { + "x": -50.30808138121269, + "y": 239.74834859306333 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435", + "type": "GENERATORS", + "data": { + "id": "SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 62.715350578040045, + "y": -33.409951260459195 + }, + "selected": false, + "positionAbsolute": { + "x": 62.715350578040045, + "y": -33.409951260459195 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LINSPACE-22c874ba-723b-436d-b7e9-650e1c664a5e", + "type": "default", + "data": { + "id": "LINSPACE-22c874ba-723b-436d-b7e9-650e1c664a5e", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -166.7500881878306, + "y": 54.366005094108885 + }, + "selected": false, + "positionAbsolute": { + "x": -166.7500881878306, + "y": 54.366005094108885 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983", + "type": "ARITHMETIC", + "data": { + "id": "ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Scalar|Vector", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Scalar|Vector", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar|Vector" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 221.75263815270193, + "y": 181.57290825446802 + }, + "selected": false, + "positionAbsolute": { + "x": 221.75263815270193, + "y": 181.57290825446802 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-d11db416-92b7-4511-a6c2-0bcdcb8064c1", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-d11db416-92b7-4511-a6c2-0bcdcb8064c1", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 367.3817123962985, + "y": 228.24217959647746 + }, + "selected": false, + "positionAbsolute": { + "x": 367.3817123962985, + "y": 228.24217959647746 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER-b69cc4b7-5314-4bdc-a841-e546ee999921", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-b69cc4b7-5314-4bdc-a841-e546ee999921", + "label": "SCATTER 1", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 367.236414655831, + "y": -53.68983399612759 + }, + "selected": false, + "positionAbsolute": { + "x": 367.236414655831, + "y": -53.68983399612759 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-22c874ba-723b-436d-b7e9-650e1c664a5e", + "sourceHandle": "default", + "target": "SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-22c874ba-723b-436d-b7e9-650e1c664a5edefault-SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435default" + }, + { + "source": "SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435", + "sourceHandle": "default", + "target": "ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983", + "targetHandle": "a", + "id": "reactflow__edge-SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435default-ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983a" + }, + { + "source": "DOUBLE_DEFINITE_INTEGRAL-c215aaac-b66e-4117-b317-1533b8e94265", + "sourceHandle": "default", + "target": "ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983", + "targetHandle": "b", + "id": "reactflow__edge-DOUBLE_DEFINITE_INTEGRAL-c215aaac-b66e-4117-b317-1533b8e94265default-ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983b" + }, + { + "source": "SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435", + "sourceHandle": "default", + "target": "SCATTER-b69cc4b7-5314-4bdc-a841-e546ee999921", + "targetHandle": "default", + "id": "reactflow__edge-SINE-808a8ccb-a21c-4f1c-8777-69d0ffde8435default-SCATTER-b69cc4b7-5314-4bdc-a841-e546ee999921default" + }, + { + "source": "ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983", + "sourceHandle": "default", + "target": "SCATTER-d11db416-92b7-4511-a6c2-0bcdcb8064c1", + "targetHandle": "default", + "id": "reactflow__edge-ADD-a5baa9e5-24f1-4272-a9cf-3ad9efdf8983default-SCATTER-d11db416-92b7-4511-a6c2-0bcdcb8064c1default" + } + ], + "viewport": { + "x": -359.3994931382954, + "y": 128.67227555309967, + "zoom": 1.0605051221303754 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1a7327e91c --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/docstring.txt @@ -0,0 +1,18 @@ + +The DOUBLE_INDEFINITE_INTEGRAL node takes an OrderedTriple (x,y,z) and have the width and height parameter. + +The width and height represent the number of columns and rows, respectively, that the x, y, and z reshape matrices will have. Here it is important to note that the length of x, y, and z is the same and that the width times the height needs to be equal to the length of x, y, and z. + +It computes the double integral approximation according to given dimensions of the matrices, and it returns a matrix where each cell represents the volume up to the given point. + +Parameters +---------- +width : int + Number of columns of the 3 matrices generated by reshaping the x, y, and z columns of the OrderedTriple. +height : int + Number of rows of the 3 matrices generated by reshaping the x, y, and z columns of the OrderedTriple. + +Returns +------- +m: Matrix + matrix that contains the volume up to that point in each cell. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..48eb2e0b99 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/a1-[autogen]/python_code.txt @@ -0,0 +1,69 @@ +from flojoy import flojoy, OrderedTriple, Matrix +import numpy as np + + +@flojoy +def DOUBLE_INDEFINITE_INTEGRAL( + default: OrderedTriple, width: int = 3, height: int = 3 +) -> Matrix: + + + def contains_only_numbers(column): + return all(isinstance(value, (np.int_, np.float_)) for value in column) + + if np.divide(len(default.x), width) == height: + if not contains_only_numbers(default.x): + raise ValueError( + "There is some values that are not of type int or float. The OrderedTriple need to contain only int or float values." + ) + elif not contains_only_numbers(default.y): + raise ValueError( + "There is some values that are not of type int or float. The OrderedTriple need to contain only int or float values." + ) + elif not contains_only_numbers(default.z): + raise ValueError( + "There is some values that are not of type int or float. The OrderedTriple need to contain only int or float values." + ) + + input_x = np.reshape(default.x, (height, width)) + input_y = np.reshape(default.y, (height, width)) + input_z = np.reshape(default.z, (height, width)) + else: + raise ArithmeticError( + f"Cannot reshape size {len(default.x)} in a matrix of {width} by {height}. Please enter appropriate width and height." + ) + + integrate = np.zeros_like(input_x) + + for i in range(1, len(input_x)): + for j in range(1, width): + cal = ( + (input_x[i][j] - input_x[i][j - 1]) + * (input_y[i][j] - input_y[i - 1][j]) + / 4 + ) + result = cal * ( + input_z[i - 1][j - 1] + + input_z[i][j - 1] + + input_z[i - 1][j] + + input_z[i][j] + ) + integrate[i][j] = result + + result = np.copy(integrate) + + for i in range(1, len(integrate)): + for j in range(1, width): + if i == 1: + result[i][j] = result[i][j - 1] + result[i][j] + elif j == 1: + result[i][j] = result[i - 1][j] + result[i][j] + else: + result[i][j] = ( + result[i][j - 1] + + result[i - 1][j] + + result[i][j] + - result[i - 1][j - 1] + ) + + return Matrix(m=result) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/examples/EX1/app.txt new file mode 100644 index 0000000000..096268ad65 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/examples/EX1/app.txt @@ -0,0 +1,450 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 100, + "id": "R_DATASET-765242a4-5a30-430b-b93f-c5028c656c47", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-765242a4-5a30-430b-b93f-c5028c656c47", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "desc": null, + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "DNase" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/R_DATASET.py", + "selected": false + }, + "position": { + "x": -649.3917309301298, + "y": -87.83251170127132 + }, + "selected": false, + "positionAbsolute": { + "x": -649.3917309301298, + "y": -87.83251170127132 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-1e7dd8e1-ed29-4384-9b3d-f26a98ee445e", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-1e7dd8e1-ed29-4384-9b3d-f26a98ee445e", + "label": "MATRIX VIEW", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "Visualization of the input data in matrix format" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 132.6017818830103, + "y": 47.683889408180164 + }, + "selected": false, + "positionAbsolute": { + "x": 132.6017818830103, + "y": 47.683889408180164 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-1c55efb8-332b-4e75-b2b4-4c3dcc13270f", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-1c55efb8-332b-4e75-b2b4-4c3dcc13270f", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": -223.93703570099424, + "y": 56.329623054485296 + }, + "selected": false, + "positionAbsolute": { + "x": -223.93703570099424, + "y": 56.329623054485296 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SURFACE3D-ed5b8670-7142-4e9f-a310-c03971aab038", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-ed5b8670-7142-4e9f-a310-c03971aab038", + "label": "SURFACE3D", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/SURFACE3D/SURFACE3D.py", + "selected": false + }, + "position": { + "x": 25.570084175839924, + "y": -225.35029458418097 + }, + "selected": false, + "positionAbsolute": { + "x": 25.570084175839924, + "y": -225.35029458418097 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fc", + "type": "TRANSFORMERS", + "data": { + "id": "DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fc", + "label": "DOUBLE INDEFINITE INTEGRAL", + "func": "DOUBLE_INDEFINITE_INTEGRAL", + "type": "TRANSFORMERS", + "ctrls": { + "width": { + "type": "int", + "default": 3, + "desc": "Number of columns of the 3 matrices generate by reshaping the x, y and z columns of the OrderedTriple.", + "functionName": "DOUBLE_INDEFINITE_INTEGRAL", + "param": "width", + "value": "16" + }, + "height": { + "type": "int", + "default": 3, + "desc": "Number of rows of the 3 matrices generate by reshaping the x, y and z columns of the OrderedTriple.", + "functionName": "DOUBLE_INDEFINITE_INTEGRAL", + "param": "height", + "value": "11" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix", + "desc": "matrix containing in each cell the volume up to that point." + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/CALCULUS/DOUBLE_INDEFINITE_INTEGRAL/DOUBLE_INDEFINITE_INTEGRAL.py", + "selected": false + }, + "position": { + "x": -203.9669414896327, + "y": -154.5368353023664 + }, + "selected": false, + "positionAbsolute": { + "x": -203.9669414896327, + "y": -154.5368353023664 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7", + "label": "DF 2 ORDEREDTRIPLE", + "func": "DF_2_ORDEREDTRIPLE", + "type": "TRANSFORMERS", + "ctrls": { + "x": { + "type": "int", + "default": 0, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "x", + "value": "1" + }, + "y": { + "type": "int", + "default": 1, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "y", + "value": "0" + }, + "z": { + "type": "int", + "default": 2, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "z", + "value": 2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple", + "desc": null + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/DF_2_ORDEREDTRIPLE.py", + "selected": false + }, + "position": { + "x": -411.4905384836551, + "y": -120.60998425014084 + }, + "selected": false, + "positionAbsolute": { + "x": -411.4905384836551, + "y": -120.60998425014084 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "R_DATASET-765242a4-5a30-430b-b93f-c5028c656c47", + "sourceHandle": "default", + "target": "DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-765242a4-5a30-430b-b93f-c5028c656c47default-DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7default" + }, + { + "source": "DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7", + "sourceHandle": "default", + "target": "DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fc", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7default-DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fcdefault" + }, + { + "source": "DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7", + "sourceHandle": "default", + "target": "TABLE-1c55efb8-332b-4e75-b2b4-4c3dcc13270f", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-3b7e2e81-69c4-4437-bef4-b86bcbb5fac7default-TABLE-1c55efb8-332b-4e75-b2b4-4c3dcc13270fdefault" + }, + { + "source": "DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fc", + "sourceHandle": "default", + "target": "SURFACE3D-ed5b8670-7142-4e9f-a310-c03971aab038", + "targetHandle": "default", + "id": "reactflow__edge-DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fcdefault-SURFACE3D-ed5b8670-7142-4e9f-a310-c03971aab038default" + }, + { + "source": "DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fc", + "sourceHandle": "default", + "target": "MATRIX_VIEW-1e7dd8e1-ed29-4384-9b3d-f26a98ee445e", + "targetHandle": "default", + "id": "reactflow__edge-DOUBLE_INDEFINITE_INTEGRAL-6768afa8-84dd-4177-9030-3a022299e6fcdefault-MATRIX_VIEW-1e7dd8e1-ed29-4384-9b3d-f26a98ee445edefault" + } + ], + "viewport": { + "x": 722.5478564221319, + "y": 307.5775746454569, + "zoom": 1.204238868134965 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..c106ca4f4e --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/docstring.txt @@ -0,0 +1,6 @@ + +The INTEGRATE node takes two lists as input and integrates it using the composite trapezoidal rule. + +Returns +------- +OrderedPair diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..beb9cd7ae3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import flojoy, OrderedPair, Vector +import numpy as np + + +def trapz(x: np.ndarray, y: np.ndarray): + m = [0] * len(x) + trapezium = (1 / 2) * (x[1] - x[0]) * (y[1] + y[0]) + m[1] = trapezium + + for i in range(2, len(x)): + trapezium = (1 / 2) * (x[i] - x[i - 1]) * (y[i] + y[i - 1]) + m[i] = m[i - 1] + trapezium + + return m + + +@flojoy +def INTEGRATE(default: OrderedPair | Vector) -> OrderedPair: + + match default: + case OrderedPair(): + input_x = default.x + input_y = default.y + case Vector(): + input_x = np.arange(len(default.v)) + input_y = default.v + + if type(input_x) != np.ndarray: + raise ValueError(f"Invalid type for x:{type(input_x)}") + elif type(input_y) != np.ndarray: + raise ValueError(f"Invalid type for y:{type(input_y)}") + elif len(input_x) != len(input_y): + raise ValueError( + f"X and Y keys must have the same length got, x:{len(input_x)} y:{len(input_y)}" + ) + + integrate = trapz(input_x, input_y) + + return OrderedPair(x=input_x, y=integrate) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/examples/EX1/app.txt new file mode 100644 index 0000000000..b7a8abceca --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/CALCULUS/INTEGRATE/examples/EX1/app.txt @@ -0,0 +1,227 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3e", + "type": "default", + "data": { + "id": "LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3e", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "10" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "100" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 225.19244648399376, + "y": 305.39359621854413 + }, + "selected": false, + "positionAbsolute": { + "x": 225.19244648399376, + "y": 305.39359621854413 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-cd291686-3929-4601-bb11-65d38032b31f", + "type": "VISUALIZERS", + "data": { + "id": "LINE-cd291686-3929-4601-bb11-65d38032b31f", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 674.2867508703306, + "y": 115.36553971341584 + }, + "selected": false, + "positionAbsolute": { + "x": 674.2867508703306, + "y": 115.36553971341584 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-cc98b9c2-cfce-4698-810a-feeebc123bda", + "type": "VISUALIZERS", + "data": { + "id": "LINE-cc98b9c2-cfce-4698-810a-feeebc123bda", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 682.0018441392014, + "y": 389.6468524352505 + }, + "selected": false, + "positionAbsolute": { + "x": 682.0018441392014, + "y": 389.6468524352505 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330", + "type": "TRANSFORMERS", + "data": { + "id": "INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330", + "label": "INTEGRATE", + "func": "INTEGRATE", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/CALCULUS/INTEGRATE/INTEGRATE.py", + "selected": false + }, + "position": { + "x": 452.9091383060205, + "y": 175.4343276959062 + }, + "selected": false, + "positionAbsolute": { + "x": 452.9091383060205, + "y": 175.4343276959062 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3e", + "sourceHandle": "default", + "target": "INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3edefault-INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330default" + }, + { + "source": "INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330", + "sourceHandle": "default", + "target": "LINE-cd291686-3929-4601-bb11-65d38032b31f", + "targetHandle": "default", + "id": "reactflow__edge-INTEGRATE-4e2112c5-6291-4685-aca8-1cc763f7a330default-LINE-cd291686-3929-4601-bb11-65d38032b31fdefault" + }, + { + "source": "LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3e", + "sourceHandle": "default", + "target": "LINE-cc98b9c2-cfce-4698-810a-feeebc123bda", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-513ce5a5-8ad9-47cf-b0bb-aa8ac2b8ca3edefault-LINE-cc98b9c2-cfce-4698-810a-feeebc123bdadefault" + } + ], + "viewport": { + "x": -359.3994931382954, + "y": 128.67227555309967, + "zoom": 1.0605051221303754 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e9da47a2fe --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ + +The EDGE_DETECTION node detects edges in the image that was passed to it. + +This is done through the Pillow image filter, FIND_EDGES. + +Note that the image is converted to greyscale during this processing. + +Inputs +------ +default : Image + The input image to apply edge detection to. + +Returns +------- +Image + The image with detected edges in white. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..6a63a97310 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/a1-[autogen]/python_code.txt @@ -0,0 +1,39 @@ +from flojoy import flojoy, Image +import cv2 +import numpy as np +from PIL import ImageFilter, Image as PILImage + + +@flojoy +def EDGE_DETECTION(default: Image) -> Image: + + r = default.r + g = default.g + b = default.b + a = default.a + + if a is not None: + rgba_image = np.stack((r, g, b, a), axis=2) + + else: + rgba_image = np.stack((r, g, b), axis=2) + + try: + image = PILImage.fromarray(rgba_image) + image = image.convert("L").filter(ImageFilter.FIND_EDGES).convert("RGB") + image = np.array(image) + + try: + r, g, b, a = cv2.split(image) + except: + r, g, b = cv2.split(image) + if a is None: + a = None + return Image( + r=r, + g=g, + b=b, + a=a, + ) + except Exception as e: + raise e diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/examples/EX1/app.txt new file mode 100644 index 0000000000..9733399779 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/examples/EX1/app.txt @@ -0,0 +1,237 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20c", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20c", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 258.31915756512785, + "y": 470.3026842082849 + }, + "selected": false, + "positionAbsolute": { + "x": 258.31915756512785, + "y": 470.3026842082849 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9ba", + "type": "TRANSFORMERS", + "data": { + "id": "EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9ba", + "label": "EDGE DETECTION", + "func": "EDGE_DETECTION", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/IMAGE_PROCESSING/EDGE_DETECTION/EDGE_DETECTION.py", + "selected": false + }, + "position": { + "x": 665.9863029617956, + "y": 369.65546594267767 + }, + "selected": false, + "positionAbsolute": { + "x": 665.9863029617956, + "y": 369.65546594267767 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-285335dd-85c9-48b9-88f6-2a3dd5680804", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-285335dd-85c9-48b9-88f6-2a3dd5680804", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 982.4493275304173, + "y": 311.74746706708333 + }, + "selected": false, + "positionAbsolute": { + "x": 982.4493275304173, + "y": 311.74746706708333 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-6cd5c97a-781e-4c8f-a926-e7d295cfa402", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-6cd5c97a-781e-4c8f-a926-e7d295cfa402", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 618.2655382685319, + "y": 643.2133248042691 + }, + "selected": false, + "positionAbsolute": { + "x": 618.2655382685319, + "y": 643.2133248042691 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20c", + "sourceHandle": "default", + "target": "EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9ba", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20cdefault-EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9badefault" + }, + { + "source": "EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9ba", + "sourceHandle": "default", + "target": "IMAGE-285335dd-85c9-48b9-88f6-2a3dd5680804", + "targetHandle": "default", + "id": "reactflow__edge-EDGE_DETECTION-1f01cece-bbff-47d7-b217-5b311f88d9badefault-IMAGE-285335dd-85c9-48b9-88f6-2a3dd5680804default" + }, + { + "source": "LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20c", + "sourceHandle": "default", + "target": "IMAGE-6cd5c97a-781e-4c8f-a926-e7d295cfa402", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-745d91c9-0bcf-4ab4-a265-210f2506f20cdefault-IMAGE-6cd5c97a-781e-4c8f-a926-e7d295cfa402default" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..6654bfd6cf --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The IMAGE_SMOOTHING node applies an image smoothing operation on the input DataContainer class, specifically for the 'image' type, represented by the RGB(A) channels. + +Note: For "gaussian" and "median" type, you are only allowed an odd number for the kernel value. + +See https://docs.opencv.org/4.x/d4/d13/tutorial_py_filtering.html for smoothing function information. + +Inputs +------ +default : Image + The input image to apply smoothing to. + +Parameters +---------- +kernel : int + The strength of the smoothing (larger = stronger smoothing). +smoothing_type : select + The type of smoothing function to use. + +Returns +------- +Image + The smoothed image. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..f3ef5fe7cf --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/a1-[autogen]/python_code.txt @@ -0,0 +1,50 @@ +from flojoy import flojoy, Image +import cv2 +import numpy as np +from typing import Literal + + +@flojoy +def IMAGE_SMOOTHING( + default: Image, + kernel: int = 5, + smoothing_type: Literal["average", "gaussian", "median", "bilateral"] = "average", +) -> Image: + + r = default.r + g = default.g + b = default.b + a = default.a + + if a is not None: + rgba_image = np.stack((r, g, b, a), axis=2) + else: + rgba_image = np.stack((r, g, b), axis=2) + + try: + match smoothing_type: + case "average": + image = cv2.blur(rgba_image, (kernel, kernel)) + case "gaussian": + assert kernel & 1, "Kernel must be odd for 'gaussian' smoothing." + image = cv2.GaussianBlur(rgba_image, (kernel, kernel), 0) + case "median": + assert kernel & 1, "Kernel must be odd for 'median' smoothing." + image = cv2.medianBlur(rgba_image, kernel) + case "bilateral": + rgba_image = cv2.cvtColor(rgba_image, cv2.COLOR_BGRA2BGR) + image = cv2.bilateralFilter(rgba_image, kernel, kernel * 5, kernel * 5) + try: + r, g, b, a = cv2.split(image) + except: + r, g, b = cv2.split(image) + if a is None: + a = None + return Image( + r=r, + g=g, + b=b, + a=a, + ) + except Exception as e: + raise e diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/examples/EX1/app.txt new file mode 100644 index 0000000000..5f5b2b3085 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/examples/EX1/app.txt @@ -0,0 +1,258 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736", + "type": "TRANSFORMERS", + "data": { + "id": "IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736", + "label": "IMAGE SMOOTHING", + "func": "IMAGE_SMOOTHING", + "type": "TRANSFORMERS", + "ctrls": { + "kernel": { + "type": "int", + "default": 5, + "functionName": "IMAGE_SMOOTHING", + "param": "kernel", + "value": "8" + }, + "smoothing_type": { + "type": "select", + "default": "average", + "options": [ + "average", + "gaussian", + "median", + "bilateral" + ], + "functionName": "IMAGE_SMOOTHING", + "param": "smoothing_type", + "value": "average" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/IMAGE_PROCESSING/IMAGE_SMOOTHING/IMAGE_SMOOTHING.py", + "selected": false + }, + "position": { + "x": 727.3487305553774, + "y": 155.3525852303302 + }, + "selected": false, + "positionAbsolute": { + "x": 727.3487305553774, + "y": 155.3525852303302 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes/LOADERS/LOCAL_FILE_SYSTEM/LOCAL_FILE/LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 393.7135717819896, + "y": 278.0915860062198 + }, + "selected": false, + "positionAbsolute": { + "x": 393.7135717819896, + "y": 278.0915860062198 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-7aacbaca-2652-4c99-babe-5779ba0ce181", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-7aacbaca-2652-4c99-babe-5779ba0ce181", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1045.9840067988252, + "y": 152.56873926010599 + }, + "selected": false, + "positionAbsolute": { + "x": 1045.9840067988252, + "y": 152.56873926010599 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-0b7bb803-8dba-43eb-a9bf-4073b3fda94c", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-0b7bb803-8dba-43eb-a9bf-4073b3fda94c", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 662.8988425018024, + "y": 513.5775685841171 + }, + "selected": false, + "positionAbsolute": { + "x": 662.8988425018024, + "y": 513.5775685841171 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497", + "sourceHandle": "default", + "target": "IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497default-IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736default" + }, + { + "source": "IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736", + "sourceHandle": "default", + "target": "IMAGE-7aacbaca-2652-4c99-babe-5779ba0ce181", + "targetHandle": "default", + "id": "reactflow__edge-IMAGE_SMOOTHING-271ab3fc-7780-4b0d-a394-9d6935b20736default-IMAGE-7aacbaca-2652-4c99-babe-5779ba0ce181default" + }, + { + "source": "LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497", + "sourceHandle": "default", + "target": "IMAGE-0b7bb803-8dba-43eb-a9bf-4073b3fda94c", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-e185ad0f-12d9-47ee-ab02-28b06f85f497default-IMAGE-0b7bb803-8dba-43eb-a9bf-4073b3fda94cdefault" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..09e44ef13d --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/docstring.txt @@ -0,0 +1,4 @@ + +The INVERT node takes two inputs, one matrix and one rcond if not a square matrix, then inverts them (or pseudo invert) and returns the result. + +If the entered value is a scalar, it returns the multiplciative inverse 1/x. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..7fd2b4a8fd --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/a1-[autogen]/python_code.txt @@ -0,0 +1,31 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, Matrix + + +@flojoy +def INVERT(default: OrderedPair | Matrix, rcond: float = 1.0) -> OrderedPair | Matrix: + + print(f"INVERT params: {rcond}") + a = np.eye(3) + b: float = rcond + + if isinstance( + default, OrderedPair + ): # v[0] is a DataContainer object with type attribute + print("Performing simple inversion") + a = default.y # scalar valued + return OrderedPair(x=a, y=1 / a) + elif isinstance(default, Matrix): + a = default.m + if not a.shape[0] == a.shape[1]: + print("Not square matrix! Using pseudoinversion...") + assert ( + type(b) == float + ), "Need scalar value to compare SVDs for pseudoinversion" + retval = np.linalg.pinv(a, rcond=b, hermitian=False) + else: + try: + retval = np.linalg.inv(a) + except np.linalg.LinAlgError: + raise ValueError("Inversion failed! Singular matrix returned...") + return Matrix(m=retval) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/examples/EX1/app.txt new file mode 100644 index 0000000000..05068d9ee1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/examples/EX1/app.txt @@ -0,0 +1,335 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 130, + "height": 130, + "id": "MATRIX-6406eff9-325a-4857-856c-3815dc85b99f", + "type": "GENERATORS", + "data": { + "id": "MATRIX-6406eff9-325a-4857-856c-3815dc85b99f", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": 2 + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": 2 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/MATRIX/MATRIX.py", + "selected": false + }, + "position": { + "x": 310.5159995449301, + "y": 302.5754010876069 + }, + "selected": false, + "positionAbsolute": { + "x": 310.5159995449301, + "y": 302.5754010876069 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-2dd75395-9aa9-49c3-94a7-8e1376a6922c", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-2dd75395-9aa9-49c3-94a7-8e1376a6922c", + "label": "MATRIX VIEW", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 722.5743320369709, + "y": 85.31019401546718 + }, + "selected": false, + "positionAbsolute": { + "x": 722.5743320369709, + "y": 85.31019401546718 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "INVERT-bc37a258-fb80-4bc9-a205-2cd02345375c", + "type": "TRANSFORMERS", + "data": { + "id": "INVERT-bc37a258-fb80-4bc9-a205-2cd02345375c", + "label": "INVERT", + "func": "INVERT", + "type": "TRANSFORMERS", + "ctrls": { + "rcond": { + "type": "float", + "default": 1, + "functionName": "INVERT", + "param": "rcond", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/MATRIX_MANIPULATION/INVERT/INVERT.py", + "selected": false + }, + "position": { + "x": 437.7534323407856, + "y": 511.7005381900798 + }, + "selected": false, + "positionAbsolute": { + "x": 437.7534323407856, + "y": 511.7005381900798 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-e0662088-8688-4898-9967-b09f5194a447", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-e0662088-8688-4898-9967-b09f5194a447", + "label": "MATRIX VIEW 1", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 729.2152576951142, + "y": 590.3244534059053 + }, + "selected": false, + "positionAbsolute": { + "x": 729.2152576951142, + "y": 590.3244534059053 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770", + "type": "TRANSFORMERS", + "data": { + "id": "MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770", + "label": "MATMUL", + "func": "MATMUL", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "Matrix", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/MATMUL.py", + "selected": false + }, + "position": { + "x": 757.9506051118608, + "y": 377.3701818036126 + }, + "selected": false, + "positionAbsolute": { + "x": 757.9506051118608, + "y": 377.3701818036126 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-3fa65156-275b-46b1-a831-386267350ee7", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-3fa65156-275b-46b1-a831-386267350ee7", + "label": "MATRIX VIEW 2", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 1115.7707907576478, + "y": 336.90228677672815 + }, + "selected": false, + "positionAbsolute": { + "x": 1115.7707907576478, + "y": 336.90228677672815 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "MATRIX-6406eff9-325a-4857-856c-3815dc85b99f", + "sourceHandle": "default", + "target": "MATRIX_VIEW-2dd75395-9aa9-49c3-94a7-8e1376a6922c", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-6406eff9-325a-4857-856c-3815dc85b99fdefault-MATRIX_VIEW-2dd75395-9aa9-49c3-94a7-8e1376a6922cdefault" + }, + { + "source": "MATRIX-6406eff9-325a-4857-856c-3815dc85b99f", + "sourceHandle": "default", + "target": "INVERT-bc37a258-fb80-4bc9-a205-2cd02345375c", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-6406eff9-325a-4857-856c-3815dc85b99fdefault-INVERT-bc37a258-fb80-4bc9-a205-2cd02345375cdefault" + }, + { + "source": "INVERT-bc37a258-fb80-4bc9-a205-2cd02345375c", + "sourceHandle": "default", + "target": "MATRIX_VIEW-e0662088-8688-4898-9967-b09f5194a447", + "targetHandle": "default", + "id": "reactflow__edge-INVERT-bc37a258-fb80-4bc9-a205-2cd02345375cdefault-MATRIX_VIEW-e0662088-8688-4898-9967-b09f5194a447default" + }, + { + "source": "MATRIX-6406eff9-325a-4857-856c-3815dc85b99f", + "sourceHandle": "default", + "target": "MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770", + "targetHandle": "a", + "id": "reactflow__edge-MATRIX-6406eff9-325a-4857-856c-3815dc85b99fdefault-MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770a" + }, + { + "source": "INVERT-bc37a258-fb80-4bc9-a205-2cd02345375c", + "sourceHandle": "default", + "target": "MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770", + "targetHandle": "b", + "id": "reactflow__edge-INVERT-bc37a258-fb80-4bc9-a205-2cd02345375cdefault-MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770b" + }, + { + "source": "MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770", + "sourceHandle": "default", + "target": "MATRIX_VIEW-3fa65156-275b-46b1-a831-386267350ee7", + "targetHandle": "default", + "id": "reactflow__edge-MATMUL-f2b3e25b-f613-4454-b941-cc8e93496770default-MATRIX_VIEW-3fa65156-275b-46b1-a831-386267350ee7default" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..6f0fafc557 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/docstring.txt @@ -0,0 +1,2 @@ + +The MATMUL node takes two input matrices, multiplies them, and returns the result. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..c4589539b4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/a1-[autogen]/python_code.txt @@ -0,0 +1,8 @@ +import numpy as np +from flojoy import flojoy, Matrix + + +@flojoy +def MATMUL(a: Matrix, b: Matrix) -> Matrix: + + return Matrix(m=np.matmul(a.m, b.m)) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/examples/EX1/app.txt new file mode 100644 index 0000000000..f3e6c5deb7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/examples/EX1/app.txt @@ -0,0 +1,327 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 130, + "height": 130, + "id": "MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbe", + "type": "GENERATORS", + "data": { + "id": "MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbe", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": 2 + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": 2 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/MATRIX/MATRIX.py", + "selected": false + }, + "position": { + "x": 237.01195912384392, + "y": 362.48176698138155 + }, + "selected": false, + "positionAbsolute": { + "x": 237.01195912384392, + "y": 362.48176698138155 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66", + "type": "GENERATORS", + "data": { + "id": "MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66", + "label": "MATRIX 1", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": 2 + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": 2 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/MATRIX/MATRIX.py", + "selected": false + }, + "position": { + "x": 236.02277015172265, + "y": 579.6972875067837 + }, + "selected": false, + "positionAbsolute": { + "x": 236.02277015172265, + "y": 579.6972875067837 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60a", + "type": "TRANSFORMERS", + "data": { + "id": "MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60a", + "label": "MATMUL", + "func": "MATMUL", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "Matrix", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/MATRIX_MANIPULATION/MATMUL/MATMUL.py", + "selected": false + }, + "position": { + "x": 606.9375812570322, + "y": 460.5957544609891 + }, + "selected": false, + "positionAbsolute": { + "x": 606.9375812570322, + "y": 460.5957544609891 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-4839a447-fd78-4c23-87c9-de5259c26472", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-4839a447-fd78-4c23-87c9-de5259c26472", + "label": "MATRIX VIEW 2", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 925.4496113422621, + "y": 421.68726003568577 + }, + "selected": false, + "positionAbsolute": { + "x": 925.4496113422621, + "y": 421.68726003568577 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-b76ba08c-ba34-481c-bd26-74db60851d49", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-b76ba08c-ba34-481c-bd26-74db60851d49", + "label": "MATRIX VIEW 1", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 580.9634328673749, + "y": 709.2645715943966 + }, + "selected": false, + "positionAbsolute": { + "x": 580.9634328673749, + "y": 709.2645715943966 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "MATRIX_VIEW-fa80c51a-9545-4e71-9122-62d441c6698d", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-fa80c51a-9545-4e71-9122-62d441c6698d", + "label": "MATRIX VIEW 2", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 576.9711475268383, + "y": 188.12192642321594 + }, + "selected": false, + "positionAbsolute": { + "x": 576.9711475268383, + "y": 188.12192642321594 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbe", + "sourceHandle": "default", + "target": "MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60a", + "targetHandle": "a", + "id": "reactflow__edge-MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbedefault-MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60aa" + }, + { + "source": "MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66", + "sourceHandle": "default", + "target": "MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60a", + "targetHandle": "b", + "id": "reactflow__edge-MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66default-MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60ab" + }, + { + "source": "MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60a", + "sourceHandle": "default", + "target": "MATRIX_VIEW-4839a447-fd78-4c23-87c9-de5259c26472", + "targetHandle": "default", + "id": "reactflow__edge-MATMUL-38d30041-5f6f-4bb6-b50b-3bbddc32d60adefault-MATRIX_VIEW-4839a447-fd78-4c23-87c9-de5259c26472default" + }, + { + "source": "MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbe", + "sourceHandle": "default", + "target": "MATRIX_VIEW-fa80c51a-9545-4e71-9122-62d441c6698d", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-633000ac-6a8c-4597-a77f-a5b009c84dbedefault-MATRIX_VIEW-fa80c51a-9545-4e71-9122-62d441c6698ddefault" + }, + { + "source": "MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66", + "sourceHandle": "default", + "target": "MATRIX_VIEW-b76ba08c-ba34-481c-bd26-74db60851d49", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-c0889eba-3ebb-4218-ac0e-65bda9c17c66default-MATRIX_VIEW-b76ba08c-ba34-481c-bd26-74db60851d49default" + } + ], + "viewport": { + "x": 0, + "y": 0, + "zoom": 1 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3597562bc6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/docstring.txt @@ -0,0 +1,27 @@ + +The BUTTER node applies a butterworth filter to an input signal. + +It is designed to have a frequency response that is as flat as possible in the pass band. + +Inputs +------ +default : OrderedPair + The data to apply the butter filter to. + +Parameters +---------- +filter_order : int + The intensity of the filter. +critical_frequency : int + The frequency where the filter takes effect. For lowpass and highpass, it takes a scalar. + For bandpass and bandstop, it takes an array with the length of 2. +btype : select + The type of the filter. +sample_rate : int + The sample rate of the input signal. + +Returns +------- +OrderedPair + x: time domain + y: filtered signal diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..03273ff40d --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/a1-[autogen]/python_code.txt @@ -0,0 +1,25 @@ +from scipy import signal +from flojoy import flojoy, OrderedPair +from typing import Literal, Union + + +@flojoy +def BUTTER( + default: OrderedPair, + filter_order: int = 1, + critical_frequency: int = 1, + btype: Literal["lowpass", "highpass", "bandpass", "bandstop"] = "lowpass", + sample_rate: int = 10, +) -> OrderedPair: + + sig = default.y + order: int = filter_order + wn: int = critical_frequency # hz + btype: str = btype + fs: int = sample_rate # hz + + sos = signal.butter(N=order, Wn=wn, btype=btype, fs=fs, output="sos") + # sos = signal.butter(10, 15, "hp", fs=1000, output="sos") + filtered = signal.sosfilt(sos, sig) + + return OrderedPair(x=default.x, y=filtered) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/examples/EX1/app.txt new file mode 100644 index 0000000000..5ef0b79aed --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/examples/EX1/app.txt @@ -0,0 +1,486 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "50" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": 10 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sawtooth" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 183.32334515456031, + "y": 241.30303574593756 + }, + "selected": false, + "positionAbsolute": { + "x": 183.32334515456031, + "y": 241.30303574593756 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bf", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bf", + "label": "FFT", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "50" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 719.0985280702616, + "y": 254.0429925314706 + }, + "selected": false, + "positionAbsolute": { + "x": 719.0985280702616, + "y": 254.0429925314706 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470", + "type": "TRANSFORMERS", + "data": { + "id": "BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470", + "label": "BUTTER", + "func": "BUTTER", + "type": "TRANSFORMERS", + "ctrls": { + "filter_order": { + "type": "int", + "default": 1, + "functionName": "BUTTER", + "param": "filter_order", + "value": "4" + }, + "critical_frequency": { + "type": "int", + "default": 1, + "functionName": "BUTTER", + "param": "critical_frequency", + "value": "5" + }, + "btype": { + "type": "select", + "default": "lowpass", + "options": [ + "lowpass", + "highpass", + "bandpass", + "bandstop" + ], + "functionName": "BUTTER", + "param": "btype", + "value": "lowpass" + }, + "sample_rate": { + "type": "int", + "default": 10, + "functionName": "BUTTER", + "param": "sample_rate", + "value": "50" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/BUTTER/BUTTER.py", + "selected": false + }, + "position": { + "x": 750.75024925327, + "y": 509.81865407098604 + }, + "selected": false, + "positionAbsolute": { + "x": 750.75024925327, + "y": 509.81865407098604 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-da75bb73-a829-499f-a419-50ee2aeed4dd", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-da75bb73-a829-499f-a419-50ee2aeed4dd", + "label": "FFT 1", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "50" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 1203.404564755418, + "y": 516.4662341336772 + }, + "selected": false, + "positionAbsolute": { + "x": 1203.404564755418, + "y": 516.4662341336772 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-c662104c-36e6-4b54-8f5f-ff7588218c5b", + "type": "VISUALIZERS", + "data": { + "id": "LINE-c662104c-36e6-4b54-8f5f-ff7588218c5b", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1105.5800368344026, + "y": 209.24902538338802 + }, + "selected": false, + "positionAbsolute": { + "x": 1105.5800368344026, + "y": 209.24902538338802 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-1615d876-d703-4009-970b-a157b5d7af5f", + "type": "VISUALIZERS", + "data": { + "id": "LINE-1615d876-d703-4009-970b-a157b5d7af5f", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1579.3044664455963, + "y": 473.9320198431452 + }, + "selected": false, + "positionAbsolute": { + "x": 1579.3044664455963, + "y": 473.9320198431452 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308", + "sourceHandle": "default", + "target": "FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bf", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308default-FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bfdefault" + }, + { + "source": "BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308", + "sourceHandle": "default", + "target": "BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-86eaccb5-f23a-4a4b-9494-df9271ed3308default-BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470default" + }, + { + "source": "BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470", + "sourceHandle": "default", + "target": "FFT-da75bb73-a829-499f-a419-50ee2aeed4dd", + "targetHandle": "default", + "id": "reactflow__edge-BUTTER-b2ffdf87-8ec3-42d1-973d-56d705301470default-FFT-da75bb73-a829-499f-a419-50ee2aeed4dddefault" + }, + { + "source": "FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bf", + "sourceHandle": "default", + "target": "LINE-c662104c-36e6-4b54-8f5f-ff7588218c5b", + "targetHandle": "default", + "id": "reactflow__edge-FFT-e97ea8b8-ce90-4c6a-aa27-ee0e5f82c9bfdefault-LINE-c662104c-36e6-4b54-8f5f-ff7588218c5bdefault" + }, + { + "source": "FFT-da75bb73-a829-499f-a419-50ee2aeed4dd", + "sourceHandle": "default", + "target": "LINE-1615d876-d703-4009-970b-a157b5d7af5f", + "targetHandle": "default", + "id": "reactflow__edge-FFT-da75bb73-a829-499f-a419-50ee2aeed4dddefault-LINE-1615d876-d703-4009-970b-a157b5d7af5fdefault" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..ed0c96feff --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The FFT node performs a Discrete Fourier Transform on the input vector. + +Through the FFT algorithm, the input vector will be transformed from a time domain into a frequency domain, which will be an ordered pair of arrays. + +Inputs +------ +default : OrderedPair + The data to apply FFT to. + +Parameters +---------- +window : select + the node will apply a window to the signal to avoid spectral leakage +real_signal : boolean + whether the input signal is real or complex +sample_rate : int + the sample rate of the signal, defaults to 1 +display : boolean + whether the output would be graphed, set to false for pure data and true for data that is more suitable to be graphed + +Returns +------- +OrderedPair if display is true + x: frequency + y: spectrum of the signal +DataFrame if display is false + time: time domain + frequency: frequency domain + real: real section of the signal + imag: imaginary section of the signal diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..5f5e19dddb --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/a1-[autogen]/python_code.txt @@ -0,0 +1,67 @@ +from scipy import signal, fft +from numpy import abs +from flojoy import flojoy, OrderedPair, DataFrame +from typing import Literal +from pandas import DataFrame as df + + +@flojoy +def FFT( + default: OrderedPair, + window: Literal[ + "none", + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos", + ] = "hann", + real_signal: bool = True, + sample_rate: int = 1, + display: bool = True, +) -> OrderedPair | DataFrame: + + if sample_rate <= 0: + raise ValueError(f"Sample rate must be greater than 0") + + signal_value = default.y + x = default.x + sample_spacing = 1.0 / sample_rate + # x-axis + frequency = ( + fft.rfftfreq(x.shape[-1], sample_spacing) + if real_signal and display + else fft.fftfreq(x.shape[-1], sample_spacing) + ) + frequency = fft.fftshift(frequency) + if display: + # y-axis + if window == "none": + fourier = fft.rfft(signal_value) if real_signal else fft.fft(signal_value) + else: + window = signal.get_window(window, len(signal_value)) + fourier = ( + fft.rfft(signal_value * window) + if real_signal + else fft.fft(signal_value * window) + ) + fourier = fft.fftshift(fourier) + fourier = abs(fourier) + return OrderedPair(x=frequency, y=fourier) + + # for processing + fourier = fft.fft(signal_value) + d = {"x": x, "frequency": frequency, "real": fourier.real, "imag": fourier.imag} + return DataFrame(df=df(data=d)) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/examples/EX1/app.txt new file mode 100644 index 0000000000..ed2a727dda --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/examples/EX1/app.txt @@ -0,0 +1,466 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94", + "type": "default", + "data": { + "id": "LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "0.75" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "600" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 131.05060402280617, + "y": 332.2195561169542 + }, + "selected": false, + "positionAbsolute": { + "x": 131.05060402280617, + "y": 332.2195561169542 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2f", + "type": "GENERATORS", + "data": { + "id": "SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2f", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": "30" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 465.8729517979642, + "y": 232.73063756313297 + }, + "selected": false, + "positionAbsolute": { + "x": 465.8729517979642, + "y": 232.73063756313297 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-15e699fe-e9e0-452d-9206-8313c657c051", + "type": "GENERATORS", + "data": { + "id": "SINE-15e699fe-e9e0-452d-9206-8313c657c051", + "label": "SINE 1", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": "0.5" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": "100" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 454.5791450829271, + "y": 488.5731369693229 + }, + "selected": false, + "positionAbsolute": { + "x": 454.5791450829271, + "y": 488.5731369693229 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-26b8771f-d073-4ee8-8bec-a69e4a23079d", + "type": "ARITHMETIC", + "data": { + "id": "ADD-26b8771f-d073-4ee8-8bec-a69e4a23079d", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 761.2995555587786, + "y": 342.6431492716158 + }, + "selected": false, + "positionAbsolute": { + "x": 761.2995555587786, + "y": 342.6431492716158 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-ae307ae3-517d-4103-a787-02fe288d2e97", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-ae307ae3-517d-4103-a787-02fe288d2e97", + "label": "FFT", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "800" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 1077.8159311850482, + "y": 333.47740435186597 + }, + "selected": false, + "positionAbsolute": { + "x": 1077.8159311850482, + "y": 333.47740435186597 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-2bb3fc2d-9616-4d6f-957d-b3321530afa0", + "type": "VISUALIZERS", + "data": { + "id": "LINE-2bb3fc2d-9616-4d6f-957d-b3321530afa0", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1525.429172539708, + "y": 297.1407554549438 + }, + "selected": false, + "positionAbsolute": { + "x": 1525.429172539708, + "y": 297.1407554549438 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94", + "sourceHandle": "default", + "target": "SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2f", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94default-SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2fdefault" + }, + { + "source": "LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94", + "sourceHandle": "default", + "target": "SINE-15e699fe-e9e0-452d-9206-8313c657c051", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-1fae0391-9694-4e08-9762-99e1d533df94default-SINE-15e699fe-e9e0-452d-9206-8313c657c051default" + }, + { + "source": "SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2f", + "sourceHandle": "default", + "target": "ADD-26b8771f-d073-4ee8-8bec-a69e4a23079d", + "targetHandle": "a", + "id": "reactflow__edge-SINE-684e15cc-d2f7-4d09-83a2-fdddd6cefd2fdefault-ADD-26b8771f-d073-4ee8-8bec-a69e4a23079da" + }, + { + "source": "SINE-15e699fe-e9e0-452d-9206-8313c657c051", + "sourceHandle": "default", + "target": "ADD-26b8771f-d073-4ee8-8bec-a69e4a23079d", + "targetHandle": "b", + "id": "reactflow__edge-SINE-15e699fe-e9e0-452d-9206-8313c657c051default-ADD-26b8771f-d073-4ee8-8bec-a69e4a23079db" + }, + { + "source": "ADD-26b8771f-d073-4ee8-8bec-a69e4a23079d", + "sourceHandle": "default", + "target": "FFT-ae307ae3-517d-4103-a787-02fe288d2e97", + "targetHandle": "default", + "id": "reactflow__edge-ADD-26b8771f-d073-4ee8-8bec-a69e4a23079ddefault-FFT-ae307ae3-517d-4103-a787-02fe288d2e97default" + }, + { + "source": "FFT-ae307ae3-517d-4103-a787-02fe288d2e97", + "sourceHandle": "default", + "target": "LINE-2bb3fc2d-9616-4d6f-957d-b3321530afa0", + "targetHandle": "default", + "id": "reactflow__edge-FFT-ae307ae3-517d-4103-a787-02fe288d2e97default-LINE-2bb3fc2d-9616-4d6f-957d-b3321530afa0default" + } + ], + "viewport": { + "x": -370.442494324109, + "y": 122.55885385221723, + "zoom": 1.093090475044996 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..cfe1534731 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The FIR node applies a low-pass FIR filter to an input vector. The filter is designed with the window method. + +This filter takes a few inputs: +the sample_rate (will be passed as a parameter if the target node is not connected), the window type of the filter, the cutoff frequency, and the number of taps (or length) of the filter. + +Inputs +------ +default : OrderedPair + The data to apply a FIR filter to. + +Parameters +---------- +sample_rate : int + the amount of samples within a second +filter_type : select + how the filter behaves +window : select + the window function used in the FIR +cutoff_low : float + the frequency cutoff to filter out the lower frequencies +cutoff_high : float + the frequency cutoff to filter out the upper frequencies +taps : int + the length of the filter + +Returns +------- +OrderedPair + x: time domain + y: filtered signal diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..24c7cb3fca --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/a1-[autogen]/python_code.txt @@ -0,0 +1,80 @@ +from scipy import signal +from flojoy import flojoy, OrderedPair +from typing import Literal, Union + + +@flojoy +def FIR( + default: OrderedPair, + sample_rate: int = 100, + filter_type: Literal["lowpass", "highpass", "bandpass", "bandstop"] = "lowpass", + window: Literal[ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos", + ] = "hann", + cutoff_low: float = 10.0, + cutoff_high: float = 15.0, + taps: int = 200, +) -> OrderedPair: + + + sample_rate: int = sample_rate # Hz + filter_type: str = filter_type + window_type: str = window + cutoff_low: float = cutoff_low + cutoff_high: float = cutoff_high + n_taps: int = taps + times = default.x + input_signal = default.y + + if input_signal.size < n_taps * 3: + raise ValueError("length of the data should be three times longer than taps") + elif ( + n_taps % 2 == 0 + ): # in the case where the passband contains the Nyquist frequency + n_taps = n_taps + 1 + + # create the filter with the parameter inputs + if filter_type == "bandpass" or filter_type == "bandstop": + fil = signal.firwin( + numtaps=n_taps, + cutoff=[cutoff_low, cutoff_high], + fs=sample_rate, + pass_zero=filter_type, + window=window_type, + ) + elif filter_type == "lowpass": + fil = signal.firwin( + numtaps=n_taps, + cutoff=cutoff_high, + fs=sample_rate, + pass_zero=filter_type, + window=window_type, + ) + else: + fil = signal.firwin( + numtaps=n_taps, + cutoff=cutoff_low, + fs=sample_rate, + pass_zero=filter_type, + window=window_type, + ) + + # ... and then apply it to the signal + filtered_x = signal.filtfilt(fil, 1.0, input_signal) + return OrderedPair(x=times, y=filtered_x) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/examples/EX1/app.txt new file mode 100644 index 0000000000..b78a7cb215 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/examples/EX1/app.txt @@ -0,0 +1,1093 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0", + "type": "TRANSFORMERS", + "data": { + "id": "FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0", + "label": "FIR", + "func": "FIR", + "type": "TRANSFORMERS", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "FIR", + "param": "sample_rate", + "value": 100 + }, + "filter_type": { + "type": "select", + "default": "lowpass", + "options": [ + "lowpass", + "highpass", + "bandpass", + "bandstop" + ], + "functionName": "FIR", + "param": "filter_type", + "value": "bandpass" + }, + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FIR", + "param": "window", + "value": "hann" + }, + "cutoff_low": { + "type": "float", + "default": 10, + "functionName": "FIR", + "param": "cutoff_low", + "value": "23" + }, + "cutoff_high": { + "type": "float", + "default": 15, + "functionName": "FIR", + "param": "cutoff_high", + "value": "28" + }, + "taps": { + "type": "int", + "default": 200, + "functionName": "FIR", + "param": "taps", + "value": "80" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FIR/FIR.py", + "selected": false + }, + "position": { + "x": 1938.1824901272164, + "y": 297.20473379383174 + }, + "selected": false, + "positionAbsolute": { + "x": 1938.1824901272164, + "y": 297.20473379383174 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-acfbd611-3f27-40a4-bcc2-c49038ba2477", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-acfbd611-3f27-40a4-bcc2-c49038ba2477", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "4" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": "1.5" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "10" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": "0" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 842.6639837331884, + "y": -84.3923028932698 + }, + "selected": false, + "positionAbsolute": { + "x": 842.6639837331884, + "y": -84.3923028932698 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-be81c3b6-2c92-4257-8e5f-e69494b12204", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-be81c3b6-2c92-4257-8e5f-e69494b12204", + "label": "BASIC OSCILLATOR 1", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "4" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": "0.75" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "15" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 847.7654130041697, + "y": 136.9928622548827 + }, + "selected": false, + "positionAbsolute": { + "x": 847.7654130041697, + "y": 136.9928622548827 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-2b6574aa-a040-42e4-bdd6-c25a39dec6a1", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-2b6574aa-a040-42e4-bdd6-c25a39dec6a1", + "label": "BASIC OSCILLATOR 2", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "4" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": "0.25" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "20" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 855.1658398776597, + "y": 362.5039574339801 + }, + "selected": false, + "positionAbsolute": { + "x": 855.1658398776597, + "y": 362.5039574339801 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394", + "label": "BASIC OSCILLATOR 3", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "4" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "25" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 854.6802389067954, + "y": 582.4180799509707 + }, + "selected": false, + "positionAbsolute": { + "x": 854.6802389067954, + "y": 582.4180799509707 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-69fc5929-55da-4773-a4d5-b68c5b2d5c28", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-69fc5929-55da-4773-a4d5-b68c5b2d5c28", + "label": "BASIC OSCILLATOR 4", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "4" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": "0.5" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "35" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": "0" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 853.4307544948048, + "y": 816.5773092632212 + }, + "selected": false, + "positionAbsolute": { + "x": 853.4307544948048, + "y": 816.5773092632212 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "type": "ARITHMETIC", + "data": { + "id": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 1364.5282788608436, + "y": 332.3035634513908 + }, + "selected": false, + "positionAbsolute": { + "x": 1364.5282788608436, + "y": 332.3035634513908 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2", + "label": "FFT 1", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "100" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 1522.19219759742, + "y": 7.6843161498964605 + }, + "selected": false, + "positionAbsolute": { + "x": 1522.19219759742, + "y": 7.6843161498964605 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-a220559c-365a-4562-aee4-10461c688970", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-a220559c-365a-4562-aee4-10461c688970", + "label": "FFT 2", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "100" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 2320.275684711439, + "y": 46.99311307504968 + }, + "selected": false, + "positionAbsolute": { + "x": 2320.275684711439, + "y": 46.99311307504968 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-26ea5c67-c2cc-4329-8e31-67da38886cfa", + "type": "VISUALIZERS", + "data": { + "id": "LINE-26ea5c67-c2cc-4329-8e31-67da38886cfa", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1843.654960686323, + "y": -76.74492641649647 + }, + "selected": false, + "positionAbsolute": { + "x": 1843.654960686323, + "y": -76.74492641649647 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-c3f1781a-b6e6-4657-9898-c88b3432f0f3", + "type": "VISUALIZERS", + "data": { + "id": "LINE-c3f1781a-b6e6-4657-9898-c88b3432f0f3", + "label": "LINE 2", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 2627.5572734025673, + "y": -52.79182985887951 + }, + "selected": false, + "positionAbsolute": { + "x": 2627.5572734025673, + "y": -52.79182985887951 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-7367f167-c5f4-4a30-a554-0ba37c959ebd", + "type": "VISUALIZERS", + "data": { + "id": "LINE-7367f167-c5f4-4a30-a554-0ba37c959ebd", + "label": "LINE 3", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 2462.153489755023, + "y": 464.27782152861425 + }, + "selected": false, + "positionAbsolute": { + "x": 2462.153489755023, + "y": 464.27782152861425 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-9b2bacf0-8051-4dc2-939c-fbe7c2639b08", + "type": "VISUALIZERS", + "data": { + "id": "LINE-9b2bacf0-8051-4dc2-939c-fbe7c2639b08", + "label": "LINE 3", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1261.5322724358994, + "y": 672.6646158797179 + }, + "selected": false, + "positionAbsolute": { + "x": 1261.5322724358994, + "y": 672.6646158797179 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-b545e47b-fb97-427e-8f00-5c2a5e08ba39", + "type": "VISUALIZERS", + "data": { + "id": "LINE-b545e47b-fb97-427e-8f00-5c2a5e08ba39", + "label": "LINE 4", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1668.5761784876431, + "y": 485.4874360913959 + }, + "selected": false, + "positionAbsolute": { + "x": 1668.5761784876431, + "y": 485.4874360913959 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "BASIC_OSCILLATOR-acfbd611-3f27-40a4-bcc2-c49038ba2477", + "sourceHandle": "default", + "target": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "targetHandle": "a", + "id": "reactflow__edge-BASIC_OSCILLATOR-acfbd611-3f27-40a4-bcc2-c49038ba2477default-ADD-15b2356b-8f79-4f9b-802c-1821c0924fcea" + }, + { + "source": "BASIC_OSCILLATOR-be81c3b6-2c92-4257-8e5f-e69494b12204", + "sourceHandle": "default", + "target": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "targetHandle": "b", + "id": "reactflow__edge-BASIC_OSCILLATOR-be81c3b6-2c92-4257-8e5f-e69494b12204default-ADD-15b2356b-8f79-4f9b-802c-1821c0924fceb" + }, + { + "source": "BASIC_OSCILLATOR-2b6574aa-a040-42e4-bdd6-c25a39dec6a1", + "sourceHandle": "default", + "target": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "targetHandle": "b", + "id": "reactflow__edge-BASIC_OSCILLATOR-2b6574aa-a040-42e4-bdd6-c25a39dec6a1default-ADD-15b2356b-8f79-4f9b-802c-1821c0924fceb" + }, + { + "source": "BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394", + "sourceHandle": "default", + "target": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "targetHandle": "b", + "id": "reactflow__edge-BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394default-ADD-15b2356b-8f79-4f9b-802c-1821c0924fceb" + }, + { + "source": "BASIC_OSCILLATOR-69fc5929-55da-4773-a4d5-b68c5b2d5c28", + "sourceHandle": "default", + "target": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "targetHandle": "b", + "id": "reactflow__edge-BASIC_OSCILLATOR-69fc5929-55da-4773-a4d5-b68c5b2d5c28default-ADD-15b2356b-8f79-4f9b-802c-1821c0924fceb" + }, + { + "source": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "sourceHandle": "default", + "target": "FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0", + "targetHandle": "default", + "id": "reactflow__edge-ADD-15b2356b-8f79-4f9b-802c-1821c0924fcedefault-FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0default" + }, + { + "source": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "sourceHandle": "default", + "target": "FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2", + "targetHandle": "default", + "id": "reactflow__edge-ADD-15b2356b-8f79-4f9b-802c-1821c0924fcedefault-FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2default" + }, + { + "source": "FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0", + "sourceHandle": "default", + "target": "FFT-a220559c-365a-4562-aee4-10461c688970", + "targetHandle": "default", + "id": "reactflow__edge-FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0default-FFT-a220559c-365a-4562-aee4-10461c688970default" + }, + { + "source": "FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2", + "sourceHandle": "default", + "target": "LINE-26ea5c67-c2cc-4329-8e31-67da38886cfa", + "targetHandle": "default", + "id": "reactflow__edge-FFT-1ee5f7c7-d72f-4d75-9804-ea9f6201edf2default-LINE-26ea5c67-c2cc-4329-8e31-67da38886cfadefault" + }, + { + "source": "FFT-a220559c-365a-4562-aee4-10461c688970", + "sourceHandle": "default", + "target": "LINE-c3f1781a-b6e6-4657-9898-c88b3432f0f3", + "targetHandle": "default", + "id": "reactflow__edge-FFT-a220559c-365a-4562-aee4-10461c688970default-LINE-c3f1781a-b6e6-4657-9898-c88b3432f0f3default" + }, + { + "source": "FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0", + "sourceHandle": "default", + "target": "LINE-7367f167-c5f4-4a30-a554-0ba37c959ebd", + "targetHandle": "default", + "id": "reactflow__edge-FIR-e4741c3f-334d-4e53-8a1a-db5549123ee0default-LINE-7367f167-c5f4-4a30-a554-0ba37c959ebddefault" + }, + { + "source": "BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394", + "sourceHandle": "default", + "target": "LINE-9b2bacf0-8051-4dc2-939c-fbe7c2639b08", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-5166d8a1-b3bb-466f-b708-40e013d7a394default-LINE-9b2bacf0-8051-4dc2-939c-fbe7c2639b08default" + }, + { + "source": "ADD-15b2356b-8f79-4f9b-802c-1821c0924fce", + "sourceHandle": "default", + "target": "LINE-b545e47b-fb97-427e-8f00-5c2a5e08ba39", + "targetHandle": "default", + "id": "reactflow__edge-ADD-15b2356b-8f79-4f9b-802c-1821c0924fcedefault-LINE-b545e47b-fb97-427e-8f00-5c2a5e08ba39default" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..1faa3ecd6e --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/docstring.txt @@ -0,0 +1,20 @@ + +The IFFT node performs the Inverse Discrete Fourier Transform on the input signal. + +With the IFFT algorith, the input signal will be transformed from the frequency domain back into the time domain. + +Inputs +------ +default : OrderedPair + The data to apply inverse FFT to. + +Parameters +---------- +real_signal : boolean + whether the input signal is real (true) or complex (false) + +Returns +------- +OrderedPair + x = time + y = reconstructed signal diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..1cf360d057 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/a1-[autogen]/python_code.txt @@ -0,0 +1,19 @@ +from scipy import fft +from flojoy import flojoy, OrderedPair, DataFrame +import pandas as pd + + +@flojoy +def IFFT(default: DataFrame, real_signal: bool = True) -> OrderedPair: + + dc: pd.DataFrame = default.m + + x = dc["x"].to_numpy() + realValue = dc["real"].to_numpy() + imagValue = dc["imag"].to_numpy() + + fourier = realValue + 1j * imagValue + + result = fft.irfft(fourier) if real_signal else fft.ifft(fourier, len(x)) + result = result.real + return OrderedPair(x=x, y=result) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/examples/EX1/app.txt new file mode 100644 index 0000000000..1135651832 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/examples/EX1/app.txt @@ -0,0 +1,710 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529", + "type": "default", + "data": { + "id": "LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "0.75" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "600" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 659.2411239313864, + "y": 277.0385130388363 + }, + "selected": false, + "positionAbsolute": { + "x": 659.2411239313864, + "y": 277.0385130388363 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-12238ccc-90fc-47f9-a679-50e628d4f156", + "type": "GENERATORS", + "data": { + "id": "SINE-12238ccc-90fc-47f9-a679-50e628d4f156", + "label": "SINE", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": "50" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 966.6153929478581, + "y": 155.08348117188388 + }, + "selected": false, + "positionAbsolute": { + "x": 966.6153929478581, + "y": 155.08348117188388 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "SINE-5569968e-4541-4ce2-88ad-ab72600b2f97", + "type": "GENERATORS", + "data": { + "id": "SINE-5569968e-4541-4ce2-88ad-ab72600b2f97", + "label": "SINE 1", + "func": "SINE", + "type": "GENERATORS", + "ctrls": { + "amplitude": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "amplitude", + "value": "0.5" + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "SINE", + "param": "frequency", + "value": "80" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "SINE", + "param": "phase", + "value": 0 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "SINE", + "param": "waveform", + "value": "sine" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/SINE/SINE.py", + "selected": false + }, + "position": { + "x": 976.5177254541807, + "y": 461.56436690031467 + }, + "selected": false, + "positionAbsolute": { + "x": 976.5177254541807, + "y": 461.56436690031467 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "type": "ARITHMETIC", + "data": { + "id": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 1245.6568513725451, + "y": 268.7960720927382 + }, + "selected": false, + "positionAbsolute": { + "x": 1245.6568513725451, + "y": 268.7960720927382 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4", + "type": "TRANSFORMERS", + "data": { + "id": "IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4", + "label": "IFFT", + "func": "IFFT", + "type": "TRANSFORMERS", + "ctrls": { + "real_signal": { + "type": "bool", + "default": true, + "functionName": "IFFT", + "param": "real_signal", + "value": false + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/IFFT/IFFT.py", + "selected": false + }, + "position": { + "x": 1793.8922242783192, + "y": 259.52225362918335 + }, + "selected": false, + "positionAbsolute": { + "x": 1793.8922242783192, + "y": 259.52225362918335 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-44f7c803-706f-469a-8c6f-bab3b3dea659", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-44f7c803-706f-469a-8c6f-bab3b3dea659", + "label": "FFT", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": false + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "800" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": false + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 1464.2878556534379, + "y": 261.0235491472342 + }, + "selected": false, + "positionAbsolute": { + "x": 1464.2878556534379, + "y": 261.0235491472342 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "FFT-db612181-529c-4e66-924e-fa820d90f450", + "type": "TRANSFORMERS", + "data": { + "id": "FFT-db612181-529c-4e66-924e-fa820d90f450", + "label": "FFT 1", + "func": "FFT", + "type": "TRANSFORMERS", + "ctrls": { + "window": { + "type": "select", + "default": "hann", + "options": [ + "boxcar", + "triang", + "blackman", + "hamming", + "hann", + "bartlett", + "flattop", + "parzen", + "bohman", + "blackmanharris", + "nuttall", + "barthann", + "cosine", + "exponential", + "tukey", + "taylor", + "lanczos" + ], + "functionName": "FFT", + "param": "window", + "value": "hann" + }, + "real_signal": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "real_signal", + "value": true + }, + "sample_rate": { + "type": "int", + "default": 1, + "functionName": "FFT", + "param": "sample_rate", + "value": "800" + }, + "display": { + "type": "bool", + "default": true, + "functionName": "FFT", + "param": "display", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/FFT/FFT.py", + "selected": false + }, + "position": { + "x": 1484.7537327043515, + "y": 3.2160607945140214 + }, + "selected": false, + "positionAbsolute": { + "x": 1484.7537327043515, + "y": 3.2160607945140214 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-eff15f6c-5cae-4dc5-afcf-595347396018", + "type": "VISUALIZERS", + "data": { + "id": "LINE-eff15f6c-5cae-4dc5-afcf-595347396018", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1403.243110386921, + "y": 502.7598748760134 + }, + "selected": false, + "positionAbsolute": { + "x": 1403.243110386921, + "y": 502.7598748760134 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-e08d8338-6374-4f4d-8477-775f633ebe6d", + "type": "VISUALIZERS", + "data": { + "id": "LINE-e08d8338-6374-4f4d-8477-775f633ebe6d", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1814.1043615213298, + "y": -47.270850465781166 + }, + "selected": false, + "positionAbsolute": { + "x": 1814.1043615213298, + "y": -47.270850465781166 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-bcc4b83a-9f6e-4444-ab14-b993716503ed", + "type": "VISUALIZERS", + "data": { + "id": "LINE-bcc4b83a-9f6e-4444-ab14-b993716503ed", + "label": "LINE 2", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 2112.172067313177, + "y": 474.1261265472838 + }, + "selected": false, + "positionAbsolute": { + "x": 2112.172067313177, + "y": 474.1261265472838 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529", + "sourceHandle": "default", + "target": "SINE-12238ccc-90fc-47f9-a679-50e628d4f156", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529default-SINE-12238ccc-90fc-47f9-a679-50e628d4f156default" + }, + { + "source": "LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529", + "sourceHandle": "default", + "target": "SINE-5569968e-4541-4ce2-88ad-ab72600b2f97", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-eb9f6c8b-1208-4626-ab2c-4085ee112529default-SINE-5569968e-4541-4ce2-88ad-ab72600b2f97default" + }, + { + "source": "SINE-12238ccc-90fc-47f9-a679-50e628d4f156", + "sourceHandle": "default", + "target": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "targetHandle": "a", + "id": "reactflow__edge-SINE-12238ccc-90fc-47f9-a679-50e628d4f156default-ADD-82417b86-8493-4cdc-867b-21e962e7ad69a" + }, + { + "source": "SINE-5569968e-4541-4ce2-88ad-ab72600b2f97", + "sourceHandle": "default", + "target": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "targetHandle": "b", + "id": "reactflow__edge-SINE-5569968e-4541-4ce2-88ad-ab72600b2f97default-ADD-82417b86-8493-4cdc-867b-21e962e7ad69b" + }, + { + "source": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "sourceHandle": "default", + "target": "FFT-44f7c803-706f-469a-8c6f-bab3b3dea659", + "targetHandle": "default", + "id": "reactflow__edge-ADD-82417b86-8493-4cdc-867b-21e962e7ad69default-FFT-44f7c803-706f-469a-8c6f-bab3b3dea659default" + }, + { + "source": "FFT-44f7c803-706f-469a-8c6f-bab3b3dea659", + "sourceHandle": "default", + "target": "IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4", + "targetHandle": "default", + "id": "reactflow__edge-FFT-44f7c803-706f-469a-8c6f-bab3b3dea659default-IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4default" + }, + { + "source": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "sourceHandle": "default", + "target": "FFT-db612181-529c-4e66-924e-fa820d90f450", + "targetHandle": "default", + "id": "reactflow__edge-ADD-82417b86-8493-4cdc-867b-21e962e7ad69default-FFT-db612181-529c-4e66-924e-fa820d90f450default" + }, + { + "source": "IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4", + "sourceHandle": "default", + "target": "LINE-bcc4b83a-9f6e-4444-ab14-b993716503ed", + "targetHandle": "default", + "id": "reactflow__edge-IFFT-d72d7f91-82ce-4591-991b-fe72f96c6cb4default-LINE-bcc4b83a-9f6e-4444-ab14-b993716503eddefault" + }, + { + "source": "FFT-db612181-529c-4e66-924e-fa820d90f450", + "sourceHandle": "default", + "target": "LINE-e08d8338-6374-4f4d-8477-775f633ebe6d", + "targetHandle": "default", + "id": "reactflow__edge-FFT-db612181-529c-4e66-924e-fa820d90f450default-LINE-e08d8338-6374-4f4d-8477-775f633ebe6ddefault" + }, + { + "source": "ADD-82417b86-8493-4cdc-867b-21e962e7ad69", + "sourceHandle": "default", + "target": "LINE-eff15f6c-5cae-4dc5-afcf-595347396018", + "targetHandle": "default", + "id": "reactflow__edge-ADD-82417b86-8493-4cdc-867b-21e962e7ad69default-LINE-eff15f6c-5cae-4dc5-afcf-595347396018default" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3dd5815e68 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ +The PID node acts like a PID function. + The returned value with be modified according to the + PID parameters Kp, Ki, and Kd. + + Inputs + ------ + default : OrderedPair + The data to apply the PID function to. + + Parameters + ---------- + Kp: float + The proprotional PID parameter. + Ki: float + The integral PID parameter. + Kd: float + The derivative PID parameter. + + Returns + ------- + OrderedPair + x: The x axis equal to the input y axis. + y: The y axis which is the PID output. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..86d2f5ea5f --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/a1-[autogen]/python_code.txt @@ -0,0 +1,60 @@ +import numpy as np +from flojoy import flojoy, OrderedPair, DefaultParams, SmallMemory + +memory_key = "pid-info" + + +@flojoy(inject_node_metadata=True) +def PID( + default: OrderedPair, + default_params: DefaultParams, + Kp: float = 5, + Ki: float = 0.0143, + Kd: float = 356.25, +) -> OrderedPair: + + + # First let's get the parameters that won't change + node_id = default_params.node_id + # Now we need some memory! We need to keep track of the running + # integral value of the inputs (regulation errors), as well as + # the previous 3 values of the regulation error + data = SmallMemory().read_memory(node_id, memory_key) + if data is None: + initialize = True + elif type(data) == np.ndarray: + initialize = False + else: + raise TypeError("Issue reading memory from REDIS.") + integral: int = 0 if initialize else data[0] + regulation_error_primes = np.zeros((3, 1)) if initialize else data[1:] + print(f"Recovered data: {data}") + + regulation_error = default.y[ + -1 + ] # constant node makes long list of items; just need the value so take last element + integral: float = integral + 0.5 * Ki * ( + regulation_error + regulation_error_primes[0] + ) + output_signal = -1 * ( + Kp * regulation_error + + integral + + 0.1667 + * Kd + * ( + regulation_error + - regulation_error_primes[2] + + 3.0 * (regulation_error_primes[0] - regulation_error_primes[1]) + ) + ) + regulation_error_primes[2] = regulation_error_primes[1] + regulation_error_primes[1] = regulation_error_primes[0] + regulation_error_primes[0] = regulation_error + + # Now write to memory ... + SmallMemory().write_to_memory( + node_id, memory_key, np.append(integral, regulation_error_primes) + ) + print(regulation_error, output_signal) + # ... and return the result + return OrderedPair(x=default.y, y=np.ones_like(default.y) * output_signal) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/examples/EX1/app.txt new file mode 100644 index 0000000000..c265ce643c --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/PID/examples/EX1/app.txt @@ -0,0 +1,506 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 160, + "height": 160, + "id": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "type": "TRANSFORMERS", + "data": { + "id": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "label": "PID", + "func": "PID", + "type": "TRANSFORMERS", + "ctrls": { + "Kp": { + "type": "float", + "default": 5, + "functionName": "PID", + "param": "Kp", + "value": 5 + }, + "Ki": { + "type": "float", + "default": 0.0143, + "functionName": "PID", + "param": "Ki", + "value": 0.0143 + }, + "Kd": { + "type": "float", + "default": 356.25, + "functionName": "PID", + "param": "Kd", + "value": 356.25 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\SIGNAL_PROCESSING\\PID\\PID.py", + "selected": false + }, + "position": { + "x": 691.7222902734321, + "y": 96.72414884146878 + }, + "selected": false, + "positionAbsolute": { + "x": 691.7222902734321, + "y": 96.72414884146878 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "type": "GENERATORS", + "data": { + "id": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "label": "SECOND ORDER SYSTEM", + "func": "SECOND_ORDER_SYSTEM", + "type": "GENERATORS", + "ctrls": { + "d1": { + "type": "float", + "default": 250, + "functionName": "SECOND_ORDER_SYSTEM", + "param": "d1", + "value": 250 + }, + "d2": { + "type": "float", + "default": 100, + "functionName": "SECOND_ORDER_SYSTEM", + "param": "d2", + "value": 100 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\SECOND_ORDER_SYSTEM\\SECOND_ORDER_SYSTEM.py", + "selected": false + }, + "position": { + "x": 969.1860703098813, + "y": 130.6366203999895 + }, + "selected": false, + "positionAbsolute": { + "x": 969.1860703098813, + "y": 130.6366203999895 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "type": "GENERATORS", + "data": { + "id": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "label": "FEEDBACK", + "func": "FEEDBACK", + "type": "GENERATORS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": null, + "functionName": "FEEDBACK", + "param": "referred_node", + "value": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\FEEDBACK\\FEEDBACK.py", + "selected": false + }, + "position": { + "x": 232.12842821463732, + "y": -2.0336450690984975 + }, + "selected": false, + "positionAbsolute": { + "x": 232.12842821463732, + "y": -2.0336450690984975 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "type": "VISUALIZERS", + "data": { + "id": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 646.7443796856828, + "y": 431.78879240282043 + }, + "selected": false, + "positionAbsolute": { + "x": 646.7443796856828, + "y": 431.78879240282043 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "type": "LOADERS", + "data": { + "id": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "label": "DS LOAD", + "func": "DS_LOAD", + "type": "LOADERS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": null, + "functionName": "DS_LOAD", + "param": "referred_node", + "value": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 226.90231299211854, + "y": 460.341992432171 + }, + "selected": false, + "positionAbsolute": { + "x": 226.90231299211854, + "y": 460.341992432171 + }, + "dragging": true + }, + { + "width": 96, + "height": 96, + "id": "LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87c", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87c", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "desc": "number of times to iterate through body nodes default is `-1` meaning infinity.", + "functionName": "LOOP", + "param": "num_loops", + "value": "15" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any", + "desc": null + }, + { + "name": "end", + "id": "end", + "type": "Any", + "desc": null + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOPS\\LOOP\\LOOP.py", + "selected": false + }, + "position": { + "x": -55.67628506838092, + "y": 265.6921237098219 + }, + "selected": false, + "positionAbsolute": { + "x": -55.67628506838092, + "y": 265.6921237098219 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277db", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277db", + "label": "100", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": "100" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": 1000 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 245.52016850960797, + "y": 232.96864047833014 + }, + "selected": false, + "positionAbsolute": { + "x": 245.52016850960797, + "y": 232.96864047833014 + }, + "dragging": true + }, + { + "width": 72, + "height": 72, + "id": "SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118", + "type": "ARITHMETIC", + "data": { + "id": "SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118", + "label": "SUBTRACT", + "func": "SUBTRACT", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Scalar|Vector", + "multiple": false, + "desc": null + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Scalar|Vector", + "multiple": true, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar|Vector", + "desc": null + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\ARITHMETIC\\SUBTRACT\\SUBTRACT.py", + "selected": false + }, + "position": { + "x": 539.5038389646794, + "y": 129.82546731386907 + }, + "selected": false, + "positionAbsolute": { + "x": 539.5038389646794, + "y": 129.82546731386907 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "sourceHandle": "default", + "target": "SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622", + "targetHandle": "default", + "id": "reactflow__edge-PID-cee43c6b-237d-45f8-98d0-319f48acaebfdefault-SECOND_ORDER_SYSTEM-f97650dd-54de-4204-be2d-a04451e4b622default" + }, + { + "source": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "sourceHandle": "default", + "target": "LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9", + "targetHandle": "default", + "id": "reactflow__edge-DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49default-LINE-ed3aba7c-7235-43dd-baeb-6ad9dbc763b9default" + }, + { + "source": "LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87c", + "sourceHandle": "body", + "target": "CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277db", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87cbody-CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277dbdefault" + }, + { + "source": "LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87c", + "sourceHandle": "body", + "target": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87cbody-FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718ddefault" + }, + { + "source": "FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718d", + "sourceHandle": "default", + "target": "SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118", + "targetHandle": "a", + "id": "reactflow__edge-FEEDBACK-7dce3ba5-d2e2-4b60-8a2c-06218b5f718ddefault-SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118a" + }, + { + "source": "CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277db", + "sourceHandle": "default", + "target": "SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118", + "targetHandle": "b", + "id": "reactflow__edge-CONSTANT-f84cbbe2-6624-49c7-8a7a-a65b34b277dbdefault-SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118b" + }, + { + "source": "SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118", + "sourceHandle": "default", + "target": "PID-cee43c6b-237d-45f8-98d0-319f48acaebf", + "targetHandle": "default", + "id": "reactflow__edge-SUBTRACT-513db751-391e-4342-aee3-9f322a4c3118default-PID-cee43c6b-237d-45f8-98d0-319f48acaebfdefault" + }, + { + "source": "LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87c", + "sourceHandle": "end", + "target": "DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-ee157ec4-dc88-4f4e-be71-5db5e3bbe87cend-DS_LOAD-1cfd0ec3-cbf0-4316-b2f0-2654e5a54e49default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d07c7fe8b0 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/docstring.txt @@ -0,0 +1,22 @@ + +The SAVGOL node applies a Savitzky-Golay filter to an input signal. It is generally used for smoothing data. + +The default behaviour is to implement a 3-point moving average of the data. + +Inputs +------ +default : OrderedPair + The data to apply the numpy savgol filter to. + +Parameters +---------- +window_length : int + the length of the filter window, must be less than or equal to the size of the input +poly_order : int + the order of the polynomial used to fit the samples, must be less than or equal to the size of window_length + +Returns +------- +OrderedPair + x: time axis + y: filtered signal diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ebb999ef3a --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/a1-[autogen]/python_code.txt @@ -0,0 +1,25 @@ +import scipy +from flojoy import flojoy, OrderedPair +import warnings + + +@flojoy +def SAVGOL( + default: OrderedPair, window_length: int = 50, poly_order: int = 1 +) -> OrderedPair: + + signal = default.y + if window_length >= len(default.y): + warnings.warn( + "Polynomial order is greater than the window size. Using p=w-1..." + ) + poly_order = len(default.y) - 1 + + if poly_order >= window_length: + warnings.warn( + "Polynomial order is greater than the window size. Using p=w-1..." + ) + poly_order = window_length - 1 + + filtered = scipy.signal.savgol_filter(signal, window_length, poly_order) + return OrderedPair(x=default.x, y=filtered) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/examples/EX1/app.txt new file mode 100644 index 0000000000..06fc6f8385 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/examples/EX1/app.txt @@ -0,0 +1,484 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-79f540d0-bf01-44ee-a5cc-bd7c22c481fe", + "type": "default", + "data": { + "id": "LINSPACE-79f540d0-bf01-44ee-a5cc-bd7c22c481fe", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": "0" + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": "60" + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": "60" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 177.40421214553245, + "y": 23.20557403225355 + }, + "selected": false, + "positionAbsolute": { + "x": 177.40421214553245, + "y": 23.20557403225355 + } + }, + { + "width": 130, + "height": 130, + "id": "RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3", + "type": "GENERATORS", + "data": { + "id": "RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3", + "label": "RAND", + "func": "RAND", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "default": "normal", + "options": [ + "normal", + "uniform", + "poisson" + ], + "functionName": "RAND", + "param": "distribution", + "value": "uniform" + }, + "lower_bound": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "upper_bound", + "value": "0.3" + }, + "normal_mean": { + "type": "float", + "default": 0, + "functionName": "RAND", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "functionName": "RAND", + "param": "poisson_events", + "value": 1 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "selected": false + }, + "position": { + "x": 488.56693400549386, + "y": 35.020946550996484 + }, + "selected": false, + "positionAbsolute": { + "x": 488.56693400549386, + "y": 35.020946550996484 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "BASIC_OSCILLATOR-d82cc0d9-4160-4683-981f-c32f6dfe1256", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-d82cc0d9-4160-4683-981f-c32f6dfe1256", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "30" + }, + "time": { + "type": "int", + "default": 10, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": "2" + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": "1" + }, + "offset": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": 0 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": 188.05797144390925, + "y": 276.8757782209271 + }, + "selected": false, + "positionAbsolute": { + "x": 188.05797144390925, + "y": 276.8757782209271 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022e", + "type": "TRANSFORMERS", + "data": { + "id": "SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022e", + "label": "SAVGOL", + "func": "SAVGOL", + "type": "TRANSFORMERS", + "ctrls": { + "window_length": { + "type": "int", + "default": 50, + "functionName": "SAVGOL", + "param": "window_length", + "value": "20" + }, + "poly_order": { + "type": "int", + "default": 1, + "functionName": "SAVGOL", + "param": "poly_order", + "value": "3" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/SAVGOL/SAVGOL.py", + "selected": false + }, + "position": { + "x": 1202.7889654568903, + "y": 128.8948299478717 + }, + "selected": false, + "positionAbsolute": { + "x": 1202.7889654568903, + "y": 128.8948299478717 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "type": "ARITHMETIC", + "data": { + "id": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 811.9422973537728, + "y": 137.422040893595 + }, + "selected": false, + "positionAbsolute": { + "x": 811.9422973537728, + "y": 137.422040893595 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-38ed0165-2ba5-418f-8603-e8592ae636c2", + "type": "VISUALIZERS", + "data": { + "id": "LINE-38ed0165-2ba5-418f-8603-e8592ae636c2", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 975.4183946292451, + "y": 378.92458730043927 + }, + "selected": false, + "positionAbsolute": { + "x": 975.4183946292451, + "y": 378.92458730043927 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-46272c52-999a-48c0-a2c4-9bf8e9f01631", + "type": "VISUALIZERS", + "data": { + "id": "LINE-46272c52-999a-48c0-a2c4-9bf8e9f01631", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 1489.3610618674375, + "y": 384.82137397850096 + }, + "selected": false, + "positionAbsolute": { + "x": 1489.3610618674375, + "y": 384.82137397850096 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-79f540d0-bf01-44ee-a5cc-bd7c22c481fe", + "sourceHandle": "default", + "target": "RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-79f540d0-bf01-44ee-a5cc-bd7c22c481fedefault-RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3default" + }, + { + "source": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "sourceHandle": "default", + "target": "SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022e", + "targetHandle": "default", + "id": "reactflow__edge-ADD-b6b71026-3b39-41be-9230-276ce8d76e70default-SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022edefault" + }, + { + "source": "RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3", + "sourceHandle": "default", + "target": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "targetHandle": "a", + "id": "reactflow__edge-RAND-67823db5-2e2b-48d2-9fa2-59711d68d8b3default-ADD-b6b71026-3b39-41be-9230-276ce8d76e70a" + }, + { + "source": "BASIC_OSCILLATOR-d82cc0d9-4160-4683-981f-c32f6dfe1256", + "sourceHandle": "default", + "target": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "targetHandle": "b", + "id": "reactflow__edge-BASIC_OSCILLATOR-d82cc0d9-4160-4683-981f-c32f6dfe1256default-ADD-b6b71026-3b39-41be-9230-276ce8d76e70b" + }, + { + "source": "ADD-b6b71026-3b39-41be-9230-276ce8d76e70", + "sourceHandle": "default", + "target": "LINE-38ed0165-2ba5-418f-8603-e8592ae636c2", + "targetHandle": "default", + "id": "reactflow__edge-ADD-b6b71026-3b39-41be-9230-276ce8d76e70default-LINE-38ed0165-2ba5-418f-8603-e8592ae636c2default" + }, + { + "source": "SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022e", + "sourceHandle": "default", + "target": "LINE-46272c52-999a-48c0-a2c4-9bf8e9f01631", + "targetHandle": "default", + "id": "reactflow__edge-SAVGOL-a8bd4f8a-63a4-4b06-bacd-4cf1289f022edefault-LINE-46272c52-999a-48c0-a2c4-9bf8e9f01631default" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..8f08af22cf --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/docstring.txt @@ -0,0 +1,27 @@ + +The TWO_DIMENSIONAL_FFT node performs a two-dimensional fourier transform function on the input matrix. + +With the FFT algorithm, the input matrix will undergo a change of basis from the space domain into the frequency domain. + +grayscale, dataframe, image, or matrix + +Inputs +------ +default : Grayscale|DataFrame|Image|Matrix + The 2D data to apply 2DFFT to. + +Parameters +---------- +real_input : boolean + true if the input matrix consists of only real numbers, false otherwise +color : select + if the input is an RGBA or RGB image, this parameter selects the color channel to perform the FFT on + +Returns +------- +Matrix if input is Matrix + m: the matrix after 2DFFT +DataFrame if input is Dataframe + m: the dataframe after 2DFFT +Image + the frequency spectrum of the color channel diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ddb054d654 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/a1-[autogen]/python_code.txt @@ -0,0 +1,60 @@ +from scipy import fft +from flojoy import flojoy, DataFrame, Matrix, Image, Grayscale +from typing import Literal +from PIL import Image as PillowImage +import pandas as pd +import numpy as np + + +def extrapolate(x): + return (x - x.min()) / (x.max() - x.min()) + + +@flojoy +def TWO_DIMENSIONAL_FFT( + default: Grayscale | DataFrame | Image | Matrix, + real_signal: bool = True, + color: Literal["red", "green", "blue", "grayscale"] = "red", +) -> Matrix | DataFrame | Image: + + + match default: + case Grayscale() | Matrix(): + input = default.m + fourier = fft.rfft2(input) if real_signal else fft.fft2(input) + if isinstance(default, Matrix): + fourier = fourier.real + return Matrix(m=fourier) + case DataFrame(): + input: pd.DataFrame = pd.DataFrame(default.m) + fourier = fft.rfft2(input) if real_signal else fft.fft2(input) + fourier = fourier.real + result = pd.DataFrame(columns=fourier.columns, index=fourier.index) + return DataFrame(m=result) + case Image(): + red = default.r + green = default.g + blue = default.b + alpha = default.a + if color == "grayscale": + if alpha is None: + rgba_image = np.stack((red, green, blue), axis=2) + else: + rgba_image = np.stack((red, green, blue, alpha), axis=2) + try: + image = PillowImage.fromarray(rgba_image) + except TypeError: + image = PillowImage.fromarray((rgba_image * 255).astype(np.uint8)) + image = image.convert("L") + grayscale = np.array(image) + fourier = fft.rfft2(grayscale) if real_signal else fft.fft2(grayscale) + else: + fourier = ( + fft.rfft2(locals()[color], axes=[0, 1]) + if real_signal + else fft.fft2(locals()[color], axes=[0, 1]) + ) + + fourier = np.log10(np.abs(fourier)) + fourier = extrapolate(fourier) + return Image(r=fourier, g=fourier, b=fourier, a=None) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/examples/EX1/app.txt new file mode 100644 index 0000000000..3624b2d2e1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/examples/EX1/app.txt @@ -0,0 +1,287 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 1049.9664410476967, + "y": 7.753302513786252 + }, + "selected": false, + "positionAbsolute": { + "x": 1049.9664410476967, + "y": 7.753302513786252 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "label": "IMAGE 1", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/IMAGE/IMAGE.py", + "selected": false + }, + "position": { + "x": 680.10784936201, + "y": 259.1429105274428 + }, + "selected": false, + "positionAbsolute": { + "x": 680.10784936201, + "y": 259.1429105274428 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76", + "type": "TRANSFORMERS", + "data": { + "id": "TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76", + "label": "TWO DIMENSIONAL FFT", + "func": "TWO_DIMENSIONAL_FFT", + "type": "TRANSFORMERS", + "ctrls": { + "real_signal": { + "type": "bool", + "default": true, + "functionName": "TWO_DIMENSIONAL_FFT", + "param": "real_signal", + "value": false + }, + "color": { + "type": "select", + "default": "red", + "options": [ + "red", + "green", + "blue", + "Grayscale" + ], + "functionName": "TWO_DIMENSIONAL_FFT", + "param": "color", + "value": "red" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Grayscale|DataFrame|Image|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix|DataFrame|Image" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/SIGNAL_PROCESSING/TWO_DIMENSIONAL_FFT/TWO_DIMENSIONAL_FFT.py", + "selected": false + }, + "position": { + "x": 751.5106356403874, + "y": 35.73398367632049 + }, + "selected": false, + "positionAbsolute": { + "x": 751.5106356403874, + "y": 35.73398367632049 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426c", + "type": "default", + "data": { + "id": "SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426c", + "label": "SKLEARNIMAGE", + "func": "SKLEARNIMAGE", + "type": "default", + "ctrls": { + "img_key": { + "type": "select", + "default": "astronaut", + "options": [ + "astronaut", + "binary_blobs", + "brain", + "brick", + "camera", + "cat", + "cell", + "cells3d", + "checkerboard", + "chelsea", + "clock", + "coffee", + "coins", + "colorwheel", + "create_image_fetcher", + "data_dir", + "download_all", + "eagle", + "file_hash", + "grass", + "gravel", + "horse", + "hubble_deep_field", + "human_mitosis", + "image_fetcher", + "immunohistochemistry", + "kidney", + "lbp_frontal_face_cascade_filename", + "lfw_subset", + "lily", + "logo", + "microaneurysms", + "moon", + "nickel_solidification", + "page", + "protein_transport", + "retina", + "rocket", + "shepp_logan_phantom", + "skin", + "stereo_motorcycle", + "text", + "vortex" + ], + "desc": null, + "functionName": "SKLEARNIMAGE", + "param": "img_key", + "value": "astronaut" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "desc": null + } + ], + "pip_dependencies": [ + { + "name": "scikit-image", + "v": "0.21.0" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_IMAGES\\SKLEARNIMAGE\\SKLEARNIMAGE.py", + "selected": false + }, + "position": { + "x": 417.41128879686454, + "y": 21.10713477860139 + }, + "selected": false, + "positionAbsolute": { + "x": 417.41128879686454, + "y": 21.10713477860139 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76", + "sourceHandle": "default", + "target": "IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427c", + "targetHandle": "default", + "id": "reactflow__edge-TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76default-IMAGE-455a09f6-8f20-4087-ab60-9f01c1b2427cdefault" + }, + { + "source": "SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426c", + "sourceHandle": "default", + "target": "TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76", + "targetHandle": "default", + "id": "reactflow__edge-SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426cdefault-TWO_DIMENSIONAL_FFT-373b4021-dbb6-4c59-8884-b146b6d2bb76default" + }, + { + "source": "SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426c", + "sourceHandle": "default", + "target": "IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406", + "targetHandle": "default", + "id": "reactflow__edge-SKLEARNIMAGE-1fe5199d-c1cf-40c3-8a55-2445b6a2426cdefault-IMAGE-135a920b-87fa-4759-bfca-0b6ad739b406default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d79add9a6b --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The DF_2_NP node takes one dataframe type data and converts it to a matrix type data. + +Returns +------- +DataFrame + Converted dataframe value from the input. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d3df21bcaf --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/a1-[autogen]/python_code.txt @@ -0,0 +1,12 @@ +import pandas as pd +from flojoy import flojoy, DataFrame, Matrix + + +@flojoy +def DF_2_NP(default: DataFrame) -> Matrix: + + + df = default.m + df_to_numpy = df.to_numpy(dtype=object) + + return Matrix(m=df_to_numpy) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/examples/EX1/app.txt new file mode 100644 index 0000000000..a05e8e3967 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/examples/EX1/app.txt @@ -0,0 +1,310 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "desc": null, + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "airquality" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/R_DATASET.py", + "selected": false + }, + "position": { + "x": -580.4601807214103, + "y": 18.651973077552213 + }, + "selected": false, + "positionAbsolute": { + "x": -580.4601807214103, + "y": 18.651973077552213 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5a", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5a", + "label": "DF 2 NP", + "func": "DF_2_NP", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix", + "desc": "Converted dataframe value from the input" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/TYPE_CASTING/DF_2_NP/DF_2_NP.py", + "selected": false + }, + "position": { + "x": -339.59500425249286, + "y": 148.88869515224056 + }, + "selected": false, + "positionAbsolute": { + "x": -339.59500425249286, + "y": 148.88869515224056 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-d6eebd8f-1c5a-4565-a07c-8591d0dc0464", + "type": "VISUALIZERS", + "data": { + "id": "LINE-d6eebd8f-1c5a-4565-a07c-8591d0dc0464", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": -126.6228737751659, + "y": 118.07746381818538 + }, + "selected": false, + "positionAbsolute": { + "x": -126.6228737751659, + "y": 118.07746381818538 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-871ab113-ab85-4c34-af5e-53037f3bebd1", + "type": "VISUALIZERS", + "data": { + "id": "LINE-871ab113-ab85-4c34-af5e-53037f3bebd1", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": -299.7005389975791, + "y": -152.8117053854877 + }, + "selected": false, + "positionAbsolute": { + "x": -299.7005389975791, + "y": -152.8117053854877 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57", + "sourceHandle": "default", + "target": "DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5a", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57default-DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5adefault" + }, + { + "source": "R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57", + "sourceHandle": "default", + "target": "LINE-871ab113-ab85-4c34-af5e-53037f3bebd1", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-b9a3532b-7924-41b5-b7a3-3b2f26342f57default-LINE-871ab113-ab85-4c34-af5e-53037f3bebd1default" + }, + { + "source": "DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5a", + "sourceHandle": "default", + "target": "LINE-d6eebd8f-1c5a-4565-a07c-8591d0dc0464", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_NP-84475e8e-a8be-4360-a62f-203a0bbc9c5adefault-LINE-d6eebd8f-1c5a-4565-a07c-8591d0dc0464default" + } + ], + "viewport": { + "x": 722.5478564221319, + "y": 307.5775746454569, + "zoom": 1.204238868134965 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..b0adc9c001 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/docstring.txt @@ -0,0 +1,14 @@ + +The DF_2_ORDEREDTRIPLE node converts a dataframe type data into an OrderedTriple type data. + +It takes one dataframe type data and selects 3 different columns to generate the OrderedTriple type. + +Parameters +---------- +x : the index of the column that represents the x axis +y : the index of the column that represents the y axis +z : the index of the column that represents the z axis + +Returns +------- +OrderedTriple diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ff398d9b66 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/a1-[autogen]/python_code.txt @@ -0,0 +1,24 @@ +from flojoy import flojoy, DataFrame, OrderedTriple + + +@flojoy +def DF_2_ORDEREDTRIPLE( + default: DataFrame, x: int = 0, y: int = 1, z: int = 2 +) -> OrderedTriple: + + + df = default.m + if df.shape[1] < 3: + raise AssertionError( + f"The DataFrame needs to have a shape greater than 2 in order to be converted to the OrderedTriple type, got: {df.shape[1]}" + ) + + x_list = df.iloc[:, x] + y_list = df.iloc[:, y] + z_list = df.iloc[:, z] + + x_numpy = x_list.to_numpy(dtype=object) + y_numpy = y_list.to_numpy(dtype=object) + z_numpy = z_list.to_numpy(dtype=object) + + return OrderedTriple(x=x_numpy, y=y_numpy, z=z_numpy) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/examples/EX1/app.txt new file mode 100644 index 0000000000..5c18533fd3 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/DF_2_ORDEREDTRIPLE/examples/EX1/app.txt @@ -0,0 +1,329 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbae", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbae", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/R_DATASET/R_DATASET.py", + "selected": false + }, + "position": { + "x": -338.7711900770852, + "y": 194.3183042659582 + }, + "selected": false, + "positionAbsolute": { + "x": -338.7711900770852, + "y": 194.3183042659582 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-a1a64ba2-624d-4309-a3a6-581e496644a7", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-a1a64ba2-624d-4309-a3a6-581e496644a7", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": 358.1790032359889, + "y": 27.327589114130035 + }, + "selected": false, + "positionAbsolute": { + "x": 358.1790032359889, + "y": 27.327589114130035 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-cb2c9e6a-e220-470e-a206-eda1820f9aa3", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-cb2c9e6a-e220-470e-a206-eda1820f9aa3", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": -8.207108311715444, + "y": 293.30295471921596 + }, + "selected": false, + "positionAbsolute": { + "x": -8.207108311715444, + "y": 293.30295471921596 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930a", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930a", + "label": "DF 2 ORDEREDTRIPLE", + "func": "DF_2_ORDEREDTRIPLE", + "type": "TRANSFORMERS", + "ctrls": { + "x": { + "type": "int", + "default": 0, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "x", + "value": 0 + }, + "y": { + "type": "int", + "default": 1, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "y", + "value": 1 + }, + "z": { + "type": "int", + "default": 2, + "desc": null, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "z", + "value": 2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple", + "desc": null + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\TYPE_CASTING\\DF_2_ORDEREDTRIPLE\\DF_2_ORDEREDTRIPLE.py", + "selected": false + }, + "position": { + "x": 22.290347003831585, + "y": 63.93602572915705 + }, + "selected": false, + "positionAbsolute": { + "x": 22.290347003831585, + "y": 63.93602572915705 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbae", + "sourceHandle": "default", + "target": "TABLE-cb2c9e6a-e220-470e-a206-eda1820f9aa3", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbaedefault-TABLE-cb2c9e6a-e220-470e-a206-eda1820f9aa3default" + }, + { + "source": "R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbae", + "sourceHandle": "default", + "target": "DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930a", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-05d7349e-095e-4a58-9ac2-d019c8abcbaedefault-DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930adefault" + }, + { + "source": "DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930a", + "sourceHandle": "default", + "target": "TABLE-a1a64ba2-624d-4309-a3a6-581e496644a7", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-62a7516d-96b6-4546-8fb2-f0f8a538930adefault-TABLE-a1a64ba2-624d-4309-a3a6-581e496644a7default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..4ac4dbaa2f --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The MAT_2_DF node takes one matrix type data and converts it to a dataframe type data. + +Returns +------- +DataFrame + Converted matrix value from the input. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..48e3dacdaa --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/a1-[autogen]/python_code.txt @@ -0,0 +1,14 @@ +from numpy import asarray +import pandas as pd +from flojoy import flojoy, Matrix, DataFrame + + +@flojoy +def MAT_2_DF(default: Matrix) -> DataFrame: + + + np_data = default.m + np_array = asarray(np_data) + df = pd.DataFrame(np_array) + + return DataFrame(df=df) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/examples/EX1/app.txt new file mode 100644 index 0000000000..413c94059d --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/examples/EX1/app.txt @@ -0,0 +1,229 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 180, + "id": "MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79", + "type": "default", + "data": { + "id": "MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79", + "label": "MATRIX", + "func": "MATRIX", + "type": "default", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "desc": "number of rows", + "functionName": "MATRIX", + "param": "row", + "value": "9" + }, + "column": { + "type": "int", + "default": 2, + "desc": "number of columns", + "functionName": "MATRIX", + "param": "column", + "value": "3" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix", + "desc": "randomly generated matrix" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/MATRIX/MATRIX.py", + "selected": false + }, + "position": { + "x": -225.25714376309378, + "y": 153.73794751935753 + }, + "selected": false, + "positionAbsolute": { + "x": -225.25714376309378, + "y": 153.73794751935753 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671", + "type": "TRANSFORMERS", + "data": { + "id": "MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671", + "label": "MAT 2 DF", + "func": "MAT_2_DF", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": "Converted matrix value from the input" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/TYPE_CASTING/MAT_2_DF/MAT_2_DF.py", + "selected": false + }, + "position": { + "x": -4.4360226148176025, + "y": 326.1357946190215 + }, + "selected": false, + "positionAbsolute": { + "x": -4.4360226148176025, + "y": 326.1357946190215 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-e4276e11-5fd7-4aa5-a357-9a3b7c57abab", + "type": "VISUALIZERS", + "data": { + "id": "LINE-e4276e11-5fd7-4aa5-a357-9a3b7c57abab", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 259.70014602948754, + "y": 315.13027092154357 + }, + "selected": false, + "positionAbsolute": { + "x": 259.70014602948754, + "y": 315.13027092154357 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-1effbf12-03cc-40ec-bc5f-22c7954a3abe", + "type": "VISUALIZERS", + "data": { + "id": "LINE-1effbf12-03cc-40ec-bc5f-22c7954a3abe", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 52.20363423768484, + "y": 16.739781481728016 + }, + "selected": false, + "positionAbsolute": { + "x": 52.20363423768484, + "y": 16.739781481728016 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79", + "sourceHandle": "default", + "target": "MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79default-MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671default" + }, + { + "source": "MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79", + "sourceHandle": "default", + "target": "LINE-1effbf12-03cc-40ec-bc5f-22c7954a3abe", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-e3ed97a3-2b6e-4ece-908e-f48e0de4ab79default-LINE-1effbf12-03cc-40ec-bc5f-22c7954a3abedefault" + }, + { + "source": "MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671", + "sourceHandle": "default", + "target": "LINE-e4276e11-5fd7-4aa5-a357-9a3b7c57abab", + "targetHandle": "default", + "id": "reactflow__edge-MAT_2_DF-e3f15cc1-ec37-40ea-94be-1e3409ef0671default-LINE-e4276e11-5fd7-4aa5-a357-9a3b7c57ababdefault" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..3fcaf662b8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/docstring.txt @@ -0,0 +1,7 @@ + +The NP_2_DF node converts numpy array data into dataframe type data. + +Returns +------- +dataframe + Converted numpy array value from the input. diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..0b5a8e1245 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/a1-[autogen]/python_code.txt @@ -0,0 +1,63 @@ +import pandas as pd +import numpy as np +from flojoy import ( + flojoy, + DataContainer, + DataFrame, + OrderedPair, + OrderedTriple, + Matrix, + Grayscale, + Image, + ParametricDataFrame, + ParametricOrderedPair, + ParametricOrderedTriple, + ParametricImage, + ParametricGrayscale, + ParametricMatrix, +) + + +@flojoy +def NP_2_DF(default: DataContainer) -> DataFrame: + + + match default: + case DataFrame() | ParametricDataFrame(): + return default + + case OrderedPair() | ParametricOrderedPair(): + df = pd.DataFrame(default.y) + return DataFrame(df=df) + + case OrderedTriple() | ParametricOrderedTriple(): + df = pd.DataFrame(default.z) + return DataFrame(df=df) + + case Matrix() | ParametricMatrix(): + np_array = np.asarray(default.m) + df = pd.DataFrame(np_array) + return DataFrame(df=df) + case Grayscale() | ParametricGrayscale(): + np_array = np.asarray(default.img) + df = pd.DataFrame(np_array) + return DataFrame(df=df) + + case Image() | ParametricImage(): + red = default.r + green = default.g + blue = default.b + + if default.a == None: + merge = np.stack((red, green, blue), axis=2) + merge = merge.reshape(-1, merge.shape[-1]) + df = pd.DataFrame(merge) + return DataFrame(df=df) + else: + alpha = default.a + merge = np.stack((red, green, blue, alpha), axis=2) + merge = merge.reshape(-1, merge.shape[-1]) + df = pd.DataFrame(merge) + return DataFrame(df=df) + case _: + raise ValueError(f"unsupported DataContainer type passed for NP_2_DF") diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/examples/EX1/app.txt new file mode 100644 index 0000000000..199cb34543 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/examples/EX1/app.txt @@ -0,0 +1,373 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 160, + "height": 160, + "id": "NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658c", + "type": "TRANSFORMERS", + "data": { + "id": "NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658c", + "label": "NP 2 DF", + "func": "NP_2_DF", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": "Converted numpy array value from the input" + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/TYPE_CASTING/NP_2_DF/NP_2_DF.py", + "selected": false + }, + "position": { + "x": -571.2328272838067, + "y": 487.3807469451905 + }, + "selected": false, + "positionAbsolute": { + "x": -571.2328272838067, + "y": 487.3807469451905 + }, + "dragging": true + }, + { + "width": 150, + "height": 180, + "id": "BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5", + "type": "default", + "data": { + "id": "BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "default", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "desc": "How many samples taken during a second", + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": "100" + }, + "time": { + "type": "int", + "default": 10, + "desc": "The total amount of time of the signal", + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": 10 + }, + "waveform": { + "type": "select", + "default": "sine", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "desc": null, + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "desc": null, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "desc": null, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "desc": null, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": "0" + }, + "phase": { + "type": "float", + "default": 0, + "desc": null, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": "0" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": -569.0550195828876, + "y": 203.47140926114037 + }, + "selected": false, + "positionAbsolute": { + "x": -569.0550195828876, + "y": 203.47140926114037 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-62e48882-7697-4c67-9e56-0b6f10152e69", + "type": "VISUALIZERS", + "data": { + "id": "LINE-62e48882-7697-4c67-9e56-0b6f10152e69", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 20.527963094804335, + "y": 428.32209712717724 + }, + "selected": false, + "positionAbsolute": { + "x": 20.527963094804335, + "y": 428.32209712717724 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "LINE-05688284-e6cc-46c5-8275-4c9748d84900", + "type": "VISUALIZERS", + "data": { + "id": "LINE-05688284-e6cc-46c5-8275-4c9748d84900", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 15.61839225442884, + "y": 150.47677369917045 + }, + "selected": false, + "positionAbsolute": { + "x": 15.61839225442884, + "y": 150.47677369917045 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-f888b0d5-bc24-4634-9ba2-fda9038f044e", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-f888b0d5-bc24-4634-9ba2-fda9038f044e", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": -364.726123767692, + "y": 427.1385364736938 + }, + "selected": false, + "positionAbsolute": { + "x": -364.726123767692, + "y": 427.1385364736938 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-8216adbc-6c2a-490a-bab9-8cf02f710e54", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-8216adbc-6c2a-490a-bab9-8cf02f710e54", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/TABLE/TABLE.py", + "selected": false + }, + "position": { + "x": -367.55298879435026, + "y": 147.1981842096718 + }, + "selected": false, + "positionAbsolute": { + "x": -367.55298879435026, + "y": 147.1981842096718 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5", + "sourceHandle": "default", + "target": "NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658c", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5default-NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658cdefault" + }, + { + "source": "BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5", + "sourceHandle": "default", + "target": "TABLE-8216adbc-6c2a-490a-bab9-8cf02f710e54", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5default-TABLE-8216adbc-6c2a-490a-bab9-8cf02f710e54default" + }, + { + "source": "BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5", + "sourceHandle": "default", + "target": "LINE-05688284-e6cc-46c5-8275-4c9748d84900", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-34b2dbb6-c35c-4109-8281-d763fb03a2e5default-LINE-05688284-e6cc-46c5-8275-4c9748d84900default" + }, + { + "source": "NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658c", + "sourceHandle": "default", + "target": "TABLE-f888b0d5-bc24-4634-9ba2-fda9038f044e", + "targetHandle": "default", + "id": "reactflow__edge-NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658cdefault-TABLE-f888b0d5-bc24-4634-9ba2-fda9038f044edefault" + }, + { + "source": "NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658c", + "sourceHandle": "default", + "target": "LINE-62e48882-7697-4c67-9e56-0b6f10152e69", + "targetHandle": "default", + "id": "reactflow__edge-NP_2_DF-11220119-eee5-4a20-8c9b-3875433e658cdefault-LINE-62e48882-7697-4c67-9e56-0b6f10152e69default" + } + ], + "viewport": { + "x": 722.5478564221319, + "y": 307.5775746454569, + "zoom": 1.204238868134965 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..2e4e49d578 --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/docstring.txt @@ -0,0 +1,10 @@ + +The ORDERED_TRIPLE_2_SURFACE node takes an "OrderedTriple" instance of the DataContainer class that contains three arrays: x, y, and z. + +It then reshapes the z array into a 2D grid using the unique values of x and y. + +The resulting 2D grid is used to create a Surface object with corresponding x, y, and z values. + +Returns +------- +Surface diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..982d6b4dba --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/a1-[autogen]/python_code.txt @@ -0,0 +1,22 @@ +from flojoy import flojoy, OrderedTriple, Surface +import numpy as np + + +@flojoy +def ORDERED_TRIPLE_2_SURFACE(default: OrderedTriple) -> Surface: + + x = np.unique(default.x) + y = np.unique(default.y) + + z_size = len(x) * len(y) + + # Truncate or pad the z array to match the desired size + if z_size > len(default.z): + z = np.pad(default.z, (0, z_size - len(default.z)), mode="constant").reshape( + len(y), len(x) + ) + else: + z = default.z[:z_size].reshape(len(y), len(x)) + + X, Y = np.meshgrid(x, y) + return Surface(x=X, y=Y, z=z) diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/hardware.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/media.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/notes.md b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/examples/EX1/app.txt new file mode 100644 index 0000000000..904916a50b --- /dev/null +++ b/docs/nodes/flojoy_nodes/TRANSFORMERS/TYPE_CASTING/ORDERED_TRIPLE_2_SURFACE/examples/EX1/app.txt @@ -0,0 +1,247 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "gapminder" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -153.13246731470204, + "y": 152.21548757941065 + }, + "selected": false, + "positionAbsolute": { + "x": -153.13246731470204, + "y": 152.21548757941065 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "label": "DF 2 ORDEREDTRIPLE", + "func": "DF_2_ORDEREDTRIPLE", + "type": "TRANSFORMERS", + "ctrls": { + "x": { + "type": "int", + "default": 0, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "x", + "value": 0 + }, + "y": { + "type": "int", + "default": 1, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "y", + "value": 1 + }, + "z": { + "type": "int", + "default": 2, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "z", + "value": 2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 138.28356151980358, + "y": 155.19957354474383 + }, + "selected": false, + "positionAbsolute": { + "x": 138.28356151980358, + "y": 155.19957354474383 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "type": "TRANSFORMERS", + "data": { + "id": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "label": "ORDERED TRIPLE 2 SURFACE", + "func": "ORDERED_TRIPLE_2_SURFACE", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Surface" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 432.81238809404584, + "y": 157.95703541664443 + }, + "selected": false, + "positionAbsolute": { + "x": 432.81238809404584, + "y": 157.95703541664443 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SURFACE3D-815e6548-3e6e-4740-b240-4e61891fec60", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-815e6548-3e6e-4740-b240-4e61891fec60", + "label": "SURFACE3D", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SURFACE3D\\SURFACE3D.py", + "selected": false + }, + "position": { + "x": 780.9204415982466, + "y": 78.56150142040786 + }, + "selected": false, + "positionAbsolute": { + "x": 780.9204415982466, + "y": 78.56150142040786 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "sourceHandle": "default", + "target": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cddefault-DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204default" + }, + { + "source": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "sourceHandle": "default", + "target": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204default-ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3default" + }, + { + "source": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "sourceHandle": "default", + "target": "SURFACE3D-815e6548-3e6e-4740-b240-4e61891fec60", + "targetHandle": "default", + "id": "reactflow__edge-ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3default-SURFACE3D-815e6548-3e6e-4740-b240-4e61891fec60default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d79b6f99e1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/docstring.txt @@ -0,0 +1,13 @@ + +The ARRAY_VIEW node takes "OrderedPair", "DataFrame", "Matrix", and "Image" objects of DataContainer class as input +and displays its visualization in an array format. + +Inputs +------- +default : OrderedPair | DataFrame | Matrix | Image + the DataContainer to be visualized in an array format + +Outputs +------- +Plotly + the DataContainer containing visualization of the input in an array format diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..007ed0a229 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/a1-[autogen]/python_code.txt @@ -0,0 +1,81 @@ +from flojoy import flojoy, OrderedPair, DataFrame, Matrix, Image, Plotly +import plotly.graph_objects as go +import numpy as np + +CELL_SIZE = 50 +FONT_SIZE = 10 +MAX_ALLOWED_SHAPE = 10 +l_dot = "$\\ldots$" + + +def numpy_array_as_table(arr: np.ndarray): + if arr.size > MAX_ALLOWED_SHAPE: + converted_type = arr.astype(object) + new_arr = converted_type[:MAX_ALLOWED_SHAPE] + new_arr[MAX_ALLOWED_SHAPE - 2] = l_dot + else: + new_arr = arr + return new_arr.reshape(-1, 1) + + +@flojoy +def ARRAY_VIEW(default: OrderedPair | Matrix | DataFrame | Image) -> Plotly: + + + if isinstance(default, OrderedPair): + data = default.y + cell_values = numpy_array_as_table(data) + elif isinstance(default, DataFrame): + data = default.m.to_numpy(dtype=object) + data = data[:, :-1] + cell_values = numpy_array_as_table(data) + elif isinstance(default, Matrix): + data = default.m + cell_values = numpy_array_as_table(data) + else: + red = default.r + green = default.g + blue = default.b + + if default.a is None: + merge = np.stack((red, green, blue), axis=2) + else: + alpha = default.a + merge = np.stack((red, green, blue, alpha), axis=2) + + merge = merge.reshape(-1, merge.shape[-1]) + cell_values = numpy_array_as_table(merge) + + fig = go.Figure( + data=[ + go.Table( + header=dict(line={"width": 0}, values=[]), + cells=dict( + values=cell_values, + line={"width": 3}, + font={"size": FONT_SIZE}, + height=CELL_SIZE, + align="center", + format=[".3"], + ), + ) + ] + ) + if default.type == "image" or default.type == "dataframe": + width = MAX_ALLOWED_SHAPE * CELL_SIZE + 800 + + else: + width = MAX_ALLOWED_SHAPE * CELL_SIZE + 80 + height = width + 80 + fig.layout = go.Layout( + autosize=False, + width=width, + height=height, + margin=dict(l=0, r=0, t=0, b=0), + xaxis=dict(visible=False), + yaxis=dict(visible=False), + hovermode="closest", + font=dict(size=FONT_SIZE), + ) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/examples/EX1/app.txt new file mode 100644 index 0000000000..463ecae5c6 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/examples/EX1/app.txt @@ -0,0 +1,336 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 240, + "height": 260, + "id": "ARRAY_VIEW-1efcd977-7ea1-4036-b70b-9e04177953f8", + "type": "VISUALIZERS", + "data": { + "id": "ARRAY_VIEW-1efcd977-7ea1-4036-b70b-9e04177953f8", + "label": "ARRAY VIEW", + "func": "ARRAY_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix|DataFrame|Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\DATA_STRUCTURE\\ARRAY_VIEW\\ARRAY_VIEW.py", + "selected": false + }, + "position": { + "x": 366.4303758700532, + "y": 134.05264409813714 + }, + "selected": false, + "positionAbsolute": { + "x": 366.4303758700532, + "y": 134.05264409813714 + }, + "dragging": true + }, + { + "width": 160, + "height": 160, + "id": "LOCAL_FILE-6cd15e81-644c-47c3-9309-bdfb92b80322", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-6cd15e81-644c-47c3-9309-bdfb92b80322", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes\\LOADERS\\LOCAL_FILE_SYSTEM\\LOCAL_FILE\\LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": -226.61117729370193, + "y": 156.29266821967894 + }, + "selected": false, + "positionAbsolute": { + "x": -226.61117729370193, + "y": 156.29266821967894 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "PLOTLY_DATASET-19eba195-7482-48cc-aac0-8cc1325fe0c9", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-19eba195-7482-48cc-aac0-8cc1325fe0c9", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "stocks" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -251.51014784091092, + "y": 626.774024234291 + }, + "selected": false, + "positionAbsolute": { + "x": -251.51014784091092, + "y": 626.774024234291 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "MATRIX-eb2f42c0-a990-4294-8032-45abfac569df", + "type": "GENERATORS", + "data": { + "id": "MATRIX-eb2f42c0-a990-4294-8032-45abfac569df", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": 2 + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": 2 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": -251.3393218267801, + "y": 419.51049841126246 + }, + "selected": false, + "positionAbsolute": { + "x": -251.3393218267801, + "y": 419.51049841126246 + }, + "dragging": true + }, + { + "width": 240, + "height": 260, + "id": "ARRAY_VIEW-111b6446-143e-43aa-83e9-3138fcdbf17b", + "type": "VISUALIZERS", + "data": { + "id": "ARRAY_VIEW-111b6446-143e-43aa-83e9-3138fcdbf17b", + "label": "ARRAY VIEW 2", + "func": "ARRAY_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix|DataFrame|Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\DATA_STRUCTURE\\ARRAY_VIEW\\ARRAY_VIEW.py", + "selected": false + }, + "position": { + "x": 50.27389361103141, + "y": 352.53231712571204 + }, + "selected": false, + "positionAbsolute": { + "x": 50.27389361103141, + "y": 352.53231712571204 + }, + "dragging": true + }, + { + "width": 240, + "height": 260, + "id": "ARRAY_VIEW-6736c8e9-a710-4b14-bdd4-829e0ee961c7", + "type": "VISUALIZERS", + "data": { + "id": "ARRAY_VIEW-6736c8e9-a710-4b14-bdd4-829e0ee961c7", + "label": "ARRAY VIEW 3", + "func": "ARRAY_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix|DataFrame|Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\DATA_STRUCTURE\\ARRAY_VIEW\\ARRAY_VIEW.py", + "selected": false + }, + "position": { + "x": 368.17200287196505, + "y": 555.6399688509405 + }, + "selected": false, + "positionAbsolute": { + "x": 368.17200287196505, + "y": 555.6399688509405 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-6cd15e81-644c-47c3-9309-bdfb92b80322", + "sourceHandle": "default", + "target": "ARRAY_VIEW-1efcd977-7ea1-4036-b70b-9e04177953f8", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-6cd15e81-644c-47c3-9309-bdfb92b80322default-ARRAY_VIEW-1efcd977-7ea1-4036-b70b-9e04177953f8default" + }, + { + "source": "MATRIX-eb2f42c0-a990-4294-8032-45abfac569df", + "sourceHandle": "default", + "target": "ARRAY_VIEW-111b6446-143e-43aa-83e9-3138fcdbf17b", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-eb2f42c0-a990-4294-8032-45abfac569dfdefault-ARRAY_VIEW-111b6446-143e-43aa-83e9-3138fcdbf17bdefault" + }, + { + "source": "PLOTLY_DATASET-19eba195-7482-48cc-aac0-8cc1325fe0c9", + "sourceHandle": "default", + "target": "ARRAY_VIEW-6736c8e9-a710-4b14-bdd4-829e0ee961c7", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-19eba195-7482-48cc-aac0-8cc1325fe0c9default-ARRAY_VIEW-6736c8e9-a710-4b14-bdd4-829e0ee961c7default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..28ab7f6f07 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The MATRIX_VIEW node takes a Matrix or OrderedPair object of DataContainer class as input and +displays its visualization using a Plotly table in matrix format. + +Inputs +------- +default : OrderedPair | Matrix + the DataContainer to be visualized in matrix format. +Outputs +------- +Plotly + the DataContainer containing visualization of the input in matrix format diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..4c16dfa71a --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/a1-[autogen]/python_code.txt @@ -0,0 +1,107 @@ +from flojoy import flojoy, OrderedPair, Matrix, Plotly, DCNpArrayType +import plotly.graph_objects as go +import numpy as np + + +CELL_SIZE = 50 +FONT_SIZE = 10 +MAX_ALLOWED_SHAPE = 8 +v_dot = "$\\vdots$" +d_dot = "$\\ddots$" +l_dot = "$\\ldots$" + + +def numpy_2d_array_as_table( + arr: DCNpArrayType, + arr_row_shape: int, + arr_col_shape: int, + placeholder: str, +): + new_arr = arr + if arr_row_shape > MAX_ALLOWED_SHAPE or arr_col_shape > MAX_ALLOWED_SHAPE: + new_arr = np.full( + (MAX_ALLOWED_SHAPE, MAX_ALLOWED_SHAPE), placeholder, dtype=object + ) + new_arr[:-2, :-2] = arr[: MAX_ALLOWED_SHAPE - 2, : MAX_ALLOWED_SHAPE - 2] + last_row = arr[arr_row_shape - 1, :] + first_cols = last_row[: MAX_ALLOWED_SHAPE - 2] + new_arr[MAX_ALLOWED_SHAPE - 1, : MAX_ALLOWED_SHAPE - 2] = first_cols + last_col = arr[:, arr.shape[1] - 1] + first_rows = last_col[: MAX_ALLOWED_SHAPE - 2] + new_arr[: MAX_ALLOWED_SHAPE - 2, MAX_ALLOWED_SHAPE - 1] = first_rows + new_arr[MAX_ALLOWED_SHAPE - 1, MAX_ALLOWED_SHAPE - 1 :] = arr[ + arr_row_shape - 1, arr.shape[1] - 1 : + ] + new_arr[0, MAX_ALLOWED_SHAPE - 2] = l_dot + new_arr[MAX_ALLOWED_SHAPE - 1, MAX_ALLOWED_SHAPE - 2] = l_dot + + new_arr[MAX_ALLOWED_SHAPE - 2, 0] = v_dot + new_arr[MAX_ALLOWED_SHAPE - 2, MAX_ALLOWED_SHAPE - 1] = v_dot + else: + new_arr + + return new_arr.T + + +def numpy_1d_array_as_table(arr: DCNpArrayType): + if arr.size > MAX_ALLOWED_SHAPE: + converted_type = arr.astype(object) + new_arr = converted_type[:MAX_ALLOWED_SHAPE] + new_arr[MAX_ALLOWED_SHAPE - 2] = l_dot + else: + new_arr = arr + return new_arr.reshape(-1, 1) + + +def numpy_array_as_table(arr: DCNpArrayType): + ndim = arr.ndim + if ndim == 1: + cell_values = numpy_1d_array_as_table(arr) + elif ndim > 2: + raise ValueError("MATRIX_VIEW can process only 2D arrays!") + else: + row_shape, col_shape = arr.shape + cell_values = numpy_2d_array_as_table(arr, row_shape, col_shape, d_dot) + return cell_values + + +@flojoy +def MATRIX_VIEW(default: OrderedPair | Matrix) -> Plotly: + + + if isinstance(default, Matrix): + np_arr = default.m + cell_values = numpy_array_as_table(np_arr) + else: + np_arr = default.y + cell_values = numpy_array_as_table(np_arr) + + fig = go.Figure( + data=[ + go.Table( + header=dict(line={"width": 0}, values=[]), + cells=dict( + values=cell_values, + line={"width": 3}, + font={"size": FONT_SIZE}, + height=CELL_SIZE, + align="center", + format=[".3"], + ), + ) + ] + ) + width = MAX_ALLOWED_SHAPE * CELL_SIZE + 80 + height = width + 80 + fig.layout = go.Layout( + autosize=False, + width=width, + height=height, + margin=dict(l=0, r=0, t=0, b=0), + xaxis=dict(visible=False), + yaxis=dict(visible=False), + hovermode="closest", + font=dict(size=FONT_SIZE), + ) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/examples/EX1/app.txt new file mode 100644 index 0000000000..83474a70d9 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/MATRIX_VIEW/examples/EX1/app.txt @@ -0,0 +1,126 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 130, + "height": 130, + "id": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "type": "GENERATORS", + "data": { + "id": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "8" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "8" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": 227.31148151690388, + "y": 171.0485680935967 + }, + "selected": false, + "positionAbsolute": { + "x": 227.31148151690388, + "y": 171.0485680935967 + }, + "dragging": true + }, + { + "width": 240, + "height": 260, + "id": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "type": "VISUALIZERS", + "data": { + "id": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "label": "MATRIX VIEW", + "func": "MATRIX_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\DATA_STRUCTURE\\MATRIX_VIEW\\MATRIX_VIEW.py", + "selected": false + }, + "position": { + "x": 611.6471944648578, + "y": 95.620522779557 + }, + "selected": false, + "positionAbsolute": { + "x": 611.6471944648578, + "y": 95.620522779557 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "MATRIX-957da30a-8624-44d8-93fb-51ec90f92485", + "sourceHandle": "default", + "target": "MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498a", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-957da30a-8624-44d8-93fb-51ec90f92485default-MATRIX_VIEW-33a3d38e-93b1-4e33-9789-9f457d04498adefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..0fe92f7f5b --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The TEXT_VIEW node creates a text visualization for a given TextBlob DataContainer type. + +Inputs +------ +default : TextBlob + the DataContainer to be visualized in text format + +Outputs +------- +TextBlob + the DataContainer containing text data diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..16cd9891c1 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/a1-[autogen]/python_code.txt @@ -0,0 +1,8 @@ +from flojoy import flojoy, TextBlob + + +@flojoy +def TEXT_VIEW(default: TextBlob): + + + return default diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..d08405404d --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The BAR node creates a Plotly Bar visualization for a given input data container. + +Inputs +------ +default : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized in bar chart + +Outputs +------- +Plotly + the DataContainer containing Plotly Bar chart visualization diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..296115e3a2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/a1-[autogen]/python_code.txt @@ -0,0 +1,67 @@ +from flojoy import flojoy, OrderedPair, DataFrame, Matrix, Plotly, Vector +import plotly.graph_objects as go +import pandas as pd +from flojoy_nodes.VISUALIZERS.template import plot_layout +import numpy as np + + +@flojoy +def BAR(default: OrderedPair | DataFrame | Matrix | Vector) -> Plotly: + + + layout = plot_layout(title="BAR") + fig = go.Figure(layout=layout) + + match default: + case OrderedPair(): + x = default.x + if isinstance(default.x, dict): + dict_keys = list(default.x.keys()) + x = default.x[dict_keys[0]] + y = default.y + fig.add_trace(go.Bar(x=x, y=y)) + case DataFrame(): + df = default.m + first_col = df.iloc[:, 0] + is_timeseries = False + if pd.api.types.is_datetime64_any_dtype(first_col): + is_timeseries = True + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace( + go.Bar( + y=df[col].values, + x=first_col, + name=col, + ) + ) + fig.update_layout(xaxis_title=df.columns[0]) + else: + for col in df.columns: + if df[col].dtype == "object": + counts = df[col].value_counts() + fig.add_trace( + go.Bar(x=counts.index.tolist(), y=counts.tolist(), name=col) + ) + else: + fig.add_trace(go.Bar(x=df.index, y=df[col], name=col)) + fig.update_layout(xaxis_title="DF index", yaxis_title="Y Axis") + + case Matrix(): + m = default.m + + num_rows, num_cols = m.shape + + x_ticks = np.arange(num_cols) + + for i in range(num_rows): + fig.add_trace(go.Bar(x=x_ticks, y=m[i, :], name=f"Row {i+1}")) + + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = default.v + x = np.arange(len(y)) + fig.add_trace(go.Bar(x=x, y=y)) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/examples/EX1/app.txt new file mode 100644 index 0000000000..4e4ae1543e --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BAR/examples/EX1/app.txt @@ -0,0 +1,319 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "TIMESERIES-305de524-fd3a-422d-bdf1-31d59094fec3", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-305de524-fd3a-422d-bdf1-31d59094fec3", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\TIMESERIES\\TIMESERIES.py", + "selected": false + }, + "position": { + "x": -63.304829660611006, + "y": 109.24551147270125 + }, + "selected": false, + "positionAbsolute": { + "x": -63.304829660611006, + "y": 109.24551147270125 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "MATRIX-a9b94d12-79cd-41b8-bac6-e764b105f4fa", + "type": "GENERATORS", + "data": { + "id": "MATRIX-a9b94d12-79cd-41b8-bac6-e764b105f4fa", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "8" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "8" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": -89.90574242528106, + "y": 369.53768944496886 + }, + "selected": false, + "positionAbsolute": { + "x": -89.90574242528106, + "y": 369.53768944496886 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "PLOTLY_DATASET-db79195b-b335-4d6e-b159-66385db68a90", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-db79195b-b335-4d6e-b159-66385db68a90", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "wind" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -69.19136719039435, + "y": 630.5641699791069 + }, + "selected": false, + "positionAbsolute": { + "x": -69.19136719039435, + "y": 630.5641699791069 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "BAR-a91c1fd4-ed0a-4c99-bb22-609ffa2299ca", + "type": "VISUALIZERS", + "data": { + "id": "BAR-a91c1fd4-ed0a-4c99-bb22-609ffa2299ca", + "label": "BAR", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BAR\\BAR.py", + "selected": false + }, + "position": { + "x": 289.7569908907779, + "y": 24.93517972661823 + }, + "selected": false, + "positionAbsolute": { + "x": 289.7569908907779, + "y": 24.93517972661823 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "BAR-67887c6e-5070-4f8b-a453-6f17094bab99", + "type": "VISUALIZERS", + "data": { + "id": "BAR-67887c6e-5070-4f8b-a453-6f17094bab99", + "label": "BAR 1", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BAR\\BAR.py", + "selected": false + }, + "position": { + "x": 348.3808606913409, + "y": 531.4079284287167 + }, + "selected": false, + "positionAbsolute": { + "x": 348.3808606913409, + "y": 531.4079284287167 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "BAR-25c3fe48-8421-43df-9cb9-24d38dc92f35", + "type": "VISUALIZERS", + "data": { + "id": "BAR-25c3fe48-8421-43df-9cb9-24d38dc92f35", + "label": "BAR 2", + "func": "BAR", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BAR\\BAR.py", + "selected": false + }, + "position": { + "x": 657.6937400125055, + "y": 249.8464792652676 + }, + "selected": false, + "positionAbsolute": { + "x": 657.6937400125055, + "y": 249.8464792652676 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-305de524-fd3a-422d-bdf1-31d59094fec3", + "sourceHandle": "default", + "target": "BAR-a91c1fd4-ed0a-4c99-bb22-609ffa2299ca", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-305de524-fd3a-422d-bdf1-31d59094fec3default-BAR-a91c1fd4-ed0a-4c99-bb22-609ffa2299cadefault" + }, + { + "source": "MATRIX-a9b94d12-79cd-41b8-bac6-e764b105f4fa", + "sourceHandle": "default", + "target": "BAR-25c3fe48-8421-43df-9cb9-24d38dc92f35", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-a9b94d12-79cd-41b8-bac6-e764b105f4fadefault-BAR-25c3fe48-8421-43df-9cb9-24d38dc92f35default" + }, + { + "source": "PLOTLY_DATASET-db79195b-b335-4d6e-b159-66385db68a90", + "sourceHandle": "default", + "target": "BAR-67887c6e-5070-4f8b-a453-6f17094bab99", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-db79195b-b335-4d6e-b159-66385db68a90default-BAR-67887c6e-5070-4f8b-a453-6f17094bab99default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..f94e9e2fe4 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/docstring.txt @@ -0,0 +1,23 @@ + +The BIG_NUMBER node generates a Plotly figure, displaying a big number with an optional prefix and suffix. + +Inputs +------ +default : OrderedPair|Scalar|Vector + the DataContainer to be visualized + +Parameters +---------- +relative_delta : bool + whether to show relative delta from last run along with big number +suffix : str + any suffix to show with big number +prefix : str + any prefix to show with big number +title : str + title of the plot, default "BIG_NUMBER" + +Outputs +------- +Plotly + the DataContainer containing Plotly big number visualization diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..8fa08eb625 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/a1-[autogen]/python_code.txt @@ -0,0 +1,58 @@ +from flojoy import ( + flojoy, + Plotly, + OrderedPair, + DefaultParams, + SmallMemory, + Scalar, + Vector, +) +import plotly.graph_objects as go +from flojoy_nodes.VISUALIZERS.template import plot_layout + +MEMORY_KEY = "BIG_NUMBER_MEMORY_KEY" + + +@flojoy(inject_node_metadata=True) +def BIG_NUMBER( + default: OrderedPair | Scalar | Vector, + default_params: DefaultParams, + suffix: str, + prefix: str, + title: str, + relative_delta: bool = True, +) -> Plotly: + + + job_id = default_params.job_id + node_name = __name__.split(".")[-1] + layout = plot_layout(title=title if title else node_name) + fig = go.Figure(layout=layout) + + prev_num = SmallMemory().read_memory(job_id, MEMORY_KEY) + match default: + case OrderedPair(): + big_num = default.y[-1] + case Scalar(): + big_num = default.c + case Vector(): + big_num = default.v[-1] + val_format = ".1%" if relative_delta is True else ".1f" + fig.add_trace( + go.Indicator( + mode="number+delta", + value=int(float(big_num)), + domain={"y": [0, 1], "x": [0, 1]}, + number={"prefix": prefix, "suffix": suffix}, + delta=None + if prev_num is None + else { + "reference": int(float(prev_num)), + "relative": relative_delta, + "valueformat": val_format, + }, + ) + ) + SmallMemory().write_to_memory(job_id, MEMORY_KEY, str(float(big_num))) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/examples/EX1/app.txt new file mode 100644 index 0000000000..1d4c362a06 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/examples/EX1/app.txt @@ -0,0 +1,447 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-69bc9f1e-8cc8-4878-b6a4-d9a06dd33a9a", + "type": "default", + "data": { + "id": "LINSPACE-69bc9f1e-8cc8-4878-b6a4-d9a06dd33a9a", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\LINSPACE\\LINSPACE.py", + "selected": false + }, + "position": { + "x": -452.9499886926942, + "y": 298.72664620965077 + }, + "selected": false, + "positionAbsolute": { + "x": -452.9499886926942, + "y": 298.72664620965077 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "LOOP-d294c908-88a7-4f19-8446-9a68061e1f14", + "type": "LOGIC_GATES", + "data": { + "id": "LOOP-d294c908-88a7-4f19-8446-9a68061e1f14", + "label": "LOOP", + "func": "LOOP", + "type": "LOGIC_GATES", + "ctrls": { + "num_loops": { + "type": "int", + "default": -1, + "functionName": "LOOP", + "param": "num_loops", + "value": "5" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "body", + "id": "body", + "type": "Any" + }, + { + "name": "end", + "id": "end", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\LOGIC_GATES\\LOOPS\\LOOP\\LOOP.py", + "selected": false + }, + "position": { + "x": -147.23570297840854, + "y": 294.4409319239364 + }, + "selected": false, + "positionAbsolute": { + "x": -147.23570297840854, + "y": 294.4409319239364 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697", + "label": "2.0", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "2.0" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 199.90715416444874, + "y": 361.5837890667936 + }, + "selected": false, + "positionAbsolute": { + "x": 199.90715416444874, + "y": 361.5837890667936 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "type": "GENERATORS", + "data": { + "id": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "label": "FEEDBACK", + "func": "FEEDBACK", + "type": "GENERATORS", + "ctrls": { + "referred_node": { + "type": "NodeReference", + "default": "", + "functionName": "FEEDBACK", + "param": "referred_node", + "value": "MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\FEEDBACK\\FEEDBACK.py", + "selected": false + }, + "position": { + "x": 357.0500113073058, + "y": 160.15521763822215 + }, + "selected": false, + "positionAbsolute": { + "x": 357.0500113073058, + "y": 160.15521763822215 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460b", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460b", + "label": "4", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "functionName": "CONSTANT", + "param": "constant", + "value": "4" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\CONSTANT\\CONSTANT.py", + "selected": false + }, + "position": { + "x": 122.76429702159146, + "y": 161.5837890667936 + }, + "selected": false, + "positionAbsolute": { + "x": 122.76429702159146, + "y": 161.5837890667936 + }, + "dragging": true + }, + { + "width": 99, + "height": 130, + "id": "MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0", + "type": "ARITHMETIC", + "data": { + "id": "MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0", + "label": "MULTIPLY", + "func": "MULTIPLY", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair", + "multiple": false + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair", + "multiple": true + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\TRANSFORMERS\\ARITHMETIC\\MULTIPLY\\MULTIPLY.py", + "selected": false + }, + "position": { + "x": 570.4750031587071, + "y": 341.0720464297038 + }, + "selected": false, + "positionAbsolute": { + "x": 570.4750031587071, + "y": 341.0720464297038 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "BIG_NUMBER-da31944f-c5f5-461e-a3c2-fe4432f870d6", + "type": "VISUALIZERS", + "data": { + "id": "BIG_NUMBER-da31944f-c5f5-461e-a3c2-fe4432f870d6", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", + "type": "VISUALIZERS", + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\BIG_NUMBER\\BIG_NUMBER.py", + "selected": false + }, + "position": { + "x": 707.7018181456433, + "y": 74.73630300474275 + }, + "selected": false, + "positionAbsolute": { + "x": 707.7018181456433, + "y": 74.73630300474275 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-69bc9f1e-8cc8-4878-b6a4-d9a06dd33a9a", + "sourceHandle": "default", + "target": "LOOP-d294c908-88a7-4f19-8446-9a68061e1f14", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-69bc9f1e-8cc8-4878-b6a4-d9a06dd33a9adefault-LOOP-d294c908-88a7-4f19-8446-9a68061e1f14default" + }, + { + "source": "LOOP-d294c908-88a7-4f19-8446-9a68061e1f14", + "sourceHandle": "body", + "target": "CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-d294c908-88a7-4f19-8446-9a68061e1f14body-CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697default" + }, + { + "source": "LOOP-d294c908-88a7-4f19-8446-9a68061e1f14", + "sourceHandle": "body", + "target": "CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460b", + "targetHandle": "default", + "id": "reactflow__edge-LOOP-d294c908-88a7-4f19-8446-9a68061e1f14body-CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460bdefault" + }, + { + "source": "CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460b", + "sourceHandle": "default", + "target": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "targetHandle": "default", + "id": "reactflow__edge-CONSTANT-2c2b2a67-fa77-41db-9f40-f6bad42c460bdefault-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault" + }, + { + "source": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "sourceHandle": "default", + "target": "MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0", + "targetHandle": "a", + "id": "reactflow__edge-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault-MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0a" + }, + { + "source": "CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697", + "sourceHandle": "default", + "target": "MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0", + "targetHandle": "b", + "id": "reactflow__edge-CONSTANT-b7112c9c-029c-4899-bd7f-ae304c690697default-MULTIPLY-de5357d2-7121-4297-9f04-d46406df63f0b" + }, + { + "source": "FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139e", + "sourceHandle": "default", + "target": "BIG_NUMBER-da31944f-c5f5-461e-a3c2-fe4432f870d6", + "targetHandle": "default", + "id": "reactflow__edge-FEEDBACK-f81e0c07-98f4-4f31-b5b3-7a32118d139edefault-BIG_NUMBER-da31944f-c5f5-461e-a3c2-fe4432f870d6default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..8853ed3905 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/docstring.txt @@ -0,0 +1,22 @@ + +The COMPOSITE node creates a combination of Plotly visualizations for a given input data container. + +Inputs +------ +primary_trace : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized as the first figure + +secondary_trace : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized as the second figure + +Parameters +---------- +first_figure : 'bar' | 'line' | 'histogram' | 'scatter' + plotly type to display as the first figure, default is 'scatter' +second_figure : 'bar' | 'line' | 'histogram' | 'scatter' + plotly type to display as the second figure, default is 'line' + +Outputs +------- +Plotly + the DataContainer containing Plotly visualization of both figures diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..dc8103f095 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/a1-[autogen]/python_code.txt @@ -0,0 +1,198 @@ +from flojoy import flojoy, OrderedPair, DataFrame, Matrix, Plotly, Vector +import plotly.graph_objects as go +import pandas as pd +import numpy as np +from flojoy_nodes.VISUALIZERS.template import plot_layout +from typing import Literal + + +@flojoy +def COMPOSITE( + primary_trace: OrderedPair | DataFrame | Matrix | Vector, + secondary_trace: OrderedPair | DataFrame | Matrix | Vector, + first_figure: Literal["bar", "line", "histogram", "scatter"] = "scatter", + second_figure: Literal["bar", "line", "histogram", "scatter"] = "line", +) -> Plotly: + + + layout = plot_layout(title="COMPOSITE") + fig = go.Figure(layout=layout) + match_figure(fig, first_figure, primary_trace) + match_figure(fig, second_figure, secondary_trace) + + fig.update_layout(dict(autosize=True, height=None, width=None)) + return Plotly(fig=fig) + + +def match_figure( + fig: go.Figure, + figure_type: Literal["bar", "line", "histogram", "scatter"], + dc: OrderedPair | Matrix | DataFrame | Vector, +): + match figure_type: + case "bar": + add_bar_trace(fig, dc) + case "histogram": + add_histogram_trace(fig, dc) + case "line": + add_line_trace(fig, dc) + case "scatter": + add_scatter_trace(fig, dc) + + +def add_bar_trace(fig: go.Figure, dc: OrderedPair | Matrix | DataFrame | Vector): + match dc: + case DataFrame(): + df = dc.m + first_col = df.iloc[:, 0] + is_timeseries = False + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace(go.Bar(y=df[col].values, x=first_col, name=col)) + fig.update_layout(xaxis_title=df.columns[0]) + else: + for col in df.columns: + if df[col].dtype == "object": + counts = df[col].value_counts() + fig.add_trace( + go.Bar( + x=counts.index.tolist(), + y=counts.tolist(), + name=col, + ) + ) + else: + fig.add_trace(go.Bar(x=df.index, y=df[col], name=col)) + fig.update_layout(xaxis_title="DF index", yaxis_title="Y Axis") + case OrderedPair(): + x = dc.x + if isinstance(dc.x, dict): + dict_keys = list(dc.x.keys()) + x = dc.x[dict_keys[0]] + y = dc.y + fig.add_trace(go.Bar(x=x, y=y)) + case Matrix(): + m = dc.m + num_rows, num_cols = m.shape + x_ticks = np.arange(num_cols) + + for i in range(num_rows): + fig.add_trace(go.Bar(x=x_ticks, y=m[i, :], name=f"Row {i+1}")) + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = dc.v + x = np.arange(len(y)) + fig.add_trace(go.Bar(x=x, y=y)) + + +def add_histogram_trace(fig: go.Figure, dc: OrderedPair | Matrix | DataFrame | Vector): + match dc: + case DataFrame(): + df = dc.m + for col in df.columns: + fig.add_trace(go.Histogram(x=df[col], name=col)) + fig.update_layout(xaxis_title="Value", yaxis_title="Frequency") + case OrderedPair(): + y = dc.y + fig.add_trace(go.Histogram(x=y)) + case Matrix(): + m = dc.m + histogram_trace = go.Histogram(x=m.flatten()) + fig.add_trace(histogram_trace) + case Vector(): + y = dc.v + fig.add_trace(go.Histogram(x=y)) + + +def add_line_trace(fig: go.Figure, dc: OrderedPair | Matrix | DataFrame | Vector): + match dc: + case DataFrame(): + df = dc.m + first_col = df.iloc[:, 0] + is_timeseries = False + if pd.api.types.is_datetime64_any_dtype(first_col): + is_timeseries = True + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace( + go.Scatter( + y=df[col].values, + x=first_col, + mode="lines", + name=col, + ) + ) + else: + for col in df.columns: + fig.add_trace( + go.Scatter( + y=df[col].values, + x=df.index, + mode="lines", + name=col, + ) + ) + case OrderedPair(): + x = dc.x + if isinstance(dc.x, dict): + dict_keys = list(dc.x.keys()) + x = dc.x[dict_keys[0]] + y = dc.y + fig.add_trace(go.Scatter(x=x, y=y, mode="lines")) + case Matrix(): + m = dc.m + num_rows, num_cols = m.shape + x_ticks = np.arange(num_cols) + for i in range(num_rows): + fig.add_trace( + go.Scatter(x=x_ticks, y=m[i, :], name=f"Row {i+1}", mode="lines") + ) + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = dc.v + x = np.arange(len(y)) + fig.add_trace(go.Scatter(x=x, y=y, mode="lines")) + + +def add_scatter_trace(fig: go.Figure, dc: OrderedPair | Matrix | DataFrame | Vector): + match dc: + case OrderedPair(): + x = dc.x + if isinstance(dc.x, dict): + dict_keys = list(dc.x.keys()) + x = dc.x[dict_keys[0]] + y = dc.y + fig.add_trace(go.Scatter(x=x, y=y, mode="markers", marker=dict(size=4))) + case DataFrame(): + df = dc.m + first_col = df.iloc[:, 0] + is_timeseries = False + if pd.api.types.is_datetime64_any_dtype(first_col): + is_timeseries = True + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace( + go.Scatter(x=first_col, y=df[col], mode="markers", name=col) + ) + else: + for col in df.columns: + fig.add_trace( + go.Scatter(x=df.index, y=df[col], mode="markers", name=col) + ) + case Matrix(): + m = dc.m + num_rows, num_cols = m.shape + x_ticks = np.arange(num_cols) + for i in range(num_rows): + fig.add_trace( + go.Scatter(x=x_ticks, y=m[i, :], name=f"Row {i+1}", mode="markers") + ) + + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = dc.v + x = np.arange(len(y)) + fig.add_trace(go.Scatter(x=x, y=y, mode="markers", marker=dict(size=4))) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/examples/EX1/app.txt new file mode 100644 index 0000000000..2eb8d1b21d --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/COMPOSITE/examples/EX1/app.txt @@ -0,0 +1,358 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 180, + "id": "LINSPACE-9f7d65a9-2b57-481e-8fec-675fd6a27c4c", + "type": "default", + "data": { + "id": "LINSPACE-9f7d65a9-2b57-481e-8fec-675fd6a27c4c", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "desc": null, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "desc": null, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "LINSPACE", + "param": "step", + "value": "300" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": -66.43604164074642, + "y": -68.3746613701575 + }, + "selected": false, + "positionAbsolute": { + "x": -66.43604164074642, + "y": -68.3746613701575 + }, + "dragging": true + }, + { + "width": 208, + "height": 132, + "id": "PLOTLY_DATASET-b564f0e8-b1ae-4315-b43c-737bc2173d0a", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-b564f0e8-b1ae-4315-b43c-737bc2173d0a", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "desc": null, + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SAMPLE_DATASETS/PLOTLY_DATASET/PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -106.64021374014129, + "y": 145.3514779489801 + }, + "selected": false, + "positionAbsolute": { + "x": -106.64021374014129, + "y": 145.3514779489801 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217", + "type": "VISUALIZERS", + "data": { + "id": "COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217", + "label": "COMPOSITE", + "func": "COMPOSITE", + "type": "VISUALIZERS", + "ctrls": { + "first_figure": { + "type": "select", + "default": "scatter", + "options": [ + "bar", + "line", + "histogram", + "scatter" + ], + "desc": null, + "functionName": "COMPOSITE", + "param": "first_figure", + "value": "line" + }, + "second_figure": { + "type": "select", + "default": "scatter", + "options": [ + "bar", + "line", + "histogram", + "scatter" + ], + "desc": null, + "functionName": "COMPOSITE", + "param": "second_figure", + "value": "scatter" + } + }, + "inputs": [ + { + "name": "primary_trace", + "id": "primary_trace", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + }, + { + "name": "secondary_trace", + "id": "secondary_trace", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": null + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/COMPOSITE/COMPOSITE.py", + "selected": false + }, + "position": { + "x": 350.43881227824863, + "y": -35.91689494861453 + }, + "selected": false, + "positionAbsolute": { + "x": 350.43881227824863, + "y": -35.91689494861453 + }, + "dragging": true + }, + { + "width": 208, + "height": 100, + "id": "CONSTANT-7c624ace-7cb4-40ab-8121-af39ec25f5fb", + "type": "GENERATORS", + "data": { + "id": "CONSTANT-7c624ace-7cb4-40ab-8121-af39ec25f5fb", + "label": "2", + "func": "CONSTANT", + "type": "GENERATORS", + "ctrls": { + "constant": { + "type": "float", + "default": 3, + "desc": null, + "functionName": "CONSTANT", + "param": "constant", + "value": "2" + }, + "step": { + "type": "int", + "default": 1000, + "desc": null, + "functionName": "CONSTANT", + "param": "step", + "value": "300" + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": null + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/CONSTANT/CONSTANT.py", + "selected": false + }, + "position": { + "x": -106.8907422401193, + "y": -197.052576359828 + }, + "selected": false, + "positionAbsolute": { + "x": -106.8907422401193, + "y": -197.052576359828 + }, + "dragging": true + }, + { + "width": 72, + "height": 72, + "id": "ADD-d7f9c6e1-013c-46ed-962d-680dc412e944", + "type": "ARITHMETIC", + "data": { + "id": "ADD-d7f9c6e1-013c-46ed-962d-680dc412e944", + "label": "ADD", + "func": "ADD", + "type": "ARITHMETIC", + "ctrls": {}, + "inputs": [ + { + "name": "a", + "id": "a", + "type": "OrderedPair|Scalar|Vector", + "multiple": false, + "desc": null + }, + { + "name": "b", + "id": "b", + "type": "OrderedPair|Scalar|Vector", + "multiple": true, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Scalar|Vector", + "desc": null + } + ], + "path": "PYTHON/nodes/TRANSFORMERS/ARITHMETIC/ADD/ADD.py", + "selected": false + }, + "position": { + "x": 161.5017601761473, + "y": -92.92555379325714 + }, + "selected": false, + "positionAbsolute": { + "x": 161.5017601761473, + "y": -92.92555379325714 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONSTANT-7c624ace-7cb4-40ab-8121-af39ec25f5fb", + "sourceHandle": "default", + "target": "ADD-d7f9c6e1-013c-46ed-962d-680dc412e944", + "targetHandle": "a", + "id": "reactflow__edge-CONSTANT-7c624ace-7cb4-40ab-8121-af39ec25f5fbdefault-ADD-d7f9c6e1-013c-46ed-962d-680dc412e944a" + }, + { + "source": "LINSPACE-9f7d65a9-2b57-481e-8fec-675fd6a27c4c", + "sourceHandle": "default", + "target": "ADD-d7f9c6e1-013c-46ed-962d-680dc412e944", + "targetHandle": "b", + "id": "reactflow__edge-LINSPACE-9f7d65a9-2b57-481e-8fec-675fd6a27c4cdefault-ADD-d7f9c6e1-013c-46ed-962d-680dc412e944b" + }, + { + "source": "ADD-d7f9c6e1-013c-46ed-962d-680dc412e944", + "sourceHandle": "default", + "target": "COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217", + "targetHandle": "primary_trace", + "id": "reactflow__edge-ADD-d7f9c6e1-013c-46ed-962d-680dc412e944default-COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217primary_trace" + }, + { + "source": "PLOTLY_DATASET-b564f0e8-b1ae-4315-b43c-737bc2173d0a", + "sourceHandle": "default", + "target": "COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217", + "targetHandle": "secondary_trace", + "id": "reactflow__edge-PLOTLY_DATASET-b564f0e8-b1ae-4315-b43c-737bc2173d0adefault-COMPOSITE-b6def6e5-2c37-4da4-9e3c-395873927217secondary_trace" + } + ], + "viewport": { + "x": 547.784939185504, + "y": 240.2714794602041, + "zoom": 0.9407196048144776 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e07b0366bd --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The HISTOGRAM node creates a Plotly Histogram visualization for a given input data container. + +Inputs +------ +default : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly Histogram visualization diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..d46d44ee45 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/a1-[autogen]/python_code.txt @@ -0,0 +1,32 @@ +import pandas as pd +import plotly.graph_objects as go +from flojoy import flojoy, OrderedPair, DataFrame, Matrix, Plotly, Vector +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def HISTOGRAM(default: OrderedPair | DataFrame | Matrix | Vector) -> Plotly: + + layout = plot_layout(title="HISTOGRAM") + fig = go.Figure(layout=layout) + + match default: + case OrderedPair(): + y = default.y + fig.add_trace(go.Histogram(x=y)) + case DataFrame(): + df = pd.DataFrame(default.m) + for col in df.columns: + fig.add_trace(go.Histogram(x=df[col], name=col)) + + fig.update_layout(xaxis_title="Value", yaxis_title="Frequency") + case Matrix(): + m = default.m + flattened_matrix = m.flatten() + histogram_trace = go.Histogram(x=flattened_matrix) + fig = fig.add_trace(histogram_trace) + case Vector(): + v = default.v + fig.add_trace(go.Histogram(x=v)) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/examples/EX1/app.txt new file mode 100644 index 0000000000..f0b602e3b8 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/HISTOGRAM/examples/EX1/app.txt @@ -0,0 +1,319 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "TIMESERIES-1f113e5c-ee47-4e67-a040-ed8107f98095", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-1f113e5c-ee47-4e67-a040-ed8107f98095", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\TIMESERIES\\TIMESERIES.py", + "selected": false + }, + "position": { + "x": -7.7821224453163325, + "y": 48.813887088913134 + }, + "selected": false, + "positionAbsolute": { + "x": -7.7821224453163325, + "y": 48.813887088913134 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "MATRIX-bb1dc76f-50a7-4e4d-94f2-66c729fef752", + "type": "GENERATORS", + "data": { + "id": "MATRIX-bb1dc76f-50a7-4e4d-94f2-66c729fef752", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "10" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "10" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": -136.49306026080123, + "y": 497.03098149496736 + }, + "selected": false, + "positionAbsolute": { + "x": -136.49306026080123, + "y": 497.03098149496736 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "PLOTLY_DATASET-a2a99924-c20c-40b8-8725-378427432b04", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-a2a99924-c20c-40b8-8725-378427432b04", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -207.3110221141082, + "y": 282.180770332777 + }, + "selected": false, + "positionAbsolute": { + "x": -207.3110221141082, + "y": 282.180770332777 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "HISTOGRAM-e3f0af53-0c45-4457-ae12-7f6eb0327f39", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-e3f0af53-0c45-4457-ae12-7f6eb0327f39", + "label": "HISTOGRAM", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\HISTOGRAM\\HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 132.4645746655445, + "y": 173.27376638391252 + }, + "selected": false, + "positionAbsolute": { + "x": 132.4645746655445, + "y": 173.27376638391252 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "HISTOGRAM-6bb3aef4-a631-4732-931b-b4a71f49557e", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-6bb3aef4-a631-4732-931b-b4a71f49557e", + "label": "HISTOGRAM 1", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\HISTOGRAM\\HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 576.1267979151604, + "y": 390.2182152496157 + }, + "selected": false, + "positionAbsolute": { + "x": 576.1267979151604, + "y": 390.2182152496157 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "HISTOGRAM-3f0b2e7d-3a6c-4d14-a17c-3ba2fe7c0bfa", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-3f0b2e7d-3a6c-4d14-a17c-3ba2fe7c0bfa", + "label": "HISTOGRAM 2", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\HISTOGRAM\\HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 520.1949127052811, + "y": -44.71890278881858 + }, + "selected": false, + "positionAbsolute": { + "x": 520.1949127052811, + "y": -44.71890278881858 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-1f113e5c-ee47-4e67-a040-ed8107f98095", + "sourceHandle": "default", + "target": "HISTOGRAM-3f0b2e7d-3a6c-4d14-a17c-3ba2fe7c0bfa", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-1f113e5c-ee47-4e67-a040-ed8107f98095default-HISTOGRAM-3f0b2e7d-3a6c-4d14-a17c-3ba2fe7c0bfadefault" + }, + { + "source": "PLOTLY_DATASET-a2a99924-c20c-40b8-8725-378427432b04", + "sourceHandle": "default", + "target": "HISTOGRAM-e3f0af53-0c45-4457-ae12-7f6eb0327f39", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-a2a99924-c20c-40b8-8725-378427432b04default-HISTOGRAM-e3f0af53-0c45-4457-ae12-7f6eb0327f39default" + }, + { + "source": "MATRIX-bb1dc76f-50a7-4e4d-94f2-66c729fef752", + "sourceHandle": "default", + "target": "HISTOGRAM-6bb3aef4-a631-4732-931b-b4a71f49557e", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-bb1dc76f-50a7-4e4d-94f2-66c729fef752default-HISTOGRAM-6bb3aef4-a631-4732-931b-b4a71f49557edefault" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..2af80fb3aa --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The IMAGE node creates a Plotly Image visualization for a given input data container type of image. + +Inputs +------ +default : Image + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly Image visualization of the input image diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..755313701e --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/a1-[autogen]/python_code.txt @@ -0,0 +1,24 @@ +from flojoy import flojoy, Image, Plotly +import plotly.express as px +import numpy as np +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def IMAGE(default: Image) -> Plotly: + + + r = default.r + g = default.g + b = default.b + a = default.a + + if a is None: + img_combined = np.stack((r, g, b), axis=2) + else: + img_combined = np.stack((r, g, b, a), axis=2) + layout = plot_layout(title="IMAGE") + fig = px.imshow(img=img_combined) + fig.layout = layout + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/examples/EX1/app.txt new file mode 100644 index 0000000000..3da6b85d8b --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/IMAGE/examples/EX1/app.txt @@ -0,0 +1,143 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "type": "LOADERS", + "data": { + "id": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "label": "LOCAL FILE", + "func": "LOCAL_FILE", + "type": "LOADERS", + "ctrls": { + "file_path": { + "type": "str", + "default": null, + "functionName": "LOCAL_FILE", + "param": "file_path", + "value": "" + }, + "file_type": { + "type": "select", + "default": "Image", + "options": [ + "Image", + "JSON", + "CSV", + "Excel", + "XML" + ], + "functionName": "LOCAL_FILE", + "param": "file_type", + "value": "Image" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Image|DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "xlrd", + "v": "2.0.1" + }, + { + "name": "lxml", + "v": "4.9.2" + } + ], + "path": "PYTHON/nodes\\LOADERS\\LOCAL_FILE_SYSTEM\\LOCAL_FILE\\LOCAL_FILE.py", + "selected": false + }, + "position": { + "x": 118.33279169679147, + "y": 120.20549002582902 + }, + "selected": false, + "positionAbsolute": { + "x": 118.33279169679147, + "y": 120.20549002582902 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "type": "VISUALIZERS", + "data": { + "id": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "label": "IMAGE", + "func": "IMAGE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Image", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\IMAGE\\IMAGE.py", + "selected": false + }, + "position": { + "x": 561.2984590249878, + "y": 85.72712333520752 + }, + "selected": false, + "positionAbsolute": { + "x": 561.2984590249878, + "y": 85.72712333520752 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6d", + "sourceHandle": "default", + "target": "IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5", + "targetHandle": "default", + "id": "reactflow__edge-LOCAL_FILE-f21874a3-6a2f-4f64-ae87-faebdfba5c6ddefault-IMAGE-c69df1a9-06a0-41aa-beb2-41bc8a400ed5default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..6769734586 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The LINE node creates a Plotly Line visualization for a given input data container. + +Inputs +------ +default : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly Line visualization of the input data diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..75e819c7be --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/a1-[autogen]/python_code.txt @@ -0,0 +1,68 @@ +from flojoy import flojoy, Plotly, OrderedPair, DataFrame, Matrix, Vector +import numpy as np +import plotly.graph_objects as go +import pandas as pd +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def LINE(default: OrderedPair | DataFrame | Matrix | Vector) -> Plotly: + + layout = plot_layout(title="LINE") + fig = go.Figure(layout=layout) + + match default: + case OrderedPair(): + x = default.x + if isinstance(default.x, dict): + dict_keys = list(default.x.keys()) + x = default.x[dict_keys[0]] + y = default.y + fig.add_trace(go.Scatter(x=x, y=y, mode="lines")) + case DataFrame(): + df = default.m + first_col = df.iloc[:, 0] + is_timeseries = False + if pd.api.types.is_datetime64_any_dtype(first_col): + is_timeseries = True + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace( + go.Scatter( + y=df[col].values, + x=first_col, + mode="lines", + name=col, + ) + ) + else: + for col in df.columns: + fig.add_trace( + go.Scatter( + y=df[col].values, + x=df.index, + mode="lines", + name=col, + ) + ) + + case Matrix(): + m = default.m + + num_rows, num_cols = m.shape + + x_ticks = np.arange(num_cols) + + for i in range(num_rows): + fig.add_trace( + go.Scatter(x=x_ticks, y=m[i, :], name=f"Row {i+1}", mode="lines") + ) + + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = default.v + x = np.arange(len(y)) + fig.add_trace(go.Scatter(x=x, y=y, mode="lines")) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/examples/EX1/app.txt new file mode 100644 index 0000000000..90ddf52d8e --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/LINE/examples/EX1/app.txt @@ -0,0 +1,396 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "MATRIX-adb7407c-2ba3-4478-8c1a-2c0d2dc1f095", + "type": "GENERATORS", + "data": { + "id": "MATRIX-adb7407c-2ba3-4478-8c1a-2c0d2dc1f095", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "8" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "8" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": 83.36011635478266, + "y": 444.9631272301297 + }, + "selected": false, + "positionAbsolute": { + "x": 83.36011635478266, + "y": 444.9631272301297 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "R_DATASET-6c382bcf-a72e-488d-a784-eb21cb00839a", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-6c382bcf-a72e-488d-a784-eb21cb00839a", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\R_DATASET\\R_DATASET.py", + "selected": false + }, + "position": { + "x": 96.13358497687051, + "y": 215.36594613774037 + }, + "selected": false, + "positionAbsolute": { + "x": 96.13358497687051, + "y": 215.36594613774037 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "TIMESERIES-511ecdda-9fd1-443e-95bb-2399e69b6484", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-511ecdda-9fd1-443e-95bb-2399e69b6484", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\TIMESERIES\\TIMESERIES.py", + "selected": false + }, + "position": { + "x": 61.722775228768, + "y": 2.6454783507012394 + }, + "selected": false, + "positionAbsolute": { + "x": 61.722775228768, + "y": 2.6454783507012394 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-b77bfca4-130d-46b6-9962-f53f605d7107", + "type": "VISUALIZERS", + "data": { + "id": "LINE-b77bfca4-130d-46b6-9962-f53f605d7107", + "label": "LINE 1", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 469.8687147537621, + "y": 362.50128832181895 + }, + "selected": false, + "positionAbsolute": { + "x": 469.8687147537621, + "y": 362.50128832181895 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-fba98010-ffc1-4864-8a5a-356f46f70a26", + "type": "VISUALIZERS", + "data": { + "id": "LINE-fba98010-ffc1-4864-8a5a-356f46f70a26", + "label": "LINE 2", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 762.7310457743708, + "y": 116.02468713396252 + }, + "selected": false, + "positionAbsolute": { + "x": 762.7310457743708, + "y": 116.02468713396252 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-be1cb8d9-dc67-4567-8952-8b7eaeb9134d", + "type": "VISUALIZERS", + "data": { + "id": "LINE-be1cb8d9-dc67-4567-8952-8b7eaeb9134d", + "label": "LINE 3", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\LINE\\LINE.py", + "selected": false + }, + "position": { + "x": 403.6067599272868, + "y": -57.773384759895634 + }, + "selected": false, + "positionAbsolute": { + "x": 403.6067599272868, + "y": -57.773384759895634 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-511ecdda-9fd1-443e-95bb-2399e69b6484", + "sourceHandle": "default", + "target": "LINE-be1cb8d9-dc67-4567-8952-8b7eaeb9134d", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-511ecdda-9fd1-443e-95bb-2399e69b6484default-LINE-be1cb8d9-dc67-4567-8952-8b7eaeb9134ddefault" + }, + { + "source": "R_DATASET-6c382bcf-a72e-488d-a784-eb21cb00839a", + "sourceHandle": "default", + "target": "LINE-fba98010-ffc1-4864-8a5a-356f46f70a26", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-6c382bcf-a72e-488d-a784-eb21cb00839adefault-LINE-fba98010-ffc1-4864-8a5a-356f46f70a26default" + }, + { + "source": "MATRIX-adb7407c-2ba3-4478-8c1a-2c0d2dc1f095", + "sourceHandle": "default", + "target": "LINE-b77bfca4-130d-46b6-9962-f53f605d7107", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-adb7407c-2ba3-4478-8c1a-2c0d2dc1f095default-LINE-b77bfca4-130d-46b6-9962-f53f605d7107default" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..62c786cb21 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/docstring.txt @@ -0,0 +1,30 @@ + +The PROPHET_COMPONENTS node plots the components of the prophet model trained in the PROPHET_PREDICT node. +This is the output plotly graph from the "plot_components_plotly" function from "prophet.plot". +It expects the trained Prophet model from the PROPHET_PREDICT node as input. + +If "run_forecast" was True in that node, the forecasted dataframe will be available in "m" attribute of default input. +Otherwise, this will make the predictions on the raw dataframe (in which case it will be the "m" attribute of default input). + +You can tell if that forecasted dataframe is available via the "extra" field of data input - "run_forecast", (data.extra["run_forecast"]). + +Inputs +------ +default : DataFrame + the DataContainer to be visualized + +data : DataContainer + the DataContainer that holds prophet model and forecast data in the `extra` field + + +Parameters +---------- +periods : int + The number of periods out to predict. + Only used if the node passed into this node (i.e. PROPHET_PREDICT) did NOT return the forecast. + If the forecast was included in the DataContainer, this parameter will be ignored. default is 365 + +Outputs +------- +Plotly + the DataContainer containing Plotly visualization of the prophet model diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..ddf1d25e1b --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/a1-[autogen]/python_code.txt @@ -0,0 +1,92 @@ +from flojoy import flojoy, run_in_venv, DataFrame, Plotly, DataContainer + + +@flojoy +@run_in_venv( + pip_dependencies=[ + "prophet==1.1.4", + ] +) +def PROPHET_COMPONENTS( + default: DataFrame, data: DataContainer, periods: int = 365 +) -> Plotly: + + + import os + import sys + import prophet + + import pandas as pd + import numpy as np + + from prophet.plot import plot_components_plotly + from prophet.serialize import model_from_json + + def _make_dummy_dataframe_for_prophet(): + Generate random time series data to test if prophet works + start_date = pd.Timestamp("2023-01-01") + end_date = pd.Timestamp("2023-07-20") + num_days = (end_date - start_date).days + 1 + timestamps = pd.date_range(start=start_date, end=end_date, freq="D") + data = np.random.randn(num_days) # Random data points + df = pd.DataFrame({"ds": timestamps, "ys": data}) + df.rename( + columns={df.columns[0]: "ds", df.columns[1]: "y"}, inplace=True + ) # PROPHET model expects first column to be `ds` and second to be `y` + return df + + def _apply_macos_prophet_hotfix(): + This is a hotfix for MacOS. See https://github.com/facebook/prophet/issues/2250#issuecomment-1559516328 for more detail + + if sys.platform != "darwin": + return + + # Test if prophet works (i.e. if the hotfix had already been applied) + try: + _dummy_df = _make_dummy_dataframe_for_prophet() + prophet.Prophet().fit(_dummy_df) + except RuntimeError: + print("Could not run prophet, applying hotfix...") + else: + return + + prophet_dir = prophet.__path__[0] # type: ignore + # Get stan dir + stan_dir = os.path.join(prophet_dir, "stan_model") + # Find cmdstan-xxxxx dir + cmdstan_basename = [x for x in os.listdir(stan_dir) if x.startswith("cmdstan")] + assert len(cmdstan_basename) == 1, "Could not find cmdstan dir" + cmdstan_basename = cmdstan_basename[0] + # Run (from stan_dir) : install_name_tool -add_rpath @executable_path//stan/lib/stan_math/lib/tbb prophet_model.bin + cmd = f"install_name_tool -add_rpath @executable_path/{cmdstan_basename}/stan/lib/stan_math/lib/tbb prophet_model.bin" + cwd = os.getcwd() + os.chdir(stan_dir) + return_code = os.system(cmd) + os.chdir(cwd) + if return_code != 0: + raise RuntimeError("Could not apply hotfix") + + _apply_macos_prophet_hotfix() + + extra = data.extra + if not extra or "prophet" not in extra: + raise ValueError( + "Prophet model must be available in DataContainer 'extra' key to plot" + ) + + node_name = __name__.split(".")[-1] + + model = model_from_json(extra["prophet"]) + if extra.get("run_forecast"): + forecast = default.m + else: + future = model.make_future_dataframe(periods=periods) + forecast = model.predict(future) + + fig = plot_components_plotly(model, forecast) + fig.update_layout( + dict(title=node_name, autosize=True, template={}, height=None, width=None), + overwrite=True, + ) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/examples/EX1/app.txt new file mode 100644 index 0000000000..3445a61a43 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/examples/EX1/app.txt @@ -0,0 +1,246 @@ +{ + "rfInstance": { + "nodes": [ + { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "type": "AI_ML", + "data": { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "label": "PROPHET PREDICT", + "func": "PROPHET_PREDICT", + "type": "AI_ML", + "ctrls": { + "run_forecast": { + "type": "bool", + "default": true, + "functionName": "PROPHET_PREDICT", + "param": "run_forecast", + "value": true + }, + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PREDICT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/PROPHET_PREDICT.py", + "selected": false + }, + "position": { + "x": 44.19991981803559, + "y": 49.45240668102545 + }, + "width": 150, + "height": 150, + "selected": false + }, + { + "width": 130, + "height": 130, + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TIMESERIES/TIMESERIES.py", + "selected": false + }, + "position": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "selected": false, + "positionAbsolute": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "label": "PROPHET COMPONENTS", + "func": "PROPHET_COMPONENTS", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_COMPONENTS", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/PROPHET_COMPONENTS.py", + "selected": false + }, + "position": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "selected": false, + "positionAbsolute": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "label": "PROPHET PLOT", + "func": "PROPHET_PLOT", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PLOT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/PROPHET_PLOT.py", + "selected": false + }, + "position": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "selected": false, + "positionAbsolute": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "sourceHandle": "default", + "target": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2default-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3default" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60default" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 103.38141914149585, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..2b5ae1901a --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/docstring.txt @@ -0,0 +1,31 @@ + +The PROPHET_PLOT node plots the forecasted trend of the time series data that was passed in. +This is the output plotly graph from the "plot_plotly" function from "prophet.plot". +It expects as input the trained Prophet model from the PROPHET_PREDICT node. + + If "run_forecast" was True in that node, the forecasted dataframe will be available in "m" attribute of default input. +Otherwise, this will make the predictions on the raw dataframe (in which case it will be the "m" attribute of default input). + +You can tell if that forecasted dataframe is available via the "extra" field of data input - "run_forecast", (data.extra["run_forecast"]). + +Inputs +------ +default : DataFrame + the DataContainer to be visualized + +data : DataContainer + the DataContainer that holds prophet model and forecast data in the `extra` field + +Parameters +---------- +periods : int + The number of periods out to predict. + Only used if the node passed into this node (i.e. PROPHET_PREDICT) did NOT return the forecast. + If the forecast was included in the DataContainer, this parameter will be ignored. + + Default = 365 + +Outputs +------- +Plotly + the DataContainer containing Plotly visualization of the prophet model diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..9fa2a46c9a --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/a1-[autogen]/python_code.txt @@ -0,0 +1,89 @@ +from flojoy import flojoy, run_in_venv, DataFrame, Plotly, DataContainer + + +@flojoy(deps={"prophet": "1.1.4", "holidays": "0.26", "pystan": "2.19.1.1"}) +@run_in_venv( + pip_dependencies=[ + "prophet==1.1.4", + ] +) +def PROPHET_PLOT(default: DataFrame, data: DataContainer, periods: int = 365) -> Plotly: + + + import os + import sys + import prophet + + import pandas as pd + import numpy as np + + from prophet.plot import plot_plotly + from prophet.serialize import model_from_json + + def _make_dummy_dataframe_for_prophet(): + Generate random time series data to test if prophet works + start_date = pd.Timestamp("2023-01-01") + end_date = pd.Timestamp("2023-07-20") + num_days = (end_date - start_date).days + 1 + timestamps = pd.date_range(start=start_date, end=end_date, freq="D") + data = np.random.randn(num_days) # Random data points + df = pd.DataFrame({"ds": timestamps, "ys": data}) + df.rename( + columns={df.columns[0]: "ds", df.columns[1]: "y"}, inplace=True + ) # PROPHET model expects first column to be `ds` and second to be `y` + return df + + def _apply_macos_prophet_hotfix(): + This is a hotfix for MacOS. See https://github.com/facebook/prophet/issues/2250#issuecomment-1559516328 for more detail + + if sys.platform != "darwin": + return + + # Test if prophet works (i.e. if the hotfix had already been applied) + try: + _dummy_df = _make_dummy_dataframe_for_prophet() + prophet.Prophet().fit(_dummy_df) + except RuntimeError: + print("Could not run prophet, applying hotfix...") + else: + return + + prophet_dir = prophet.__path__[0] # type: ignore + # Get stan dir + stan_dir = os.path.join(prophet_dir, "stan_model") + # Find cmdstan-xxxxx dir + cmdstan_basename = [x for x in os.listdir(stan_dir) if x.startswith("cmdstan")] + assert len(cmdstan_basename) == 1, "Could not find cmdstan dir" + cmdstan_basename = cmdstan_basename[0] + # Run (from stan_dir) : install_name_tool -add_rpath @executable_path//stan/lib/stan_math/lib/tbb prophet_model.bin + cmd = f"install_name_tool -add_rpath @executable_path/{cmdstan_basename}/stan/lib/stan_math/lib/tbb prophet_model.bin" + cwd = os.getcwd() + os.chdir(stan_dir) + return_code = os.system(cmd) + os.chdir(cwd) + if return_code != 0: + raise RuntimeError("Could not apply hotfix") + + _apply_macos_prophet_hotfix() + + extra = data.extra + if not extra or "prophet" not in extra: + raise ValueError( + "Prophet model must be available in DataContainer 'extra' key to plot" + ) + + node_name = __name__.split(".")[-1] + + model = model_from_json(extra["prophet"]) + if extra.get("run_forecast") is not None: + forecast = default.m + else: + future = model.make_future_dataframe(periods=periods) + forecast = model.predict(future) + fig = plot_plotly(model, forecast) + fig.update_layout( + dict(title=node_name, autosize=True, template={}, height=None, width=None), + overwrite=True, + ) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/examples/EX1/app.txt new file mode 100644 index 0000000000..3445a61a43 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/examples/EX1/app.txt @@ -0,0 +1,246 @@ +{ + "rfInstance": { + "nodes": [ + { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "type": "AI_ML", + "data": { + "id": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "label": "PROPHET PREDICT", + "func": "PROPHET_PREDICT", + "type": "AI_ML", + "ctrls": { + "run_forecast": { + "type": "bool", + "default": true, + "functionName": "PROPHET_PREDICT", + "param": "run_forecast", + "value": true + }, + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PREDICT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/AI_ML/PREDICT_TIME_SERIES/PROPHET_PREDICT/PROPHET_PREDICT.py", + "selected": false + }, + "position": { + "x": 44.19991981803559, + "y": 49.45240668102545 + }, + "width": 150, + "height": 150, + "selected": false + }, + { + "width": 130, + "height": 130, + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TIMESERIES/TIMESERIES.py", + "selected": false + }, + "position": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "selected": false, + "positionAbsolute": { + "x": -270.66778749945627, + "y": 36.19707996443299 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "label": "PROPHET COMPONENTS", + "func": "PROPHET_COMPONENTS", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_COMPONENTS", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_COMPONENTS/PROPHET_COMPONENTS.py", + "selected": false + }, + "position": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "selected": false, + "positionAbsolute": { + "x": 373.3721041848318, + "y": -114.45853015527874 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "type": "VISUALIZERS", + "data": { + "id": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "label": "PROPHET PLOT", + "func": "PROPHET_PLOT", + "type": "VISUALIZERS", + "ctrls": { + "periods": { + "type": "int", + "default": 365, + "functionName": "PROPHET_PLOT", + "param": "periods", + "value": 365 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/PROPHET_PLOT/PROPHET_PLOT.py", + "selected": false + }, + "position": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "selected": false, + "positionAbsolute": { + "x": 361.84400062339495, + "y": 269.6217029641205 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2", + "sourceHandle": "default", + "target": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-9938e1c3-e758-46d4-af6e-0a764e77dfd2default-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_COMPONENTS-38474a31-dfa1-4d2b-8834-558ecadb82e3default" + }, + { + "source": "PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62af", + "sourceHandle": "default", + "target": "PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60", + "targetHandle": "default", + "id": "reactflow__edge-PROPHET_PREDICT-f91b407d-a959-4080-8f4f-9ccb8aaf62afdefault-PROPHET_PLOT-94b3e918-2bd3-4b08-9620-0017623eef60default" + } + ], + "viewport": { + "x": -277.07893884404893, + "y": 103.38141914149585, + "zoom": 0.8175961276759318 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..e0bad986fe --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The SCATTER node creates a Plotly Scatter visualization for a given input data container. + +Inputs +------ +default : OrderedPair|DataFrame|Matrix|Vector + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly Scatter visualization diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..2d19d9a8a2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/a1-[autogen]/python_code.txt @@ -0,0 +1,56 @@ +import numpy as np +import pandas as pd +import plotly.graph_objects as go +from flojoy import DataFrame, Matrix, OrderedPair, Plotly, flojoy, Vector +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def SCATTER(default: OrderedPair | DataFrame | Matrix | Vector) -> Plotly: + + layout = plot_layout(title="SCATTER") + fig = go.Figure(layout=layout) + match default: + case OrderedPair(): + x = default.x + if isinstance(default.x, dict): + dict_keys = list(default.x.keys()) + x = default.x[dict_keys[0]] + y = default.y + fig.add_trace(go.Scatter(x=x, y=y, mode="markers", marker=dict(size=4))) + case DataFrame(): + df = pd.DataFrame(default.m) + first_col = df.iloc[:, 0] + is_timeseries = False + if pd.api.types.is_datetime64_any_dtype(first_col): + is_timeseries = True + if is_timeseries: + for col in df.columns: + if col != df.columns[0]: + fig.add_trace( + go.Scatter(x=first_col, y=df[col], mode="markers", name=col) + ) + else: + for col in df.columns: + fig.add_trace( + go.Scatter(x=df.index, y=df[col], mode="markers", name=col) + ) + + case Matrix(): + m: np.ndarray = default.m + num_rows, num_cols = m.shape + + x_ticks = np.arange(num_cols) + + for i in range(num_rows): + fig.add_trace( + go.Scatter(x=x_ticks, y=m[i, :], name=f"Row {i+1}", mode="markers") + ) + + fig.update_layout(xaxis_title="Column", yaxis_title="Value") + case Vector(): + y = default.v + x = np.arange(len(y)) + fig.add_trace(go.Scatter(x=x, y=y, mode="markers", marker=dict(size=4))) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/examples/EX1/app.txt new file mode 100644 index 0000000000..5cbf9f492f --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER/examples/EX1/app.txt @@ -0,0 +1,319 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 208, + "height": 96, + "id": "PLOTLY_DATASET-686a1fd9-8dab-4de2-80d6-21386dc65e34", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-686a1fd9-8dab-4de2-80d6-21386dc65e34", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": 96.7381246005109, + "y": 744.7785434386891 + }, + "selected": false, + "positionAbsolute": { + "x": 96.7381246005109, + "y": 744.7785434386891 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "TIMESERIES-a11c4d23-595e-4325-91ab-6901e4626395", + "type": "GENERATORS", + "data": { + "id": "TIMESERIES-a11c4d23-595e-4325-91ab-6901e4626395", + "label": "TIMESERIES", + "func": "TIMESERIES", + "type": "GENERATORS", + "ctrls": { + "start_date": { + "type": "str", + "default": "2023-01-01", + "functionName": "TIMESERIES", + "param": "start_date", + "value": "2023-01-01" + }, + "end_date": { + "type": "str", + "default": "2023-07-20", + "functionName": "TIMESERIES", + "param": "end_date", + "value": "2023-07-20" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\TIMESERIES\\TIMESERIES.py", + "selected": false + }, + "position": { + "x": 96.06118244399238, + "y": 329.71860208595893 + }, + "selected": false, + "positionAbsolute": { + "x": 96.06118244399238, + "y": 329.71860208595893 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "MATRIX-8f1eae39-3d4b-4382-a18a-8db31ab0e1a8", + "type": "GENERATORS", + "data": { + "id": "MATRIX-8f1eae39-3d4b-4382-a18a-8db31ab0e1a8", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "10" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "10" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": 107.17107103989554, + "y": 547.4990642631835 + }, + "selected": false, + "positionAbsolute": { + "x": 107.17107103989554, + "y": 547.4990642631835 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-8f064bb5-af44-44fd-82f4-9a948f3695b5", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-8f064bb5-af44-44fd-82f4-9a948f3695b5", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SCATTER\\SCATTER.py", + "selected": false + }, + "position": { + "x": 345.47622757570446, + "y": 453.29086666590865 + }, + "selected": false, + "positionAbsolute": { + "x": 345.47622757570446, + "y": 453.29086666590865 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-bbfa1109-425d-457f-8f4f-bd6477f6ed0f", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-bbfa1109-425d-457f-8f4f-bd6477f6ed0f", + "label": "SCATTER 1", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SCATTER\\SCATTER.py", + "selected": false + }, + "position": { + "x": 761.4205476584486, + "y": 659.4631580061657 + }, + "selected": false, + "positionAbsolute": { + "x": 761.4205476584486, + "y": 659.4631580061657 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-a4744b2a-78e6-4874-a2ae-177e1dd6aa82", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-a4744b2a-78e6-4874-a2ae-177e1dd6aa82", + "label": "SCATTER 2", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SCATTER\\SCATTER.py", + "selected": false + }, + "position": { + "x": 713.7453784769118, + "y": 248.50330062718808 + }, + "selected": false, + "positionAbsolute": { + "x": 713.7453784769118, + "y": 248.50330062718808 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "TIMESERIES-a11c4d23-595e-4325-91ab-6901e4626395", + "sourceHandle": "default", + "target": "SCATTER-a4744b2a-78e6-4874-a2ae-177e1dd6aa82", + "targetHandle": "default", + "id": "reactflow__edge-TIMESERIES-a11c4d23-595e-4325-91ab-6901e4626395default-SCATTER-a4744b2a-78e6-4874-a2ae-177e1dd6aa82default" + }, + { + "source": "MATRIX-8f1eae39-3d4b-4382-a18a-8db31ab0e1a8", + "sourceHandle": "default", + "target": "SCATTER-8f064bb5-af44-44fd-82f4-9a948f3695b5", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-8f1eae39-3d4b-4382-a18a-8db31ab0e1a8default-SCATTER-8f064bb5-af44-44fd-82f4-9a948f3695b5default" + }, + { + "source": "PLOTLY_DATASET-686a1fd9-8dab-4de2-80d6-21386dc65e34", + "sourceHandle": "default", + "target": "SCATTER-bbfa1109-425d-457f-8f4f-bd6477f6ed0f", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-686a1fd9-8dab-4de2-80d6-21386dc65e34default-SCATTER-bbfa1109-425d-457f-8f4f-bd6477f6ed0fdefault" + } + ], + "viewport": { + "x": 606.4472645567363, + "y": 234.63130388602087, + "zoom": 0.9186369849831518 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..9630b02c0f --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/docstring.txt @@ -0,0 +1,12 @@ + +The SCATTER3D node creates a Plotly 3D Scatter visualization for a given input data container. + +Inputs +------ +default : OrderedTriple|DataFrame + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly 3D Scatter visualization diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..144dc3887a --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/a1-[autogen]/python_code.txt @@ -0,0 +1,35 @@ +import plotly.graph_objects as go +import plotly.express as px +from flojoy import OrderedTriple, DataFrame, Plotly, flojoy +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def SCATTER3D(default: OrderedTriple | DataFrame) -> Plotly: + + + layout = plot_layout(title="SCATTER3D") + fig = go.Figure(layout=layout) + match default: + case OrderedTriple(): + x = default.x + if isinstance(default.x, dict): + dict_keys = list(default.x.keys()) + x = default.x[dict_keys[0]] + y = default.y + z = default.z + fig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode="markers")) + case DataFrame(): + df = default.m + if len(df.columns) < 3: + raise ValueError( + "DataFrame must have at least 3 columns for x, y, and z coordinates." + ) + + x_column = df.columns[0] + y_column = df.columns[1] + z_column = df.columns[2] + + fig = px.scatter_3d(df, x=x_column, y=y_column, z=z_column, color=z_column) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/examples/EX1/app.txt new file mode 100644 index 0000000000..2c93687618 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SCATTER3D/examples/EX1/app.txt @@ -0,0 +1,247 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -298.0815755738636, + "y": 105.97367325652914 + }, + "selected": false, + "positionAbsolute": { + "x": -298.0815755738636, + "y": 105.97367325652914 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58", + "label": "DF 2 ORDEREDTRIPLE", + "func": "DF_2_ORDEREDTRIPLE", + "type": "TRANSFORMERS", + "ctrls": { + "x": { + "type": "int", + "default": 0, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "x", + "value": 0 + }, + "y": { + "type": "int", + "default": 1, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "y", + "value": 1 + }, + "z": { + "type": "int", + "default": 2, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "z", + "value": 2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 133.23533231847682, + "y": 94.6441744121388 + }, + "selected": false, + "positionAbsolute": { + "x": 133.23533231847682, + "y": 94.6441744121388 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER3D-27578128-aa7b-40fe-8dfd-d971192bba27", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER3D-27578128-aa7b-40fe-8dfd-d971192bba27", + "label": "SCATTER3D 1", + "func": "SCATTER3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SCATTER3D\\SCATTER3D.py", + "selected": false + }, + "position": { + "x": 194.33796607992497, + "y": 418.50728439606235 + }, + "selected": false, + "positionAbsolute": { + "x": 194.33796607992497, + "y": 418.50728439606235 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "SCATTER3D-0ba51c41-646b-47e4-a6e0-a306230f4ec6", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER3D-0ba51c41-646b-47e4-a6e0-a306230f4ec6", + "label": "SCATTER3D 1", + "func": "SCATTER3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SCATTER3D\\SCATTER3D.py", + "selected": false + }, + "position": { + "x": 484.38259832770757, + "y": 34.16199428293129 + }, + "selected": false, + "positionAbsolute": { + "x": 484.38259832770757, + "y": 34.16199428293129 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894", + "sourceHandle": "default", + "target": "DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894default-DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58default" + }, + { + "source": "PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894", + "sourceHandle": "default", + "target": "SCATTER3D-27578128-aa7b-40fe-8dfd-d971192bba27", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-6af3469b-5751-4778-84a1-2b17bc9c0894default-SCATTER3D-27578128-aa7b-40fe-8dfd-d971192bba27default" + }, + { + "source": "DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58", + "sourceHandle": "default", + "target": "SCATTER3D-0ba51c41-646b-47e4-a6e0-a306230f4ec6", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-a3a65384-680c-4114-81e1-476ec8835a58default-SCATTER3D-0ba51c41-646b-47e4-a6e0-a306230f4ec6default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..65d2f96b64 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/docstring.txt @@ -0,0 +1,13 @@ + +The SURFACE3D node creates a Plotly 3D Surface visualization for a given input data container. + +Inputs +------ +default : OrderedTriple|DataFrame|Surface|Matrix + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly 3D Surface visualization + diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..b75e7f2630 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/a1-[autogen]/python_code.txt @@ -0,0 +1,51 @@ +import plotly.graph_objects as go # type:ignore +from flojoy import Plotly, OrderedTriple, DataFrame, flojoy, Surface, Matrix +from flojoy_nodes.VISUALIZERS.template import plot_layout +import numpy as np + + +@flojoy +def SURFACE3D(default: OrderedTriple | DataFrame | Surface | Matrix) -> Plotly: + + + layout = plot_layout(title="SURFACE3D") + + match default: + case OrderedTriple(): + x = np.unique(default.x) + y = np.unique(default.y) + + z_size = len(x) * len(y) + + # Truncate or pad the z array to match the desired size + if z_size > len(default.z): + z = np.pad( + default.z, (0, z_size - len(default.z)), mode="constant" + ).reshape(len(y), len(x)) + else: + z = default.z[:z_size].reshape(len(y), len(x)) + + X, Y = np.meshgrid(x, y) + if z.ndim < 2: + num_columns = len(z) // 2 + z = np.reshape(z, (2, num_columns)) + fig = go.Figure( + data=[go.Surface(x=X, y=Y, z=z)], + layout=layout, + ) + case Surface(): + x = default.x + y = default.y + z = default.z + fig = go.Figure(data=[go.Surface(x=x, y=y, z=z)], layout=layout) + case Matrix(): + m = default.m + if m.ndim < 2: + num_columns = len(m) // 2 + m = np.reshape(m, (2, num_columns)) + fig = go.Figure(data=[go.Surface(z=m)], layout=layout) + case DataFrame(): + df = default.m + fig = go.Figure(data=[go.Surface(z=df.values)], layout=layout) + + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/examples/EX1/app.txt new file mode 100644 index 0000000000..83679af0f7 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/SURFACE3D/examples/EX1/app.txt @@ -0,0 +1,435 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "type": "GENERATORS", + "data": { + "id": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "label": "PLOTLY DATASET", + "func": "PLOTLY_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "wind", + "options": [ + "wind", + "iris", + "carshare", + "tips", + "election", + "experiment", + "gapminder", + "medals_long", + "medals_wide", + "stocks" + ], + "functionName": "PLOTLY_DATASET", + "param": "dataset_key", + "value": "gapminder" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\PLOTLY_DATASET\\PLOTLY_DATASET.py", + "selected": false + }, + "position": { + "x": -153.13246731470204, + "y": 152.21548757941065 + }, + "selected": false, + "positionAbsolute": { + "x": -153.13246731470204, + "y": 152.21548757941065 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "type": "TRANSFORMERS", + "data": { + "id": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "label": "DF 2 ORDEREDTRIPLE", + "func": "DF_2_ORDEREDTRIPLE", + "type": "TRANSFORMERS", + "ctrls": { + "x": { + "type": "int", + "default": 0, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "x", + "value": 0 + }, + "y": { + "type": "int", + "default": 1, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "y", + "value": 1 + }, + "z": { + "type": "int", + "default": 2, + "functionName": "DF_2_ORDEREDTRIPLE", + "param": "z", + "value": 2 + } + }, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 138.28356151980358, + "y": 155.19957354474383 + }, + "selected": false, + "positionAbsolute": { + "x": 138.28356151980358, + "y": 155.19957354474383 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "type": "TRANSFORMERS", + "data": { + "id": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "label": "ORDERED TRIPLE 2 SURFACE", + "func": "ORDERED_TRIPLE_2_SURFACE", + "type": "TRANSFORMERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Surface" + } + ], + "path": "", + "selected": false + }, + "position": { + "x": 464.045404438885, + "y": 185.28592471837874 + }, + "selected": false, + "positionAbsolute": { + "x": 464.045404438885, + "y": 185.28592471837874 + }, + "dragging": true + }, + { + "width": 130, + "height": 130, + "id": "MATRIX-a7f20c72-1c4e-4e31-9b3f-94cf1f228fd5", + "type": "GENERATORS", + "data": { + "id": "MATRIX-a7f20c72-1c4e-4e31-9b3f-94cf1f228fd5", + "label": "MATRIX", + "func": "MATRIX", + "type": "GENERATORS", + "ctrls": { + "row": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "row", + "value": "10" + }, + "column": { + "type": "int", + "default": 2, + "functionName": "MATRIX", + "param": "column", + "value": "10" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Matrix" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\MATRIX\\MATRIX.py", + "selected": false + }, + "position": { + "x": 579.8521281496937, + "y": 536.6430374399084 + }, + "selected": false, + "positionAbsolute": { + "x": 579.8521281496937, + "y": 536.6430374399084 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SURFACE3D-62cf3ecc-359b-4cd4-ad49-bd0e6995a522", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-62cf3ecc-359b-4cd4-ad49-bd0e6995a522", + "label": "SURFACE3D 1", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SURFACE3D\\SURFACE3D.py", + "selected": false + }, + "position": { + "x": 592.7351595694264, + "y": -184.92364835673408 + }, + "selected": false, + "positionAbsolute": { + "x": 592.7351595694264, + "y": -184.92364835673408 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SURFACE3D-8be10741-50fe-4df3-b2a5-afdcf56c1035", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-8be10741-50fe-4df3-b2a5-afdcf56c1035", + "label": "SURFACE3D 2", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SURFACE3D\\SURFACE3D.py", + "selected": false + }, + "position": { + "x": 954.7062224469232, + "y": 494.12216042293704 + }, + "selected": false, + "positionAbsolute": { + "x": 954.7062224469232, + "y": 494.12216042293704 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SURFACE3D-19305f4e-d1e0-489b-adc7-383816dd5f49", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-19305f4e-d1e0-489b-adc7-383816dd5f49", + "label": "SURFACE3D 3", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SURFACE3D\\SURFACE3D.py", + "selected": false + }, + "position": { + "x": 131.90508644311723, + "y": 462.8719302399147 + }, + "selected": false, + "positionAbsolute": { + "x": 131.90508644311723, + "y": 462.8719302399147 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SURFACE3D-f4e1f4c2-c6fe-4a06-b7ad-89ffab8a1c01", + "type": "VISUALIZERS", + "data": { + "id": "SURFACE3D-f4e1f4c2-c6fe-4a06-b7ad-89ffab8a1c01", + "label": "SURFACE3D 3", + "func": "SURFACE3D", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|DataFrame|Surface|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\SURFACE3D\\SURFACE3D.py", + "selected": false + }, + "position": { + "x": 941.4106709993805, + "y": 111.8507417555283 + }, + "selected": false, + "positionAbsolute": { + "x": 941.4106709993805, + "y": 111.8507417555283 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "sourceHandle": "default", + "target": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cddefault-DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204default" + }, + { + "source": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "sourceHandle": "default", + "target": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204default-ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3default" + }, + { + "source": "PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cd", + "sourceHandle": "default", + "target": "SURFACE3D-19305f4e-d1e0-489b-adc7-383816dd5f49", + "targetHandle": "default", + "id": "reactflow__edge-PLOTLY_DATASET-5a7231e7-7fa7-480f-9562-c117499c99cddefault-SURFACE3D-19305f4e-d1e0-489b-adc7-383816dd5f49default" + }, + { + "source": "MATRIX-a7f20c72-1c4e-4e31-9b3f-94cf1f228fd5", + "sourceHandle": "default", + "target": "SURFACE3D-8be10741-50fe-4df3-b2a5-afdcf56c1035", + "targetHandle": "default", + "id": "reactflow__edge-MATRIX-a7f20c72-1c4e-4e31-9b3f-94cf1f228fd5default-SURFACE3D-8be10741-50fe-4df3-b2a5-afdcf56c1035default" + }, + { + "source": "DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204", + "sourceHandle": "default", + "target": "SURFACE3D-62cf3ecc-359b-4cd4-ad49-bd0e6995a522", + "targetHandle": "default", + "id": "reactflow__edge-DF_2_ORDEREDTRIPLE-c2918872-5cb8-4469-b2c7-3e2ab878d204default-SURFACE3D-62cf3ecc-359b-4cd4-ad49-bd0e6995a522default" + }, + { + "source": "ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3", + "sourceHandle": "default", + "target": "SURFACE3D-f4e1f4c2-c6fe-4a06-b7ad-89ffab8a1c01", + "targetHandle": "default", + "id": "reactflow__edge-ORDERED_TRIPLE_2_SURFACE-810534da-2e75-4d23-b28a-d07602ab0cf3default-SURFACE3D-f4e1f4c2-c6fe-4a06-b7ad-89ffab8a1c01default" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/docstring.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..280abaf070 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/docstring.txt @@ -0,0 +1,13 @@ + +The TABLE node creates a Plotly Table visualization for a given input data container. + +Inputs +------ +default : OrderedTriple|OrderedPair|DataFrame|Vector + the DataContainer to be visualized + +Outputs +------- +Plotly + the DataContainer containing Plotly Table visualization + diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/python_code.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..dca744dcf2 --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/a1-[autogen]/python_code.txt @@ -0,0 +1,50 @@ +from flojoy import flojoy, OrderedPair, OrderedTriple, DataFrame, Vector, Plotly +import plotly.graph_objects as go +import pandas as pd +from flojoy_nodes.VISUALIZERS.template import plot_layout + + +@flojoy +def TABLE(default: OrderedTriple | OrderedPair | DataFrame | Vector) -> Plotly: + + + layout = plot_layout(title="TABLE") + fig = go.Figure(layout=layout) + + match default: + case OrderedPair(): + x = default.x + y = default.y + fig.add_trace( + go.Table( + header=dict(values=["x", "y"], align="center"), + cells=dict(values=[x, y], align="center"), + ) + ) + case OrderedTriple(): + x = default.x + y = default.y + z = default.z + fig.add_trace( + go.Table( + header=dict(values=["x", "y", "z"], align="center"), + cells=dict(values=[x, y, z], align="center"), + ) + ) + case Vector(): + v = default.v + fig.add_trace( + go.Table( + header=dict(values=["v"], align="center"), + cells=dict(values=[v], align="center"), + ) + ) + case DataFrame(): + df = pd.DataFrame(default.m) + fig.add_trace( + go.Table( + header=dict(values=list(df.columns), align="center"), + cells=dict(values=[df[col] for col in df.columns], align="center"), + ) + ) + return Plotly(fig=fig) diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/hardware.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/hardware.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/media.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/media.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/notes.md b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/appendix/notes.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/examples/EX1/app.txt b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/examples/EX1/app.txt new file mode 100644 index 0000000000..87eedd42eb --- /dev/null +++ b/docs/nodes/flojoy_nodes/VISUALIZERS/PLOTLY/TABLE/examples/EX1/app.txt @@ -0,0 +1,309 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 150, + "height": 150, + "id": "LINSPACE-96f418c8-14ed-4457-abea-9520da6d5078", + "type": "default", + "data": { + "id": "LINSPACE-96f418c8-14ed-4457-abea-9520da6d5078", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "default", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SIMULATIONS\\LINSPACE\\LINSPACE.py", + "selected": false + }, + "position": { + "x": 68.51593747608788, + "y": 49.87310163004685 + }, + "selected": false, + "positionAbsolute": { + "x": 68.51593747608788, + "y": 49.87310163004685 + }, + "dragging": true + }, + { + "width": 150, + "height": 150, + "id": "R_DATASET-44eaa566-97ed-4dca-a9c5-0bcb7f680ad8", + "type": "GENERATORS", + "data": { + "id": "R_DATASET-44eaa566-97ed-4dca-a9c5-0bcb7f680ad8", + "label": "R DATASET", + "func": "R_DATASET", + "type": "GENERATORS", + "ctrls": { + "dataset_key": { + "type": "select", + "default": "iris", + "options": [ + "ability.cov", + "airmiles", + "AirPassengers", + "airquality", + "anscombe", + "attenu", + "attitude", + "austres", + "BJsales", + "BOD", + "cars", + "ChickWeight", + "chickwts", + "co2", + "crimtab", + "discoveries", + "DNase", + "esoph", + "euro", + "EuStockMarkets", + "faithful", + "Formaldehyde", + "freeny", + "HairEyeColor", + "Harman23", + "Harman74", + "Indometh", + "infert", + "InsectSprays", + "iris", + "iris3", + "islands", + "JohnsonJohnson", + "LakeHuron", + "LifeCycleSavings", + "Loblolly", + "longley", + "lynx", + "morley", + "mtcars", + "nhtemp", + "Nile", + "nottem", + "npk", + "occupationalStatus", + "Orange", + "OrchardSprays", + "PlantGrowth", + "precip", + "presidents", + "pressure", + "Puromycin", + "quakes", + "randu", + "rivers", + "rock", + "Seatbelts", + "sleep", + "stackloss", + "sunspot.month", + "sunspot.year", + "sunspots", + "swiss", + "Theoph", + "Titanic", + "ToothGrowth", + "treering", + "trees", + "UCBAdmissions", + "UKDriverDeaths", + "UKgas", + "USAccDeaths", + "USArrests", + "USJudgeRatings", + "USPersonalExpenditure", + "VADeaths", + "volcano", + "warpbreaks", + "women", + "WorldPhones", + "WWWusage" + ], + "functionName": "R_DATASET", + "param": "dataset_key", + "value": "iris" + } + }, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "DataFrame" + } + ], + "pip_dependencies": [ + { + "name": "rdatasets", + "v": "0.1.0" + } + ], + "path": "PYTHON/nodes\\GENERATORS\\SAMPLE_DATASETS\\R_DATASET\\R_DATASET.py", + "selected": false + }, + "position": { + "x": 48.515937476087885, + "y": 399.8731016300469 + }, + "selected": false, + "positionAbsolute": { + "x": 48.515937476087885, + "y": 399.8731016300469 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "TABLE-41e3d344-1ece-4eb2-adb8-dc944c80b49b", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-41e3d344-1ece-4eb2-adb8-dc944c80b49b", + "label": "TABLE", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\TABLE\\TABLE.py", + "selected": false + }, + "position": { + "x": 507.0873660475165, + "y": 11.301673058618121 + }, + "selected": false, + "positionAbsolute": { + "x": 507.0873660475165, + "y": 11.301673058618121 + }, + "dragging": true + }, + { + "width": 225, + "height": 226, + "id": "TABLE-57c89935-c3df-4ba4-a8a5-f53534c47ee9", + "type": "VISUALIZERS", + "data": { + "id": "TABLE-57c89935-c3df-4ba4-a8a5-f53534c47ee9", + "label": "TABLE 1", + "func": "TABLE", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedTriple|OrderedPair|DataFrame", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes\\VISUALIZERS\\PLOTLY\\TABLE\\TABLE.py", + "selected": false + }, + "position": { + "x": 597.0873660475164, + "y": 379.87310163004656 + }, + "selected": false, + "positionAbsolute": { + "x": 597.0873660475164, + "y": 379.87310163004656 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "R_DATASET-44eaa566-97ed-4dca-a9c5-0bcb7f680ad8", + "sourceHandle": "default", + "target": "TABLE-57c89935-c3df-4ba4-a8a5-f53534c47ee9", + "targetHandle": "default", + "id": "reactflow__edge-R_DATASET-44eaa566-97ed-4dca-a9c5-0bcb7f680ad8default-TABLE-57c89935-c3df-4ba4-a8a5-f53534c47ee9default" + }, + { + "source": "LINSPACE-96f418c8-14ed-4457-abea-9520da6d5078", + "sourceHandle": "default", + "target": "TABLE-41e3d344-1ece-4eb2-adb8-dc944c80b49b", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-96f418c8-14ed-4457-abea-9520da6d5078default-TABLE-41e3d344-1ece-4eb2-adb8-dc944c80b49bdefault" + } + ], + "viewport": { + "x": -296.35399545928726, + "y": 66.8470830817738, + "zoom": 0.8744723800359967 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file