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

stats package #120

Merged
merged 51 commits into from
Jun 13, 2022
Merged

stats package #120

merged 51 commits into from
Jun 13, 2022

Conversation

leotrs
Copy link
Collaborator

@leotrs leotrs commented Jun 7, 2022

This PR adds the stats package which implements NodeStat, EdgeStat and related functionality. For an overview of all the new features, see the tutorial.

The main changes are all within the newly created xgi/stats/ package. Other classes affected are Hypergraph, NodeView, and EdgeView. Additionally, DegreeView and EdgeSizeView are deleted.

This is a big diff, but it can basically be broken in three: changes to the docs (docstrings and *rst files), new tests (this PR adds 51 new tests collected by pytest), and the actual implementation, which is mostly within xgi/stats/, xgi/classes/hypergraph.py and xgi/classes/reportviews.py.

In terms of documentation, I believe we now have the minimum required to make sense of the new features, but a lot more can be done for sure. To avoid repetition, in some places I just added a direct link to the tutorial.

On a technical note. The way the xgi/stats/ package is implemented is the following. xgi/stats/__init__.py contains all the major classes and decorators. xgi/stats/nodestats.py contains only the functions that actually compute node statistics (like degree clustering, etc). Similarly, xgi/stats/edgestats.py contains only the functions that compute edge statistics. I don't like having so much code in the __init__.py module, but it is necessary for the current implementation that nodestats.py and edgestats.py ONLY contain functions that compute the corresponding statistics.

leotrs added 30 commits June 7, 2022 16:25
…wargs when calling from the Hypergraph itself
…only return a single element, while there may be multiple elements that achieve the maximum
…odeStats. Also, add the dist() convenience function
…cstring uses the function "my_degree". However, the test_user_defined test function also defined a function with name "my_degree". The latter was leaking into the namespace during pytest runs so we decided to change the name of the latter to "user_degree" instead.
@leotrs leotrs changed the title Nodestats stats package Jun 7, 2022
@leotrs
Copy link
Collaborator Author

leotrs commented Jun 7, 2022

Please do NOT review/merge unless #121 has been merged. Review away!

@@ -0,0 +1,35 @@
xgi.stats.EdgeStat
Copy link
Collaborator

@nwlandry nwlandry Jun 11, 2022

Choose a reason for hiding this comment

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

There seem to be a few duplicate file names in docs/source/api/stats

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of nodestats, NodeStat, and nodestat are valid names implemented in this PR: the module, the class, and the decorator. All three names are imported into the xgi.stats package, so sphinx creates all three files.

I think it's fine, at least documentation-wise, though these three names are too similar to each other that they may eventually cause a problem with end-users?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Open to suggestions here

xgi/stats/nodestats.py Outdated Show resolved Hide resolved
…he documentation tree that differed only in the case of some of the characters; this was causing problems for git on windows. So we have changed the decorators nodestat and edgestat to nodestat_func and edgestat_func. Additionally, we also fixed some documentation errors
@leotrs leotrs merged commit 6484a95 into main Jun 13, 2022
@leotrs leotrs deleted the feat_nodestats branch June 13, 2022 22:11
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.

None yet

2 participants