Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
nchristensen committed Jan 31, 2023
2 parents 5113334 + 05ab3da commit 2c499de
Show file tree
Hide file tree
Showing 24 changed files with 506 additions and 182 deletions.
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
8 changes: 4 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]

steps:
Expand Down 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
55 changes: 38 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ on:
- main
# Release branches
- "[0-9]+.[0-9]+.X"

create:
tags:
- v*

release:
types: [created]

env:
package-name: ConfigSpace

Expand All @@ -65,7 +66,8 @@ jobs:
strategy:
fail-fast: false
matrix:
py: [cp37, cp38, cp39, cp310]
# We can drop "i686" once "cp37" is dropped
py: [cp37, cp38, cp39, cp310, cp311]
arch: ["x86_64", "i686", "aarch64"]
system: ["manylinux", "musllinux"]

Expand All @@ -74,9 +76,19 @@ jobs:
# Not supported by numpy
- system: "musllinux"

# Scipy doesn't have a wheel for cp310 i686
# Scipy lacks some i686 support, which cause the testing of the wheels
# to fail, as scipy is attempted to be built form scratch
- py: cp38
arch: i686

- py: cp39
arch: i686

- py: cp310
arch: "i686"
arch: i686

- py: cp311
arch: i686

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

- name: Build wheels with cibuildwheel to wheelhouse/*.whl
uses: pypa/cibuildwheel@v2.3.1
uses: pypa/cibuildwheel@v2.11.4
env:
CIBW_BUILD: ${{ matrix.py }}-${{ matrix.system }}_*
CIBW_ARCHS: ${{ matrix.arch }}
Expand All @@ -105,7 +117,7 @@ jobs:
strategy:
fail-fast: false
matrix:
py: [cp37, cp38, cp39, cp310]
py: [cp37, cp38, cp39, cp310, cp311]
arch: ["x86_64", "universal2", "arm64"]
exclude:

Expand All @@ -121,7 +133,7 @@ jobs:
uses: actions/checkout@v2

- name: Build wheels with cibuildwheel to wheelhouse/*.whl
uses: pypa/cibuildwheel@v2.3.1
uses: pypa/cibuildwheel@v2.11.4
env:
CIBW_BUILD: ${{ matrix.py }}-*
CIBW_ARCHS: ${{ matrix.arch }}
Expand All @@ -139,21 +151,30 @@ jobs:
strategy:
fail-fast: false
matrix:
py: [cp37, cp38, cp39, cp310]
py: [cp37, cp38, cp39, cp310, cp311]
arch: ["AMD64", "x86"]

exclude:
# Scipy lacks win32 support, which cause the testing of the wheels
# to fail, as scipy is attempted to be built form scratch
- py: cp38
arch: x86

- py: cp39
arch: x86

# We can't build win32 (x86) with cp310 because numpy doesn't have a win32 wheel
- py: cp310
arch: "x86"
arch: x86

- py: cp311
arch: x86

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

- name: Build wheels with cibuildwheel to wheelhouse/*.whl
uses: pypa/cibuildwheel@v2.3.1
uses: pypa/cibuildwheel@v2.11.4
env:
CIBW_BUILD: ${{ matrix.py }}-*
CIBW_ARCHS: ${{ matrix.arch }}
Expand All @@ -171,7 +192,7 @@ jobs:
strategy:
fail-fast: false
matrix:
py: ["3.7", "3.8", "3.9", "3.10"]
py: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout ${{ env.package-name }}
Expand All @@ -184,9 +205,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 -m 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 Expand Up @@ -223,7 +244,7 @@ jobs:
needs: [build_linux_wheels, build_macos_wheels, build_windows_wheels, build_sdist]

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

steps:
- name: Checkout ${{ env.package-name }}
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 @@ -54,6 +52,8 @@
UniformFloatHyperparameter,
UniformIntegerHyperparameter,
UnParametrizedHyperparameter)
import ConfigSpace.api.distributions as distributions
import ConfigSpace.api.types as types

__all__ = [
"__authors__",
Expand Down
2 changes: 1 addition & 1 deletion ConfigSpace/__version__.py
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"
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
27 changes: 17 additions & 10 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 Expand Up @@ -1528,12 +1526,12 @@ class ConfigurationSpace(collections.abc.Mapping):
new_child = new_configspace[child_name]
new_parent = new_configspace[parent_name]

if hasattr(condition, 'value'):
condition_arg = getattr(condition, 'value')
substituted_condition = condition_type(child=new_child, parent=new_parent, value=condition_arg)
elif hasattr(condition, 'values'):
if hasattr(condition, 'values'):
condition_arg = getattr(condition, 'values')
substituted_condition = condition_type(child=new_child, parent=new_parent, values=condition_arg)
elif hasattr(condition, 'value'):
condition_arg = getattr(condition, 'value')
substituted_condition = condition_type(child=new_child, parent=new_parent, value=condition_arg)
else:
raise AttributeError(f'Did not find the expected attribute in condition {type(condition)}.')

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

if hasattr(forbidden, 'value'):
forbidden_arg = getattr(forbidden, 'value')
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, value=forbidden_arg)
elif hasattr(forbidden, 'values'):
if hasattr(forbidden, 'values'):
forbidden_arg = getattr(forbidden, 'values')
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, values=forbidden_arg)
elif hasattr(forbidden, 'value'):
forbidden_arg = getattr(forbidden, 'value')
substituted_forbidden = forbidden_type(hyperparameter=new_hyperparameter, value=forbidden_arg)
else:
raise AttributeError(f'Did not find the expected attribute in forbidden {type(forbidden)}.')

new_forbiddens.append(substituted_forbidden)
elif isinstance(forbidden, ForbiddenRelation):
forbidden_type = type(forbidden)
left_name = getattr(forbidden.left, 'name')
left_hyperparameter = new_configspace[left_name]
right_name = getattr(forbidden.right, 'name')
right_hyperparameter = new_configspace[right_name]

substituted_forbidden = forbidden_type(left=left_hyperparameter, right=right_hyperparameter)
new_forbiddens.append(substituted_forbidden)
else:
raise TypeError(f'Did not expect the supplied forbidden type {type(forbidden)}.')
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 @@ -27,8 +27,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

0 comments on commit 2c499de

Please sign in to comment.