Skip to content

Commit

Permalink
Merge pull request #24 from arogozhnikov/dev
Browse files Browse the repository at this point in the history
Improve docs
  • Loading branch information
arogozhnikov authored May 15, 2023
2 parents a253721 + 9f71f57 commit 9595298
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ def kmeans(init_centers, X, n_iterations: int):
centers = init_centers.copy()
for _ in range(n_iterations):
d = cdist(centers, X)
clusters = np.argmin(d, axis=0)
clusters = np.argmin(d, axis=0)
new_centers_sum = np.zeros_like(centers)
clstr_indices = np.tile(clusters[:, None], reps=(1, n_dim))
dim_indices = np.tile(np.arange(n_dim)[None, :], reps=(n_onservations, 1))
np.add.at(new_centers_sum, (clstr_indices, dim_indices), X)
indices_dim = np.arange(n_dim)[None, :]
np.add.at(new_centers_sum, (clusters[:, None], indices_dim), X)
cluster_counts = np.bincount(clusters, minlength=n_clusters)
centers = new_centers_sum / cluster_counts[:, None]
return centers
Expand Down
21 changes: 9 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "A concept of multidimensional indexing for tensors"
readme = "README.md"
requires-python = ">=3.8"

keywords = ['indexing', 'numpy', 'tensor', 'tensor indexing', 'einops']
keywords = ['indexing', 'numpy', 'tensor', 'tensor indexing', 'eindex', 'einops']
license = { text = 'MIT' }
classifiers = [
'Intended Audience :: Science/Research',
Expand Down Expand Up @@ -48,27 +48,24 @@ exclude = [
# should use packages from main section



[tool.hatch.envs.pypi.scripts]
# hatch run pypi:deploy_test
deploy_test = "hatch build --clean && hatch publish -r test"
deploy = "hatch build --clean && hatch publish"

[tool.hatch.envs.testing.env-vars]
# currently using nightly numpy, so we need to add an additional index
PIP_INDEX_URL = "https://pypi.anaconda.org/scipy-wheels-nightly/simple/"
# fallback to original code
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/"
# allow pre-releases
PIP_PRE = "1"


[tool.hatch.envs.testing]
dependencies = ['numpy', 'pytest']

[tool.hatch.envs.testing.scripts]
# currently using nightly numpy, so we need to add an additional index
# fallback to standard pypi for other packages
# allow pre-releases
env-vars = { PIP_INDEX_URL = "https://pypi.anaconda.org/scipy-wheels-nightly/simple/", PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/", PIP_PRE = "1" }
# [tool.hatch.envs.testing.env-vars]

# hatch run testing:test
test = "pytest tests"
scripts = { test = "pytest tests" }


[tool.black]
line-length = 120
Expand Down

0 comments on commit 9595298

Please sign in to comment.