Skip to content

feat: add with_positions option to ring_lattice (#623)#729

Open
leotrs wants to merge 33 commits into
devfrom
lattice-store-positions
Open

feat: add with_positions option to ring_lattice (#623)#729
leotrs wants to merge 33 commits into
devfrom
lattice-store-positions

Conversation

@leotrs

@leotrs leotrs commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #623. Adds a with_positions=False keyword argument to ring_lattice. When True, stores each node's coordinate on a unit circle as the \"pos\" node attribute. Naming follows the NetworkX convention (e.g., triangular_lattice_graph(with_positions=True)) as Max suggested in the issue.

Combined with #728 (H.nodes.pos accessor), the natural workflow becomes:

H = xgi.ring_lattice(8, 3, 2, 0, with_positions=True)
xgi.draw(H, pos=H.nodes.pos.asdict())

ring_lattice is currently the only lattice generator in xgi, so this is a one-function change. Future lattice generators (e.g., triangular) should follow the same convention.

Test plan

  • test_ring_lattice_with_positions covers both default (no pos) and with_positions=True (verifies unit-circle coordinates)
  • Full test suite passes (411 passed, 6 skipped)

leotrs and others added 30 commits March 31, 2026 06:40
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.
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)
leotrs and others added 3 commits May 28, 2026 08:58
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
Stores each node's coordinate on a unit circle as the "pos" node
attribute. Naming follows NetworkX convention (e.g.,
triangular_lattice_graph(with_positions=True)).

Combined with PR #728, this enables a clean redraw workflow:

    H = xgi.ring_lattice(8, 3, 2, 0, with_positions=True)
    xgi.draw(H, pos=H.nodes.pos.asdict())

Closes #623

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.69%. Comparing base (bd8a39e) to head (8ac6fa2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #729   +/-   ##
=======================================
  Coverage   93.68%   93.69%           
=======================================
  Files          66       66           
  Lines        5213     5217    +4     
=======================================
+ Hits         4884     4888    +4     
  Misses        329      329           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leotrs leotrs changed the base branch from main to dev May 29, 2026 12:38
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.

Store lattice positions as node attributes

4 participants