Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Speedup, refactoring and modernization #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
45cffba
Added optimizations by @maciejlibraryx
fjwillemsen Jun 14, 2023
ee21d71
Local Cythonizing working, split code to clean init file
fjwillemsen Jun 26, 2023
8ab7f8d
Refactored package and module structure
fjwillemsen Jun 27, 2023
81e23b1
Updated project metadata
fjwillemsen Jun 27, 2023
923aa77
>10x speedup by rewrite and Cythonization of FunctionConstraint
fjwillemsen Jun 27, 2023
ed6377d
Refactored from one monolithic file to appropriate split files, impro…
fjwillemsen Jun 27, 2023
4dce751
Recompiled code
fjwillemsen Jul 14, 2023
a8a17ae
Added function for obtaining the solutions in a specified order
fjwillemsen Jul 20, 2023
4952466
Optimized getSolutions
fjwillemsen Aug 14, 2023
eb07608
Added a bruteforce solver
fjwillemsen Aug 15, 2023
054c9b8
Attempt to use Cython Parallelism
fjwillemsen Aug 15, 2023
e586e00
Rolled back parallel and bruteforce implementations: does not work we…
fjwillemsen Aug 15, 2023
e7ca5e6
Added MaxProdConstraint to constraint
fjwillemsen Aug 15, 2023
9e90b94
Optimizations via type hints
fjwillemsen Aug 16, 2023
fb0bdd1
Attempt to improve performance by mapping variable names to integers
fjwillemsen Aug 16, 2023
11faaa8
Revert to previous commit
fjwillemsen Aug 16, 2023
0e91422
Revert to previous commit
fjwillemsen Aug 16, 2023
d0c72bc
Revert "Revert to previous commit"
fjwillemsen Aug 16, 2023
abb94f2
Revert "Revert to previous commit"
fjwillemsen Aug 16, 2023
e3e7ead
Revert "Attempt to improve performance by mapping variable names to i…
fjwillemsen Aug 16, 2023
fe9eb3b
Properly typed function signatures
fjwillemsen Aug 17, 2023
6df4c58
Added MinProdConstraint, removed MaxProd and MinProd preprocessing be…
fjwillemsen Aug 18, 2023
d6b3725
Fixed an issue with MaxSumConstraint preprocessing that resulted in i…
fjwillemsen Aug 18, 2023
4920372
Fixed an issue in MinProdConstraint that caused invalid outcomes
fjwillemsen Aug 18, 2023
5f47f88
Added preprocessing for MaxProd and MinProd, improved getSolutionsAsL…
fjwillemsen Aug 21, 2023
88c2e1e
Complete switching to pyproject, added Nox tests, fix with type hints…
fjwillemsen Aug 24, 2023
84457a9
Added and satisfied codestyle tests, pyproject.toml tests, improved p…
fjwillemsen Aug 25, 2023
a8e86b0
Added coverage checking, added tests
fjwillemsen Aug 25, 2023
5c9b1e3
Minor change to solvers
fjwillemsen Aug 25, 2023
9fef5d4
Updated changelog
fjwillemsen Aug 25, 2023
56b72a1
Removed redundant project info file for single source of truth
fjwillemsen Aug 25, 2023
d85d9da
Updated documentation, doctests and references
fjwillemsen Aug 29, 2023
a1fbe14
Updated README, doctests and references
fjwillemsen Aug 29, 2023
8d1c454
Converted Epytext to Google style docstrings, many improvements to do…
fjwillemsen Aug 29, 2023
ecfa7ae
Converted Epytext to Google style docstrings, many improvements to do…
fjwillemsen Aug 29, 2023
31e80a4
Fixed Doctest indentation
fjwillemsen Aug 29, 2023
99f886d
Added doctests to standard tests, raised test coverage to >75
fjwillemsen Aug 29, 2023
13bcfe8
Improved preprocessing, testcoverage >80, added and extended tests, u…
fjwillemsen Aug 29, 2023
70829a6
Completed documentation, several minor fixes and improvements
fjwillemsen Aug 29, 2023
97bb5bc
Added a workflow for automatic testing on main, release and pull requ…
fjwillemsen Aug 30, 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
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
source = constraint
omit = *tests*, *examples*

[report]
exclude_lines =
if __name__ == .__main__.:
pragma: no cover
40 changes: 40 additions & 0 deletions .github/workflows/build-test-python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint for the supported Python versions.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python.

name: Build & Test

on:
push:
branches:
- main
- release/*
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff --format=github --select=E9,F63,F7,F82 --config=pyproject.toml .
# default set of ruff rules with GitHub Annotations
ruff --format=github --config=pyproject.toml .
- name: Test with pytest
run: |
pytest
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ target/

# PyCharm / Intellij
.idea/

### OS Specific ###

# Mac
.DS_store
.AppleDouble
.LSOverride
37 changes: 20 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
language: python
python:
- '2.7'
- '3.4'
- '3.5'
- '3.6'
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
install:
- pip install -qq flake8
- pip install coveralls --quiet
- pip install .
- pip install -qq flake8
- pip install coveralls --quiet
- pip install .
script:
- nosetests -s -v --with-coverage --cover-package=constraint
- flake8 --ignore E501,W504 constraint examples tests
- nosetests -s -v --with-coverage --cover-package=constraint
- flake8 --ignore E501,W504 constraint examples tests
after_success:
- coveralls
- coveralls
deploy:
provider: pypi
user: "scls"
password:
secure: YP1I8vi04F2mhaexylEK4PoizOMKfPy6ixDGYYLg5WAvgNdHvBN39xFsd9WHavMGg0RcV3xn5jAawQN1dDnXYVNW8LAivwfkUazXjqxAf4IeMp92203kOjQij/D494etHYeIw4SNJgk7J2tDil+goITJ/OhJ4t7fDC0eA0nILn8ifyZZQUgZppW5CoAf1L8cxY1JWICXLKQFQ42zPkFaIA9oBSOgok5wlNoyguScJ70mqUwZewhZHk4L07WSFRbDEOawHe5CAHCPO8rVCkhk2WdLWRoY9uHijDxHn9eCZ3zm4ac/jAwPtFol43q5u9wTCSm8WmeVfU/mJLjgGvmyDhb5Z2fTVbWGsX/N/WHvASr85HfKS0Vq2hAHYozukLbJ8EQZL6ZoOiFhjbL1LJv6Ex3EZ3PTkjKZEGEiLS/aiLZSj95CDMnfKjaNnAN2qFxzR1yi7tFHttS7XiaTCuKoegeN/RNA1iTdFPsXIcmCklhqYr9jCoTaKOXic8W5C1ej3V8oogx1xA79/mf7ZtHxtHWeT9o7cG2EK5gYfvPi6bhKPZDQ2hq49tt8AbcjX4/ycovTmX/cTn0CCoUfLB7Ok9/UvdcdUiflVZEm4cH1WAXAeD3CW+WGTOEHSgNArl9ERxUyomsWhyhutGPmeZIPQ1COeuqFFBTIaHWDG1ytqN4=
distributions: sdist bdist_wheel
on:
tags: true
provider: pypi
user: "scls"
password:
secure: YP1I8vi04F2mhaexylEK4PoizOMKfPy6ixDGYYLg5WAvgNdHvBN39xFsd9WHavMGg0RcV3xn5jAawQN1dDnXYVNW8LAivwfkUazXjqxAf4IeMp92203kOjQij/D494etHYeIw4SNJgk7J2tDil+goITJ/OhJ4t7fDC0eA0nILn8ifyZZQUgZppW5CoAf1L8cxY1JWICXLKQFQ42zPkFaIA9oBSOgok5wlNoyguScJ70mqUwZewhZHk4L07WSFRbDEOawHe5CAHCPO8rVCkhk2WdLWRoY9uHijDxHn9eCZ3zm4ac/jAwPtFol43q5u9wTCSm8WmeVfU/mJLjgGvmyDhb5Z2fTVbWGsX/N/WHvASr85HfKS0Vq2hAHYozukLbJ8EQZL6ZoOiFhjbL1LJv6Ex3EZ3PTkjKZEGEiLS/aiLZSj95CDMnfKjaNnAN2qFxzR1yi7tFHttS7XiaTCuKoegeN/RNA1iTdFPsXIcmCklhqYr9jCoTaKOXic8W5C1ej3V8oogx1xA79/mf7ZtHxtHWeT9o7cG2EK5gYfvPi6bhKPZDQ2hq49tt8AbcjX4/ycovTmX/cTn0CCoUfLB7Ok9/UvdcdUiflVZEm4cH1WAXAeD3CW+WGTOEHSgNArl9ERxUyomsWhyhutGPmeZIPQ1COeuqFFBTIaHWDG1ytqN4=
distributions: sdist bdist_wheel
on:
tags: true
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--config=pyproject.toml"
],
"ruff.args": [
"--config=pyproject.toml"
],
"autoDocstring.docstringFormat": "google-notypes",
"esbonio.sphinx.confDir": "",
}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
All notable changes to this code base will be documented in this file,
in every released version.

### Version 2.0.0

- Released: TBD
- Issues/Enhancements:
- Cythonized the package
- Added the `OptimizedBacktracking` solver based on [issue #62](https://github.com/python-constraint/python-constraint/issues/62)
- Added type-hints to improve Cythonization
- Added the MaxProd and MinProd constraints
- Improved pre-processing for the MaxSum constraint
- Optimized the Function constraint
- Added `getSolutionsOrderedList` and `getSolutionsAsListDict` functions for efficient result shaping
- Overall optimization of common bottlenecks
- Split the codebase into multiple files for convenience
- Switched from `setup.py` to `pyproject.toml`
- Achieved and requires test coverage of at least 65%
- Added `nox` for testing against all supported Python versions
- Added `ruff` for codestyle testing
- Dropped Python 3.4, 3.5, 3.6, 3.7 support

### Version 1.4.0

- Released: 2018-11-05
Expand Down
20 changes: 15 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ python-constraint

Introduction
------------
The Python constraint module offers solvers for `Constraint Satisfaction Problems (CSPs) <https://en.wikipedia.org/wiki/Constraint_satisfaction_problem>`_ over finite domains in simple and pure Python. CSP is class of problems which may be represented in terms of variables (a, b, ...), domains (a in [1, 2, 3], ...), and constraints (a < b, ...).
The Python constraint module offers efficient solvers for `Constraint Satisfaction Problems (CSPs) <https://en.wikipedia.org/wiki/Constraint_satisfaction_problem>`_ over finite domains in an accessible Python package.
CSP is class of problems which may be represented in terms of variables (a, b, ...), domains (a in [1, 2, 3], ...), and constraints (a < b, ...).

Examples
--------

Basics
~~~~~~

This interactive Python session demonstrates the module basic operation:
This interactive Python session demonstrates basic operations:

.. code-block:: python

Expand Down Expand Up @@ -97,10 +98,10 @@ Features
The following solvers are available:

- Backtracking solver
- Optimized backtracking solver
- Recursive backtracking solver
- Minimum conflicts solver


.. role:: python(code)
:language: python

Expand All @@ -109,17 +110,20 @@ Predefined constraint types currently available:
- :python:`FunctionConstraint`
- :python:`AllDifferentConstraint`
- :python:`AllEqualConstraint`
- :python:`ExactSumConstraint`
- :python:`MaxSumConstraint`
- :python:`ExactSumConstraint`
- :python:`MinSumConstraint`
- :python:`MaxProdConstraint`
- :python:`MinProdConstraint`
- :python:`InSetConstraint`
- :python:`NotInSetConstraint`
- :python:`SomeInSetConstraint`
- :python:`SomeNotInSetConstraint`

API documentation
-----------------
Documentation for the module is available at: http://labix.org/doc/constraint/
Documentation for the module is available at: http://labix.org/doc/constraint/.
It can be built locally by running `make clean html` from the `documentation` folder.

Download and install
--------------------
Expand All @@ -128,6 +132,11 @@ Download and install

$ pip install python-constraint

Testing
-------

Run `pytest` (for local Python) or `nox` (for all supported Python versions).

Roadmap
-------

Expand All @@ -146,6 +155,7 @@ Contact
-------
- `Gustavo Niemeyer <https://github.com/niemeyer/>`_ <[email protected]>
- `Sébastien Celles <https://github.com/scls19fr/>`_ <[email protected]>
- `Floris-Jan Willemsen <https://github.com/fjwillemsen>`

But it's probably better to `open an issue <https://github.com/python-constraint/python-constraint/issues>`_.

Expand Down
Loading