-
Notifications
You must be signed in to change notification settings - Fork 9
Add Root Node to Graph #192
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8dcec8e
Add new func
michaelmckinsey1 77e8f7a
Add name col to df
michaelmckinsey1 8dd8f13
Add get_node function
michaelmckinsey1 6949c72
Add docstring
michaelmckinsey1 2223c8e
Avoid F402
michaelmckinsey1 b969ccf
call stats reapply func
michaelmckinsey1 c9db841
Change pop
michaelmckinsey1 3b4c8f5
Change imports to be consistent
michaelmckinsey1 c38e7c8
Fix grammar
michaelmckinsey1 2886c46
Raise error if node not found
michaelmckinsey1 13b69e7
Add unit tests
michaelmckinsey1 c38a78f
Set depth and hnid automatically
michaelmckinsey1 e2035f7
Add validation check at the end
michaelmckinsey1 cb5d2f8
update unit test
michaelmckinsey1 ee996a9
Black
michaelmckinsey1 9e2438d
enumerate_traverse calls enumerate_depth
michaelmckinsey1 7294aac
Fix flake check
michaelmckinsey1 53f8718
Properly mark unused arguments
michaelmckinsey1 5053f83
Change ValueError to KeyError
michaelmckinsey1 fcc266a
Remove warning, add to docstring
michaelmckinsey1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2022 Lawrence Livermore National Security, LLC and other | ||
| # Thicket Project Developers. See the top-level LICENSE file for details. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from hatchet.node import Node | ||
|
|
||
|
|
||
| def test_add_root_node(literal_thickets): | ||
| tk, _, _ = literal_thickets | ||
|
|
||
| assert len(tk.graph) == 4 | ||
|
|
||
| # Call add_root_node | ||
| tk.add_root_node({"name": "Test", "type": "function"}) | ||
| # Get node variable | ||
| test_node = tk.get_node("Test") | ||
|
|
||
| # Check if node was inserted in all components | ||
| assert isinstance(test_node, Node) | ||
| assert test_node._hatchet_nid == 3 | ||
| assert test_node._depth == 0 | ||
| assert len(tk.graph) == 5 | ||
| assert len(tk.statsframe.graph) == 5 | ||
| assert test_node in tk.dataframe.index.get_level_values("node") | ||
| assert test_node in tk.statsframe.dataframe.index.get_level_values("node") | ||
|
|
||
| assert tk.dataframe.loc[test_node, "name"].values[0] == "Test" | ||
| assert tk.statsframe.dataframe.loc[test_node, "name"] == "Test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2022 Lawrence Livermore National Security, LLC and other | ||
| # Thicket Project Developers. See the top-level LICENSE file for details. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def test_get_node(literal_thickets): | ||
| tk, _, _ = literal_thickets | ||
|
|
||
| with pytest.raises(KeyError): | ||
| tk.get_node("Foo") | ||
|
|
||
| baz = tk.get_node("Baz") | ||
|
|
||
| # Check node properties | ||
| assert baz.frame["name"] == "Baz" | ||
| assert baz.frame["type"] == "function" | ||
| assert baz._hatchet_nid == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.