Skip to content

Custom components and conditions #83

Discussion options

You must be logged in to vote

Hi Filippo,

How about something like this?

from pyddm import Drift
class DriftCondition(Drift):
    name = "Drift depends on a condition value"
    required_parameters = ["drift1", "drift2", "drift3"]
    required_conditions = ["cond"] # <--Can be 1, 2, or 3
    def get_drift(self, conditions, **kwargs):
        if conditions['cond'] == 1:
            return self.drift1
        elif conditions['cond'] == 2:
            return self.drift2
        elif conditions['cond'] == 3:
            return self.drift3

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@filippoferrari
Comment options

Answer selected by filippoferrari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants