Skip to content

Commit

Permalink
Ensure passing numpy arrays to rust (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger authored Apr 20, 2020
1 parent 169d8d9 commit e156586
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gapstat-rs"
version = "2.0.0"
version = "2.0.1"
authors = ["Miles Granger <[email protected]>"]

[lib]
Expand Down
9 changes: 6 additions & 3 deletions gap_statistic/optimalK.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ def _process_with_rust(
)
raise

X = X if isinstance(X, np.ndarray) else X.values
X = X.astype(np.float64)

cluster_array = np.array(cluster_array, dtype=np.int64)

for (
n_clusters,
gap_value,
Expand All @@ -336,9 +341,7 @@ def _process_with_rust(
sk,
gap_star,
sk_star,
) in gapstat_rs.optimal_k(
X.astype(np.float64), cluster_array.astype(np.int64), self.n_iter, n_refs
):
) in gapstat_rs.optimal_k(X, cluster_array, self.n_iter, n_refs):
yield GapCalcResult(
gap_value, n_clusters, ref_dispersion_std, sdk, sk, gap_star, sk_star
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="gap-stat",
version="2.0.0",
version="2.0.1",
author="Miles Granger",
maintainer="Miles Granger",
author_email="[email protected]",
Expand Down

0 comments on commit e156586

Please sign in to comment.