Skip to content

Commit e735e9a

Browse files
authored
Merge pull request #57 from jajupmochi/v0.2.x
V0.2.x
2 parents 1d154cc + 13fbce2 commit e735e9a

File tree

8 files changed

+280
-59
lines changed

8 files changed

+280
-59
lines changed

.github/workflows/github-actions-ubuntu.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ jobs:
9191
# python setup.py bdist_wheel
9292
python setup.py install
9393
# pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ged/
94-
pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ --ignore=gklearn/tests/test_median_preimage_generator.py --ignore=gklearn/tests/test_graphkernels.py
94+
pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ --ignore=gklearn/tests/test_median_preimage_generator.py --ignore=gklearn/tests/test_graphkernels.py --ignore=gklearn/tests/ged/test_gedlib.py
9595
9696
- name: Run code coverage
9797
run: |
9898
codecov
9999
100-
- name: Publish distribution 📦 to Test PyPI
101-
if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
102-
uses: pypa/gh-action-pypi-publish@release/v1
103-
with:
104-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
105-
repository-url: https://test.pypi.org/legacy/
106-
107-
- name: Publish distribution 📦 to PyPI
108-
if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
109-
uses: pypa/gh-action-pypi-publish@release/v1
110-
with:
111-
user: __token__
112-
password: ${{ secrets.PYPI_API_TOKEN }}
100+
# - name: Publish distribution 📦 to Test PyPI
101+
# if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
102+
# uses: pypa/gh-action-pypi-publish@release/v1
103+
# with:
104+
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
105+
# repository-url: https://test.pypi.org/legacy/
106+
107+
# - name: Publish distribution 📦 to PyPI
108+
# if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
109+
# uses: pypa/gh-action-pypi-publish@release/v1
110+
# with:
111+
# user: __token__
112+
# password: ${{ secrets.PYPI_API_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# graphkit-learn
22

3-
![GitHub Actions](https://github.com/jajupmochi/graphkit-learn/actions/workflows/github-actions.yml/badge.svg)
3+
![GitHub Actions](https://github.com/jajupmochi/graphkit-learn/actions/workflows/github-actions-ubuntu.yml/badge.svg)
44
[![Build status](https://ci.appveyor.com/api/projects/status/bdxsolk0t1uji9rd?svg=true)](https://ci.appveyor.com/project/jajupmochi/graphkit-learn)
55
[![codecov](https://codecov.io/gh/jajupmochi/graphkit-learn/branch/master/graph/badge.svg)](https://codecov.io/gh/jajupmochi/graphkit-learn)
66
[![Documentation Status](https://readthedocs.org/projects/graphkit-learn/badge/?version=master)](https://graphkit-learn.readthedocs.io/en/master/?badge=master)

gklearn/ged/model/__init__.py

Whitespace-only changes.

gklearn/ged/model/ged_model.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ def clear_attributes(self): # @todo: update
258258
delattr(self, '_Y')
259259
if hasattr(self, '_run_time'):
260260
delattr(self, '_run_time')
261+
if hasattr(self, '_test_run_time'):
262+
delattr(self, '_test_run_time')
261263

262264

263265
def validate_parameters(self):
@@ -330,24 +332,26 @@ def compute_distance_matrix(self, Y=None, **kwargs):
330332

331333
else:
332334
# Compute kernel matrix between Y and self._graphs (X).
335+
Y_copy = ([g.copy() for g in Y] if self.copy_graphs else Y)
336+
graphs_copy = ([g.copy() for g in
337+
self._graphs] if self.copy_graphs else self._graphs)
338+
333339
start_time = time.time()
334340

335341
if self.parallel == 'imap_unordered':
336342
dis_matrix = self._compute_distance_matrix_imap_unordered(Y)
337343

338344
elif self.parallel is None:
339-
Y_copy = ([g.copy() for g in Y] if self.copy_graphs else Y)
340-
graphs_copy = ([g.copy() for g in
341-
self._graphs] if self.copy_graphs else self._graphs)
342345
dis_matrix = self._compute_distance_matrix_series(
343346
Y_copy, graphs_copy, **kwargs
344347
)
345348

346-
self._run_time = time.time() - start_time
349+
self._test_run_time = time.time() - start_time
350+
347351
if self.verbose:
348352
print(
349353
'Distance matrix of size (%d, %d) built in %s seconds.'
350-
% (len(Y), len(self._graphs), self._run_time)
354+
% (len(Y), len(self._graphs), self._test_run_time)
351355
)
352356

353357
return dis_matrix
@@ -620,10 +624,11 @@ def compute_edit_costs(self, Y=None, Y_targets=None, **kwargs):
620624
# return dis_mat, dis_max, dis_min, dis_mean
621625

622626
def _compute_X_distance_matrix(self, **kwargs):
623-
start_time = time.time()
624-
625627
graphs = ([g.copy() for g in
626628
self._graphs] if self.copy_graphs else self._graphs)
629+
630+
start_time = time.time()
631+
627632
if self.parallel == 'imap_unordered':
628633
dis_matrix = self._compute_X_dm_imap_unordered(graphs, **kwargs)
629634
elif self.parallel is None:
@@ -632,6 +637,7 @@ def _compute_X_distance_matrix(self, **kwargs):
632637
raise Exception('Parallel mode is not set correctly.')
633638

634639
self._run_time = time.time() - start_time
640+
635641
if self.verbose:
636642
print(
637643
'Distance matrix of size %d built in %s seconds.'
@@ -646,7 +652,7 @@ def _compute_X_dm_series(self, graphs, **kwargs):
646652
dis_matrix = np.zeros((n, n))
647653

648654
iterator = combinations(range(n), 2)
649-
len_itr = int(n * (n + 1) / 2)
655+
len_itr = int(n * (n - 1) / 2)
650656
if self.verbose:
651657
print('Graphs in total: %d.' % len(graphs))
652658
print('The total # of pairs is %d.' % len_itr)
@@ -780,6 +786,26 @@ def is_graph(self, graph):
780786
if isinstance(graph, nx.MultiDiGraph):
781787
return True
782788
return False
789+
790+
791+
def __repr__(self):
792+
return (
793+
f"{self.__class__.__name__}("
794+
f"optim_method={self.optim_method}, "
795+
f"ed_method={self.ed_method}, "
796+
f"edit_cost_fun={self.edit_cost_fun}, "
797+
f"node_labels={self.node_labels}, "
798+
f"edge_labels={self.edge_labels}, "
799+
f"optim_options={self.optim_options}, "
800+
f"init_edit_cost_constants={self.init_edit_cost_constants}, "
801+
f"copy_graphs={self.copy_graphs}, "
802+
f"parallel={self.parallel}, "
803+
f"n_jobs={self.n_jobs}, "
804+
f"verbose={self.verbose}, "
805+
f"normalize={self.normalize}, "
806+
f"run_time={self.run_time}"
807+
f")"
808+
)
783809

784810

785811
@property
@@ -807,15 +833,18 @@ def graphs(self):
807833
def run_time(self):
808834
return self._run_time
809835

836+
@property
837+
def test_run_time(self):
838+
return self._test_run_time
810839

811840
@property
812841
def dis_matrix(self):
813-
return self._dis_matrix
842+
return self._dm_train
814843

815844

816845
@dis_matrix.setter
817846
def dis_matrix(self, value):
818-
self._dis_matrix = value
847+
self._dm_train = value
819848

820849

821850
@property

0 commit comments

Comments
 (0)