code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
class Solution: <NEW_LINE> <INDENT> def aplusb(self, a, b): <NEW_LINE> <INDENT> if (b == 0) : <NEW_LINE> <INDENT> return a <NEW_LINE> <DEDENT> return Solution.aplusb(self,a^b,(a&b)<<1) | @param a: An integer
@param b: An integer
@return: The sum of a and b | 62598f7c16aa5153ce3ffea3 |
class Logger: <NEW_LINE> <INDENT> def log(self, level, msg, logging_context): <NEW_LINE> <INDENT> args = logging_context['args'] <NEW_LINE> kwargs = logging_context['kwargs'] <NEW_LINE> for line in re.split(r'\r?\n', str(msg)): <NEW_LINE> <INDENT> request_logger.log(level, line, *args, **kwargs) <NEW_LINE> <DEDENT> <DE... | Do some logging. | 62598f7ca4f1c619b294df90 |
class InterruptAttachingToTangle: <NEW_LINE> <INDENT> def __init__(self, url): <NEW_LINE> <INDENT> command = {'command': 'interruptAttachingToTangle'} <NEW_LINE> stringified = json.dumps(command) <NEW_LINE> stringified = stringified.encode('utf-8') <NEW_LINE> headers = {'content-type': 'application/json', 'X-IOTA-API-V... | Interrupts and completely aborts the attachToTangle process.
Constructor:
url (str): URL of node sever including port
Methods:
jsonResponse: Return the complete JSON response. | 62598f7c15baa72349461923 |
class LastAccessStatsCronJob(AbstractClientStatsCronJob): <NEW_LINE> <INDENT> frequency = rdfvalue.Duration("1d") <NEW_LINE> lifetime = rdfvalue.Duration("20h") <NEW_LINE> recency_window = rdfvalue.Duration("60d") <NEW_LINE> _bins = [1, 2, 3, 7, 14, 30, 60] <NEW_LINE> def _ValuesForLabel(self, label): <NEW_LINE> <INDEN... | Calculates a histogram statistics of clients last contacted times. | 62598f7c507cdc57c63a4730 |
class DBLException(Exception): <NEW_LINE> <INDENT> pass | Base exception class for dblpy
Ideally speaking, this could be caught to handle any exceptions thrown from this library. | 62598f7c15baa72349461924 |
class MobileBertEmbeddings(nn.Module): <NEW_LINE> <INDENT> def __init__(self, config): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.trigram_input = config.trigram_input <NEW_LINE> self.embedding_size = config.embedding_size <NEW_LINE> self.hidden_size = config.hidden_size <NEW_LINE> self.word_embeddings = nn.... | Construct the embeddings from word, position and token_type embeddings. | 62598f7c9b70327d1c57e748 |
class tensor_index: <NEW_LINE> <INDENT> _p = None <NEW_LINE> _side = None <NEW_LINE> _l = 1 <NEW_LINE> _n = 0 <NEW_LINE> @classmethod <NEW_LINE> def from_go(cls, go, *args, **kwargs): <NEW_LINE> <INDENT> ret = cls(go.ndims, repeat = go.repeat, side = go._side) <NEW_LINE> ret._n, ret._l = len(go.ndims), np.prod(go.ndims... | returns indices of sides and corners | 62598f7c0a366e3fb87dc36f |
class PlanValidationError(Exception): <NEW_LINE> <INDENT> pass | Exception to be thrown when validating the MigrationPlan.
e.g. Repository specified does not exist. | 62598f7c26068e7796d4c2ff |
class BaseNodeManagerActor(pykka.ThreadingActor): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(pykka.ThreadingActor, self).__init__(*args, **kwargs) <NEW_LINE> self.actor_ref = TellableActorRef(self) <NEW_LINE> <DEDENT> def on_failure(self, exception_type, exception_value, tb): <NE... | Base class for actors in node manager, redefining actor_ref as a
TellableActorRef and providing a default on_failure handler. | 62598f7ce76e3b2f99fd83d7 |
class Config: <NEW_LINE> <INDENT> SECRET_KEY = os.environ.get('SECRET_KEY') <NEW_LINE> if not SECRET_KEY: <NEW_LINE> <INDENT> raise ValueError("No SECRET_KEY set for Flask application. Did you follow the setup instructions?") <NEW_LINE> <DEDENT> LOGIN_DISABLED = os.environ.get("LOGIN_DISABLED") == 'True' | Base configuration variables. | 62598f7c30dc7b766599f1fd |
class X: <NEW_LINE> <INDENT> def __init__(self, other): <NEW_LINE> <INDENT> self.func = func <NEW_LINE> self.other = other <NEW_LINE> self.x = None <NEW_LINE> <DEDENT> def test(self): <NEW_LINE> <INDENT> self.func() <NEW_LINE> self.other() <NEW_LINE> self.x() <NEW_LINE> self.y() | should only generate a warning w/-A, --callattr cmd line options | 62598f7c29b78933be269dad |
class Object(AbstractObject): <NEW_LINE> <INDENT> __metaclass__ = ABCMeta <NEW_LINE> def __init__ (self, obj, parent=None): <NEW_LINE> <INDENT> super(Object, self).__init__() <NEW_LINE> self.bge_object = obj <NEW_LINE> self.robot_parent = parent <NEW_LINE> self.level = self.bge_object.get("abstraction_level", "default"... | Basic Class for all 3D objects (components) used in the simulation.
Provides common attributes. | 62598f7c3eb6a72ae0389fe6 |
class RobotHandler: <NEW_LINE> <INDENT> def __init__(self, url: str) -> None: <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.robot_files = ["robot.txt", "robots.txt"] <NEW_LINE> self.keywords = [line.strip('\n') for line in open("wordlists/robot.txt").readlines()] <NEW_LINE> self.dir_pattern = re.compile(r".+: ... | Class for handling/analyzing robots.txt | 62598f7c6fece00bbaccb32b |
class Projects(ndb.Model): <NEW_LINE> <INDENT> projects = ndb.PickleProperty() | Cache a list of all project exports in the bucket. | 62598f7cfb3f5b602db47e82 |
class Meta: <NEW_LINE> <INDENT> unknown = INCLUDE | To include unknown fields ( those which were not defined in schema or model) in the schema otherwise a
ValidationError will be raised. | 62598f7cbe8e80087fbbea06 |
class GridDefinition(CoordinateDefinition): <NEW_LINE> <INDENT> def __init__(self, lons, lats, nprocs=1): <NEW_LINE> <INDENT> if lons.shape != lats.shape: <NEW_LINE> <INDENT> raise ValueError('lon and lat grid must have same shape') <NEW_LINE> <DEDENT> elif lons.ndim != 2: <NEW_LINE> <INDENT> raise ValueError('2 dimens... | Grid defined by lons and lats
:Parameters:
lons : numpy array
lats : numpy array
nprocs : int, optional
Number of processor cores to be used for calculations.
:Attributes:
shape : tuple
Grid shape as (rows, cols)
size : int
Number of elements in grid
Properties:
lons : object
Grid lons
lats : object
... | 62598f7c287bf620b627155d |
class FrenchDeck(Sequence): <NEW_LINE> <INDENT> ranks = [str(n) for n in range(2, 11)] + list('JQKA') <NEW_LINE> suits = 'spades diamonds clubs hearts'.split() <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> self._cards = [Card(rank, suit) for suit in self.suits for rank in self.ranks] <NEW_LINE> <DEDENT> def __len_... | It is basically a Sequence by implementing __len__ and
__getitem__ | 62598f7c38b623060ffa8a3c |
class Config(db.Model): <NEW_LINE> <INDENT> maxOccurrenceUntilIgnore = db.IntegerProperty(required=True) | Root of all mediasearch data. | 62598f7c0fa83653e46f4895 |
class Duplicated: <NEW_LINE> <INDENT> def __init__(self, newListFiles): <NEW_LINE> <INDENT> self.listFiles = newListFiles <NEW_LINE> <DEDENT> def files(self): <NEW_LINE> <INDENT> mapFiles = {} <NEW_LINE> for fileTmp in self.listFiles: <NEW_LINE> <INDENT> mapFiles[fileTmp] = fileTmp.name().name() <NEW_LINE> <DEDENT> du... | @overview: class with the list of files and the occurrences of the homonym files | 62598f7cd4950a0f3b110b07 |
class ConstantAssignment(CustomError): <NEW_LINE> <INDENT> def __init__(self, strObject, objTraceback = None, iSkipFrames = None): <NEW_LINE> <INDENT> strError = "Cannot change value of the constant {}".format(strObject) <NEW_LINE> super(ConstantAssignment, self).__init__(strError) <NEW_LINE> self.args = (strObject, ) ... | Custom exception class to be raised in the situations related to the
assignment to or attempted deletion of a constant type object. Can be used
as an 'umbrella' exception type to catch ConstantAttributeAssignment type
errors.
Must be raised / instantiated with a mandatory positional argument as the
name of an object, ... | 62598f7c94891a1f408b93c1 |
class GetRouteTableResult(object): <NEW_LINE> <INDENT> def __init__(__self__, location=None, routes=None, subnets=None, tags=None, id=None): <NEW_LINE> <INDENT> if location and not isinstance(location, str): <NEW_LINE> <INDENT> raise TypeError('Expected argument location to be a str') <NEW_LINE> <DEDENT> __self__.locat... | A collection of values returned by getRouteTable. | 62598f7ca4f1c619b294df92 |
class BundleVersion(models.Model): <NEW_LINE> <INDENT> id = models.BigAutoField(primary_key=True) <NEW_LINE> bundle = models.ForeignKey( Bundle, related_name="versions", related_query_name="version", editable=False ) <NEW_LINE> version_num = models.PositiveIntegerField(editable=False) <NEW_LINE> snapshot_digest = model... | The contents of a BundleVersion are immutable (the snapshot it points to),
but the metadata about a BundleVersion (e.g. change_description) can be
changed. Other entities in the system that need to attach metadata to
versions of Bundles should use this model and not reference Snapshots
directly.
Target Scale: 1B rows | 62598f7cd6c5a102081e1aed |
class FlowchartDiagramItem(diagram.Item): <NEW_LINE> <INDENT> def __init__(self, label, shape, **attrs): <NEW_LINE> <INDENT> attrs.update({'shape':shape}) <NEW_LINE> diagram.Item.__init__(self, label, **attrs) <NEW_LINE> self.nodeBranches = None <NEW_LINE> <DEDENT> def Branch(self, **branches): <NEW_LINE> <INDENT> self... | Base class for all Items in a Flowchart Diagram | 62598f7c9b70327d1c57e74a |
class AccountAnalyticAccount(orm.Model): <NEW_LINE> <INDENT> _inherit = 'account.analytic.account' <NEW_LINE> _columns = { 'gdoc_ids': fields.one2many( 'gdoc.document', 'account_id', 'Google Document'), } | Model name: Account analytic account
| 62598f7cbde94217f3707339 |
class Job(abc.ABC): <NEW_LINE> <INDENT> def __init__( self, interval: int, loop: Optional[asyncio.AbstractEventLoop] = None) -> None: <NEW_LINE> <INDENT> if loop is None: <NEW_LINE> <INDENT> self._loop = asyncio.get_event_loop() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._loop = loop <NEW_LINE> <DEDENT> self._t... | This is a base class that provides functions for a specific task to
ensure regular completion of the loop.
A co-routine run must be implemented by a subclass.
periodic() will call the co-routine at a regular interval set by
self._interval. | 62598f7c26068e7796d4c301 |
class RequestsClient(HttpClient): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.session = requests.Session() <NEW_LINE> self.authenticator = None <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def separate_params(request_params): <NEW_LINE> <INDENT> sanitized_params = request_params.copy() <NEW_LINE> m... | Synchronous HTTP client implementation.
| 62598f7c21bff66bcd72260c |
class NASAForm(forms.Form): <NEW_LINE> <INDENT> from rmgpy.chemkin import read_thermo_entry <NEW_LINE> nasa = forms.CharField(label="NASA Polynomial", widget=forms.Textarea(attrs={'cols': 100, 'rows': 10}), required=True) <NEW_LINE> def clean_species(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> nasa = self.clean... | Form for entering a CHEMKIN format NASA polynomial | 62598f7c30c21e258be981af |
class GPUConnectMixin: <NEW_LINE> <INDENT> def _alloc_device_memory(self, shape): <NEW_LINE> <INDENT> _nbytes = np.prod(shape) * 4 <NEW_LINE> _device_data = cuda.mem_alloc(int(_nbytes)) <NEW_LINE> _device_data.shape = tuple(shape) <NEW_LINE> _device_data.dtype = np.float32 <NEW_LINE> return _device_data <NEW_LINE> <DED... | Mixin for GPU connect | 62598f7cc432627299fa297f |
class TestSnapshotViewSchema(unittest.TestCase): <NEW_LINE> <INDENT> def test_post_schema(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> Draft4Validator.check_schema(snapshot.SnapshotView.POST_SCHEMA) <NEW_LINE> schema_valid = True <NEW_LINE> <DEDENT> except RuntimeError: <NEW_LINE> <INDENT> schema_valid = False <... | A set of test cases for the schemas of /api/1/inf/snapshot | 62598f7c76d4e153a661c5b8 |
class TestUser(unittest.TestCase): <NEW_LINE> <INDENT> def test_class(self): <NEW_LINE> <INDENT> obj = State() <NEW_LINE> bm = BaseModel() <NEW_LINE> self.assertEqual(type(obj), State) <NEW_LINE> self.assertTrue(issubclass(State, BaseModel)) <NEW_LINE> <DEDENT> def test_attr(self): <NEW_LINE> <INDENT> obj = State() <NE... | State unittest | 62598f7cbe8e80087fbbea08 |
class AccessLogMonitor(): <NEW_LINE> <INDENT> def __init__( self, alert_window=120, alert_threshold=10, alerting_interval=1, reporting_interval=10, path_to_log='./access_log_monitor/access.log', log_format=( r'^(?P<host>.*?) (?P<referrer>.*?) (?P<user>.*?) \[(?P<timestamp>.*?)\] ' r'"(?P<request>.*?)" (?P<status_code>\... | Main class that launches a watch on the target log file
Starts a worker class in a background thread to generate necessary
alerts and reports according to the time intervals set
Note: Ideas for some of the implementation were taken from:
http://www.dabeaz.com/generators/Generators.pdf | 62598f7c1d351010ab8f34e5 |
class StaticUploadError(Exception): <NEW_LINE> <INDENT> pass | Error uploading object to the static server | 62598f7c50485f2cf55da917 |
class SanityTest(unittest.TestCase): <NEW_LINE> <INDENT> def test_math(self): <NEW_LINE> <INDENT> self.assertTrue((1 + 1) == 2) | Sanity tests. | 62598f7ccad5886f8bdc4cca |
class Nest(Builtin): <NEW_LINE> <INDENT> def apply(self, f, expr, n, evaluation): <NEW_LINE> <INDENT> n = n.get_int_value() <NEW_LINE> if n is None or n < 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> result = expr <NEW_LINE> for k in range(n): <NEW_LINE> <INDENT> result = Expression(f, result).evaluate(evaluation)... | <dl>
<dt>'Nest[$f$, $expr$, $n$]'
<dd>returns an expression with $f$ applied $n$ times to $expr$.
</dl>
>> Nest[f, x, 3]
= f[f[f[x]]]
>> Nest[(1+#) ^ 2 &, x, 2]
= (1 + (1 + x) ^ 2) ^ 2 | 62598f7cd99f1b3c44d05053 |
class InsufficientResourceError(Exception): <NEW_LINE> <INDENT> pass | Indication that a process failed because adequate resources were not
available in the machine. | 62598f7c94891a1f408b93c2 |
@snake_case_methods <NEW_LINE> class MemFile(_FileBase, QROOT.TMemFile): <NEW_LINE> <INDENT> _ROOT = QROOT.TMemFile <NEW_LINE> def __init__(self, name=None, mode='recreate'): <NEW_LINE> <INDENT> if name is None: <NEW_LINE> <INDENT> name = uuid.uuid4().hex <NEW_LINE> <DEDENT> super(MemFile, self).__init__(name, mode) | A subclass of ROOT's TMemFile [1]
Examples
--------
>>> from rootpy.io import MemFile
>>> f = MemFile()
References
----------
.. [1] http://root.cern.ch/root/html/TMemFile.html | 62598f7cb830903b9686e145 |
class JSONResponse(BaseResponse): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def make_response( cls, error: "ParamsValueError", fuzzy: bool = False, formatter: t.Optional[t.Callable] = None ) -> "Response": <NEW_LINE> <INDENT> result = cls.fmt_result(error, fuzzy) <NEW_LINE> if formatter and error: <NEW_LINE> <INDENT>... | Handler response with json format
| 62598f7c07f4c71912baedf5 |
class M(object): <NEW_LINE> <INDENT> def __init__(self, fmt, *args, **kwargs): <NEW_LINE> <INDENT> self.fmt = fmt <NEW_LINE> self.args = args <NEW_LINE> self.kwargs = kwargs <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.fmt.format(*self.args, **self.kwargs) | Simple message class to allow to use {}-style formatting with the
logging module. For details, see:
https://docs.python.org/3/howto/logging-cookbook.html#using-custom-message-objects | 62598f7cd99f1b3c44d05054 |
class User(BaseUser, Authed): <NEW_LINE> <INDENT> def __init__(self, id, auth_token=None, session=None): <NEW_LINE> <INDENT> super(User, self).__init__(auth_token=auth_token, session=session) <NEW_LINE> self.id = id <NEW_LINE> <DEDENT> def User(self): <NEW_LINE> <INDENT> api_data = self.get('https://public-api.secure.p... | A Pixiv user
:param int id: the id of this user | 62598f7c596a89723612761a |
class CliTest(GodfatherTest): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> super().setUp() <NEW_LINE> clear_global_events() <NEW_LINE> self.game_dir_tempfile = tempfile.TemporaryDirectory() <NEW_LINE> os.chdir(self.game_dir_tempfile.name) <NEW_LINE> <DEDENT> @property <NEW_LINE> def game_path(self): <NEW_LI... | Base class for tests of the godfather command line interface. | 62598f7c4e696a045264dad4 |
class CODEBRIM: <NEW_LINE> <INDENT> def __init__(self, is_gpu, args): <NEW_LINE> <INDENT> self.num_classes = 6 <NEW_LINE> self.dataset_path = args.dataset_path <NEW_LINE> self.dataset_xml_list = [os.path.join(args.dataset_path, 'metadata/background.xml'), os.path.join(args.dataset_path, 'metadata/defects.xml')] <NEW_LI... | definition of CODEBRIM dataset, train/val/test splits, train/val/test loaders
Parameters:
args (argparse.Namespace): parsed command line arguments
is_gpu (bool): if computational device is gpu or cpu
Attributes:
num_classes (int): number of classes in the dataset (= 6)
dataset_path (string): path to d... | 62598f7cbde94217f370733a |
class OutListError(Exception): <NEW_LINE> <INDENT> def __init__(self,error_info="Exceeded list maximum length"): <NEW_LINE> <INDENT> if error_info: <NEW_LINE> <INDENT> self.err=error_info <NEW_LINE> self.__doc__=error_info | Exceeded list maximum length | 62598f7c30dc7b766599f201 |
class CompatibilityBranch(object): <NEW_LINE> <INDENT> def __init__(self, node): <NEW_LINE> <INDENT> self.node = node <NEW_LINE> self.client_list = [] <NEW_LINE> self.minimum_leaves = self.node.min <NEW_LINE> self.maximum_leaves = self.node.max <NEW_LINE> self.leaves = self.client_list <NEW_LINE> <DEDENT> def name(self... | Forms a relationship between the node and the clients it is related with.
(node is the branch, clients are the leaves). | 62598f7c29b78933be269daf |
class TranslatedField(models.ForeignKey): <NEW_LINE> <INDENT> to = 'translations.Translation' <NEW_LINE> requires_unique_target = False <NEW_LINE> forward_related_accessor_class = TranslationDescriptor <NEW_LINE> def __init__(self, **kwargs): <NEW_LINE> <INDENT> kwargs.update({ 'null': True, 'to_field': 'id', 'unique':... | A foreign key to the translations table.
If require_locale=False, the fallback join will not use a locale. Instead,
we will look for 1) a translation in the current locale and 2) fallback
with any translation matching the foreign key. | 62598f7c30c21e258be981b1 |
class ZincAnalysisParser(AnalysisParser): <NEW_LINE> <INDENT> empty_test_header = b'products' <NEW_LINE> current_test_header = ZincAnalysis.FORMAT_VERSION_LINE <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> self._underlying_parser = UnderlyingParser() <NEW_LINE> <DEDENT> def parse(self, infile): <NEW_LINE> <INDENT>... | Parses a zinc analysis file.
Implemented by delegating to an underlying zincutils.ZincAnalysisParser instance. | 62598f7c8c3a8732951f5ef0 |
class Movie(): <NEW_LINE> <INDENT> def __init__(self, movie_title, poster_image, trailer_youtube): <NEW_LINE> <INDENT> self.title = movie_title <NEW_LINE> self.poster_image_url = poster_image <NEW_LINE> self.trailer_youtube_url = trailer_youtube | Initializes instance of movie class, storing movie title, poster url
and trailer url | 62598f7c711fe17d825e008f |
class ParentCommand(Enum): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def get(cls, value, default=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return cls(value) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> for klass in cls.__subclasses__(): <NEW_LINE> <INDENT> try: <NEW_LI... | Enum class with can be inherited.
It allow to group Enumerable in the came category | 62598f7c50485f2cf55da91a |
class Attachable(object): <NEW_LINE> <INDENT> def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.__args__ = kwargs <NEW_LINE> for arg, value in kwargs.items(): <NEW_LINE> <INDENT> setattr(self, arg, value) <NEW_LINE> <DEDENT> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return "%s(%s)" % (self.__class__.__name_... | A class that attaches all constructor named parameters as attributes.
For example--
>>> obj = Attachable(foo=42, size="of the universe")
>>> obj.foo
42
>>> obj.size
'of the universe' | 62598f7c16aa5153ce3ffea9 |
class FlogFormatter(logging.Formatter): <NEW_LINE> <INDENT> datefmt = '%Y-%m-%d %H:%M:%S' <NEW_LINE> def format(self, record): <NEW_LINE> <INDENT> error_location = "%s.%s" % (record.name, record.funcName) <NEW_LINE> line_number = "%s" % (record.lineno) <NEW_LINE> location_line = error_location[:21] + ":" + line_number ... | Format the meta data in the log message to fix string length. | 62598f7c23e79379d538bea3 |
class WebError(FaustError): <NEW_LINE> <INDENT> code: int = cast(int, None) <NEW_LINE> detail: str = 'Default not set on class' <NEW_LINE> extra_context: Dict <NEW_LINE> def __init__(self, detail: str = None, *, code: int = None, **extra_context: Any) -> None: <NEW_LINE> <INDENT> if detail: <NEW_LINE> <INDENT> self.det... | Web related error.
Web related errors will have a status :attr:`code`,
and a :attr:`detail` for the human readable error string.
It may also keep :attr:`extra_context`. | 62598f7c10dbd63aa1c7055a |
class DQN: <NEW_LINE> <INDENT> def __init__(self, action_space, state_space, weights): <NEW_LINE> <INDENT> self.action_space = action_space <NEW_LINE> self.state_space = state_space <NEW_LINE> self.epsilon = 1.0 <NEW_LINE> self.gamma = .99 <NEW_LINE> self.batch_size = 64 <NEW_LINE> self.epsilon_min = .01 <NEW_LINE> sel... | Implementation of deep q learning algorithm | 62598f7cb830903b9686e146 |
class I4(BaseNumber): <NEW_LINE> <INDENT> format_code = 0o34 <NEW_LINE> text_code = "I4" <NEW_LINE> _base_type = int <NEW_LINE> _min = -2147483648 <NEW_LINE> _max = 2147483647 <NEW_LINE> _bytes = 4 <NEW_LINE> _struct_code = "l" <NEW_LINE> preferred_types = [int] | Secs type for 4 byte signed data.
:param value: initial value
:type value: list/integer
:param count: number of items this value
:type count: integer | 62598f7c07f4c71912baedf7 |
class VGG(nn.Module): <NEW_LINE> <INDENT> def __init__(self, vgg_type, pretrained=True): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> if vgg_type == "vgg11": <NEW_LINE> <INDENT> vgg = models.vgg11(pretrained=pretrained) <NEW_LINE> <DEDENT> elif vgg_type == "vgg11_bn": <NEW_LINE> <INDENT> vgg = models.vgg11_bn(pret... | VGG convinience wrapper.
| 62598f7cb57a9660fecd1427 |
class BOT_258: <NEW_LINE> <INDENT> pass | Zerek, Master Cloner | 62598f7c82261d6c5272fba8 |
class ElectionsContributions(VeritzaBaseModel): <NEW_LINE> <INDENT> class Meta: <NEW_LINE> <INDENT> verbose_name_plural = "Elections contributions" <NEW_LINE> <DEDENT> date = models.DateField(null=True, blank=True) <NEW_LINE> election_type = models.CharField(max_length=255, null=True, blank=True) <NEW_LINE> election_pl... | From Elections commission database | 62598f7ce76e3b2f99fd83dd |
class MalformedRegex(Exception): <NEW_LINE> <INDENT> pass | Exception to be raise when the library can't parse
a regular expression. | 62598f7cd53ae8145f917e41 |
class BadOrderError(Exception): <NEW_LINE> <INDENT> pass | Raised when an order-numbering string is malformed. | 62598f7ccad5886f8bdc4cce |
class DeletionPolicy(CloudFormationLintRule): <NEW_LINE> <INDENT> id = 'E3035' <NEW_LINE> shortdesc = 'Check DeletionPolicy values for Resources' <NEW_LINE> description = 'Check that the DeletionPolicy values are valid' <NEW_LINE> source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribut... | Check Base Resource Configuration | 62598f7c8a43f66fc4bf1b29 |
class Body: <NEW_LINE> <INDENT> def __init__(self, name='', year=0, day=24, offset=0, parent=None, extra=None): <NEW_LINE> <INDENT> self.Name = name <NEW_LINE> self.Year = year <NEW_LINE> self.Day = day <NEW_LINE> self.Offset = offset <NEW_LINE> self.Parent = parent <NEW_LINE> self.children = [] <NEW_LINE> if extra is ... | Body Class
Holds all data for our celestial bodies. | 62598f7c004d5f362081ecd0 |
class ExpressRouteCircuitListResult(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'value': {'key': 'value', 'type': '[ExpressRouteCircuit]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(ExpressRouteCircuitListResult, self)... | Response for ListExpressRouteCircuit API service call.
:param value: A list of ExpressRouteCircuits in a resource group.
:type value: list[~azure.mgmt.network.v2019_09_01.models.ExpressRouteCircuit]
:param next_link: The URL to get the next set of results.
:type next_link: str | 62598f7c50485f2cf55da91c |
class BaseInstalledDistribution(Distribution): <NEW_LINE> <INDENT> hasher = None <NEW_LINE> def __init__(self, metadata, path, env=None): <NEW_LINE> <INDENT> super(BaseInstalledDistribution, self).__init__(metadata) <NEW_LINE> self.path = path <NEW_LINE> self.dist_path = env <NEW_LINE> <DEDENT> def get_hash(self, data,... | This is the base.css class for installed distributions (whether PEP 376 or
legacy). | 62598f7c38b623060ffa8a42 |
class UnsatObject: <NEW_LINE> <INDENT> def __init__(self, facts, rules): <NEW_LINE> <INDENT> self.facts = facts <NEW_LINE> self.rules = rules | this class represents an object that contains facts and the rules that they violate | 62598f7cd10714528d69d879 |
class Login(graphene.Mutation, name="LoginPayload"): <NEW_LINE> <INDENT> ok = graphene.Boolean(required=True) <NEW_LINE> class Arguments: <NEW_LINE> <INDENT> username = graphene.String(required=True) <NEW_LINE> password = graphene.String(required=True) <NEW_LINE> <DEDENT> def mutate(self, info, username, password): <NE... | Login mutation.
Login implementation, following the Channels guide:
https://channels.readthedocs.io/en/latest/topics/authentication.html | 62598f7c7b25080760ed6e4e |
class Rotation(Duty): <NEW_LINE> <INDENT> group = models.ForeignKey('auth.Group') <NEW_LINE> length = models.IntegerField('Users to be contacted before escalation. Set to zero if primary is always set.') <NEW_LINE> users = models.ManyToManyField('auth.User', through='oncall.UsersInRotation') <NEW_LINE> def validate_uni... | The on-call rotations available | 62598f7c82261d6c5272fba9 |
class ErpReceivable(Document): <NEW_LINE> <INDENT> def __init__(self, ErpRecLineItems=None, *args, **kw_args): <NEW_LINE> <INDENT> self._ErpRecLineItems = [] <NEW_LINE> self.ErpRecLineItems = [] if ErpRecLineItems is None else ErpRecLineItems <NEW_LINE> super(ErpReceivable, self).__init__(*args, **kw_args) <NEW_LINE> <... | Transaction representing an invoice, credit memo or debit memo to a customer. It is an open (unpaid) item in the Accounts Receivable ledger.Transaction representing an invoice, credit memo or debit memo to a customer. It is an open (unpaid) item in the Accounts Receivable ledger.
| 62598f7c96565a6dacd2cc4f |
@final <NEW_LINE> class WrongInCompareTypeViolation(ASTViolation): <NEW_LINE> <INDENT> error_template = 'Found `in` used with a non-set container' <NEW_LINE> code = 510 <NEW_LINE> previous_codes = {473} | Forbids to use ``in`` with static containers except ``set`` nodes.
We enforce people to use sets as a static containers.
You can also use variables, calls, methods, etc.
Dynamic values are not checked.
Reasoning:
Using static ``list``, ``tuple``, or ``dict`` elements
to check that some element is inside the c... | 62598f7c30dc7b766599f205 |
class RecordStreamException(Core.StreamException): <NEW_LINE> <INDENT> __swig_setmethods__ = {} <NEW_LINE> for _s in [Core.StreamException]: <NEW_LINE> <INDENT> __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) <NEW_LINE> <DEDENT> __setattr__ = lambda self, name, value: _swig_setattr(self, RecordStream... | Proxy of C++ Seiscomp::IO::RecordStreamException class. | 62598f7c15fb5d323ce7e6d6 |
class Router(metaclass=ABCMeta): <NEW_LINE> <INDENT> def __init__(self, workers, func_name="submit", *args, **kwargs): <NEW_LINE> <INDENT> self._workers = workers <NEW_LINE> self._func_name = func_name <NEW_LINE> super().__init__(*args, **kwargs) <NEW_LINE> <DEDENT> @property <NEW_LINE> def workers(self): <NEW_LINE> <I... | Oversimplified router system to enroute messages to a pool of workers
actor, by subclassing this it is possible to add different heuristic of
message routing. If the len of the workers pool is just 1, ignore every
defined heuristic and send the message to that only worker.
Attributes
----------
:type workers: int
:par... | 62598f7c1f037a2d8b9e3a96 |
class PostLimitMiddleware(object): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> self.redis = connect_redis() <NEW_LINE> self.bypass = hasattr(settings, 'BYPASS_AE_MIDDLEWARE') and getattr(settings, 'BYPASS_AE_MIDDLEWARE', False) <NEW_LINE> <DEDENT> def process_request(self, request): <NE... | Jednoduchy middleware, ktery hlida pocet POSTu na adresu /pridat/, a to
dvojim zpusobem:
* celkovy pocet POSTu provedenych za PERIOD vterin; pokud jich je vice
nez POSTS_PER_PERIOD, pak aplikace vrati HTTP response kod 408 (Timeout)
* celkovy pocet POSTu provedenych za IP_PERIOD vterin z dane IP adresy; pokud
jich... | 62598f7cbe8e80087fbbea0e |
class Blah: <NEW_LINE> <INDENT> def __init__(self, x): <NEW_LINE> <INDENT> pass | A Blah.
Parameters
----------
x : int | 62598f7ca4f1c619b294df99 |
class EpollSelector(_BaseSelectorImpl): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self._epoll = select.epoll() <NEW_LINE> <DEDENT> def fileno(self): <NEW_LINE> <INDENT> return self._epoll.fileno() <NEW_LINE> <DEDENT> def register(self, fileobj, events, data=None): <NEW_LI... | Epoll-based selector. | 62598f7c50485f2cf55da91d |
class ObjectDefinition(Statement): <NEW_LINE> <INDENT> attrs = ["name", "block", "parentnames", "parentdefinitions"] <NEW_LINE> def __init__(self, name, block, parentnames=None, parentdefinitions=None): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.block = block <NEW_LINE> if parentnames is None: <NEW_LINE> <IND... | Makes a new normal object.
The block is immediately executed with the new object as the
implicit self. The 'name' is bound to the new object in the
outer scope's implicit self.
Example:
object x:
def f(y):
y
# --------------------------------------------------
# the following can be ignored ... | 62598f7cb57a9660fecd142a |
class TestAssociationSendNCreate(object): <NEW_LINE> <INDENT> def setup(self): <NEW_LINE> <INDENT> self.scp = None <NEW_LINE> <DEDENT> def teardown(self): <NEW_LINE> <INDENT> if self.scp: <NEW_LINE> <INDENT> self.scp.abort() <NEW_LINE> <DEDENT> time.sleep(0.1) <NEW_LINE> for thread in threading.enumerate(): <NEW_LINE> ... | Run tests on Assocation send_n_create. | 62598f7c66656f66f7d59d9f |
class DeprecationWarning(UserWarning): <NEW_LINE> <INDENT> pass | Shadows the internal warning, but isn't muted by default. | 62598f7cf7d966606f747994 |
class SurnamesBot(ExistingPageBot, FollowRedirectPageBot): <NEW_LINE> <INDENT> def __init__(self, generator, **kwargs): <NEW_LINE> <INDENT> self.available_options.update({ 'surnames_last': False, }) <NEW_LINE> super().__init__(generator=generator, **kwargs) <NEW_LINE> <DEDENT> def treat_page(self): <NEW_LINE> <INDENT> ... | Surnames Bot. | 62598f7c0fa83653e46f489d |
class unitDict(dict): <NEW_LINE> <INDENT> def update(self, other): <NEW_LINE> <INDENT> for key in other: <NEW_LINE> <INDENT> if key in self: <NEW_LINE> <INDENT> dict.update(self, {key: self[key]+other[key]}) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dict.update(self, {key: other[key]}) <NEW_LINE> <DEDENT> <DEDENT> ... | A dictionary sublcass used to store units and their powers. | 62598f7ca05bb46b3848a229 |
class GitStatusCommand(WindowCommand, GitStatusBuilder): <NEW_LINE> <INDENT> def run(self, refresh_only=False): <NEW_LINE> <INDENT> repo = self.get_repo(silent=True if refresh_only else False) <NEW_LINE> if not repo: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> title = GIT_STATUS_VIEW_TITLE_PREFIX + os.path.basename(... | Documentation coming soon. | 62598f7c9b70327d1c57e752 |
class VirtualNetworkGatewayConnectionListResult(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'next_link': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'value': {'key': 'value', 'type': '[VirtualNetworkGatewayConnection]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } <NEW_LINE> def __in... | Response for the ListVirtualNetworkGatewayConnections API service call.
Variables are only populated by the server, and will be ignored when sending a request.
:param value: Gets a list of VirtualNetworkGatewayConnection resources that exists in a
resource group.
:type value: list[~azure.mgmt.network.v2017_10_01.mod... | 62598f7c4e696a045264dad7 |
class ConnectorBackend(models.AbstractModel): <NEW_LINE> <INDENT> _name = 'connector.backend' <NEW_LINE> _description = 'Connector Backend' <NEW_LINE> _backend_type = None <NEW_LINE> name = fields.Char(required=True) <NEW_LINE> version = fields.Selection(selection=[], required=True) <NEW_LINE> @api.multi <NEW_LINE> def... | An instance of an external backend to synchronize with.
The backends have to ``_inherit`` this model in the connectors
modules. | 62598f7c10dbd63aa1c7055f |
class Migrate_0_13_x_to_1_1_0(object): <NEW_LINE> <INDENT> OLD_QS = [ reactor.get_trigger_cud_queue("st2.trigger.watch.timers", routing_key="#"), reactor.get_trigger_cud_queue( "st2.trigger.watch.sensorwrapper", routing_key="#" ), reactor.get_trigger_cud_queue("st2.trigger.watch.webhooks", routing_key="#"), ] <NEW_LINE... | Handles migration of messaging setup from 0.13.x to 1.1. | 62598f7c21a7993f00c6591e |
class GitError(UVCError): <NEW_LINE> <INDENT> pass | A Git-dialect specific error. | 62598f7c96565a6dacd2cc50 |
class UEFANationsLeague(League): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super().__init__("soccer", "uefanationsleague") | Provides access to UEFA Nations League config files. | 62598f7cec188e330fdf824d |
class ExecOption(Option): <NEW_LINE> <INDENT> def __init__(self, key, value): <NEW_LINE> <INDENT> self.command = value <NEW_LINE> <DEDENT> def execute(self, fullpath, fstat, test=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> command = self.command.replace('{}', fullpath) <NEW_LINE> print(salt.utils.args.shlex_sp... | Execute the given command, {} replaced by filename.
Quote the {} if commands might include whitespace. | 62598f7c8a349b6b43685bf1 |
class TapNetRegressor(BaseDeepRegressor, TapNetNetwork): <NEW_LINE> <INDENT> def __init__( self, batch_size=16, dropout=0.5, filter_sizes=[256, 256, 128], kernel_size=[8, 5, 3], dilation=1, layers=[500, 300], use_rp=True, rp_params=[-1, 3], use_att=True, use_ss=False, use_metric=False, use_muse=False, use_lstm=True, us... | Implentation of TapNet found at https://github.com/kdd2019-tapnet/tapnet
Currently does not implement custom distance matrix loss function or class based self attention.
@inproceedings{zhang2020tapnet,
title={Tapnet: Multivariate time series classification with attentional prototypical network},
author={Zhang, Xuchao... | 62598f7cb57a9660fecd142c |
class DescribeVulLevelCountRequest(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.VulCategory = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> self.VulCategory = params.get("VulCategory") <NEW_LINE> memeber_set = set(params.keys()) <NEW_LINE> for name, val... | DescribeVulLevelCount请求参数结构体
| 62598f7c004d5f362081ecd2 |
class Oracle(BaseStaticEnsemble): <NEW_LINE> <INDENT> def __init__(self, pool_classifiers=None, random_state=None): <NEW_LINE> <INDENT> super(Oracle, self).__init__(pool_classifiers=pool_classifiers, random_state=random_state) <NEW_LINE> <DEDENT> def fit(self, X, y): <NEW_LINE> <INDENT> X, y = check_X_y(X, y) <NEW_LINE... | Abstract method that always selects the base classifier that predicts
the correct label if such classifier exists. This method is often used to
measure the upper-limit performance that can be achieved by a dynamic
classifier selection technique. It is used as a benchmark by several
dynamic selection algorithms
Pa... | 62598f7c8e05c05ec3f6eb1e |
class WOUDCExtCSVReaderError(Exception): <NEW_LINE> <INDENT> def __init__(self, message, errors): <NEW_LINE> <INDENT> super(WOUDCExtCSVReaderError, self).__init__(message) <NEW_LINE> self.errors = errors | WOUDC extended CSV reader error | 62598f7c23e79379d538bea8 |
class Chaos(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.aes_mode = AES.MODE_CBC <NEW_LINE> self.bs = AES.block_size <NEW_LINE> <DEDENT> @dec.catch(True, TypeError) <NEW_LINE> def encrypt(self, plain, algorithm='md5'): <NEW_LINE> <INDENT> plain = helper.to_bytes(plain) <NEW_LINE> return get... | 加密混淆 | 62598f7c8e71fb1e983bb466 |
class GaussianDerivativeKernel(ConvolutionKernel): <NEW_LINE> <INDENT> args = Args([Float("standard_deviation", default=1.0), Int("order", default=1)]) | Init as a Gaussian derivative of order 'order'. The radius of the
kernel is always 3*std_dev.
*standard_deviation*
The standard deviation of the Gaussian kernel.
*order*
The order of the Gaussian kernel. | 62598f7cd6c5a102081e1af7 |
class FirewallPolicyLogAnalyticsWorkspace(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'region': {'key': 'region', 'type': 'str'}, 'workspace_id': {'key': 'workspaceId', 'type': 'SubResource'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(FirewallPolicyLogAnalyticsWorksp... | Log Analytics Workspace for Firewall Policy Insights.
:param region: Region to configure the Workspace.
:type region: str
:param workspace_id: The workspace Id for Firewall Policy Insights.
:type workspace_id: ~azure.mgmt.network.v2021_02_01.models.SubResource | 62598f7c07f4c71912baedfd |
class PathFeature(Feature): <NEW_LINE> <INDENT> def __init__(self, path): <NEW_LINE> <INDENT> super(PathFeature, self).__init__() <NEW_LINE> self.path = path <NEW_LINE> <DEDENT> def _probe(self): <NEW_LINE> <INDENT> return os.path.exists(self.path) <NEW_LINE> <DEDENT> def feature_name(self): <NEW_LINE> <INDENT> return ... | Feature testing whether a particular path exists. | 62598f7c21bff66bcd722616 |
class Institution(models.Model): <NEW_LINE> <INDENT> parent = models.ForeignKey('self', null=True, blank=True) <NEW_LINE> name = models.CharField(u'Наименование', max_length=100) <NEW_LINE> inn = models.CharField(u'ИНН', max_length=12) <NEW_LINE> kpp = models.CharField(u'КПП', max_length=9) <NEW_LINE> def __unicode__(s... | Учреждение | 62598f7cf8510a7c17d7de50 |
class AdminEventAddWebcast(webapp.RequestHandler): <NEW_LINE> <INDENT> def post(self, event_key_id): <NEW_LINE> <INDENT> webcast = dict() <NEW_LINE> webcast["type"] = self.request.get("webcast_type") <NEW_LINE> webcast["channel"] = self.request.get("webcast_channel") <NEW_LINE> if self.request.get("webcast_file"): <NEW... | Add a webcast to an Event. | 62598f7c73bcbd0ca4bc9c00 |
class ConsultCommand(AbstractCommand): <NEW_LINE> <INDENT> COMMAND_PATTERN = re.compile(r"^/23consult\s(\S+)(\s(\d)+)?$") <NEW_LINE> COMMAND_NAME = "23consult" <NEW_LINE> async def _do_match(self, match, msg): <NEW_LINE> <INDENT> category, line_number = match.group(1, 3) <NEW_LINE> if line_number is not None: <NEW_LINE... | This command allows database consulting. The command is : /23consult CATEGORY [LINE]. With
this command, users can display all registered facts for the provided category and, if a line is
provided, displays the fact located at this line. | 62598f7c76d4e153a661c5c2 |
class JsonExportPipeline(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.file = open('articleexport.json', 'wb') <NEW_LINE> self.exporter = JsonItemExporter(self.file, encoding='utf-8', ensure_ascii=False) <NEW_LINE> self.exporter.start_exporting() <NEW_LINE> <DEDENT> def close_spider(self, sp... | 调用scrapy提供的json export导出json文件 | 62598f7ca4f1c619b294df9d |
class color_histogram: <NEW_LINE> <INDENT> def __init__(self, bins, color_space='bgr'): <NEW_LINE> <INDENT> self.bins = bins <NEW_LINE> if color_space not in ['bgr', 'lab', 'hsv']: <NEW_LINE> <INDENT> raise ValueError("color_space must be in ['bgr', 'lab', 'hsv']") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.col... | class to produce color histogram features given an input image | 62598f7c3eb6a72ae0389ff2 |
class HorizonatalCoordinateSerializer(serializers.Serializer): <NEW_LINE> <INDENT> x = FloatField() <NEW_LINE> y = FloatField() <NEW_LINE> datum = serializers.CharField() <NEW_LINE> type = serializers.CharField() <NEW_LINE> latitude = FloatField() <NEW_LINE> longitude = FloatField() <NEW_LINE> units = serializers.CharF... | Serializes a :class:`basin3d.synthesis.models.field.HorizonatalCoordinate` and its child classes | 62598f7c63f4b57ef0085a46 |
class CInt(Int): <NEW_LINE> <INDENT> def validate(self, obj, value): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> value = int(value) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> self.error(obj, value) <NEW_LINE> <DEDENT> return _validate_bounds(self, obj, value) | A casting version of the int trait. | 62598f7c287bf620b6271569 |
class CsoundChannelList(_object): <NEW_LINE> <INDENT> __swig_setmethods__ = {} <NEW_LINE> __setattr__ = lambda self, name, value: _swig_setattr(self, CsoundChannelList, name, value) <NEW_LINE> __swig_getmethods__ = {} <NEW_LINE> __getattr__ = lambda self, name: _swig_getattr(self, CsoundChannelList, name) <NEW_LINE> __... | Proxy of C++ CsoundChannelList class | 62598f7c16aa5153ce3ffeb0 |
class InvalidParamError(Error, ValueError): <NEW_LINE> <INDENT> def __init__(self, param, value, msg): <NEW_LINE> <INDENT> Error.__init__(self, msg) <NEW_LINE> self._param, self._value = param, value <NEW_LINE> <DEDENT> def param(self): <NEW_LINE> <INDENT> return self._param <NEW_LINE> <DEDENT> def value(self): <NEW_LI... | Invalid parameter passed. | 62598f7c23e79379d538beab |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.