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
Docs spiff up #202
Docs spiff up #202
Conversation
leotrs
commented
Oct 28, 2022
- Added a short blurb on the landing page. This was a feedback I received from someone who looked at the page and told me they have no idea what the library was even for!
- Added a reference that seemed relevant.
- Updated python version to 3.11.
- Fixes Doc for H.degree() not pointing to H.nodes.degree() #185.
…the returned function
@maximelucas This PR addresses #185. Could you please confirm that the proposed solution actually solves the issue to your satisfaction? The old behavior was: >>> H.degree?
Signature: H.degree(node=None, *args, **kwargs)
Docstring: <no docstring>
File: ~/code/xgi/xgi/classes/hypergraph.py
Type: function The new behavior is: >>> H.degree?
Signature: H.degree(node=None, *args, **kwargs)
Docstring:
Equivalent to H.nodes.degree.asdict(). For accepted *args and
**kwargs, see documentation of H.nodes.degree.
File: ~/code/xgi/xgi/classes/hypergraph.py
Type: function
>>> H.size?
Signature: H.size(node=None, *args, **kwargs)
Docstring:
Equivalent to H.edges.size.asdict(). For accepted *args and
**kwargs, see documentation of H.edges.size.
File: ~/code/xgi/xgi/classes/hypergraph.py
Type: function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, Leo!!
I like it, thanks Leo. I'm thinking now we might need to go further.
I'm not sure how yet, but I'm realising we might need to make the link between these things much more explicit for new users. So far, the best "explanation" of how stats work and what they are is probably the tutorial. |
Okay I realise now that the user can get some info from >>> H.nodes.degree?
Signature: H.nodes.degree(*args, **kwargs)
Type: NodeStat
String form: NodeStat('degree')
File: ~/WORK/SCIENCE/xgi/xgi/stats/__init__.py
Docstring:
An arbitrary node-quantity mapping.
`NodeStat` objects represent a mapping that assigns a value to each node in a
network. For more details, see the `tutorial
<https://github.com/ComplexGroupInteractions/xgi/blob/main/tutorials/Tutorial%206%20-%20Statistics.ipynb>`_. The docstring describes NodeStat (rather than the degree stat) and points to the tutorial. |
Oh that's a good point. The docstring of We could try to merge the two docstrings somehow but I'm not sure what's the best/most efficient way of doing this. In particular, a big problem is that |
How is the equivalence between I think:
If there is a way to solve the last point without writing the docstrings twice, great. If not, I suggest we write it twice (at least for now). |
The short answer is that each NodeStat object is created with a reference to one of the functions in The long answer is, well, long. When a user executes
(Note: writing this all down makes me realize that we can simplify this entire pipeline a great deal in at least two different ways, so I'll work on changing that soon!) (Note: this has been simplified a bit by #209 )
As you point this out, I realize that the docs of H.nodes?
Type: property
String form: <property object at 0x7f9c7aa7b4f0>
Docstring: A :class:`NodeView` of this network. This is because In [26]: H._nodeview?
Signature: H._nodeview(bunch)
Type: NodeView
String form: []
Length: 0
File: ~/code/xgi/xgi/classes/reportviews.py
Docstring:
An IDView that keeps track of node ids.
Parameters
----------
hypergraph : Hypergraph
The hypergraph whose nodes this view will keep track of.
bunch : optional iterable, default None
The node ids to keep track of. If None (default), keep track of all node ids.
Notes
-----
In addition to the methods listed in this page, other methods defined in the `stats`
package are also accessible via the `NodeView` class. For more details, see the
`tutorial
<https://github.com/ComplexGroupInteractions/xgi/blob/main/tutorials/Tutorial%206%20-%20Statistics.ipynb>`_.
Call docstring:
Filter to the given bunch.
Parameters
----------
bunch : Iterable
Iterable of IDs
Returns
-------
IDView
A new view that keeps track only of the IDs in the bunch. As you can see, these latter docs actually DO mention and point to the tutorial! Perhaps we should add another link to the stats package, and make sure that
Agreed on all three.
How about something like this: H.nodes.degree?
Signature: H.nodes.degree(*args, **kwargs)
Type: NodeStat
String form: NodeStat('degree')
File: ~/code/xgi/xgi/stats/__init__.py
Docstring:
A node mapping with name "degree".
Executing `H.nodes.degree(*args, **kwargs).asdict()` is equivalent to
`xgi.stats.nodestats.degree(H, *args, **kwargs)`. The available *args
and **kwargs are listed in the docstring of `xgi.stats.nodestats.degree`.
Said docstring is appended at the end of this docstring for reference.
For more details, see the `tutorial
<https://github.com/ComplexGroupInteractions/xgi/blob/main/tutorials/Tutorial%206%20-%20Statistics.ipynb>`_.
What follows is the docstring of `xgi.stats.nodestats.degree`.
Node degree.
The degree of a node is the number of edges it belongs to.
Parameters
----------
net : xgi.Hypergraph
The network.
bunch : Iterable
Nodes in `net`.
order : int | None
If not None (default), only count the edges of the given order.
weight : str | None
If not None, specifies the name of the edge attribute that determines the weight
of each edge.
Returns
-------
dict Or something along those lines? We can do this fairly easily. Anything more complicated will require some major redesigining. |
Note: your PR #209 proposes to simplify that.
Oh okay that's where it is. But yes, it should also be available from
Nice, looks much better. Is this hard-coded copy-paste or you found another clever way? If just copy-pasted, why not just adapt the docs as follows: H.nodes.degree?
Signature: H.nodes.degree(*args, **kwargs)
Type: NodeStat
String form: NodeStat('degree')
File: ~/code/xgi/xgi/stats/__init__.py
Docstring:
A node mapping with name "degree".
The degree of a node is the number of edges it belongs to.
Executing `H.nodes.degree(*args, **kwargs).asdict()` is equivalent to
`xgi.stats.nodestats.degree(H, *args, **kwargs)`. The available *args
and **kwargs are listed in the docstring of `xgi.stats.nodestats.degree`.
For more details, see the `tutorial
<https://github.com/ComplexGroupInteractions/xgi/blob/main/tutorials/Tutorial%206%20-%20Statistics.ipynb>`_.
Parameters
----------
bunch : Iterable
Nodes in `net`.
order : int | None
If not None (default), only count the edges of the given order.
weight : str | None
If not None, specifies the name of the edge attribute that determines the weight
of each edge.
Returns
-------
dict |
What I posted is possible by just doing something like |
I did not know that. Great then, I like your solution. |