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

Skip to content

Conversation

RabiyaF
Copy link
Member

@RabiyaF RabiyaF commented Sep 12, 2023

Task List

  • Added the enums.
    1. ParallelOptions
    2. Procedures
    3. DisplayOptions
    4. BoundHandlingOptions
    5. StrategyOptions
  • Added pydantic classes for procedures.
    1. Added BaseProcedure with following properties:
      - parallel
      - calcSldDuringFit
      - resamPars
      - display
    2. Added Calculate with following properties:
      - procedure
    3. Added Simplex with following properties:
      - procedure
      - tolX
      - tolFun
      - maxFunEvals
      - maxIter
      - updateFreq
      - updatePlotFreq
    4. Added DE with following properties:
      - procedure
      - populationSize
      - fWeight
      - crossoverProbability
      - strategy
      - targetValue
      - numGenerations
    5. Added NS with following properties:
      - procedure
      - Nlive
      - Nmcmc
      - propScale
      - nsTolerance
    6. Added Dream with following properties:
      - procedure
      - nSamples
      - nChains
      - jumpProb originally named lambda in MATLAB
      - pUnitGamma
      - boundHandling
  • Refactored ControlsClass.
  • Verified similar exceptions are raised in python as the MATLAB version.
  • Added verification of inputs.
  • Added __repr__ method.
    image
  • Added tests. Test Coverage:
  • Added doc strings.

What kind of change does this PR introduce ?

  • Feature / New class in python / Rewrite of MATLAB class

What is the current behaviour ?

What is the new behaviour ?

  • PR will add ControlsClass in the python version of RAT which allows users to define the calculation settings.

Does this PR introduce a breaking change ?

  • lambda variable from MATLAB class is renamed in python version to jumpProb.
  • None in boundHandlingOptions enum from MATLAB is renamed in python version to off.

Other Information

  • setProcedure method from the MATLAB class is dropped in the python version.

Usage

Create ControlsClass by passing procedure. If no procedure is provided then it is set to Procedures.Calculate.

    calculate = ControlsClass() 
    dream = ControlsClass(procedure = Procedures.Dream)

Properties can be updated individually after ControlsClass is created.

    calculate.controls.calcSldDuringFit = True

Properties can also be set when ControlsClass is created by passing **kwargs.

    simplex = ControlsClass(procedure = Procedures.Simplex, tolX = 2e-5, maxIter = 500) 

@RabiyaF RabiyaF marked this pull request as draft September 12, 2023 21:37
@RabiyaF RabiyaF changed the title added the test file for controls class added the controlsClass Sep 12, 2023
@RabiyaF RabiyaF marked this pull request as ready for review September 18, 2023 08:06
@RabiyaF RabiyaF self-assigned this Sep 18, 2023
@RabiyaF RabiyaF requested a review from DrPaulSharp September 18, 2023 18:32
@RabiyaF RabiyaF added the enhancement New feature or request label Sep 18, 2023
Copy link
Collaborator

@DrPaulSharp DrPaulSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and should do the job well. I think though that we should look to implement the procedure classes in pydantic - we will get all of the same functionality and save a LOT of lines of code. You can see how it works in "RAT/models.py"

@RabiyaF RabiyaF requested a review from DrPaulSharp September 21, 2023 22:43
Copy link
Collaborator

@DrPaulSharp DrPaulSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've done a great job of using pydantic here, and it definitely makes for some cleaner code. Have a look at the comments here, and one they're sorted I'll have a closer look at the tests.

@RabiyaF RabiyaF requested a review from DrPaulSharp September 22, 2023 17:59
Copy link
Collaborator

@DrPaulSharp DrPaulSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, well done. Just a couple of minor points to address and then we're there!

@DrPaulSharp DrPaulSharp merged commit 6f329ed into RascalSoftware:main Sep 25, 2023
DrPaulSharp added a commit that referenced this pull request Sep 25, 2023
@RabiyaF RabiyaF deleted the controls-class branch September 25, 2023 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the controlsClass
2 participants