From e4350fcc530fe1f4c12b5968825ce522ddb1d968 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Sat, 2 Aug 2025 13:33:56 -0400 Subject: [PATCH 1/2] added Source node --- src/App.jsx | 1 + src/pathsim_utils.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index fd6630e9..34f85eeb 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -38,6 +38,7 @@ const nodeTypes = { process_horizontal: ProcessNodeHorizontal, delay: DelayNode, constant: SourceNode, + source: SourceNode, stepsource: StepSourceNode, pulsesource: SourceNode, amplifier: AmplifierNode, diff --git a/src/pathsim_utils.py b/src/pathsim_utils.py index d20371cd..bc8b2d08 100644 --- a/src/pathsim_utils.py +++ b/src/pathsim_utils.py @@ -7,6 +7,7 @@ Scope, Block, Constant, + Source, StepSource, PulseSource, Amplifier, @@ -40,6 +41,7 @@ } map_str_to_object = { "constant": Constant, + "source": Source, "stepsource": StepSource, "pulsesource": PulseSource, "amplifier": Amplifier, From b3846539e983fa64ffe87d93c359b415a128c834 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Sat, 2 Aug 2025 13:34:23 -0400 Subject: [PATCH 2/2] if an object is not serialisable then just write "default" --- src/backend.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend.py b/src/backend.py index 25f1e2c1..ab8291c7 100644 --- a/src/backend.py +++ b/src/backend.py @@ -80,6 +80,16 @@ def get_default_values(node_type): default_values[param] = None # Handle empty defaults else: default_values[param] = default_value + # check if default value is serializable to JSON + if not isinstance( + default_value, (int, float, str, bool, list, dict) + ): + # Attempt to convert to JSON serializable type + try: + default_values[param] = json.dumps(default_value) + except TypeError: + # If conversion fails, set to a string 'default' + default_values[param] = "default" return jsonify(default_values) except Exception as e: return jsonify(