feat: add H.nodes.pos stat accessor for node positions (#624)#728
Open
leotrs wants to merge 33 commits into
Open
feat: add H.nodes.pos stat accessor for node positions (#624)#728leotrs wants to merge 33 commits into
leotrs wants to merge 33 commits into
Conversation
Add _stat_property non-data descriptor to expose built-in stats as class-level attributes on NodeView, EdgeView, DiNodeView, and DiEdgeView. Stats now appear in dir(), IDE autocomplete, and Jupyter tab completion. __getattr__ remains as fallback for user-defined stats registered via @nodestat_func. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add .pyi stub file declaring built-in stats as typed attributes on NodeView, EdgeView, DiNodeView, and DiEdgeView. This enables static analysis tools (Pylance, PyCharm, mypy) to provide autocomplete and type checking for the stats interface. Also adds py.typed marker and configures pyproject.toml to include stub files in package distributions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ckstart - Revise "XGI in 5 minutes" to introduce the stats interface after the histogram section: shows stat objects, output formats, filtering. - Add stats cheat sheet page with quick reference for all stats, output formats, filter modes, custom stats, and visualization integration. - Link the orphaned quickstart.ipynb from the Getting Started index. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ubuntu-20.04 has been deprecated by ReadTheDocs, causing build failures. Closes #702 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: make built-in stats discoverable in dir() and IDE autocomplete
- Add outputs to new stats cells in 5-minute notebook - Use smaller H (20 nodes, seeded) for stats demo instead of H_new (50 nodes) - Fix filter threshold to produce meaningful results - Move stats cheat sheet from top nav to User Guides page Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Stats reference page now links to cheat sheet and tutorial - Focus tutorial 6 links to cheat sheet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
H.nodes.degree? now shows the actual degree docstring instead of the generic NodeStat class docstring. Closes #357 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Update using-xgi.rst * Fix issues with PR --------- Co-authored-by: Nicholas Landry <nicholas.landry.91@gmail.com>
feat: forward stat function docstrings to stat objects
docs: introduce stats earlier, add cheat sheet, link quickstart
feat: add type stubs for stats on view classes
* docs: automated the generation of the "Using XGI" page * Response to review: added docs and fixed formatting * docs: change reverse-alphabetical to alphabetical * response to review * Update generate_using_xgi.py
Add fields for Python and xgi versions in bug report template.
Update issue templates
Adds an empties parameter to cleanup() on Hypergraph, DiHypergraph, and SimplicialComplex. Defaults to False (matching the convention of other cleanup flags), so empty edges are removed by default. Closes #570 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Several stats are thin wrappers around xgi.algorithms functions but were carrying their own copies of the formulas, references, and notes. Those copies had drifted from the originals. Rewrites the wrapper stat docstrings to point at the algorithm via See Also rather than re-explaining. Adds a short stat-accessor note to each algorithm so users discover both calling conventions from either direction. Affects clustering_coefficient, local_clustering_coefficient, two_node_clustering_coefficient, clique_eigenvector_centrality, h_eigenvector_centrality, z_eigenvector_centrality, node_edge_centrality, katz_centrality, and the local simpliciality stats. Closes #621 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A common confusion is that H.edges[0] returns the empty attribute dict rather than the members of edge 0. The behavior is correct but the docstring did not point users at the actual member-access methods. Add an upfront note and concrete examples showing both attribute access and the alternatives (.members, .memberships). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feat: add empties option to cleanup methods (#570)
docs: deduplicate stats docstrings and link to algorithms (#621)
H.nodes? and H.edges? are common discovery moves; surface the attr-vs-member distinction in the class docstrings where users will actually encounter it (per Max's review on #727). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
docs: clarify that H.edges[idx] returns attributes, not members
Adds a `pos` stat on NodeView (and DiNodeView) as a discoverable
shortcut for the conventional "pos" node attribute used by xgi's
drawing functions. Equivalent to `H.nodes.attrs("pos")` but visible
in dir(), tab completion, and IDE autocomplete.
Usage:
xgi.draw(H, pos=H.nodes.pos.asdict())
Also:
- Updated type stubs (views.pyi)
- Added entries to the stats reference page and cheat sheet
- Added a recipe to tutorials/recipes/recipes.ipynb
- Pointed the draw() docstring at H.nodes.pos.asdict()
Closes #624
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #728 +/- ##
=======================================
Coverage 93.68% 93.69%
=======================================
Files 66 66
Lines 5213 5219 +6
=======================================
+ Hits 4884 4890 +6
Misses 329 329 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2 tasks
2 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #624. Adds
posas a first-class stat onNodeViewandDiNodeView— a discoverable shortcut for the conventional\"pos\"node attribute that xgi's drawing functions use.Why promote
posto a stat? It's already a privileged attribute name in the library (the whole reason the issue exists), and the descriptor pattern from #699 means it now appears indir(), tab completion, and IDE autocomplete. So the natural call site becomes:This is what the original issue asked for, achieved without adding a new top-level helper. Nodes without a
\"pos\"attribute map toNone(same asattrs(\"pos\")does today).Changes
xgi/stats/nodestats.py: newposfunction (3-line body, full docstring)xgi/stats/dinodestats.py: same, forDiHypergraphxgi/core/views.py: register onNodeViewandDiNodeViewxgi/core/views.pyi: type stubsxgi/drawing/draw.py: point theposparameter docstring atH.nodes.pos.asdict()docs/source/api/stats.rst: list it under both node-stats sectionsdocs/source/stats_cheatsheet.rst: add a rowtutorials/recipes/recipes.ipynb: new recipe showing the layout-store-redraw patternTest plan
test_pos_statcoversHypergraph+DiHypergraph, with and without the attribute set, and equivalence toattrs(\"pos\")posfunction passes