:param detector_class: Class inheriting from `AbstractDetector`.
491675
def register_detector(self, detector_class):
        
        self._check_common_things('detector', detector_class, AbstractDetector, self._detectors)

        instance = detector_class(self, logger_detector)
        self._detectors.append(instance)
1253559
def classes_(self):
        
        if self.__classes is None:
            try:
                return self.estimator.classes_
            except AttributeError:
                return None
        return self.__classes
1159362
def contribute_to_class(self, cls, name, virtual_only=False):
        
        super(RegexField, self).contribute_to_class(cls, name, virtual_only)
        setattr(cls, name, CastOnAssignDescriptor(self))
873326
def detect(agent, fill_none=False):
    
    result = dict(platform=dict(name=None, version=None))
    _suggested_detectors = []

    for info_type in detectorshub:
        detectors = _suggested_detectors or detectorshub[info_type]
        for detector in detectors:
            try:
                detector.detect(agent, result)
            except Exception as _err:
                pass

    if fill_none:
        for outer_key in ('os', 'browser'):
            outer_value = result.setdefault(outer_key, dict())
            for inner_key in ('name', 'version'):
                outer_value.setdefault(inner_key, None)

    return result
550904
def _get_class_handlers(cls, signal_name, instance):
        
        handlers = cls._signal_handlers_sorted[signal_name]
        return [getattr(instance, hname) for hname in handlers]
61891
def class_subobjects(
        class_: Type) -> Generator[Tuple[str, Type, bool], None, None]:
    
    argspec = inspect.getfullargspec(class_.__init__)
    defaults = argspec.defaults if argspec.defaults else []
    num_optional = len(defaults)
    first_optional = len(argspec.args) - num_optional

    for i, attr_name in enumerate(argspec.args):
        if attr_name == 'self':
            continue
        if attr_name == 'yatiml_extra':
            continue
        attr_type = argspec.annotations.get(attr_name, Any)
        yield attr_name, attr_type, i < first_optional
953209
def print_class_histogram(roidbs):
    
    dataset = DetectionDataset()
    hist_bins = np.arange(dataset.num_classes + 1)

    # Histogram of ground-truth objects
    gt_hist = np.zeros((dataset.num_classes,), dtype=np.int)
    for entry in roidbs:
        # filter crowd?
        gt_inds = np.where(
            (entry['class'] > 0) & (entry['is_crowd'] == 0))[0]
        gt_classes = entry['class'][gt_inds]
        gt_hist += np.histogram(gt_classes, bins=hist_bins)[0]
    data = [[dataset.class_names[i], v] for i, v in enumerate(gt_hist)]
    data.append(['total', sum(x[1] for x in data)])
    # the first line is BG
    table = tabulate(data[1:], headers=['class', '#box'], tablefmt='pipe')
    logger.info("Ground-Truth Boxes:\n" + colored(table, 'cyan'))
1229115
def get_detectors(self, name=None, tags=None, batch_size=100, **kwargs):
        
        detectors = []
        offset = 0
        while True:
            resp = self._get(
                self._u(self._DETECTOR_ENDPOINT_SUFFIX),
                params={
                    'offset': offset,
                    'limit': batch_size,
                    'name': name,
                    'tags': tags or [],
                },
                **kwargs)
            resp.raise_for_status()
            data = resp.json()
            detectors += data['results']
            if len(detectors) == data['count']:
                break
            offset = len(detectors)
        return detectors
583856
def subclasses(self, inherited=False):
        
        data = clips.data.DataObject(self._env)

        lib.EnvClassSubclasses(self._env, self._cls, data.byref, int(inherited))

        for klass in classes(self._env, data.value):
            yield klass
787035
def calledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.calledWithMatch(*args, **kwargs)):
            raise cls.failException(cls.message)
1141834
def __check_classes(self):
        
        # msg took from BaseAuthentication
        msg = (
            "Sanic JWT was not initialized properly. It did not received "
            "an instance of {}"
        )
        if not issubclass(self.authentication_class, Authentication):
            raise exceptions.InitializationFailure(
                message=msg.format("Authentication")
            )

        if not issubclass(self.configuration_class, Configuration):
            raise exceptions.InitializationFailure(
                message=msg.format("Configuration")
            )

        if not issubclass(self.responses_class, Responses):
            raise exceptions.InitializationFailure(
                message=msg.format("Responses")
            )
298229
def get_detectors_and_printers():
    

    detectors = [getattr(all_detectors, name) for name in dir(all_detectors)]
    detectors = [d for d in detectors if inspect.isclass(d) and issubclass(d, AbstractDetector)]

    printers = [getattr(all_printers, name) for name in dir(all_printers)]
    printers = [p for p in printers if inspect.isclass(p) and issubclass(p, AbstractPrinter)]

    # Handle plugins!
    for entry_point in iter_entry_points(group='slither_analyzer.plugin', name=None):
        make_plugin = entry_point.load()

        plugin_detectors, plugin_printers = make_plugin()

        if not all(issubclass(d, AbstractDetector) for d in plugin_detectors):
            raise Exception('Error when loading plugin %s, %r is not a detector' % (entry_point, d))

        if not all(issubclass(p, AbstractPrinter) for p in plugin_printers):
            raise Exception('Error when loading plugin %s, %r is not a printer' % (entry_point, p))

        # We convert those to lists in case someone returns a tuple
        detectors += list(plugin_detectors)
        printers += list(plugin_printers)

    return detectors, printers
322469
def default_instance(cls):
        
        if cls._instance is None:
            with cls._instance_lock:
                if cls._instance is None:
                    cls._instance = MessageDispatcher()

        return cls._instance
308727
def construct_exc_class(cls):
    """"""

    class ProxyException(cls, BaseException):
        __pep3134__ = True

        @property
        def __traceback__(self):
            if self.__fixed_traceback__:
                return self.__fixed_traceback__

            current_exc, current_tb = sys.exc_info()[1:]
            if current_exc is self:
                return current_tb

        def __init__(self, instance=None):  # pylint: disable=W0231
            self.__original_exception__ = instance
            self.__fixed_traceback__ = None

        def __getattr__(self, item):
            return getattr(self.__original_exception__, item)

        def __repr__(self):
            return repr(self.__original_exception__)

        def __str__(self):
            return str(self.__original_exception__)

        def with_traceback(self, traceback):
            instance = copy.copy(self)
            instance.__fixed_traceback__ = traceback
            return instance

    ProxyException.__name__ = cls.__name__

    return ProxyException
236191
public function setupDetectors()
    {
        $request = $this->_request();
        $detectors = $this->getConfig('detectors');

        foreach ($detectors as $name => $config) {
            $request->addDetector($name, function (ServerRequest $request) use ($config) {
                if ($config['ext'] !== false && $request->getParam('_ext') === $config['ext']) {
                    return true;
                }

                return $request->accepts($config['accepts']);
            });
        }

        $request->addDetector('api', function (ServerRequest $request) use ($detectors) {
            foreach ($detectors as $name => $config) {
                if ($request->is($name)) {
                    return true;
                }
            }

            return false;
        });
    }
1305604
def with_class(self, cls):
        
        rcls = []
        for key, value in self._classification.items():
            if value[0] == cls:
                rcls.append(key)
        return rcls
720742
def filter_positive_detections(detections):
        
        class_idx = 0
        assert(isinstance(detections, mx.nd.NDArray) or isinstance(detections, np.ndarray))
        detections_per_image = []
        # for each image
        for i in range(detections.shape[0]):
            result = []
            det = detections[i, :, :]
            for obj in det:
                if obj[class_idx] >= 0:
                    result.append(obj)
            detections_per_image.append(result)
        logging.info("%d positive detections", len(result))
        return detections_per_image