Exemple #1
0
    def _validate_variable(self, variable, context=None):
        """Validate that variable has only one item: activation_input.
        """

        # Skip LearningMechanism._validate_variable in call to super(), as it requires variable to have 3 items
        variable = super(LearningMechanism, self)._validate_variable(variable, context)

        if np.array(variable).ndim != 2 or not is_numeric(variable):
            raise KohonenLearningMechanismError("Variable for {} ({}) must be a list with two items "
                                                "or a 2d np.array, all of which may contain only numbers".
                                                        format(self.name, variable))
        return variable
    def _validate_variable(self, variable, context=None):
        """Validate that variable has only one item: activation_input.
        """

        # Skip LearningMechanism._validate_variable in call to super(), as it requires variable to have 3 items
        variable = super(LearningMechanism,
                         self)._validate_variable(variable, context)

        # # MODIFIED 9/22/17 NEW: [HACK] JDC: 6/29/18 -> CAUSES DEFAULT variable [[0]] OR ANYTHING OF size=1 TO FAIL
        # if np.array(np.squeeze(variable)).ndim != 1 or not is_numeric(variable):
        # MODIFIED 6/29/18 NEWER JDC: ALLOW size=1, AND DEFER FAILURE TO LearningFunction IF enbale_learning=True
        if np.array(variable)[0].ndim != 1 or not is_numeric(variable):
            # MODIFIED 9/22/17 END
            raise AutoAssociativeLearningMechanismError(
                "Variable for {} ({}) must be "
                "a list or 1d np.array containing only numbers".format(
                    self.name, variable))
        return variable