Skip to content

Commit 2c499de

Browse files
committed
Fix merge conflict
2 parents 5113334 + 05ab3da commit 2c499de

24 files changed

+506
-182
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636

3737
- name: Install dependencies
3838
run: |
39+
pip install build
3940
pip install ".[dev]"
4041
4142
- name: Make docs

.github/workflows/pytest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
strategy:
5757
fail-fast: false
5858
matrix:
59-
python-version: ["3.7", "3.8", "3.9", "3.10"]
59+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
6060
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
6161

6262
steps:
@@ -159,9 +159,9 @@ jobs:
159159
- name: Create sdist
160160
id: sdist
161161
run: |
162-
python -m pip install --upgrade pip
163-
python setup.py sdist
164-
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
162+
python -m pip install --upgrade pip build
163+
python -m build --sdist
164+
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"
165165
166166
- name: Install ${{ env.package-name }}
167167
run: |

.github/workflows/release.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ on:
4343
- main
4444
# Release branches
4545
- "[0-9]+.[0-9]+.X"
46-
47-
create:
4846
tags:
4947
- v*
5048

49+
release:
50+
types: [created]
51+
5152
env:
5253
package-name: ConfigSpace
5354

@@ -65,7 +66,8 @@ jobs:
6566
strategy:
6667
fail-fast: false
6768
matrix:
68-
py: [cp37, cp38, cp39, cp310]
69+
# We can drop "i686" once "cp37" is dropped
70+
py: [cp37, cp38, cp39, cp310, cp311]
6971
arch: ["x86_64", "i686", "aarch64"]
7072
system: ["manylinux", "musllinux"]
7173

@@ -74,9 +76,19 @@ jobs:
7476
# Not supported by numpy
7577
- system: "musllinux"
7678

77-
# Scipy doesn't have a wheel for cp310 i686
79+
# Scipy lacks some i686 support, which cause the testing of the wheels
80+
# to fail, as scipy is attempted to be built form scratch
81+
- py: cp38
82+
arch: i686
83+
84+
- py: cp39
85+
arch: i686
86+
7887
- py: cp310
79-
arch: "i686"
88+
arch: i686
89+
90+
- py: cp311
91+
arch: i686
8092

8193
steps:
8294
- name: Checkout ${{ env.package-name }}
@@ -87,7 +99,7 @@ jobs:
8799
uses: docker/setup-qemu-action@v1
88100

89101
- name: Build wheels with cibuildwheel to wheelhouse/*.whl
90-
uses: pypa/cibuildwheel@v2.3.1
102+
uses: pypa/cibuildwheel@v2.11.4
91103
env:
92104
CIBW_BUILD: ${{ matrix.py }}-${{ matrix.system }}_*
93105
CIBW_ARCHS: ${{ matrix.arch }}
@@ -105,7 +117,7 @@ jobs:
105117
strategy:
106118
fail-fast: false
107119
matrix:
108-
py: [cp37, cp38, cp39, cp310]
120+
py: [cp37, cp38, cp39, cp310, cp311]
109121
arch: ["x86_64", "universal2", "arm64"]
110122
exclude:
111123

@@ -121,7 +133,7 @@ jobs:
121133
uses: actions/checkout@v2
122134

123135
- name: Build wheels with cibuildwheel to wheelhouse/*.whl
124-
uses: pypa/cibuildwheel@v2.3.1
136+
uses: pypa/cibuildwheel@v2.11.4
125137
env:
126138
CIBW_BUILD: ${{ matrix.py }}-*
127139
CIBW_ARCHS: ${{ matrix.arch }}
@@ -139,21 +151,30 @@ jobs:
139151
strategy:
140152
fail-fast: false
141153
matrix:
142-
py: [cp37, cp38, cp39, cp310]
154+
py: [cp37, cp38, cp39, cp310, cp311]
143155
arch: ["AMD64", "x86"]
156+
144157
exclude:
158+
# Scipy lacks win32 support, which cause the testing of the wheels
159+
# to fail, as scipy is attempted to be built form scratch
160+
- py: cp38
161+
arch: x86
162+
163+
- py: cp39
164+
arch: x86
145165

146-
# We can't build win32 (x86) with cp310 because numpy doesn't have a win32 wheel
147166
- py: cp310
148-
arch: "x86"
167+
arch: x86
149168

169+
- py: cp311
170+
arch: x86
150171

151172
steps:
152173
- name: Checkout ${{ env.package-name }}
153174
uses: actions/checkout@v2
154175

155176
- name: Build wheels with cibuildwheel to wheelhouse/*.whl
156-
uses: pypa/cibuildwheel@v2.3.1
177+
uses: pypa/cibuildwheel@v2.11.4
157178
env:
158179
CIBW_BUILD: ${{ matrix.py }}-*
159180
CIBW_ARCHS: ${{ matrix.arch }}
@@ -171,7 +192,7 @@ jobs:
171192
strategy:
172193
fail-fast: false
173194
matrix:
174-
py: ["3.7", "3.8", "3.9", "3.10"]
195+
py: ["3.7", "3.8", "3.9", "3.10", "3.11"]
175196

176197
steps:
177198
- name: Checkout ${{ env.package-name }}
@@ -184,9 +205,9 @@ jobs:
184205

185206
- name: Build source distribution
186207
run: |
187-
python -m pip install --upgrade pip
188-
python setup.py sdist
189-
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
208+
python -m pip install --upgrade pip build
209+
python -m build --sdist
210+
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"
190211
191212
- name: Twine check ${{ env.package-name }}
192213
run: |
@@ -223,7 +244,7 @@ jobs:
223244
needs: [build_linux_wheels, build_macos_wheels, build_windows_wheels, build_sdist]
224245

225246
# Only on a tagged release, push
226-
if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request'
247+
if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request'
227248

228249
steps:
229250
- name: Checkout ${{ env.package-name }}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ repos:
77
name: mypy ConfigSpace
88
files: ConfigSpace
99

10-
- repo: https://gitlab.com/pycqa/flake8
11-
rev: 4.0.1
10+
- repo: https://github.com/pycqa/flake8
11+
rev: 5.0.4
1212
hooks:
1313
- id: flake8
1414
name: flake8 ConfigSpace

ConfigSpace/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from ConfigSpace.__version__ import __version__
3030
from ConfigSpace.__authors__ import __authors__
3131

32-
import ConfigSpace.api.distributions as distributions
33-
import ConfigSpace.api.types as types
3432
from ConfigSpace.api import (Beta, Categorical, Distribution, Float, Integer,
3533
Normal, Uniform)
3634
from ConfigSpace.conditions import (AndConjunction, EqualsCondition,
@@ -54,6 +52,8 @@
5452
UniformFloatHyperparameter,
5553
UniformIntegerHyperparameter,
5654
UnParametrizedHyperparameter)
55+
import ConfigSpace.api.distributions as distributions
56+
import ConfigSpace.api.types as types
5757

5858
__all__ = [
5959
"__authors__",

ConfigSpace/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Version information."""
22

33
# The following line *must* be the last in the module, exactly as formatted:
4-
__version__ = "0.6.0"
4+
__version__ = "0.6.1"

ConfigSpace/c_util.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
from collections import deque
42

53
import numpy as np

ConfigSpace/conditions.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
import numpy as np
42
cimport numpy as np
53

ConfigSpace/conditions.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2727
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
# cython: language_level=3
30-
3129
import io
3230
from functools import reduce
3331
from abc import ABCMeta, abstractmethod

ConfigSpace/configuration_space.pyx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2727
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
# cython: language_level=3
30-
3129
import collections.abc
3230
from collections import defaultdict, deque, OrderedDict
3331
import copy
@@ -1528,12 +1526,12 @@ class ConfigurationSpace(collections.abc.Mapping):
15281526
new_child = new_configspace[child_name]
15291527
new_parent = new_configspace[parent_name]
15301528

1531-
if hasattr(condition, 'value'):
1532-
condition_arg = getattr(condition, 'value')
1533-
substituted_condition = condition_type(child=new_child, parent=new_parent, value=condition_arg)
1534-
elif hasattr(condition, 'values'):
1529+
if hasattr(condition, 'values'):
15351530
condition_arg = getattr(condition, 'values')
15361531
substituted_condition = condition_type(child=new_child, parent=new_parent, values=condition_arg)
1532+
elif hasattr(condition, 'value'):
1533+
condition_arg = getattr(condition, 'value')
1534+
substituted_condition = condition_type(child=new_child, parent=new_parent, value=condition_arg)
15371535
else:
15381536
raise AttributeError(f'Did not find the expected attribute in condition {type(condition)}.')
15391537

@@ -1575,15 +1573,24 @@ class ConfigurationSpace(collections.abc.Mapping):
15751573
hyperparameter_name = getattr(forbidden.hyperparameter, 'name')
15761574
new_hyperparameter = new_configspace[hyperparameter_name]
15771575

1578-
if hasattr(forbidden, 'value'):
1579-
forbidden_arg = getattr(forbidden, 'value')
1580-
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, value=forbidden_arg)
1581-
elif hasattr(forbidden, 'values'):
1576+
if hasattr(forbidden, 'values'):
15821577
forbidden_arg = getattr(forbidden, 'values')
15831578
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, values=forbidden_arg)
1579+
elif hasattr(forbidden, 'value'):
1580+
forbidden_arg = getattr(forbidden, 'value')
1581+
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, value=forbidden_arg)
15841582
else:
15851583
raise AttributeError(f'Did not find the expected attribute in forbidden {type(forbidden)}.')
15861584

1585+
new_forbiddens.append(substituted_forbidden)
1586+
elif isinstance(forbidden, ForbiddenRelation):
1587+
forbidden_type = type(forbidden)
1588+
left_name = getattr(forbidden.left, 'name')
1589+
left_hyperparameter = new_configspace[left_name]
1590+
right_name = getattr(forbidden.right, 'name')
1591+
right_hyperparameter = new_configspace[right_name]
1592+
1593+
substituted_forbidden = forbidden_type(left=left_hyperparameter, right=right_hyperparameter)
15871594
new_forbiddens.append(substituted_forbidden)
15881595
else:
15891596
raise TypeError(f'Did not expect the supplied forbidden type {type(forbidden)}.')

ConfigSpace/forbidden.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
import numpy as np
42
cimport numpy as np
53

ConfigSpace/forbidden.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
# cython: language_level=3
31-
3230
import copy
3331
import numpy as np
3432
import io

ConfigSpace/functional.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from typing import Iterator
2+
3+
from more_itertools import roundrobin
4+
import numpy as np
5+
6+
7+
def center_range(
8+
center: int,
9+
low: int,
10+
high: int,
11+
step: int = 1,
12+
) -> Iterator[int]:
13+
"""Get a range centered around a value.
14+
15+
>>> list(center_range(5, 0, 10))
16+
[4, 6, 3, 7, 2, 8, 1, 9, 0, 10]
17+
18+
Parameters
19+
----------
20+
center: int
21+
The center of the range
22+
23+
low: int
24+
The low end of the range
25+
26+
high: int
27+
The high end of the range
28+
29+
step: int = 1
30+
The step size
31+
32+
Returns
33+
-------
34+
Iterator[int]
35+
"""
36+
assert low <= center <= high
37+
above_center = range(center + step, high + 1, step)
38+
below_center = range(center - step, low - 1, -step)
39+
yield from roundrobin(below_center, above_center)
40+
41+
42+
def arange_chunked(
43+
start: int,
44+
stop: int,
45+
step: int = 1,
46+
*,
47+
chunk_size: int,
48+
) -> Iterator[np.ndarray]:
49+
"""Get np.arange in a chunked fashion.
50+
51+
>>> list(arange_chunked(0, 10, 3))
52+
[array([0, 1, 2]), array([3, 4, 5]), array([6, 7, 8]), array([9])]
53+
54+
Parameters
55+
----------
56+
start: int
57+
The start of the range
58+
59+
stop: int
60+
The stop of the range
61+
62+
chunk_size: int
63+
The size of the chunks
64+
65+
step: int = 1
66+
The step size
67+
68+
Returns
69+
-------
70+
Iterator[np.ndarray]
71+
"""
72+
assert step > 0
73+
assert chunk_size > 0
74+
assert start < stop
75+
n_items = int(np.ceil((stop - start) / step))
76+
n_chunks = int(np.ceil(n_items / chunk_size))
77+
78+
for chunk in range(0, n_chunks):
79+
chunk_start = start + (chunk * chunk_size)
80+
chunk_stop = min(chunk_start + chunk_size, stop)
81+
yield np.arange(chunk_start, chunk_stop, step)

ConfigSpace/hyperparameters.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# cython: language_level=3
21
from typing import Union
32
import numpy as np
43
cimport numpy as np

0 commit comments

Comments
 (0)