-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fall back to memory efficient replace_values in relabel
- Loading branch information
Showing
7 changed files
with
63 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,11 @@ | |
*.ipynb | ||
*.db | ||
*.py[cod] | ||
*.c | ||
*.cpp | ||
*.so | ||
lsd.egg-info | ||
build | ||
docker/lsd | ||
docker/requirements.txt | ||
docker/setup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ LABEL maintainer [email protected] | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
wget \ | ||
git \ | ||
python-numpy \ | ||
libmlpack-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -116,5 +117,7 @@ ENV PYTHONPATH ${DAISY_ROOT}:$PYTHONPATH | |
# Makefile ensures that) | ||
ADD lsd /src/lsd/lsd | ||
ADD requirements.txt /src/lsd/requirements.txt | ||
ADD setup.py /src/lsd/setup.py | ||
WORKDIR /src/lsd | ||
RUN python setup.py build_ext --inplace | ||
ENV PYTHONPATH /src/lsd:$PYTHONPATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from libcpp.map cimport map | ||
cimport cython | ||
import logging | ||
import numpy as np | ||
cimport numpy as np | ||
|
||
@cython.boundscheck(False) | ||
@cython.wraparound(False) | ||
def replace_values(array_np, values_map): | ||
|
||
cdef Py_ssize_t i = 0 | ||
cdef Py_ssize_t n = array_np.size() | ||
|
||
replaced_np = np.zeros_like(array_np) | ||
cdef np.npy_uint64[:] array = array_np | ||
cdef np.npy_uint64[:] replaced = replaced_np | ||
cdef map[np.npy_uint64, np.npy_uint64] cmap = values_map | ||
|
||
for i in range(n): | ||
replaced[i] = cmap[array[i]] | ||
|
||
return replaced_np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters