-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
506 additions
and
182 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 |
---|---|---|
|
@@ -36,6 +36,7 @@ jobs: | |
|
||
- name: Install dependencies | ||
run: | | ||
pip install build | ||
pip install ".[dev]" | ||
- name: Make docs | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Version information.""" | ||
|
||
# The following line *must* be the last in the module, exactly as formatted: | ||
__version__ = "0.6.0" | ||
__version__ = "0.6.1" |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# cython: language_level=3 | ||
|
||
from collections import deque | ||
|
||
import numpy as 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# cython: language_level=3 | ||
|
||
import numpy as np | ||
cimport numpy as 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
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# cython: language_level=3 | ||
|
||
import numpy as np | ||
cimport numpy as 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
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,81 @@ | ||
from typing import Iterator | ||
|
||
from more_itertools import roundrobin | ||
import numpy as np | ||
|
||
|
||
def center_range( | ||
center: int, | ||
low: int, | ||
high: int, | ||
step: int = 1, | ||
) -> Iterator[int]: | ||
"""Get a range centered around a value. | ||
>>> list(center_range(5, 0, 10)) | ||
[4, 6, 3, 7, 2, 8, 1, 9, 0, 10] | ||
Parameters | ||
---------- | ||
center: int | ||
The center of the range | ||
low: int | ||
The low end of the range | ||
high: int | ||
The high end of the range | ||
step: int = 1 | ||
The step size | ||
Returns | ||
------- | ||
Iterator[int] | ||
""" | ||
assert low <= center <= high | ||
above_center = range(center + step, high + 1, step) | ||
below_center = range(center - step, low - 1, -step) | ||
yield from roundrobin(below_center, above_center) | ||
|
||
|
||
def arange_chunked( | ||
start: int, | ||
stop: int, | ||
step: int = 1, | ||
*, | ||
chunk_size: int, | ||
) -> Iterator[np.ndarray]: | ||
"""Get np.arange in a chunked fashion. | ||
>>> list(arange_chunked(0, 10, 3)) | ||
[array([0, 1, 2]), array([3, 4, 5]), array([6, 7, 8]), array([9])] | ||
Parameters | ||
---------- | ||
start: int | ||
The start of the range | ||
stop: int | ||
The stop of the range | ||
chunk_size: int | ||
The size of the chunks | ||
step: int = 1 | ||
The step size | ||
Returns | ||
------- | ||
Iterator[np.ndarray] | ||
""" | ||
assert step > 0 | ||
assert chunk_size > 0 | ||
assert start < stop | ||
n_items = int(np.ceil((stop - start) / step)) | ||
n_chunks = int(np.ceil(n_items / chunk_size)) | ||
|
||
for chunk in range(0, n_chunks): | ||
chunk_start = start + (chunk * chunk_size) | ||
chunk_stop = min(chunk_start + chunk_size, stop) | ||
yield np.arange(chunk_start, chunk_stop, step) |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# cython: language_level=3 | ||
from typing import Union | ||
import numpy as np | ||
cimport numpy as np | ||
|
Oops, something went wrong.