Skip to content

MNT: Extract logic from info in rocket class #312

@GabrielBarberini

Description

@GabrielBarberini

Is your feature request related to a problem? Please describe.

Currently, there is a bunch of logic and conditional loops inside the Rocket class allInfo(self) (line 1169) method. This makes it harder for the frontend team to consume a subset view data of allInfo without code duplication, hence violating DRY.

Describe the solution you'd like

I think a good approach would be to encapsulate every loop and conditional existing at the allInfo method in a private method or lambda making the logic behind the view (print) transparent for the allInfo method.

Additional context

For instance, in the parachute data:

 # Print parachute data
        for chute in self.parachutes:
            print("\n" + chute.name.title() + " Parachute")
            print("CdS Coefficient: " + str(chute.CdS) + " m2")
            if chute.trigger.__name__ == "<lambda>":
                line = getsourcelines(chute.trigger)[0][0]
                print(
                    "Ejection signal trigger: "
                    + line.split("lambda ")[1].split(",")[0].split("\n")[0]
                )
            else:
                print("Ejection signal trigger: " + chute.trigger.__name__)
            print("Ejection system refresh rate: " + str(chute.samplingRate) + " Hz.")
            print(
                "Time between ejection signal is triggered and the "
                "parachute is fully opened: " + str(chute.lag) + " s"
            )

I think it would be better if we had something like:

 # Print parachute data
    print("\n" + parachutes_name_and_coefficient())
    print("\n" + ejection_sinal_trigger())

Metadata

Metadata

Labels

OutputsDedicated to visualizations enhancements like prints and plotsRefactor

Type

No type

Projects

Status

Closed

Relationships

None yet

Development

No branches or pull requests

Issue actions