From 6c6447f0cb3c1215b40f4a177f2a2eb4733a4a03 Mon Sep 17 00:00:00 2001 From: Alex Rogozhnikov Date: Mon, 15 May 2023 00:44:28 -0700 Subject: [PATCH 1/3] compactify pyproject.toml --- pyproject.toml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 51c44ea..9a598a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 From b82cafaf01cee107c8e9e704a3e54d87509673ed Mon Sep 17 00:00:00 2001 From: Alex Rogozhnikov Date: Mon, 15 May 2023 00:50:57 -0700 Subject: [PATCH 2/3] found a shorter example for numpy indexing --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 47ef4ef..b625ad9 100644 --- a/README.md +++ b/README.md @@ -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 From 9f71f57abcc6d7ad4b1401f7f2eca1e41b2dcf58 Mon Sep 17 00:00:00 2001 From: Alex Rogozhnikov Date: Mon, 15 May 2023 00:51:21 -0700 Subject: [PATCH 3/3] minor: keywords --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9a598a6..ca784af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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',