Validates whether the ODE equations provided make sense  i.e. the number of right-hand side equations
        match the number of left-hand side equations.
356340
def validate(self):
        
        if self.left_hand_side.rows != self.right_hand_side.rows:
            raise ValueError("There are {0} left hand side equations and {1} right hand side equations. "
                             "The same number is expected.".format(self.left_hand_side.rows, self.right_hand_side.rows))
628553
def _dK_ode_dtheta(self, target):
        """"""
        t_ode = self._t[self._index>0]
        dL_dK_ode = self._dL_dK[self._index>0, :]
        index_ode = self._index[self._index>0]-1
        if self._t2 is None:
            if t_ode.size==0:
                return        
            t2_ode = t_ode
            dL_dK_ode = dL_dK_ode[:, self._index>0]
            index2_ode = index_ode
        else:
            t2_ode = self._t2[self._index2>0]
            dL_dK_ode = dL_dK_ode[:, self._index2>0]
            if t_ode.size==0 or t2_ode.size==0:
                return
            index2_ode = self._index2[self._index2>0]-1

        h1 = self._compute_H(t_ode, index_ode, t2_ode, index2_ode, stationary=self.is_stationary, update_derivatives=True)
        #self._dK_ddelay = self._dh_ddelay
        self._dK_dsigma = self._dh_dsigma

        if self._t2 is None:
            h2 = h1
        else:
            h2 = self._compute_H(t2_ode, index2_ode, t_ode, index_ode, stationary=self.is_stationary, update_derivatives=True)

        #self._dK_ddelay += self._dh_ddelay.T
        self._dK_dsigma += self._dh_dsigma.T
        # C1 = self.sensitivity
        # C2 = self.sensitivity

        # K = 0.5 * (h1 + h2.T)
        # var2 = C1*C2
        # if self.is_normalized:
        #     dk_dD1 = (sum(sum(dL_dK.*dh1_dD1)) + sum(sum(dL_dK.*dh2_dD1.T)))*0.5*var2
        #     dk_dD2 = (sum(sum(dL_dK.*dh1_dD2)) + sum(sum(dL_dK.*dh2_dD2.T)))*0.5*var2
        #     dk_dsigma = 0.5 * var2 * sum(sum(dL_dK.*dK_dsigma))
        #     dk_dC1 = C2 * sum(sum(dL_dK.*K))
        #     dk_dC2 = C1 * sum(sum(dL_dK.*K))
        # else:
        #     K = np.sqrt(np.pi) * K
        #     dk_dD1 = (sum(sum(dL_dK.*dh1_dD1)) + * sum(sum(dL_dK.*K))
        #     dk_dC2 = self.sigma * C1 * sum(sum(dL_dK.*K))


        # dk_dSim1Variance = dk_dC1
        # Last element is the length scale.
        (dL_dK_ode[:, :, None]*self._dh_ddelay[:, None, :]).sum(2)

        target[-1] += (dL_dK_ode*self._dK_dsigma/np.sqrt(2)).sum()
44185
def validate(self):
        
        if self.stoichiometry_matrix.cols != self.propensities.rows:
            raise ValueError('There must be a column in stoichiometry matrix '
                             'for each row in propensities matrix. '
                             'S ({0.rows}x{0.cols}): {0!r} , '
                             'propensities ({1.rows}x{1.cols}): {1!r}'.format(self.stoichiometry_matrix,
                                                                              self.propensities))

        if self.stoichiometry_matrix.rows != len(self.species):
            raise ValueError('There must be a row in stoichiometry matrix for each variable. '
                             'S ({0.rows}x{0.cols}): {0!r}, variables: {1!r}'.format(self.stoichiometry_matrix,
                                                                                     self.species))

        seen_free_symbols = set()
        parameters = set(self.parameters)
        species = set(self.species)

        # Check if there are any parameters in both lists
        intersection = parameters & species
        if intersection:
            raise ValueError("Some symbols are in both parameters and species lists")

        both = parameters | species
        for row in self.propensities:
            free_symbols = row.free_symbols
            # Do not check the seen symbols twice
            free_symbols = free_symbols - seen_free_symbols
            for symbol in free_symbols:
                if symbol not in both:
                    raise ValueError('Propensity {0!r} '
                                     'contains a free symbol {1!r} '
                                     'that is not in listed in parameters or species lists '
                                     'Parameters: {2!r}; '
                                     'Species: {3!r}'.format(row, symbol,
                                                             self.parameters,
                                                             self.species))

            seen_free_symbols.update(free_symbols)
1288673
public boolean matches(SameDiff sameDiff, DifferentialFunction rootFn){

        if(!root.matches(sameDiff, rootFn)){
            return false;
        }

        SDVariable[] inputs = rootFn.args();
        int inCount = inputs == null ? 0 : inputs.length;
        if(inputCount != null){
            if(inCount != this.inputCount)
                return false;
        }

        SDVariable[] outputs = rootFn.outputVariables();
        int outCount = outputs == null ? 0 : outputs.length;
        if(outputCount != null){
            if(outCount != outputCount)
                return false;
        }

        for(Map<Integer,OpPredicate> m : Arrays.asList(opInputMatchPredicates, opInputSubgraphPredicates)) {
            for (Map.Entry<Integer, OpPredicate> e : m.entrySet()) {
                int inNum = e.getKey();
                if (inNum >= inCount) {
                    return false;
                }

                SDVariable in = inputs[inNum];
                DifferentialFunction df = sameDiff.getVariableOutputFunction(in.getVarName());
                if (df == null || !e.getValue().matches(sameDiff, df)) {
                    return false;
                }
            }
        }

        return true;
    }
1303053
private void evaluateConstraints(DoubleSolution solution)  {
    double[] constraint = new double[this.getNumberOfConstraints()];

    double x1 = solution.getVariableValue(0);
    double x2 = solution.getVariableValue(1);
        
    constraint[0] = -x2 - (4.0 * x1) + 4.0  ;
    constraint[1] = x1 + 1.0 ;
    constraint[2] = x2 - x1 + 2.0 ;

    double overallConstraintViolation = 0.0;
    int violatedConstraints = 0;
    for (int i = 0; i < getNumberOfConstraints(); i++) {
      if (constraint[i]<0.0){
        overallConstraintViolation+=constraint[i];
        violatedConstraints++;
      }
    }

    overallConstraintViolationDegree.setAttribute(solution, overallConstraintViolation);
    numberOfViolatedConstraints.setAttribute(solution, violatedConstraints);
  }
397116
public static boolean notEqualWithinTolerance(double left, double right, double tolerance) {
    if (Doubles.isFinite(left) && Doubles.isFinite(right)) {
      return Math.abs(left - right) > Math.abs(tolerance);
    } else {
      return false;
    }
  }
859980
private void evaluateConstraints(DoubleSolution solution)  {
    double[] constraint = new double[this.getNumberOfConstraints()];
    double x1,x2,x3,x4,x5,x6,x7;

    x1 = solution.getVariableValue(0);
    x2 = solution.getVariableValue(1);
    x3 = solution.getVariableValue(2);
    x4 = solution.getVariableValue(3);
    x5 = solution.getVariableValue(4);
    x6 = solution.getVariableValue(5);
    x7 = solution.getVariableValue(6);

    constraint[0] = -((1.0/(x1*x2*x2*x3)) -(1.0/27.0));
    constraint[1] = -((1.0/(x1*x2*x2*x3*x3))-(1.0/397.5));
    constraint[2] = -((x4*x4*x4)/(x2*x3*x3*x6*x6*x6*x6)-(1.0/1.93));
    constraint[3] = -((x5*x5*x5)/(x2*x3*x7*x7*x7*x7)- (1.0/1.93));
    constraint[4] = -(x2*x3 - 40.0);
    constraint[5] = -((x1/x2) - 12.0);
    constraint[6] = -(5.0 - (x1/x2));
    constraint[7] = -(1.9 - x4 + 1.5*x6);
    constraint[8] = -(1.9 - x5 + 1.1*x7);

    double aux = 745.0 * x4 / (x2 * x3);
    double f2 = java.lang.Math.sqrt((aux*aux)+1.69e7) / (0.1*x6*x6*x6);
    constraint[9] = -(f2 - 1300);
    double a = 745.0*x5/(x2*x3);
    double b = 1.575e8;
    constraint[10] = -(java.lang.Math.sqrt(a*a+b)/(0.1*x7*x7*x7)-1100.0);

    double overallConstraintViolation = 0.0;
    int violatedConstraints = 0;
    for (int i = 0; i < getNumberOfConstraints(); i++) {
      if (constraint[i]<0.0){
        overallConstraintViolation+=constraint[i];
        violatedConstraints++;
      }
    }

    overallConstraintViolationDegree.setAttribute(solution, overallConstraintViolation);
    numberOfViolatedConstraints.setAttribute(solution, violatedConstraints);
  }
1334579
public boolean matches(Object left, Object right) {
    if (left == null && right == null) {
      // if both are null L == R
      return true;
    }
    if (left == null || right == null) {
      // we know both aren't null, therefore L != R
      return false;
    }
    final String arg = left.toString();
    if (right instanceof java.util.regex.Pattern) {
      return ((java.util.regex.Pattern) right).matcher(arg).matches();
    }
    else {
      return arg.matches(right.toString());
    }
  }
245935
def is_solved(self):
        
        for side in "LUFDRB":
            sample = self.cube[side].facings[side]
            for square in sum(self.cube.get_face(side), []):
                if square != sample:
                    return False
        return True
640066
@Override
	public boolean refine(Polygon2D_F64 input, Polygon2D_F64 output)
	{
		if( input.size() != output.size())
			throw new IllegalArgumentException("Input and output sides do not match. "+input.size()+" "+output.size());

		// sanity check input.  If it's too small this algorithm won't work
		if( checkShapeTooSmall(input) )
			return false;

		// see if this work space needs to be resized
		if( general.length < input.size() ) {
			general = new LineGeneral2D_F64[input.size() ];
			for (int i = 0; i < general.length; i++) {
				general[i] = new LineGeneral2D_F64();
			}
		}

		// estimate line equations
		return optimize(input,output);
	}
875108
def satisfies_constraints(self, possible_solution):
        """"""
        for c in self._constraints:
            values = c.extract_values(possible_solution)
            if any(type(v) is NilObject for v in values) or not c(*values):
                return False
        return True
1105890
public boolean correct(GrowQueue_I8 input , GrowQueue_I8 ecc )
	{
		computeSyndromes(input,ecc,syndromes);
		findErrorLocatorPolynomialBM(syndromes,errorLocatorPoly);
		if( !findErrorLocations_BruteForce(errorLocatorPoly,input.size+ecc.size,errorLocations))
			return false;

		correctErrors(input,input.size+ecc.size,syndromes,errorLocatorPoly,errorLocations);
		return true;
	}
1236688
def is_valid_input_array(x, ndim=None):
    """"""
    x = np.asarray(x)

    if ndim is None or ndim == 1:
        return x.ndim == 1 and x.size > 1 or x.ndim == 2 and x.shape[0] == 1
    else:
        return x.ndim == 2 and x.shape[0] == ndim
244489
public boolean isValid() {
		if (isEmpty()) {
			return true;
		}
		if (!isClosed()) {
			return false;
		}
		Coordinate[] coordinates = getCoordinates();

		if (coordinates.length < 4) {
			return false;
		}

		for (int i = 0; i < coordinates.length - 1; i++) {
			for (int j = 0; j < coordinates.length - 1; j++) {
				if (Mathlib.lineIntersects(coordinates[i], coordinates[i + 1], coordinates[j], coordinates[j + 1])) {
					return false;
				}
			}
		}

		return true;
	}
778600
def validate(self, answer):
        
        if answer is None:
            return False
        else:
            if isinstance(self.validator, list):
                for v in self.validator:
                    if not v.validate(answer):
                        return False
                return True
            else:
                return self.validator.validate(answer)
1308849
def verify(self):
        
        if self.firstdate >= self.lastdate:
            raise ValueError(
                f'Unplausible timegrid. The first given date '
                f'{self.firstdate}, the second given date is {self.lastdate}.')
        if (self.lastdate-self.firstdate) % self.stepsize:
            raise ValueError(
                f'Unplausible timegrid. The period span between the given '
                f'dates {self.firstdate} and {self.lastdate} is not '
                f'a multiple of the given step size {self.stepsize}.')
1296401
protected function validate_answers($data, $errors) {
        // Check the answers.
        $answercount = 0;
        $maxgrade = false;
        $answers = $data['answer'];
        foreach ($answers as $key => $answer) {
            $trimmedanswer = trim($answer);
            if ($trimmedanswer != '') {
                $answercount++;
                if (!$this->is_valid_answer($trimmedanswer, $data)) {
                    $errors['answeroptions[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
                }
                if ($data['fraction'][$key] == 1) {
                    $maxgrade = true;
                }
                if ($answer !== '*' && $data['tolerance'][$key] === false) {
                    $errors['answeroptions['.$key.']'] =
                            get_string('xmustbenumeric', 'qtype_numerical',
                                get_string('acceptederror', 'qtype_numerical'));
                }
            } else if ($data['fraction'][$key] != 0 ||
                    !html_is_blank($data['feedback'][$key]['text'])) {
                $errors['answeroptions[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
                $answercount++;
            }
        }
        if ($answercount == 0) {
            $errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_numerical');
        }
        if ($maxgrade == false) {
            $errors['answeroptions[0]'] = get_string('fractionsnomax', 'question');
        }

        return $errors;
    }