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

Updated add_simplices_from to match add_hyperedges_from #220

Merged
merged 5 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: format numbering in docs
  • Loading branch information
maximelucas committed Nov 9, 2022
commit 5922e6cf30cf9b59073e88abc219ac178ba4e52a
19 changes: 10 additions & 9 deletions xgi/classes/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,20 +502,21 @@ def add_edges_from(self, ebunch_to_add, **attr):
----------
ebunch_to_add : Iterable

An iterable of edges. This may be a dict of the form `{edge_id:
edge_members}`, or it may be an iterable of iterables, where each element
contains the members of the edge specified as valid node IDs.
An iterable of edges. This may be an iterable of iterables (Format 1),
where each element contains the members of the edge specified as valid node IDs.
Alternatively, each element could also be a tuple in any of the following
formats:

* Format 1: 2-tuple (members, edge_id), or
* Format 2: 2-tuple (members, attr), or
* Format 3: 3-tuple (members, edge_id, attr),
* Format 2: 2-tuple (members, edge_id), or
* Format 3: 2-tuple (members, attr), or
* Format 4: 3-tuple (members, edge_id, attr),

where `members` is an iterable of node IDs, `edge_id` is a hashable to use
as edge ID, and `attr` is a dict of attributes. The first and second formats
are unambiguous because `attr` dicts are not hashable, while `id`s must be.
In Formats 1-3, each element of `ebunch_to_add` must have the same length,
as edge ID, and `attr` is a dict of attributes. Finally, `ebunch_to_add`
may be a dict of the form `{edge_id: edge_members}` (Format 5).

Formats 2 and 3 are unambiguous because `attr` dicts are not hashable, while `id`s must be.
In Formats 2-4, each element of `ebunch_to_add` must have the same length,
i.e. you cannot mix different formats. The iterables containing edge
members cannot be strings.

Expand Down
19 changes: 10 additions & 9 deletions xgi/classes/simplicialcomplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,21 @@ def add_simplices_from(self, ebunch_to_add, max_order=None, **attr):
----------
ebunch_to_add : Iterable

An iterable of simplices. This may be a dict of the form `{simplex_id:
simplex_members}`, or it may be an iterable of iterables, where each element
contains the members of the simplex specified as valid node IDs.
An iterable of simplices. This may be an iterable of iterables (Format 1),
where each element contains the members of the simplex specified as valid node IDs.
Alternatively, each element could also be a tuple in any of the following
formats:

* Format 1: 2-tuple (members, simplex_id), or
* Format 2: 2-tuple (members, attr), or
* Format 3: 3-tuple (members, simplex_id, attr),
* Format 2: 2-tuple (members, simplex_id), or
* Format 3: 2-tuple (members, attr), or
* Format 4: 3-tuple (members, simplex_id, attr),

where `members` is an iterable of node IDs, `simplex_id` is a hashable to use
as simplex ID, and `attr` is a dict of attributes. The first and second formats
are unambiguous because `attr` dicts are not hashable, while `id`s must be.
In Formats 1-3, each element of `ebunch_to_add` must have the same length,
as simplex ID, and `attr` is a dict of attributes. Finally, `ebunch_to_add`
may be a dict of the form `{simplex_id: simplex_members}` (Format 5).

Formats 2 and 3 are unambiguous because `attr` dicts are not hashable, while `id`s must be.
In Formats 2-4, each element of `ebunch_to_add` must have the same length,
i.e. you cannot mix different formats. The iterables containing simplex
members cannot be strings.

Expand Down