From a5d9bf1558a391cc953819b5dd50c0fcb69069c5 Mon Sep 17 00:00:00 2001 From: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:54:41 -0700 Subject: [PATCH 1/4] reset `all_layers` for both figure types --- schematic/visualization/tangled_tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schematic/visualization/tangled_tree.py b/schematic/visualization/tangled_tree.py index 07757a14d..3c661e278 100644 --- a/schematic/visualization/tangled_tree.py +++ b/schematic/visualization/tangled_tree.py @@ -747,6 +747,7 @@ def get_tangled_tree_layers(self, save_file=True): ''' # Gather the data model's, topological generations, nodes and edges topological_gen, nodes, edges, subg = self.get_topological_generations() + all_layers = [] if self.figure_type == 'component': # Gather all source nodes @@ -762,7 +763,7 @@ def get_tangled_tree_layers(self, save_file=True): layers_json = self.get_node_layers_json(topological_gen, source_nodes, child_parents, parent_children, all_parent_children=all_parent_children) # If indicated save outputs locally else gather all layers. - all_layers = self.save_outputs(save_file, layers_json) + all_layers = self.save_outputs(save_file, layers_json, all_layers=all_layers) if self.figure_type == 'dependency': # Get component digraph and nodes. @@ -774,7 +775,6 @@ def get_tangled_tree_layers(self, save_file=True): attributes_df = pd.read_table(StringIO(attributes_csv_str), sep=",") - all_layers =[] for cn in component_nodes: # Gather attribute and dependency information per node conditional_attributes, ca_alias, all_attributes = self.gather_component_dependency_info(cn, attributes_df) From e8270007db931c91b4039bfb99ed5eb110562791 Mon Sep 17 00:00:00 2001 From: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:16:46 -0700 Subject: [PATCH 2/4] add todo --- tests/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_api.py b/tests/test_api.py index 9d69c63b2..6cbb72448 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -881,6 +881,7 @@ def test_visualize_attributes(self, client, data_model_jsonld): @pytest.mark.parametrize("figure_type", ["component", "dependency"]) def test_visualize_tangled_tree_layers(self, client, figure_type, data_model_jsonld): + # TODO: Determine a 2nd data model to use for this test, test both models sequentially, add checks for content of response params = { "schema_url": data_model_jsonld, "figure_type": figure_type From 5673e75e9d9608823ffe6c2b6d8a3695e9afa9f1 Mon Sep 17 00:00:00 2001 From: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:14:25 -0700 Subject: [PATCH 3/4] change var initialization --- schematic/visualization/tangled_tree.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/schematic/visualization/tangled_tree.py b/schematic/visualization/tangled_tree.py index 3c661e278..68e28e7b6 100644 --- a/schematic/visualization/tangled_tree.py +++ b/schematic/visualization/tangled_tree.py @@ -688,7 +688,7 @@ def get_node_layers_json(self, topological_gen, source_nodes, child_parents, par return layers_json - def save_outputs(self, save_file, layers_json, cn='', all_layers=[]): + def save_outputs(self, save_file, layers_json, cn='', all_layers=None): ''' Inputs: save_file (bool): Indicates whether to save a file locally or not.: @@ -702,6 +702,8 @@ def save_outputs(self, save_file, layers_json, cn='', all_layers=[]): If save_file == False: Each string represents contains the layers for a single tangled tree. If save_file ==True: is an empty list. ''' + if all_layers is None: + all_layers = [] if save_file == True: if cn: output_file_name = f"{self.schema_abbr}_{self.figure_type}_{cn}_tangled_tree.json" From 2cf78d0de3e110b71668b7ce239be51e62152431 Mon Sep 17 00:00:00 2001 From: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:15:36 -0700 Subject: [PATCH 4/4] Revert "reset `all_layers` for both figure types" This reverts commit a5d9bf1558a391cc953819b5dd50c0fcb69069c5. --- schematic/visualization/tangled_tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schematic/visualization/tangled_tree.py b/schematic/visualization/tangled_tree.py index 68e28e7b6..d5b838e85 100644 --- a/schematic/visualization/tangled_tree.py +++ b/schematic/visualization/tangled_tree.py @@ -749,7 +749,6 @@ def get_tangled_tree_layers(self, save_file=True): ''' # Gather the data model's, topological generations, nodes and edges topological_gen, nodes, edges, subg = self.get_topological_generations() - all_layers = [] if self.figure_type == 'component': # Gather all source nodes @@ -765,7 +764,7 @@ def get_tangled_tree_layers(self, save_file=True): layers_json = self.get_node_layers_json(topological_gen, source_nodes, child_parents, parent_children, all_parent_children=all_parent_children) # If indicated save outputs locally else gather all layers. - all_layers = self.save_outputs(save_file, layers_json, all_layers=all_layers) + all_layers = self.save_outputs(save_file, layers_json) if self.figure_type == 'dependency': # Get component digraph and nodes. @@ -777,6 +776,7 @@ def get_tangled_tree_layers(self, save_file=True): attributes_df = pd.read_table(StringIO(attributes_csv_str), sep=",") + all_layers =[] for cn in component_nodes: # Gather attribute and dependency information per node conditional_attributes, ca_alias, all_attributes = self.gather_component_dependency_info(cn, attributes_df)