huawei-noah / trustworthyAI

Trustworthy AI related projects
Apache License 2.0
958 stars 216 forks source link

Enhancement: Updated _simulate_linear_sem() function to support list of SEM types #118

Closed VineetMalik14 closed 1 year ago

VineetMalik14 commented 1 year ago

This PR introduces an enhancement to the _simulate_linear_sem() function in the simulator.py file. The changes now allow the function to accept both a single string or a list of strings for the sem_type parameter, providing users with the flexibility to define different SEM types for each variable in the model.

Notably, these changes are backward compatible. Users who wish to continue using a single string for sem_type can do so without any disruption. The single string will still be interpreted as the SEM type for all variables, as in the previous version.

Changes made in this PR include:

  1. Updated the sem_type parameter handling in the _simulate_linear_sem() function to allow for a list of SEM types as well as a single string.
  2. Enhanced the _simulate_single_equation() method to generate variable noise according to the specified sem_type_single.
  3. Updated the docstrings for both _simulate_linear_sem() and _simulate_single_equation() to reflect these changes.
  4. Added robust error checking to ensure that the sem_type parameter is correctly formatted, either as a string or a list of strings of appropriate length.

These updates have been thoroughly tested to ensure correct and expected behavior.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

shaido987 commented 1 year ago

Thank you!