Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_edges_under_consolidation Function #927

Merged
merged 2 commits into from
Jun 7, 2023

Conversation

MariusWirtz
Copy link
Collaborator

Useful when synchronizing sub hierarchies between instances

Fixes #915

@MariusWirtz MariusWirtz force-pushed the feature/get-edges-under-consolidation branch from 0c36ca2 to ae26f3f Compare June 7, 2023 11:37
Useful when synchronizing sub hierarchies between instances

Fixes #915
@MariusWirtz MariusWirtz force-pushed the feature/get-edges-under-consolidation branch from ae26f3f to 4f79510 Compare June 7, 2023 13:31
Copy link
Collaborator

@Kevin-Dekker Kevin-Dekker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a problem if the edges order deviates? Check the below test case:

def test_get_edges_under_consolidation_remove_read(self):
       edges = self.tm1.dimensions.hierarchies.elements.get_edges_under_consolidation(
           self.dimension_name,
           self.hierarchy_name,
           "All Consolidations",
           max_depth=99)
       h = self.tm1.hierarchies.get(self.dimension_name, self.hierarchy_name)
       h_original = copy.deepcopy(h)

       h.remove_all_edges()
       for edge, weight in edges.items():
           h.add_edge(edge[0], edge[1], weight=weight)

       self.assertEqual(h_original, h)

@MariusWirtz
Copy link
Collaborator Author

Would it be a problem if the edges order deviates? Check the below test case:

def test_get_edges_under_consolidation_remove_read(self):
       edges = self.tm1.dimensions.hierarchies.elements.get_edges_under_consolidation(
           self.dimension_name,
           self.hierarchy_name,
           "All Consolidations",
           max_depth=99)
       h = self.tm1.hierarchies.get(self.dimension_name, self.hierarchy_name)
       h_original = copy.deepcopy(h)

       h.remove_all_edges()
       for edge, weight in edges.items():
           h.add_edge(edge[0], edge[1], weight=weight)

       self.assertEqual(h_original, h)

I think you identified a problem in the __eq__ function of the Hierarchy / TM1Object class.
If we change the last line of the suggested test to: self.assertEqual(h_original.edges, h.edges), it succeeds.
I will include the modified test

@MariusWirtz MariusWirtz merged commit 51cd109 into master Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add get_edges_under_consolidation function
2 participants