From 4201631bf552c098ff0618cc62c42d8b4dbb4ac2 Mon Sep 17 00:00:00 2001 From: parashardhapola Date: Thu, 29 Jul 2021 11:27:49 +0200 Subject: [PATCH] rewrote chained comparisons in _optimize_layout_aligned_euclidean_single_epoch --- requirements.txt | 3 ++- umap/layouts.py | 14 +++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 726cee69..c6ef0e61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ scipy>=1.3.1 scikit-learn>=0.22 numba>=0.51.2 pynndescent>=0.5 -tbb>=2019.0 \ No newline at end of file +tbb>=2019.0 +tqdm diff --git a/umap/layouts.py b/umap/layouts.py index 2a8a9669..46e58339 100644 --- a/umap/layouts.py +++ b/umap/layouts.py @@ -860,9 +860,7 @@ def _optimize_layout_aligned_euclidean_single_epoch( for offset in range(-window_size, window_size): neighbor_m = m + offset if ( - neighbor_m >= 0 - and neighbor_m < n_embeddings - and offset != 0 + n_embeddings > neighbor_m >= 0 != offset ): identified_index = relations[m, offset + window_size, j] if identified_index >= 0: @@ -884,9 +882,7 @@ def _optimize_layout_aligned_euclidean_single_epoch( for offset in range(-window_size, window_size): neighbor_m = m + offset if ( - neighbor_m >= 0 - and neighbor_m < n_embeddings - and offset != 0 + n_embeddings > neighbor_m >= 0 != offset ): identified_index = relations[m, offset + window_size, k] if identified_index >= 0: @@ -940,11 +936,7 @@ def _optimize_layout_aligned_euclidean_single_epoch( for offset in range(-window_size, window_size): neighbor_m = m + offset - if ( - neighbor_m >= 0 - and neighbor_m < n_embeddings - and offset != 0 - ): + if n_embeddings > neighbor_m >= 0 != offset: identified_index = relations[m, offset + window_size, j] if identified_index >= 0: grad_d -= clip(