Skip to content

Support for python's dataclass members #126

@akriese

Description

@akriese

Hi, I am currently documenting a python project with neogen and I am liking it very much so far!

One thing that I am currently missing is the support for dataclass attributes.

@dataclass
class RunSettings():
    """A collection of settings for an algorithm run.

    Attributes:
        algorithm: String resembling the type of algorithm used.
            Currently, only 'nsga2' and 'ga' are supported.
        population: Population size of the run.
        generations: Number of generations of the run.
        objectives: Dict with load values for each objective.
            E.g. { "torque": 2e10, "compression": 4.6e4 }
        architecture: Decides the used substructure architecture for the run.
            Currently 'simple' or 'complex'.
        constraints: SubstructureConstraints object that sets design
            constraints for the algorithm run.
        combine_stabilities: Bool deciding if the static stability test values
            should be combined into one value.
        probabilities: Dict with probabilities for mutation and crossover.
        tracking: Bool deciding, if genealogical tracking information is saved
            in design dicts throughout the run.
    """

    algorithm: str = "nsga2"
    population: int = 20
    generations: int = 5
    objectives: dict = field(default_factory=lambda: REAL_LIFE_LOADS)
    architecture: str = "simple"
    constraints: SubstructureConstraints = None
    combine_stabilities: bool = True
    probabilities: dict = field(default_factory=lambda: DEFAULT_PROBABILITIES)
    tracking: bool = False

    def __post_init__(self):
        do_stuff()

Currently, when generating the docstring for this class, only Attributes that are set in some of its functions are included in the list.

Do you think, this is complicated to implement? If I find time, I could also try to understand the source code of neogen and try to create a PR :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions