From be17ce41d60316f1c6fad924aec9a860ff73b634 Mon Sep 17 00:00:00 2001 From: Nicholas Landry Date: Wed, 1 Dec 2021 00:05:50 -0700 Subject: [PATCH] V0.1.1 (#16) * moved unique edge size function from hypergraph class and fixed bug. * update version * Fixed small documentation issue * fixed numpy dependency * update long description --- CITATION.cff | 2 +- README.md | 8 ++- docs/source/about.rst | 5 +- docs/source/conf.py | 2 +- docs/source/index.rst | 7 +- long_description.rst | 74 +++++++++++++++++++++ requirements/default.txt | 9 ++- requirements/{doc.txt => documentation.txt} | 1 + requirements/{example.txt => tutorial.txt} | 0 setup.py | 40 +++++------ xgi/classes/function.py | 24 +++++++ xgi/classes/hypergraph.py | 24 +------ xgi/classes/hypergraphviews.py | 7 +- xgi/metadata.py | 2 +- xgi/readwrite/bipartite.py | 2 +- 15 files changed, 147 insertions(+), 60 deletions(-) create mode 100644 long_description.rst rename requirements/{doc.txt => documentation.txt} (60%) rename requirements/{example.txt => tutorial.txt} (100%) diff --git a/CITATION.cff b/CITATION.cff index 3930620f1..72da9c8b0 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -11,5 +11,5 @@ cff-version: "1.1.0" license: "BSD-3" message: "If you use this software, please cite it using these metadata." title: XGI -version: "0.1" +version: "0.1.1" ... \ No newline at end of file diff --git a/README.md b/README.md index 1106ed11d..e7f8ffe3e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ To get started, take a look at the [tutorials](/tutorials/) illustrating the lib ## Documentation -For more documentation, see our [Read The Docs](https://xgi.readthedocs.io/en/latest/) page +For more documentation, see our [Read The Docs](https://xgi.readthedocs.io/en/latest/) page. ## Contributing Contributions are always welcome. Please report any bugs that you find [here](../../issues). Or, even better, fork the repository on [GitHub](../../) and create a pull request (PR). We welcome all changes, big or small, and we will help you make the PR if you are new to `git` (just ask on the issue and/or see our [contributing guidelines](CONTRIBUTING.md)). @@ -60,16 +60,18 @@ a citation in your preferred format, and will also integrate well with citation Our full code of conduct, and how we enforce it, can be read in [our repository](CODE_OF_CONDUCT.md). ## License -Released under the 3-Clause BSD license (see `license.md`) +Released under the 3-Clause BSD license (see [`license.md`](license.md)) Copyright (C) 2021 XGI Developers + Nicholas Landry + Leo Torres The XGI library has copied or modified code from the HyperNetX and NetworkX libraries, the licenses of which can be found in our [license file](license.md) ## Funding -The XGI package has been supported by NSF Grant 2121905, ["HNDS-I: Using Hypergraphs to Study Spreading Processes in Complex Social Networks"](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2121905) +The XGI package has been supported by NSF Grant 2121905, ["HNDS-I: Using Hypergraphs to Study Spreading Processes in Complex Social Networks"](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2121905). ## Other resources This library may not meet your needs and if this is this case, consider checking out these other resources: diff --git a/docs/source/about.rst b/docs/source/about.rst index aa25ed061..2a884db18 100644 --- a/docs/source/about.rst +++ b/docs/source/about.rst @@ -1,6 +1,9 @@ About ===== +.. image:: ../../logo/logo.svg + :width: 200 + The ``XGI`` library provides data structures and algorithms for modeling and analyzing complex systems with group (higher-order) interactions. @@ -30,7 +33,6 @@ installed by ``pip`` during the installation process License ------- - This project is licensed under the `BSD 3-Clause License `__. Note that this excludes any images/pictures/figures shown here or in the @@ -38,7 +40,6 @@ documentation. Contributing ------------ - If you want to contribute to this project, please make sure to read the `code of conduct `__ diff --git a/docs/source/conf.py b/docs/source/conf.py index 4443c1b27..898fccbf5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,7 +24,7 @@ author = "Nicholas W. Landry and Leo Torres" # The full version, including alpha/beta/rc tags -release = "0.1" +release = "0.1.1" # -- General configuration --------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 892f36b79..5448208bf 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,6 +1,9 @@ -======= +=== XGI -======= +=== + +.. image:: ../../logo/logo.svg + :width: 200 Description ----------- diff --git a/long_description.rst b/long_description.rst new file mode 100644 index 000000000..2795bed52 --- /dev/null +++ b/long_description.rst @@ -0,0 +1,74 @@ +XGI +=== + +.. image:: https://github.com/ComplexGroupInteractions/xgi/blob/main/logo/logo.svg + :width: 200 + +CompleX Group Interactions (XGI) is a Python package for the representation, manipulation, +and study of the structure, dynamics, and functions of complex systems with group (higher-order) interactions. + +- **Source**: https://github.com/ComplexGroupInteractions/xgi +- **Bug reports**: https://github.com/ComplexGroupInteractions/xgi/issues +- **GitHub Discussions**: https://github.com/ComplexGroupInteractions/xgi/discussions +- **Documentation**: https://xgi.readthedocs.io/en/latest/ + +Installation +------------ +XGI runs on Python 3.7 or higher. + +To install the latest version of XGI, run the following command +.. code:: bash + + pip install xgi + +To install this package locally: +- Clone this repository +- Navigate to the folder on your local machine +- Run the following command +.. code:: bash + + pip install -e .["all"] + + +Getting Started +--------------- +To get started, take a look at the `tutorials `_ +illustrating the library's basic functionality. + +Documentation +------------- +For more documentation, see our `Read The Docs `_ page. + +Contributing +------------ +Contributions are always welcome. Please report any bugs that you find `here `_. +Or, even better, fork the repository on `GitHub `_ and create a pull request (PR). +We welcome all changes, big or small, and we will help you make the PR if you are new to `git` +(just ask on the issue and/or see our `contributing guidelines `_. + +How to Cite +----------- +We acknowledge the importance of good software to support research, and we note +that research becomes more valuable when it is communicated effectively. To +demonstrate the value of XGI, we ask that you cite XGI in your work. +Currently, the best way to cite XGI is to go to our +`repository page `_ and +click the "cite this repository" button on the right sidebar. This will generate +a citation in your preferred format, and will also integrate well with citation managers. + +Code of Conduct +--------------- +Our full code of conduct, and how we enforce it, can be read in `our repository `_. + +License +------- +Released under the 3-Clause BSD license (see the `license file `_) + +Copyright (C) 2021 XGI Developers + +Nicholas Landry + +Leo Torres + +The XGI library has copied or modified code from the HyperNetX and NetworkX libraries, the licenses of which can be found in the +`license file `_. \ No newline at end of file diff --git a/requirements/default.txt b/requirements/default.txt index cc693c71b..b6ee3b536 100644 --- a/requirements/default.txt +++ b/requirements/default.txt @@ -1,5 +1,4 @@ -numpy>=1.19 -scipy>=1.5,!=1.6.1 -pandas>=1.1 -networkx>=2.5 -python>=3.7 \ No newline at end of file +networkx>=2.2 +numpy>=1.19,<1.22 +scipy>=1.5 +pandas>=1.0 \ No newline at end of file diff --git a/requirements/doc.txt b/requirements/documentation.txt similarity index 60% rename from requirements/doc.txt rename to requirements/documentation.txt index c5de6845a..e11b6cc2e 100644 --- a/requirements/doc.txt +++ b/requirements/documentation.txt @@ -1,3 +1,4 @@ sphinx~=4.0 +sphinx-rtd-theme>=0.4.2 numpydoc>=1.1 pillow>=8.2 \ No newline at end of file diff --git a/requirements/example.txt b/requirements/tutorial.txt similarity index 100% rename from requirements/example.txt rename to requirements/tutorial.txt diff --git a/setup.py b/setup.py index 809459e18..13e363cbb 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup import sys -__version__ = "0.1" +__version__ = "0.1.1" if sys.version_info < (3, 7): sys.exit("XGI requires Python 3.7 or later.") @@ -18,7 +18,7 @@ "xgi.utils", ] -version = "0.1" +version = "0.1.1" authors = "Nicholas Landry and Leo Torres" @@ -26,29 +26,30 @@ url = "https://github.com/ComplexGroupInteractions/xgi" -description = "XGI is a Python library for the representation and analysis of complex systems with group (higher-order) interaction." +description = """XGI is a Python library for the representation +and analysis of complex systems with group (higher-order) interactions.""" -install_requires = [ - "networkx>=2.2,<3.0", - "numpy>=1.15.0,<2.0", - "scipy>=1.1.0,<2.0", - "pandas>=0.23", -] +with open("long_description.rst") as file: + long_description = file.read() + + +def parse_requirements_file(filename): + with open(filename) as fid: + requires = [l.strip() for l in fid.readlines() if not l.startswith("#")] + return requires -license = "3-Clause BSD license" extras_require = { - "testing": ["pytest>=4.0"], - "tutorials": ["jupyter>=1.0"], - "documentation": ["sphinx>=1.8.2", "sphinx-rtd-theme>=0.4.2"], - "all": [ - "sphinx>=1.8.2", - "sphinx-rtd-theme>=0.4.2", - "pytest>=4.0", - "jupyter>=1.0", - ], + dep: parse_requirements_file("requirements/" + dep + ".txt") + for dep in ["developer", "documentation", "release", "test", "tutorial"] } +extras_require["all"] = list({item for dep in extras_require.values() for item in dep}) + +install_requires = parse_requirements_file("requirements/default.txt") + +license = "3-Clause BSD license" + setup( name=name, packages=packages, @@ -57,6 +58,7 @@ author_email=author_email, url=url, description=description, + long_description=long_description, install_requires=install_requires, extras_require=extras_require, ) diff --git a/xgi/classes/function.py b/xgi/classes/function.py index 7b0a545a1..dc648b855 100644 --- a/xgi/classes/function.py +++ b/xgi/classes/function.py @@ -2,10 +2,12 @@ """ from collections import Counter +import numpy as np import xgi __all__ = [ "degree_histogram", + "unique_edge_sizes", "freeze", "is_frozen", "create_empty_copy", @@ -48,6 +50,28 @@ def degree_histogram(H): return [counts.get(i, 0) for i in range(max(counts) + 1)] +def unique_edge_sizes(H, return_counts=False): + """A function that returns the unique edge sizes. + + Parameters + ---------- + H : Hypergraph object + The hypergraph of interest + return_counts : bool, default: False + Specifies whether to include the number of occurences of that edge size + + Returns + ------- + if return_counts: + numpy.ndarray, numpy.ndarray + Numpy arrays of the unique edge sizes and the number of each size respectively + else: + numpy.ndarray + A numpy array of the unique edge sizes + """ + return np.unique(list(H.edge_size), return_counts=return_counts) + + def frozen(*args, **kwargs): """Dummy method that raises an error when trying to modify frozen hypergraphs diff --git a/xgi/classes/hypergraph.py b/xgi/classes/hypergraph.py index 89325145f..99792b887 100644 --- a/xgi/classes/hypergraph.py +++ b/xgi/classes/hypergraph.py @@ -24,6 +24,7 @@ class Hypergraph: """A class to represent undirected hypergraphs.""" + node_dict_factory = dict node_attr_dict_factory = dict hyperedge_dict_factory = dict @@ -883,25 +884,6 @@ def edge_size(self): """ return EdgeSizeView(self) - def unique_edge_sizes(self, return_counts=False): - """A function that returns the unique edge sizes. - - Parameters - ---------- - return_counts : bool, default: False - Specifies whether to include the number of occurences of that edge size - - Returns - ------- - if return_counts: - numpy.ndarray, numpy.ndarray - Numpy arrays of the unique edge sizes and the number of each size respectively - else: - numpy.ndarray - A numpy array of the unique edge sizes - """ - return np.unique(list(self.edge_degree), return_counts=return_counts) - def clear(self): """Remove all nodes and edges from the graph. @@ -1159,9 +1141,7 @@ def bunch_iter(nlist, nodes): exc, message = e, e.args[0] # capture error for non-sequence/iterator nbunch. if "iter" in message: - exc = XGIError( - "nbunch is not a node or a sequence of nodes." - ) + exc = XGIError("nbunch is not a node or a sequence of nodes.") # capture error for unhashable node. if "hashable" in message: exc = XGIError( diff --git a/xgi/classes/hypergraphviews.py b/xgi/classes/hypergraphviews.py index 34880aefd..3a35b6d0f 100644 --- a/xgi/classes/hypergraphviews.py +++ b/xgi/classes/hypergraphviews.py @@ -13,7 +13,6 @@ """ - import xgi __all__ = ["generic_hypergraph_view", "subhypergraph_view"] @@ -21,7 +20,7 @@ def generic_hypergraph_view(H, create_using=None): """Create a read-only view of the hypergraph - + The read-only view shares the same memory as the original hypergraph and "freezes" the hypergraph by removing the methods that can modify the hypergraph. @@ -100,6 +99,8 @@ def subhypergraph_view(H, filtered_nodes=None, filtered_edges=None): newH._edge_attr = {edge: H._edge_attr[edge] for edge in newH._edge} # Add the filtered nodes with connections to the remaining edges after filtering - newH._node = {node: set(H._node[node]).intersection(newH._edge.keys()) for node in nodes} + newH._node = { + node: set(H._node[node]).intersection(newH._edge.keys()) for node in nodes + } newH._node_attr = {node: H._node_attr[node] for node in nodes} return newH diff --git a/xgi/metadata.py b/xgi/metadata.py index 6f0d0ddf9..9f0bc31f8 100644 --- a/xgi/metadata.py +++ b/xgi/metadata.py @@ -3,7 +3,7 @@ Contains information about this package. """ -__version__ = "0.1" +__version__ = "0.1.1" __author__ = "Nicholas W. Landry and Leo Torres" __copyright__ = "Copyright 2021-2022, " + __author__ diff --git a/xgi/readwrite/bipartite.py b/xgi/readwrite/bipartite.py index 7c08749ce..5ed8c40a9 100644 --- a/xgi/readwrite/bipartite.py +++ b/xgi/readwrite/bipartite.py @@ -1,4 +1,4 @@ -import xgi +import xgi from xgi.exception import XGIError __all__ = [