Skip to content

Commit

Permalink
Release v0.4.4 (#63)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ulupo and flomlo authored Feb 12, 2021
1 parent 24c1d8c commit 02dcf26
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 15 deletions.
1 change: 1 addition & 0 deletions CODE_AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
Guillaume Tauzin, [email protected]
Julian Burella Pérez, [email protected]
Umberto Lupo, [email protected]
Florian Unger, [email protected]
28 changes: 28 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -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
=============

Expand Down
2 changes: 0 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ jobs:
displayName: 'Uninstall pyflagser dev'
- script: |
pip install wheel
python setup.py bdist_wheel
failOnStderr: false
displayName: 'Build the wheels'
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pyflagser/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyflagser/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
#

__version__ = '0.4.3'
__version__ = '0.4.4'
16 changes: 8 additions & 8 deletions pyflagser/flagio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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``
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 13 additions & 1 deletion pyflagser/tests/test_flagio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
MAINTAINER_EMAIL = '[email protected]'
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',
Expand Down

0 comments on commit 02dcf26

Please sign in to comment.