Add docstrings for constraints.py and implement unit test framework for Constraints class #23
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Add Docstrings for
constraints.pyand Implement Unit Test Framework forConstraintsClassDescription
This pull request introduces the following changes to the
src/constraint.pyfile andtest/test_quadratic_program.py:Constraintsclass and its methods to improve code readability and make it easier to use.TestConstraintsMethods()for unit tests for theConstraintsclass.test_add_constaints_init()andtest_add_constraints_init_error(): This method validates the correct initialization of theConstraintsclass.These improvements aim to help developers better understand the functionality and usage of the
Constraintsclass, and the unit test framework will ensure to reach 100% coverage in the Constraint class insrc/constraint.py.Changes:
1. Added Docstrings
Constraintsclass to describe their functionality, parameters, return values, and potential exceptions.2. Unit Test Framework
Created a basic unit test structure using the
unittestframework.Implemented the
test_init()method to test the initialization logic of theConstraintsclass, verifying that theselectionargument is processed correctly and that the class attributes are initialized properly.Example of
test_add_constaints_init(self)method:3. Updated Import Paths:
I changed the import statements in the code to reflect the updated folder structure. Specifically:
This change was necessary because the test file is not directly under the root folder. With the modified folder structure, imports need to be adjusted to access the correct modules from the
src/directory.Next Steps:
TestConstraintsMethods Classin the next few commits.Thanks!