Skip to content

Commit

Permalink
Merge pull request #391 from pyt-team/frantzen/0.1-preparations
Browse files Browse the repository at this point in the history
Preparations for 0.1 release
  • Loading branch information
ffl096 authored Aug 14, 2024
2 parents 498a36c + 0c13103 commit 937227f
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 158 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
repository-name: pyt-team/pyt-team.github.io
target-folder: toponetx
clean: true

numpydoc-validation:
runs-on: ${{matrix.os}}
strategy:
Expand All @@ -70,6 +71,4 @@ jobs:
pip install -e .[doc]
- name: Checking NumpyDoc Validation for files
run: |
pip install pre-commit
pre-commit install
pre-commit run --all-files numpydoc-validation
numpydoc lint test/**/*.py toponetx/**/*.py
54 changes: 32 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</h2>

<h3 align="center">
Computing with Relational Data abstracted as Topological Domains
Computing with Relational Data Abstracted as Topological Domains
</h3>

<p align="center">
Expand Down Expand Up @@ -81,29 +81,10 @@ TNX is developed by the [pyt-team](https://github.com/pyt-team)

# 🤖 Installing TopoNetX

1. Clone a copy of `TopoNetX` from source:

```bash
git clone https://github.com/pyt-team/TopoNetX
cd TopoNetX
```

2. If you have already cloned `TopoNetX` from source, update it:
`TopoNetX` is available on PyPI and can be installed using `pip`:

```bash
git pull
```

3. Install `TopoNetX` in editable mode (requires pip ≥ 21.3 for [PEP 660](https://peps.python.org/pep-0610/) support):

```bash
pip install -e '.[all]'
```

4. Install pre-commit hooks:

```bash
pre-commit install
pip install toponetx
```

# 🦾 Getting Started
Expand Down Expand Up @@ -161,6 +142,35 @@ B02 = cc.incidence_matrix(0, 2)
B03 = cc.incidence_matrix(0, 3)
```

## 🧑‍💻 Install from source

To install the latest version from source, follow these steps:

1. Clone a copy of `TopoNetX` from source:

```bash
git clone https://github.com/pyt-team/TopoNetX
cd TopoNetX
```

2. If you have already cloned `TopoNetX` from source, update it:

```bash
git pull
```

3. Install `TopoNetX` in editable mode (requires `pip` ≥ 21.3 for [PEP 660](https://peps.python.org/pep-0610/) support):

```bash
pip install -e '.[all]'
```

4. Install pre-commit hooks:

```bash
pre-commit install
```

## 🔍 References

To learn more about topological domains, and how they can be used in deep learning:
Expand Down
7 changes: 3 additions & 4 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ API Reference
The API reference gives an overview of ``TopoNetX``, which consists of several modules:

- ``classes`` implements the topological domains: simplicial complexes, cellular complexes, combinatorial complexes.
- ``algorithms`` implements signal processing techniques on topological domains, such as the eigendecomposition of a laplacian.
- ``datasets`` implements utilities to load small datasets on topological domains.
- ``transform`` implements functions to transform the topological domain that supports a dataset, effectively "lifting" the dataset onto another domain.
- ``algorithms`` implements signal processing techniques on topological domains, such as the eigendecomposition of a laplacian.
- ``generators`` implements functions to generate random topological domains.
- ``transform`` implements functions to convert a graph to a topological domain: simplicial complexes etc.
- ``readwrite`` implements functions to read and write topological domains from and to disk.


.. toctree::
:maxdepth: 2
:caption: Packages & Modules

datasets
classes
datasets
transform
algorithms
generators
transform
readwrite
4 changes: 2 additions & 2 deletions docs/api/readwrite.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*********
**********
Read-Write
*********
**********

.. automodule:: toponetx.readwrite.atomlist
:members:
Expand Down
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ TNX was developed by the pyt-team.

6. Package dependencies are kept to a minimum, to facilitate easy installation and to reduce future installation issues arising from such dependencies.

🤖 Installing TopoNetX
----------------------

``TopoNetX`` is available on PyPI and can be installed using ``pip``:

.. code-block:: bash
pip install toponetx
🔍 References
-------------

Expand Down Expand Up @@ -103,3 +112,14 @@ Want to try it yourself? Check out our tutorials to get started.
api/index
tutorials/index
contributing/index

⭐ Funding
----------

.. image:: https://raw.githubusercontent.com/pyt-team/TopoNetX/main/resources/erc_logo.png
:align: right
:width: 200

Partially funded by the European Union (ERC, HIGH-HOPeS, 101039827). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.

Partially funded by the National Science Foundation (DMS-2134231, DMS-2134241).
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ doc = [
"jupyter",
"nbsphinx",
"nbsphinx_link",
"numpydoc",
"numpydoc >= 1.8.0",
"sphinx",
"sphinx_gallery",
"pydata-sphinx-theme"
Expand Down
15 changes: 0 additions & 15 deletions test/classes/test_cell_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,21 +824,6 @@ def test_cell_equivalence_class(self):

assert len(equivalence_classes) == 4

def test__remove_equivalent_cells(self):
"""Test the remove equivalent cells method."""
CC = CellComplex()
CC.add_cell((1, 2, 3, 4), rank=2)
CC.add_cell((2, 3, 4, 1), rank=2)
CC.add_cell((1, 2, 3, 4), rank=2)
CC.add_cell((1, 2, 3, 6), rank=2)
CC.add_cell((3, 4, 1, 2), rank=2)
CC.add_cell((4, 3, 2, 1), rank=2)
CC.add_cell((1, 2, 7, 3), rank=2)
c1 = Cell((1, 2, 3, 4, 5))
CC.add_cell(c1, rank=2)
CC._remove_equivalent_cells()
assert len(CC.cells) == 4

def test_get_cell_attributes2(self):
"""Test the remove equivalent cells method."""
import networkx as nx
Expand Down
49 changes: 13 additions & 36 deletions toponetx/classes/cell_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,37 +463,6 @@ def _cell_equivalence_class(self) -> dict[Cell, set[Cell]]:
all_inserted_cells.add(j)
return equiv_classes

def _remove_equivalent_cells(self) -> None:
"""Remove homotopic cells from the cell complex.
Examples
--------
>>> CC = tnx.CellComplex()
>>> CC.add_cell((1, 2, 3, 4), rank=2)
>>> CC.add_cell((2, 3, 4, 1), rank=2)
>>> CC.add_cell((1, 2, 3, 4), rank=2)
>>> CC.add_cell((1, 2, 3, 6), rank=2)
>>> CC.add_cell((3, 4, 1, 2), rank=2)
>>> CC.add_cell((4, 3, 2, 1), rank=2)
>>> CC.add_cell((1, 2, 7, 3), rank=2)
>>> c1 = tnx.Cell((1, 2, 3, 4, 5))
>>> CC.add_cell(c1, rank=2)
>>> CC._remove_equivalent_cells()
>>> CC
"""
equiv_classes = self._cell_equivalence_class()
for c in list(self.cells):
if c not in equiv_classes:
d = self._cells._cells[c.elements]
if len(d) == 1:
self._delete_cell(c)
else:
d_c = dict(d)
for k in d_c:
if len(d) == 1:
break
self._delete_cell(c, k)

def degree(self, node: Hashable, rank: int = 1) -> int:
"""Compute the number of cells of certain rank that contain node.
Expand Down Expand Up @@ -1134,7 +1103,7 @@ def set_cell_attributes(
... (1, 2, 3, 4): {"color": "red", "attr2": 1},
... (1, 2, 4): {"color": "blue", "attr2": 3},
... }
>>> CC.set_cell_attributes(d)
>>> CC.set_cell_attributes(d, rank=2)
>>> CC.cells[(1, 2, 3, 4)][0]["color"]
'red'
"""
Expand Down Expand Up @@ -1359,9 +1328,19 @@ def remove_equivalent_cells(self) -> None:
>>> CC.add_cell([3, 4, 8], rank=2)
>>> print(CC.cells)
>>> CC.remove_equivalent_cells()
>>> print(CC.cells) # observe homotopic cells have been removed
"""
self._remove_equivalent_cells()
equiv_classes = self._cell_equivalence_class()
for c in list(self.cells):
if c not in equiv_classes:
d = self._cells._cells[c.elements]
if len(d) == 1:
self._delete_cell(c)
else:
d_c = dict(d)
for k in d_c:
if len(d) == 1:
break
self._delete_cell(c, k)

def is_insertable_cycle(
self,
Expand Down Expand Up @@ -1833,8 +1812,6 @@ def up_laplacian_matrix(
>>> CC.add_cell([1, 2, 3], rank=2)
>>> CC.add_cell([3, 4, 5], rank=2)
>>> index, L1_up = CC.up_laplacian_matrix(1, index=True)
>>> print(index)
>>> print(L1_up)
"""
if weight is not None:
raise ValueError("Weighted Laplacian is not supported in this version.")
Expand Down
2 changes: 0 additions & 2 deletions toponetx/classes/colored_hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,6 @@ def node_to_all_cell_adjacnecy_matrix(self, index: bool = False, s: int = 1):
def coadjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False):
"""Compute the coadjacency matrix.
The sparse weighted :term:`s-coadjacency matrix`.
Parameters
----------
rank : int
Expand Down
4 changes: 1 addition & 3 deletions toponetx/classes/combinatorial_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def incidence_matrix(
)

def adjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False):
"""Sparse weighted :term:`s-adjacency matrix`.
"""Sparse weighted `s-adjacency matrix`.
Parameters
----------
Expand Down Expand Up @@ -877,8 +877,6 @@ def adjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False):
def coadjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False):
"""Compute the coadjacency matrix of self.
The sparse weighted :term:`s-coadjacency matrix`
Parameters
----------
rank, via_rank : int
Expand Down
Loading

0 comments on commit 937227f

Please sign in to comment.