From 02dcf26ac56d7a372395e14ae6a78f7aa30f1310 Mon Sep 17 00:00:00 2001 From: Umberto Lupo <46537483+ulupo@users.noreply.github.com> Date: Fri, 12 Feb 2021 10:11:10 +0100 Subject: [PATCH] Release v0.4.4 (#63) * Prepare v0.4.4 (#62) * Bump version to 0.4.4, update code authors, and write release notes * Replace deprecated np.bool and np.float with bool and float builtins * Use np.floating instead of np.float_ to cover other floats than 64-bit * [CI] Remove unnecessary pip install wheel Co-authored-by: flomlo --- CODE_AUTHORS | 1 + RELEASE.rst | 28 ++++++++++++++++++++++++++++ azure-pipelines.yml | 2 -- pyflagser/_utils.py | 4 ++-- pyflagser/_version.py | 2 +- pyflagser/flagio.py | 16 ++++++++-------- pyflagser/tests/test_flagio.py | 14 +++++++++++++- setup.py | 2 +- 8 files changed, 54 insertions(+), 15 deletions(-) diff --git a/CODE_AUTHORS b/CODE_AUTHORS index cab38a9..fd05e30 100644 --- a/CODE_AUTHORS +++ b/CODE_AUTHORS @@ -4,3 +4,4 @@ Guillaume Tauzin, guillaume.tauzin@epfl.ch Julian Burella PĂ©rez, julian.burellaperez@heig-vd.ch Umberto Lupo, u.lupo@l2f.ch +Florian Unger, florian.unger@fau.de diff --git a/RELEASE.rst b/RELEASE.rst index 3bfdc59..a3247af 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -1,3 +1,31 @@ +Release 0.4.4 +============= + +Major Features and Improvements +------------------------------- + +None. + +Bug Fixes +--------- + +A fatal error in ``save_unweighted_flag`` has been fixed (Florian Unger). + +Backwards-Incompatible Changes +------------------------------ + +None. + +Thanks to our Contributors +-------------------------- + +This release contains contributions from: + +Florian Unger and Umberto Lupo. + +We are also grateful to all who filed issues or helped resolve them, asked and answered questions, and were part of inspiring discussions. + + Release 0.4.3 ============= diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 02dfaaf..12dea4e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -116,7 +116,6 @@ jobs: displayName: 'Uninstall pyflagser dev' - script: | - pip install wheel python setup.py bdist_wheel failOnStderr: false displayName: 'Build the wheels' @@ -214,7 +213,6 @@ jobs: - bash: | sed -i $'s/\r$//' README.rst - pip install wheel python setup.py bdist_wheel failOnStderr: false displayName: 'Build the wheels' diff --git a/pyflagser/_utils.py b/pyflagser/_utils.py index 16e6729..b0244dd 100644 --- a/pyflagser/_utils.py +++ b/pyflagser/_utils.py @@ -14,7 +14,7 @@ def _extract_unweighted_graph(adjacency_matrix): # Extract vertices and give them weight one n_vertices = max(input_shape) - vertices = np.ones(n_vertices, dtype=np.float) + vertices = np.ones(n_vertices, dtype=float) # Extract edge indices if isinstance(adjacency_matrix, np.ndarray): @@ -71,7 +71,7 @@ def _extract_weighted_graph(adjacency_matrix, max_edge_weight): mask = row != column # Mask infinite or thresholded weights - if np.issubdtype(adjacency_matrix.dtype, np.float_): + if np.issubdtype(adjacency_matrix.dtype, np.floating): if (max_edge_weight is None) or np.isposinf(max_edge_weight): mask = np.logical_and(mask, np.isfinite(data)) else: diff --git a/pyflagser/_version.py b/pyflagser/_version.py index 27609ae..1f17d02 100644 --- a/pyflagser/_version.py +++ b/pyflagser/_version.py @@ -17,4 +17,4 @@ # 'X.Y.dev0' is the canonical version of 'X.Y.dev' # -__version__ = '0.4.3' +__version__ = '0.4.4' diff --git a/pyflagser/flagio.py b/pyflagser/flagio.py index 7f3ebc9..b5932be 100644 --- a/pyflagser/flagio.py +++ b/pyflagser/flagio.py @@ -7,7 +7,7 @@ from ._utils import _extract_unweighted_graph, _extract_weighted_graph -def load_unweighted_flag(fname, fmt='csr', dtype=np.bool): +def load_unweighted_flag(fname, fmt='csr', dtype=bool): """Load a ``.flag`` file and return the adjacency matrix of the directed/undirected unweighted graph it describes. @@ -23,7 +23,7 @@ def load_unweighted_flag(fname, fmt='csr', dtype=np.bool): returned. Keep in mind that some matrix formats do not track zero values. - dtype : data-type, optional, default: ``np.bool`` + dtype : data-type, optional, default: ``bool`` Data-type of the resulting array. Returns @@ -65,7 +65,7 @@ def load_unweighted_flag(fname, fmt='csr', dtype=np.bool): return adjacency_matrix.asformat(fmt) -def load_weighted_flag(fname, fmt='csr', dtype=np.float, infinity_value=None): +def load_weighted_flag(fname, fmt='csr', dtype=float, infinity_value=None): """Load a ``.flag`` file and return the adjacency matrix of the directed/undirected weighted graph it describes. @@ -81,7 +81,7 @@ def load_weighted_flag(fname, fmt='csr', dtype=np.float, infinity_value=None): returned. Keep in mind that some matrix formats do not track zero values. - dtype : data-type, optional, default: ``np.float`` + dtype : data-type, optional, default: ``float`` Data-type of the resulting array. infinity_value : int or float or None, optional, default: ``None`` @@ -122,7 +122,7 @@ def load_weighted_flag(fname, fmt='csr', dtype=np.float, infinity_value=None): # Get the maximum value depending on adjacency_matrix.dtype if np.issubdtype(dtype, np.integer): _infinity_value = np.iinfo(dtype).max - elif np.issubdtype(dtype, np.float_): + elif np.issubdtype(dtype, np.floating): _infinity_value = np.inf else: _infinity_value = 0 @@ -191,9 +191,9 @@ def save_unweighted_flag(fname, adjacency_matrix): vertices, edges = _extract_unweighted_graph(adjacency_matrix) with open(fname, 'w') as f: - np.savetxt(f, vertices, delimiter=' ', comments='', header='dim 0', - fmt='%.18e') - np.savetxt(f, edges, comments='', header='dim 1', fmt='%i %i') + np.savetxt(f, vertices.reshape((1, -1)), delimiter=' ', header='dim 0', + fmt='%i') + np.savetxt(f, edges, comments='', header='dim 1', fmt='%i %i %i') def save_weighted_flag(fname, adjacency_matrix, max_edge_weight=None): diff --git a/pyflagser/tests/test_flagio.py b/pyflagser/tests/test_flagio.py index 843abf4..bf392c9 100644 --- a/pyflagser/tests/test_flagio.py +++ b/pyflagser/tests/test_flagio.py @@ -7,7 +7,7 @@ from numpy.testing import assert_almost_equal from pyflagser import load_unweighted_flag, load_weighted_flag, \ - save_weighted_flag + save_weighted_flag, save_unweighted_flag from pyflagser._utils import _extract_unweighted_graph, \ _extract_weighted_graph @@ -34,3 +34,15 @@ def test_weighted(flag_file_small, max_edge_length): os.remove(fname_temp) assert_almost_equal(vertices_a, vertices_a) assert_almost_equal(edges_b, edges_b) + + +def test_unweighted(flag_file_small): + adjacency_matrix = load_unweighted_flag(flag_file_small) + vertices_a, edges_a = _extract_unweighted_graph(adjacency_matrix) + fname_temp = os.path.split(flag_file_small)[1] + save_unweighted_flag(fname_temp, adjacency_matrix) + adjacency_matrix = load_unweighted_flag(fname_temp) + vertices_b, edges_b = _extract_unweighted_graph(adjacency_matrix) + os.remove(fname_temp) + assert_almost_equal(vertices_a, vertices_a) + assert_almost_equal(edges_b, edges_b) diff --git a/setup.py b/setup.py index 1bd83b4..d5e321d 100755 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ MAINTAINER_EMAIL = 'maintainers@giotto.ai' URL = 'https://github.com/giotto-ai/pyflagser' LICENSE = 'GNU AGPLv3' -DOWNLOAD_URL = 'https://github.com/giotto-ai/pyflagser/tarball/v0.4.3' +DOWNLOAD_URL = 'https://github.com/giotto-ai/pyflagser/tarball/v0.4.4' VERSION = __version__ # noqa CLASSIFIERS = ['Intended Audience :: Science/Research', 'Intended Audience :: Developers',