Skip to content

Commit

Permalink
Remove pyemd in favor of scipy (#37)
Browse files Browse the repository at this point in the history
* Remove pyemd in favor of scipy

* Bump python version to 3.8 in actions and setup

* Fix python version for YAML

Per actions/setup-python#160
  • Loading branch information
gkirgizov committed Feb 21, 2023
1 parent 5149238 commit 6b2fa54
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
python-version: [ 3.8, 3.9 ]
python-version: [ 3.8, '3.10' ]

steps:
- name: Checkout branch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
python-version: [ 3.8, 3.9 ]
python-version: [ 3.8, 3.9, '3.10' ]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 4 additions & 2 deletions golem/metrics/mmd.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import itertools
import numpy as np
from scipy.linalg import toeplitz
import pyemd
from scipy.stats import wasserstein_distance


def emd(x, y, distance_scaling=1.0):
"""Earth's mover distance (or Wasserstein metric)
between 2 probability distributions."""
support_size = max(len(x), len(y))
d_mat = toeplitz(range(support_size)).astype(np.float64)
distance_mat = d_mat / distance_scaling
Expand All @@ -17,7 +19,7 @@ def emd(x, y, distance_scaling=1.0):
elif len(y) < len(x):
y = np.hstack((y, [0.0] * (support_size - len(y))))

emd_value = pyemd.emd(x, y, distance_mat)
emd_value = wasserstein_distance(x, y, distance_mat)
return emd_value


Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ hyperopt>=0.2.7
# Tests
pytest>=6.2.0
testfixtures>=6.18.0

# Examples
pyemd
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

README = Path(HERE, 'README_en.rst').read_text(encoding='utf-8')
URL = 'https://github.com/aimclub/GOLEM'
REQUIRES_PYTHON = '>=3.7'
REQUIRES_PYTHON = '>=3.8'
LICENSE = 'BSD 3-Clause'


Expand Down Expand Up @@ -53,8 +53,8 @@ def _get_requirements(req_name: str):
},
classifiers=[
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
'Programming Language :: Python :: 3.10'
],
)

0 comments on commit 6b2fa54

Please sign in to comment.