Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e2566e8
test: Add reproducing test
eddiebergman Dec 15, 2022
bbc4161
fix: Make sampling neighbors form uniform Int stable
eddiebergman Dec 15, 2022
c31e3d6
fix: Memory leak with UniformIntegerHyperparameter
eddiebergman Jan 3, 2023
5aa9aab
fix: Memory issues with Normal and Beta dists
eddiebergman Jan 4, 2023
7afcaea
chore: Update flake8
eddiebergman Jan 4, 2023
91d590b
fix: flake8 version compatible with Python 3.7
eddiebergman Jan 4, 2023
57b4182
fix: Name generators properly
eddiebergman Jan 4, 2023
9f0b18d
fix: Test numbers
eddiebergman Jan 4, 2023
3a8286d
doc: typo fixes
eddiebergman Jan 4, 2023
c36d292
perf: Generate all possible neighbors at once
eddiebergman Jan 4, 2023
367e508
test: Add test for center_range and arange_chunked
eddiebergman Jan 4, 2023
c5b3281
perf: Call transform on np vector from rvs
eddiebergman Jan 4, 2023
e1fac33
perf: Use numpy `.astype(int)` instead of `int`
eddiebergman Jan 4, 2023
564c0a4
doc: Document how to get flamegraphs for optimizing
eddiebergman Jan 4, 2023
c5d2090
fix: Allow for negatives in arange_chunked again
eddiebergman Jan 4, 2023
5f51df1
fix: Change build back to raw Extensions
eddiebergman Jan 4, 2023
29dd3db
build: Properly set compiler_directives
eddiebergman Jan 4, 2023
555c5da
ci: Update makefile with helpful commands
eddiebergman Jan 4, 2023
d833df9
ci: Fix docs to install build
eddiebergman Jan 4, 2023
0a7aafb
perf: cython optimizations
eddiebergman Jan 7, 2023
e24dd25
perf: Fix possible memory leak with UniformIntegerHyperparam
eddiebergman Jan 7, 2023
d52f28c
fix: Duplicates as `list` instead of set
eddiebergman Jan 7, 2023
94b4d9c
fix: Convert to `long long` vector
eddiebergman Jan 7, 2023
e6d3222
perf: Revert clip to truncnorm
eddiebergman Jan 10, 2023
395ea60
test: Test values not match implementation
eddiebergman Jan 10, 2023
1f69f51
Intermediate commit
mfeurer Jan 10, 2023
ba2a174
INtermediate commit 2
mfeurer Jan 10, 2023
dd5bd75
Update neighborhood generation for UniformIntegerHyperparameter
mfeurer Jan 11, 2023
c4e7f42
Update tests
mfeurer Jan 11, 2023
2a647a3
Make the benchmark sampling script more robust
mfeurer Jan 11, 2023
e0bef0e
Revert small change in util function
mfeurer Jan 11, 2023
1702342
Improve readability
mfeurer Jan 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:

- name: Install dependencies
run: |
pip install build
pip install ".[dev]"

- name: Make docs
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ jobs:
- name: Create sdist
id: sdist
run: |
python -m pip install --upgrade pip
python setup.py sdist
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
python -m pip install --upgrade pip build
python -m build --sdist
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"

- name: Install ${{ env.package-name }}
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ jobs:

- name: Build source distribution
run: |
python -m pip install --upgrade pip
python setup.py sdist
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
python -m pip install --upgrade pip build
python build --sdist
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"

- name: Twine check ${{ env.package-name }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ repos:
name: mypy ConfigSpace
files: ConfigSpace

- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
name: flake8 ConfigSpace
Expand Down
4 changes: 2 additions & 2 deletions ConfigSpace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from ConfigSpace.__version__ import __version__
from ConfigSpace.__authors__ import __authors__

import ConfigSpace.api.distributions as distributions
import ConfigSpace.api.types as types
from ConfigSpace.api import (Beta, Categorical, Distribution, Float, Integer,
Normal, Uniform)
from ConfigSpace.conditions import (AndConjunction, EqualsCondition,
Expand All @@ -53,6 +51,8 @@
UniformFloatHyperparameter,
UniformIntegerHyperparameter,
UnParametrizedHyperparameter)
import ConfigSpace.api.distributions as distributions
import ConfigSpace.api.types as types

__all__ = [
"__authors__",
Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/c_util.pyx
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
Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/conditions.pxd
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

Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/conditions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# cython: language_level=3

import io
from functools import reduce
from abc import ABCMeta, abstractmethod
Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/configuration_space.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# cython: language_level=3

import collections.abc
from collections import defaultdict, deque, OrderedDict
import copy
Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/forbidden.pxd
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

Expand Down
2 changes: 0 additions & 2 deletions ConfigSpace/forbidden.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# cython: language_level=3

import copy
import numpy as np
import io
Expand Down
81 changes: 81 additions & 0 deletions ConfigSpace/functional.py
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)
1 change: 0 additions & 1 deletion ConfigSpace/hyperparameters.pxd
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
Expand Down
Loading