Used to check layer validity.
770112
def layer_pre_save(instance, *args, **kwargs):
    

    is_valid = True

    # we do not need to check validity for WM layers
    if not instance.service.type == 'Hypermap:WorldMap':

        # 0. a layer is invalid if its service its invalid as well
        if not instance.service.is_valid:
            is_valid = False
            LOGGER.debug('Layer with id %s is marked invalid because its service is invalid' % instance.id)

        # 1. a layer is invalid with an extent within (-2, -2, +2, +2)
        if instance.bbox_x0 > -2 and instance.bbox_x1 < 2 and instance.bbox_y0 > -2 and instance.bbox_y1 < 2:
            is_valid = False
            LOGGER.debug(
                'Layer with id %s is marked invalid because its extent is within (-2, -2, +2, +2)' % instance.id
            )

    instance.is_valid = is_valid
1101445
def validate(self):
        """"""

        for key, req in self.stored().items():
            val = getattr(self, key)
            req.validate(val)

        # Run checks defined in __checkers__
        self._run_checks()
362390
def verifyArguments(self, arg):
        
        for l in arg:
            if not type(l) == list and \
               not type(l) == type(Numeric.array([0.0])) and \
               not type(l) == tuple and \
               not type(l) == dict:
                return 0
            if type(l) == dict:
                for i in l:
                    if not type(i) == str and i not in list(self.layers.keys()):
                        return 0
            else:
                for i in l:
                    if not type(i) == float and not type(i) == int:
                        return 0
        return 1
586859
def _validate(self):
        
        checker = (self._check0, self._check1, self._check2, self._check3,
                   self._check4, self._check5)
        if not 0 <= self.field_type <= 5:
            raise NotImplementedError("unsupported widget type")
        if type(self.rect) is not Rect:
            raise ValueError("invalid rect")
        if self.rect.isInfinite or self.rect.isEmpty:
            raise ValueError("rect must be finite and not empty")
        if not self.field_name:
            raise ValueError("field name missing")

        if self.border_color:
            if not len(self.border_color) in range(1,5) or \
               type(self.border_color) not in (list, tuple):
               raise ValueError("border_color must be 1 - 4 floats")

        if self.fill_color:
            if not len(self.fill_color) in range(1,5) or \
               type(self.fill_color) not in (list, tuple):
               raise ValueError("fill_color must be 1 - 4 floats")

        if not self.text_color:
            self.text_color = (0, 0, 0)
        if not len(self.text_color) in range(1,5) or \
            type(self.text_color) not in (list, tuple):
            raise ValueError("text_color must be 1 - 4 floats")

        if not self.border_width:
            self.border_width = 0

        if not self.text_fontsize:
            self.text_fontsize = 0

        checker[self.field_type]()
986026
def is_layer(layer, layer_type):
    '''
    '''

    if layer_type == "Input":
        return isinstance(layer, StubInput)
    elif layer_type == "Conv":
        return isinstance(layer, StubConv)
    elif layer_type == "Dense":
        return isinstance(layer, (StubDense,))
    elif layer_type == "BatchNormalization":
        return isinstance(layer, (StubBatchNormalization,))
    elif layer_type == "Concatenate":
        return isinstance(layer, (StubConcatenate,))
    elif layer_type == "Add":
        return isinstance(layer, (StubAdd,))
    elif layer_type == "Pooling":
        return isinstance(layer, StubPooling)
    elif layer_type == "Dropout":
        return isinstance(layer, (StubDropout,))
    elif layer_type == "Softmax":
        return isinstance(layer, (StubSoftmax,))
    elif layer_type == "ReLU":
        return isinstance(layer, (StubReLU,))
    elif layer_type == "Flatten":
        return isinstance(layer, (StubFlatten,))
    elif layer_type == "GlobalAveragePooling":
        return isinstance(layer, StubGlobalPooling)
1265250
private void validateCoefficients() {
        if (coefsValid)
            return;

        if (n >= 2) {
            double xBar = (double) sumX / n;
            double yBar = (double) sumY / n;

            a1 = (double) ((n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX));
            a0 = (double) (yBar - a1 * xBar);
        } else {
            a0 = a1 = Double.NaN;
        }

        coefsValid = true;
    }
939758
private void verifyChunkedSums(
      byte[] data, int dataOff, int dataLen,
      byte[] checksums, int checksumsOff, String fileName,
      long basePos) throws ChecksumException {
    
    int remaining = dataLen;
    int dataPos = 0;
    while (remaining > 0) {
      int n = Math.min(remaining, bytesPerChecksum);
      
      summer.reset();
      summer.update(data, dataOff + dataPos, n);
      dataPos += n;
      remaining -= n;
      
      int calculated = (int)summer.getValue();
      int stored = (checksums[checksumsOff] << 24 & 0xff000000) |
        (checksums[checksumsOff + 1] << 16 & 0xff0000) |
        (checksums[checksumsOff + 2] << 8 & 0xff00) |
        checksums[checksumsOff + 3] & 0xff;
      checksumsOff += 4;
      if (calculated != stored) {
        long errPos = basePos + dataPos - n;
        throw new ChecksumException(
            "Checksum error: "+ fileName + " at "+ errPos +
            " exp: " + stored + " got: " + calculated, errPos);
      }
    }
  }
29092
public static void assertNOutSet(String layerType, String layerName, long layerIndex, long nOut) {
        if (nOut <= 0) {
            if (layerName == null)
                layerName = "(name not set)";
            throw new DL4JInvalidConfigException(layerType + " (index=" + layerIndex + ", name=" + layerName + ") nOut="
                            + nOut + "; nOut must be > 0");
        }
    }
179090
def validate(self):
        
        self.pixel_truth_sum = np.sum(self.pixel_truth_counts, axis=0)
        self.pixel_classification_sum = np.sum(self.pixel_classification_counts, axis=0)
1209393
def validate_input(self):
        
        self.exposure_layer = layer_from_combo(self.dock.exposure_layer_combo)
        self.hazard_layer = layer_from_combo(self.dock.hazard_layer_combo)
        self.aggregation_layer = layer_from_combo(
            self.dock.aggregation_layer_combo)

        is_valid = True
        warning_message = None
        if self.exposure_layer is None:
            warning_message = tr(
                'Exposure layer is not found, can not save scenario. Please '
                'add exposure layer to do so.')
            is_valid = False

        if self.hazard_layer is None:
            warning_message = tr(
                'Hazard layer is not found, can not save scenario. Please add '
                'hazard layer to do so.')
            is_valid = False

        return is_valid, warning_message
1165908
function() {

        // set the newly selected base layer
        for(var i=0, len=this.baseLayers.length; i<len; i++) {
            var layerEntry = this.baseLayers[i];
            if (layerEntry.inputElem.checked) {
                this.map.setBaseLayer(layerEntry.layer, false);
            }
        }

        // set the correct visibilities for the overlays
        for(var i=0, len=this.dataLayers.length; i<len; i++) {
            var layerEntry = this.dataLayers[i];
            layerEntry.layer.setVisibility(layerEntry.inputElem.checked);
        }

    }
1237975
public function verifySettings()
    {
        if ($this->min < 0 && $this->max < 0) {
            $this->setError(
                "You must set at least one of the min or the " .
                "max levels."
            );
        }
        if ($this->max < $this->min && $this->max > -1) {
            $this->setError("The maximum depth is lower than the minimum.");
        }
    }
526666
def is_valid_tile(self, x, y):
        """"""
        x = int(x)
        y = int(y)

        if x < 0:
            return False
        if y < 0:
            return False
        if x > self.size_in_tiles.X:
            return False
        if y > self.size_in_tiles.Y:
            return False

        return True
1325958
def validate(self, data, offset):
        """"""
        recorded_checksum = self.field.getval()

        # convert negative offset to positive
        if offset < 0:
            offset += len(data)

        # replace checksum region with zero
        data = b''.join((data[:offset],
                         b"\x00" * self.bytes_required,
                         data[offset + self.bytes_required:]))
        actual_checksum = self.algo(data[self.start:self.end])
        if recorded_checksum != actual_checksum:
            raise SuitcaseChecksumException(
                "recorded checksum %r did not match actual %r.  full data: %r",
                recorded_checksum, actual_checksum, data)
1089890
def check(self, radl):
        """"""

        if not isinstance(self.max_time, int) or self.max_time < 0:
            raise RADLParseException("Invalid 'max time' in 'contextualize'",
                                     line=self.line)
        if self.items is not None:
            for i in self.items.values():
                i.check(radl)
65024
def check_available(self):
        
        success = True
        start_time = datetime.datetime.utcnow()
        message = ''
        LOGGER.debug('Checking layer id %s' % self.id)

        signals.post_save.disconnect(layer_post_save, sender=Layer)

        try:
            self.update_thumbnail()
        except ValueError, err:
            # caused by update_thumbnail()
            # self.href is empty in arcserver.ExportMap
            if str(err).startswith("unknown url type:"):
                LOGGER.debug('Thumbnail can not be updated: %s' % str(err))
        except Exception, err:
            message = str(err)
            success = False

        signals.post_save.connect(layer_post_save, sender=Layer)

        end_time = datetime.datetime.utcnow()

        delta = end_time - start_time
        response_time = '%s.%s' % (delta.seconds, delta.microseconds)

        check = Check(
            content_object=self,
            success=success,
            response_time=response_time,
            message=message
        )
        check.save()
        LOGGER.debug('Layer checked in %s seconds, status is %s' % (response_time, success))
        return success, message
949205
def is_valid(self):
        """"""
        if not all([
            isinstance(self.zoom, int),
            self.zoom >= 0,
            isinstance(self.row, int),
            self.row >= 0,
            isinstance(self.col, int),
            self.col >= 0
        ]):
            raise TypeError("zoom, col and row must be integers >= 0")
        cols = self.tile_pyramid.matrix_width(self.zoom)
        rows = self.tile_pyramid.matrix_height(self.zoom)
        if self.col >= cols:
            raise ValueError("col (%s) exceeds matrix width (%s)" % (self.col, cols))
        if self.row >= rows:
            raise ValueError("row (%s) exceeds matrix height (%s)" % (self.row, rows))
        return True