From 5de989e5cca8e619660b85cff6cc1affdfa4e402 Mon Sep 17 00:00:00 2001 From: Dennis Jabs Date: Thu, 12 Oct 2023 11:22:48 +0200 Subject: [PATCH] D. Jabs: - Changed name of project to PyCSPSolver --- .github/workflows/PyCSP.yml | 4 ++-- {PyCSP => PyCSPSolver}/__init__.py | 0 {PyCSP => PyCSPSolver}/constraint.py | 0 {PyCSP => PyCSPSolver}/csp.py | 2 +- README.md | 15 +++++++++------ setup.py | 4 ++-- tests/test_constraint.py | 2 +- tests/test_csp.py | 4 ++-- 8 files changed, 17 insertions(+), 14 deletions(-) rename {PyCSP => PyCSPSolver}/__init__.py (100%) rename {PyCSP => PyCSPSolver}/constraint.py (100%) rename {PyCSP => PyCSPSolver}/csp.py (98%) diff --git a/.github/workflows/PyCSP.yml b/.github/workflows/PyCSP.yml index ac62b07..a9f6468 100644 --- a/.github/workflows/PyCSP.yml +++ b/.github/workflows/PyCSP.yml @@ -1,8 +1,8 @@ -name: Build & Test PyCSP +name: Build & Test PyCSPSolver on: push: - paths: ["PyCSP/*", "tests/*"] + paths: ["PyCSPSolver/*", "tests/*"] jobs: job: diff --git a/PyCSP/__init__.py b/PyCSPSolver/__init__.py similarity index 100% rename from PyCSP/__init__.py rename to PyCSPSolver/__init__.py diff --git a/PyCSP/constraint.py b/PyCSPSolver/constraint.py similarity index 100% rename from PyCSP/constraint.py rename to PyCSPSolver/constraint.py diff --git a/PyCSP/csp.py b/PyCSPSolver/csp.py similarity index 98% rename from PyCSP/csp.py rename to PyCSPSolver/csp.py index cab7ead..103346e 100644 --- a/PyCSP/csp.py +++ b/PyCSPSolver/csp.py @@ -1,6 +1,6 @@ from typing import TypeVar, Generic, Optional -from PyCSP.constraint import Constraint +from PyCSPSolver.constraint import Constraint V = TypeVar("V") D = TypeVar("D") diff --git a/README.md b/README.md index b4ac32d..4212ebc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# PyCSP -PyCSP is a simple Python Framework for solving Constraint Satisfaction Problems (CSPs). +# PyCSPSolver +PyCSPSolver is a simple Python Framework for solving Constraint Satisfaction Problems (CSPs). You can find more information about CSPs [here](https://en.wikipedia.org/wiki/Constraint_satisfaction_problem). -### Solving CSPs with PyCSP +### Solving CSPs with PyCSPSolver In the following, we want to solve a 2x2 sudoku puzzle with PyCSP. First we need to define our problem as CSP. So we have to define variables, domains and constraints before we can solve it. @@ -59,8 +59,9 @@ PyCSP has in principal four different types of constraints. | NotEqualConstraint() | variables should have not an equal value | X1 != X2 | The following shows how to define the constraints from the example: + ```python -from PyCSP.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint +from PyCSPSolver.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint constraint1 = EqualToConstraint(["X1"], 1) constraint2 = EqualConstraint(["X1", "X2"]) @@ -72,8 +73,9 @@ With that in mind, we can now define the constraints of the 2x2 sudoku board, wh sudoku. The sudoku rules are that in each row, column or 2x2 square each value should only exist once. The following shows the constraint of the 2x2 sudoku board: + ```python -from PyCSP.constraint import NotEqualConstraint +from PyCSPSolver.constraint import NotEqualConstraint row1 = NotEqualConstraint(["X1", "X2", "X3", "X4"]) row2 = NotEqualConstraint(["X5", "X6", "X7", "X8"]) @@ -92,8 +94,9 @@ square4 = NotEqualConstraint(["X11", "X12", "X15", "X16"]) Now we have defined our 2x2 sudoku board as a CSP. With all combined, we can now solve the CSP with PyCSP. The following code shows how to solve the CSP with simple backtracking search: + ```python -from PyCSP.csp import CSP +from PyCSPSolver.csp import CSP csp = CSP[str, int](variables=variables, domains=domains) diff --git a/setup.py b/setup.py index 7bedeed..c787748 100644 --- a/setup.py +++ b/setup.py @@ -9,10 +9,10 @@ long_description = file.read() setup( - name="PyCSP", + name="PyCSPSolver", version="0.0.1", author=["Dennis J.", "Patrick B."], - url="https://github.com/nobodyPerfecZ/py-csp", + url="https://github.com/nobodyPerfecZ/py-csp-solver", python_requires=">=3.10", packages=find_packages( exclude=[ diff --git a/tests/test_constraint.py b/tests/test_constraint.py index 576bbeb..9f18f79 100644 --- a/tests/test_constraint.py +++ b/tests/test_constraint.py @@ -1,6 +1,6 @@ import unittest -from PyCSP.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint +from PyCSPSolver.constraint import EqualToConstraint, EqualConstraint, NotEqualToConstraint, NotEqualConstraint class TestEqualToConstraint(unittest.TestCase): diff --git a/tests/test_csp.py b/tests/test_csp.py index 8e09c7c..e299508 100644 --- a/tests/test_csp.py +++ b/tests/test_csp.py @@ -1,7 +1,7 @@ import unittest -from PyCSP.csp import CSP -from PyCSP.constraint import NotEqualConstraint +from PyCSPSolver.csp import CSP +from PyCSPSolver.constraint import NotEqualConstraint class TestCSP(unittest.TestCase):