Ejemplo n.º 1
0
    def pull_data(self, dirs, fs):
        """
        Parses the folders for each participant and
        generates the corresponding Condition objects.

        :param dirs: string, A list of directories relevant to this participant
        :param fs: string, may be provided to specify a different folder structure.
            (Environment is assumed to the be the 1st condition, separated by underscores)
        """

        # Find the folder structure levels for interface and conditions
        ui_level = fs.split("/").index("Interface")
        cond_level = fs.split("/").index("Conditions")

        # Initialize a temporary data structure for condition info
        conditions = {}

        # Loop through each directory for this participant and parse out the conditions
        for _dir in dirs:
            path = _dir[len("../Data")+1:]
            cond = (path.split("\\")[ui_level], path.split("\\")[cond_level])

            # If it's the first time seeing this condition, add it
            if cond not in conditions:
                conditions[cond] = []

            # Add the current directory to the list for this Condition
            conditions[cond].append(_dir)

        # Once we have all conditions for the participant, simply create
        # each object, populate it, and add it to the participant
        for c in sorted(conditions.keys()):
            ui = c[0]
            env = c[1].split("_")[0]
            conds = [] if "_" not in c[1] else c[1].split("_")[1]

            condition = Condition(ui, env, conds)
            condition.pull_data(conditions[c], fs)
            self.add_condition(condition)
Ejemplo n.º 2
0
 def setUp(self):
     self.condition = Condition((0, 0), (0, 0))
Ejemplo n.º 3
0
a3 = Variable(TypeVariable.INPUT)

g1 = Variable(TypeVariable.OUTPUT)
g2 = Variable(TypeVariable.OUTPUT)
g3 = Variable(TypeVariable.OUTPUT)

# """ test of contradictions """
# test = Condition(Side(a), Side(), StateConditions.IS_ZERO)
# test2 = Condition(Side(a), Side(), StateConditions.IS_NOT_ZERO)
# assert test.is_contradiction(test2)

# test = Condition(Side(a, a2, g3), Side(), StateConditions.IS_ZERO)
# test2 = Condition(Side(a, a2, g3), Side(), StateConditions.IS_NOT_ZERO)
# assert test.is_contradiction(test2)
""" test of useless """
test = Condition(Side(), Side(), StateConditions.IS_ZERO)
assert test.is_useless()

test = Condition(Side(a, g3), Side(g3, a), StateConditions.IS_EQUAL)
assert test.is_useless()

test = Condition(Side(a, g3), Side(a, g3), StateConditions.IS_EQUAL)
assert test.is_useless()

test = Condition(Side(a, g3), Side(), StateConditions.IS_ZERO)
assert test.is_useless() == False
""" test of normalise """
test = Condition(Side(a, g3), Side(), StateConditions.IS_EQUAL)
test2 = Condition(Side(g3), Side(a), StateConditions.IS_EQUAL)
test.normalise()
assert test == test2
Ejemplo n.º 4
0
 def condition(self):
     if not self._condition: self._condition = Condition()
     return self._condition