Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ jobs:
run: >-
pixi run -e tests-linux-py314
python -m doctest -v docs/source/how_to/how_to_constraints.md
run-mypy:
name: Run mypy
run-ty:
name: Run ty
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -131,6 +131,6 @@ jobs:
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
frozen: true
environments: type-checking
- name: Run mypy
- name: Run ty
shell: bash -el {0}
run: pixi run -e type-checking mypy
run: pixi run -e type-checking ty --output-format github
24 changes: 12 additions & 12 deletions .tools/create_algo_selection_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _get_algorithms_in_module(module: ModuleType) -> dict[str, Type[Algorithm]]:
}
algos = {}
for candidate in candidate_dict.values():
name = candidate.algo_info.name
name = candidate.algo_info.name # ty:ignore[unresolved-attribute]
if issubclass(candidate, Algorithm) and candidate is not Algorithm:
algos[name] = candidate
return algos
Expand All @@ -119,47 +119,47 @@ def _get_algorithms_in_module(module: ModuleType) -> dict[str, Type[Algorithm]]:
# Functions to filter algorithms by selectors
# ======================================================================================
def _is_gradient_based(algo: Type[Algorithm]) -> bool:
return algo.algo_info.needs_jac # type: ignore
return algo.algo_info.needs_jac


def _is_gradient_free(algo: Type[Algorithm]) -> bool:
return not _is_gradient_based(algo)


def _is_global(algo: Type[Algorithm]) -> bool:
return algo.algo_info.is_global # type: ignore
return algo.algo_info.is_global


def _is_local(algo: Type[Algorithm]) -> bool:
return not _is_global(algo)


def _is_bounded(algo: Type[Algorithm]) -> bool:
return algo.algo_info.supports_bounds # type: ignore
return algo.algo_info.supports_bounds


def _is_linear_constrained(algo: Type[Algorithm]) -> bool:
return algo.algo_info.supports_linear_constraints # type: ignore
return algo.algo_info.supports_linear_constraints


def _is_nonlinear_constrained(algo: Type[Algorithm]) -> bool:
return algo.algo_info.supports_nonlinear_constraints # type: ignore
return algo.algo_info.supports_nonlinear_constraints


def _is_scalar(algo: Type[Algorithm]) -> bool:
return algo.algo_info.solver_type == AggregationLevel.SCALAR # type: ignore
return algo.algo_info.solver_type == AggregationLevel.SCALAR


def _is_least_squares(algo: Type[Algorithm]) -> bool:
return algo.algo_info.solver_type == AggregationLevel.LEAST_SQUARES # type: ignore
return algo.algo_info.solver_type == AggregationLevel.LEAST_SQUARES


def _is_likelihood(algo: Type[Algorithm]) -> bool:
return algo.algo_info.solver_type == AggregationLevel.LIKELIHOOD # type: ignore
return algo.algo_info.solver_type == AggregationLevel.LIKELIHOOD


def _is_parallel(algo: Type[Algorithm]) -> bool:
return algo.algo_info.supports_parallelism # type: ignore
return algo.algo_info.supports_parallelism


def _get_filters() -> dict[str, Callable[[Type[Algorithm]], bool]]:
Expand Down Expand Up @@ -223,7 +223,7 @@ def _generate_category_combinations(categories: list[str]) -> list[tuple[str, ..
result: list[tuple[str, ...]] = []
for r in range(len(categories) + 1):
result.extend(map(tuple, map(sorted, combinations(categories, r))))
return sorted(result, key=len, reverse=True)
return sorted(result, key=len, reverse=True) # ty:ignore[invalid-return-type]


def _apply_filters(
Expand Down Expand Up @@ -385,7 +385,7 @@ def _all(self) -> list[Type[Algorithm]]:
def _available(self) -> list[Type[Algorithm]]:
_all = self._all()
return [
a for a in _all if a.algo_info.is_available # type: ignore
a for a in _all if a.algo_info.is_available
]

@property
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/how_to_contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ For regular contributors: **Clone** the [repository](https://github.com/optimagi
use:

```console
$ pixi run mypy
$ pixi run ty
```

To see all available pixi tasks, run:
Expand Down
204 changes: 57 additions & 147 deletions pixi.lock

Large diffs are not rendered by default.

Loading
Loading