Skip to content

Commit 9e299eb

Browse files
authored
Merge pull request #1107 from lmcinnes/bit_hamming
Bit hamming
2 parents 8bfc563 + 044b17b commit 9e299eb

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

azure-pipelines.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ stages:
2727
- job: run_platform_tests
2828
strategy:
2929
matrix:
30-
mac_py38:
31-
imageName: 'macOS-latest'
32-
python.version: '3.8'
33-
linux_py38:
34-
imageName: 'ubuntu-latest'
35-
python.version: '3.8'
36-
windows_py38:
37-
imageName: 'windows-latest'
38-
python.version: '3.8'
3930
mac_py39:
4031
imageName: 'macOS-latest'
4132
python.version: '3.9'
@@ -63,7 +54,16 @@ stages:
6354
windows_py311:
6455
imageName: 'windows-latest'
6556
python.version: '3.11'
66-
57+
mac_py312:
58+
imageName: 'macOS-latest'
59+
python.version: '3.12'
60+
linux_py312:
61+
imageName: 'ubuntu-latest'
62+
python.version: '3.12'
63+
windows_py312:
64+
imageName: 'windows-latest'
65+
python.version: '3.12'
66+
6767
pool:
6868
vmImage: $(imageName)
6969

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def readme():
1616

1717
configuration = {
1818
"name": "umap-learn",
19-
"version": "0.5.5",
19+
"version": "0.5.6",
2020
"description": "Uniform Manifold Approximation and Projection",
2121
"long_description": readme(),
2222
"long_description_content_type": "text/x-rst",
@@ -33,10 +33,10 @@ def readme():
3333
"Operating System :: POSIX",
3434
"Operating System :: Unix",
3535
"Operating System :: MacOS",
36-
"Programming Language :: Python :: 3.6",
37-
"Programming Language :: Python :: 3.7",
38-
"Programming Language :: Python :: 3.8",
3936
"Programming Language :: Python :: 3.9",
37+
"Programming Language :: Python :: 3.10",
38+
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
4040
],
4141
"keywords": "dimension reduction t-sne manifold",
4242
"url": "http://github.com/lmcinnes/umap",

umap/umap_.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"cosine": 2,
6464
"hellinger": 1,
6565
"jaccard": 1,
66+
"bit_jaccard": 1,
6667
"dice": 1,
6768
}
6869

@@ -2351,8 +2352,10 @@ def fit(self, X, y=None, force_all_finite=True):
23512352
- 'allow-nan': accepts only np.nan and pd.NA values in array.
23522353
Values cannot be infinite.
23532354
"""
2354-
2355-
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
2355+
if self.metric in ("bit_hamming", "bit_jaccard"):
2356+
X = check_array(X, dtype=np.uint8, order="C", force_all_finite=force_all_finite)
2357+
else:
2358+
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
23562359
self._raw_data = X
23572360

23582361
# Handle all the optional arguments, setting default
@@ -2926,7 +2929,10 @@ def transform(self, X, force_all_finite=True):
29262929
"Transform unavailable when model was fit with only a single data sample."
29272930
)
29282931
# If we just have the original input then short circuit things
2929-
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
2932+
if self.metric in ("bit_hamming", "bit_jaccard"):
2933+
X = check_array(X, dtype=np.uint8, order="C", force_all_finite=force_all_finite)
2934+
else:
2935+
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
29302936
x_hash = joblib.hash(X)
29312937
if x_hash == self._input_hash:
29322938
if self.transform_mode == "embedding":
@@ -3297,7 +3303,10 @@ def _output_dist_only(x, y, *kwds):
32973303
return inv_transformed_points
32983304

32993305
def update(self, X, force_all_finite=True):
3300-
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
3306+
if self.metric in ("bit_hamming", "bit_jaccard"):
3307+
X = check_array(X, dtype=np.uint8, order="C", force_all_finite=force_all_finite)
3308+
else:
3309+
X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C", force_all_finite=force_all_finite)
33013310
random_state = check_random_state(self.transform_seed)
33023311
rng_state = random_state.randint(INT32_MIN, INT32_MAX, 3).astype(np.int64)
33033312

0 commit comments

Comments
 (0)