code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
class SoundFileError(Exception): <NEW_LINE> <INDENT> pass | Class to report sound file failed to load | 6259902ad6c5a102081e30f5 |
class SharedRMSprop(optim.Optimizer): <NEW_LINE> <INDENT> def __init__(self, params, lr=7e-4, alpha=0.99, eps=0.1, weight_decay=0, momentum=0, centered=False): <NEW_LINE> <INDENT> defaults = defaultdict( lr=lr, alpha=alpha, eps=eps, weight_decay=weight_decay, momentum=momentum, centered=centered) <NEW_LINE> super(Share... | Implements RMSprop algorithm with shared states.
| 6259902a66673b3332c313be |
class BanchiFlask(Flask): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> self.endpoints = {} <NEW_LINE> self.__dict__.update({ method: self.__shorthand(methods=[method.upper()]) for method in ["get", "post", "put"]}) <NEW_LINE> return Flask.__init__(self, *args, **kwargs) <NEW_LINE> <DEDEN... | BanchiFlask:
This is just an expansion on the Flask app class to add fancier decorators
to the app | 6259902a26238365f5fadb21 |
class GetParamDescriptionForNonManufacturerPid(ParamDescriptionTestFixture): <NEW_LINE> <INDENT> CATEGORY = TestCategory.ERROR_CONDITIONS <NEW_LINE> PID = 'PARAMETER_DESCRIPTION' <NEW_LINE> REQUIRES = ['manufacturer_parameters'] <NEW_LINE> def Test(self): <NEW_LINE> <INDENT> device_info_pid = self.LookupPid('DEVICE_INF... | GET parameter description for a non-manufacturer pid. | 6259902a8e05c05ec3f6f643 |
class Dummy_x(basebehavior.behaviorimplementation.BehaviorImplementation): <NEW_LINE> <INDENT> def implementation_init(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def implementation_update(self): <NEW_LINE> <INDENT> pass | this is a behavior implementation template | 6259902aa4f1c619b294f5c4 |
class ResourceSkuZoneDetails(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'name': {'readonly': True}, 'capabilities': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'name': {'key': 'name', 'type': '[str]'}, 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, } <NEW_LINE> def __i... | Describes The zonal capabilities of a SKU.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The set of zones that the SKU is available in with the specified capabilities.
:vartype name: list[str]
:ivar capabilities: A list of capabilities that are available for the S... | 6259902a63f4b57ef008655a |
class DesignateQuotas(object): <NEW_LINE> <INDENT> QUOTAS_SCHEMA = { "type": "object", "additionalProperties": False, "properties": { "domains": { "type": "integer", "minimum": 1 }, "domain_recordsets": { "type": "integer", "minimum": 1 }, "domain_records": { "type": "integer", "minimum": 1 }, "recordset_records": { "t... | Management of Designate quotas. | 6259902a8c3a8732951f7528 |
class Renderer(base.Renderer): <NEW_LINE> <INDENT> _template = ViewPageTemplateFile('projectOverview.pt') <NEW_LINE> def __init__(self, *args): <NEW_LINE> <INDENT> base.Renderer.__init__(self, *args) <NEW_LINE> try: <NEW_LINE> <INDENT> self.project = aq_inner(self.context).getProjectRoot() <NEW_LINE> <DEDENT> except At... | returns the HTML for this portlet. | 6259902a21bff66bcd723c33 |
class ProcessReportGenerator(object): <NEW_LINE> <INDENT> def __call__(self): <NEW_LINE> <INDENT> return pm.ProcessModel(psutil.Process(os.getpid())) | A Process Data Generator
This generator returns a
:class:`openstack.common.report.models.process.ProcessModel`
based on the current process (which will also include
all subprocesses, recursively) using the :class:`psutil.Process` class`. | 6259902a30c21e258be997dc |
class InvitationForm(forms.Form): <NEW_LINE> <INDENT> email = forms.EmailField( validators=[validate_free_email], widget=forms.TextInput(attrs={'max_length': 75}), label=strings.INVITATION_EMAIL ) <NEW_LINE> def clean_email(self): <NEW_LINE> <INDENT> email = self.cleaned_data['email'] <NEW_LINE> email = multiple_whites... | Form must check if the email is unique | 6259902ac432627299fa3fc4 |
class PowerRating(models.Model): <NEW_LINE> <INDENT> power = models.FloatField('The ammount of power') <NEW_LINE> minRpm = models.IntegerField('How many RPMs for this rating', null = True) <NEW_LINE> maxRpm = models.IntegerField('Maximum RPMs for this rating', null = True) | Meansures how powerful the engine is | 6259902a5166f23b2e2443a6 |
class Room(object): <NEW_LINE> <INDENT> def __init__(self, name, description1): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.description1 = description1 <NEW_LINE> self.description2 = '' <NEW_LINE> self.visited = False <NEW_LINE> self.exits = {} <NEW_LINE> self.items = {} <NEW_LINE> <DEDENT> def setDescription2... | Classe que define uma sala dentro do jogo | 6259902a56b00c62f0fb3891 |
class TestOptionalViews(ViewCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> super(TestOptionalViews, self).setUp() <NEW_LINE> self.v0 = self.create({ 'model': 'a', 'arch': '<qweb><base/></qweb>', }) <NEW_LINE> self.v1 = self.create({ 'model': 'a', 'inherit_id': self.v0, 'application': 'always', 'priorit... | Tests ability to enable/disable inherited views, formerly known as
inherit_option_id | 6259902a5e10d32532ce40ec |
class DummyQualitySupplier(object): <NEW_LINE> <INDENT> implements(IScaledImageQuality) <NEW_LINE> def getQuality(self): <NEW_LINE> <INDENT> return 1 | fake utility for plone.app.imaging's scaling quality | 6259902a23e79379d538d4dc |
class LocalizedDescription(ClientValue): <NEW_LINE> <INDENT> def __init__(self, language_tag=None, description=None): <NEW_LINE> <INDENT> super(LocalizedDescription, self).__init__() <NEW_LINE> self.languageTag = language_tag <NEW_LINE> self.description = description | Represents the localized description used to describe a term in the term store. | 6259902ad10714528d69ee75 |
class ApiMethodInfo(messages.Message): <NEW_LINE> <INDENT> relative_path = messages.StringField(1) <NEW_LINE> method_id = messages.StringField(2) <NEW_LINE> http_method = messages.StringField(3) <NEW_LINE> path_params = messages.StringField(4, repeated=True) <NEW_LINE> query_params = messages.StringField(5, repeated=Tr... | Configuration info for an API method.
All fields are strings unless noted otherwise.
Fields:
relative_path: Relative path for this method.
method_id: ID for this method.
http_method: HTTP verb to use for this method.
path_params: (repeated) path parameters for this method.
query_params: (repeated) query par... | 6259902a8c3a8732951f752a |
class MainHandler(BaseHandler, TemplateRendering): <NEW_LINE> <INDENT> def get(self, *args): <NEW_LINE> <INDENT> variables = {'message':'Hello, Tornado!', 'page_title': self.settings["page_title"], 'page_description': '', 'page_author': 'The author of the page.', 'sourcecode_stylesheet': self.settings["sourcecode_style... | MainHandler
Extends from both BaseHandler and | 6259902ad99f1b3c44d06675 |
class WebsocketError(AmbientError): <NEW_LINE> <INDENT> pass | Define an error related to generic websocket errors. | 6259902ad6c5a102081e30f9 |
class RelancementAdmin(admin.ModelAdmin): <NEW_LINE> <INDENT> list_display = ('applicant', 'content', 'approval_status', 'creation_time') <NEW_LINE> list_filter = ('creation_time', 'approval_status') <NEW_LINE> ordering = ('-creation_time',) <NEW_LINE> search_fields = ('applicant',) | 公告管理 | 6259902ac432627299fa3fc6 |
class NumericColumnRowFormat(BaseRowFormat): <NEW_LINE> <INDENT> def __init__(self, args): <NEW_LINE> <INDENT> super(NumericColumnRowFormat, self).__init__(args) <NEW_LINE> self.base_headers = ['Name', 'ID', 'Genomic region coordinates'] <NEW_LINE> up = args.get_upstream() <NEW_LINE> down = args.get_downstream() <NEW_L... | Adds numeric columns with individual prediction values to 6 base columns | 6259902a0a366e3fb87dd9ba |
class Item: <NEW_LINE> <INDENT> nom = "" <NEW_LINE> description = "" <NEW_LINE> quantity = 0 <NEW_LINE> def __init__(self, nom, quantity, texturedir, description=""): <NEW_LINE> <INDENT> self.nom = nom <NEW_LINE> self.description = description <NEW_LINE> self.texture = pygame.image.load(texturedir).convert_alpha() <NEW... | Classe Item permettant de base pour tout item de l'inventaire | 6259902a5e10d32532ce40ed |
class ExpressRouteCircuitAuthorization(SubResource): <NEW_LINE> <INDENT> _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'authorization_key': {'key': 'properties.authorizationKey', 'type': 'str'}, 'authorization_use_status': {'key': ... | Authorization in an ExpressRouteCircuit resource.
:param id: Resource Identifier.
:type id: str
:param name: Gets name of the resource that is unique within a resource group. This name can be
used to access the resource.
:type name: str
:param etag: A unique read-only string that changes whenever the resource is upda... | 6259902a8e05c05ec3f6f645 |
class ObservedPeriod(ParameterPanel): <NEW_LINE> <INDENT> get_default_start_date = None <NEW_LINE> get_default_end_date = None <NEW_LINE> def __init__(self, **kw): <NEW_LINE> <INDENT> kw.update( start_date=models.DateField( _("Period from"), blank=True, null=True, default=self.get_default_start_date, help_text="""Start... | Parameter panel which defines two fields `start_date`
and `end_date` which default to empty | 6259902a73bcbd0ca4bcb265 |
class value_t(object): <NEW_LINE> <INDENT> def __init__(self, value): <NEW_LINE> <INDENT> self.value = value <NEW_LINE> return <NEW_LINE> <DEDENT> def copy(self): <NEW_LINE> <INDENT> return value_t(self.value) <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return type(other) == value_t and self.value ... | any literal value | 6259902a3eb6a72ae038b638 |
class SupplierViewSet(PermissionHelperMixin, viewsets.ReadOnlyModelViewSet): <NEW_LINE> <INDENT> queryset = Supplier.objects.all() <NEW_LINE> serializer_class = SupplierSerializer <NEW_LINE> def get_view_name(self): <NEW_LINE> <INDENT> return _("Suppliers") <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def get_help_text(... | retrieve: Fetches a supplier by its ID.
list: Lists all available suppliers. | 6259902ad10714528d69ee76 |
class TestPost(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self) -> None: <NEW_LINE> <INDENT> self.session = requests.session() <NEW_LINE> self.token = get_main_page_token(self.session) <NEW_LINE> self.token_id = get_login_token_id(self.session) <NEW_LINE> <DEDENT> def tearDown(self) -> None: <NEW_LINE> <INDENT> ... | 发帖模块测试用例 | 6259902abe8e80087fbc004d |
class ELOIndex(indexes.SearchIndex, indexes.Indexable): <NEW_LINE> <INDENT> text = indexes.CharField(document=True, use_template=True) <NEW_LINE> author = indexes.CharField(model_attr='author') <NEW_LINE> create_date = indexes.DateTimeField(model_attr='create_date') <NEW_LINE> update_date = indexes.DateTimeField(model_... | Index of ELO | 6259902a9b70327d1c57fd56 |
class k_means(object): <NEW_LINE> <INDENT> def __init__(self, m, data): <NEW_LINE> <INDENT> self.m = m <NEW_LINE> self.data = data <NEW_LINE> <DEDENT> def cluster_centroid_initialization(self, K): <NEW_LINE> <INDENT> cluster_centroids = random.sample(self.data, K) <NEW_LINE> return cluster_centroids <NEW_LINE> <DEDENT>... | K-means clustering algorithm, unsupervised learning. Most of code assumes only one feature. | 6259902a8c3a8732951f752c |
@pytest.mark.usefixtures('psql_settings', 'settings', scope='class') <NEW_LINE> class TestServicePostgresql(): <NEW_LINE> <INDENT> def test_postgresl(self, psql_settings): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> logger.info("connecting to postgres with user {user}".format(user=psql_settings['user'])) <NEW_LINE> wi... | Class to test the posgresql service. | 6259902a1d351010ab8f4aec |
class PrivateLinkServiceConnection(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'request_message': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'private_link_service_id': {'key': 'properties.privateLinkServiceId', 'type': 'str'}, 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, '... | A grouping of information about the connection to the remote resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar private_link_service_id: The resource id of the private link service. Required on PUT
(CreateOrUpdate) requests.
:vartype private_link_service_id: str
:... | 6259902a23e79379d538d4e0 |
class IndexItemsView(abc.ItemsView): <NEW_LINE> <INDENT> __slots__ = () <NEW_LINE> def __iter__(self): <NEW_LINE> <INDENT> return zip(self._mapping._variables, self._mapping._data.flat) | Faster read access to the numpy array | 6259902aec188e330fdf9868 |
class MaxMinPriceMethod(LPMethod): <NEW_LINE> <INDENT> def __init__(self, valuations, verbosity=1): <NEW_LINE> <INDENT> super().__init__(valuations, verbosity) <NEW_LINE> <DEDENT> def solve_prices(self): <NEW_LINE> <INDENT> c = np.zeros((self.n + 1, 1)) <NEW_LINE> c[-1, 0] = -1 <NEW_LINE> all_G = [] <NEW_LINE> all_h = ... | Implementation of the fairness splitting algorithm.
Example usage:
valuations = get_valuations()
method = FairnessMethod(valuations)
self.assignemnts, self.prices = method.solve() | 6259902a5166f23b2e2443ac |
class NotebookIntrospector(Mapping): <NEW_LINE> <INDENT> def __init__(self, path, literal_eval=True, to_df=False): <NEW_LINE> <INDENT> self.nb = nbformat.read(path, nbformat.NO_CONVERT) <NEW_LINE> self.tag2output_raw = self._tag2output() <NEW_LINE> self.literal_eval = literal_eval <NEW_LINE> self.tag2output = { k: _par... | Retrieve output from a notebook file with tagged cells.
For instructions on tagging cells,
`see this <https://papermill.readthedocs.io/en/latest/usage-parameterize.html>`_.
Notes
-----
Ignores untagged cells, if a cell has more than one tag, it uses the first
one as identifier. If a cell has more than one output, it ... | 6259902a0a366e3fb87dd9be |
class SimpleTestTopology(unittest.TestCase): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> self.net = None <NEW_LINE> self.api = None <NEW_LINE> self.s = [] <NEW_LINE> self.h = [] <NEW_LINE> self.d = [] <NEW_LINE> self.dc = [] <NEW_LINE> self.docker_cli = None <NEW_LINE> super(SimpleTestT... | Helper class to do basic test setups.
s1 -- s2 -- s3 -- ... -- sN | 6259902a6fece00bbaccc986 |
class RemoteExploitableVerifier(PythonTemplateVerifier): <NEW_LINE> <INDENT> tmp_file = "/tmp/triage.pkl" <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> path_to_this_file = os.path.split(os.path.realpath(__file__))[0] <NEW_LINE> super(RemoteExploitableVerifier, self).__init__( config_path=os.path.join(path_to_this_... | This is a remote exploitable verifier for Lucky CAT.
It is based on the triage.py script of exploitable
(https://github.com/jfoote/exploitable). | 6259902ad53ae8145f91943a |
class SelectiveProxyMiddleware(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.proxy = self.parse_proxy(settings.get('HTTP_PROXY'), 'http') <NEW_LINE> self.proxy_spiders = set(settings.getlist('PROXY_SPIDERS', [])) <NEW_LINE> <DEDENT> def parse_proxy(self, url, orig_type): <NEW_LINE> <INDENT> ... | A middleware to enable http proxy to selected spiders only.
Settings:
HTTP_PROXY -- proxy uri. e.g.: http://user:pass@proxy.host:port
PROXY_SPIDERS -- all requests from these spiders will be routed
through the proxy | 6259902a26238365f5fadb29 |
class TokenAuth(object, metaclass=Singleton): <NEW_LINE> <INDENT> _handler = None <NEW_LINE> def __new__(cls, *args, **kwargs): <NEW_LINE> <INDENT> cls._handler = get_token_auth() <NEW_LINE> return cls._handler | Singleton for accessing the Bearer Token | 6259902a8e05c05ec3f6f647 |
class TestSmartServerBzrDirRequestGetBranches( tests.TestCaseWithMemoryTransport): <NEW_LINE> <INDENT> def test_simple(self): <NEW_LINE> <INDENT> backing = self.get_transport() <NEW_LINE> branch = self.make_branch('.') <NEW_LINE> request_class = smart_dir.SmartServerBzrDirRequestGetBranches <NEW_LINE> request = request... | Tests for BzrDir.get_branches. | 6259902a8c3a8732951f7530 |
class NewsListView(ListView): <NEW_LINE> <INDENT> model = News <NEW_LINE> template_name = "list.html" <NEW_LINE> context_object_name = "post_list" <NEW_LINE> paginate_by = 3 | List view for model list. | 6259902a1d351010ab8f4aef |
class CaesarSubstitution(object): <NEW_LINE> <INDENT> def __init__(self, pt_data, key, to_path): <NEW_LINE> <INDENT> self.pt_data = pt_data <NEW_LINE> self.new_alphabet = [] <NEW_LINE> self.key = key <NEW_LINE> self.to_path = to_path <NEW_LINE> <DEDENT> def sub_mapping(self, key): <NEW_LINE> <INDENT> new_alphabet = [''... | Caesar substitution | 6259902a1f5feb6acb163bc8 |
class Metric(collections.namedtuple('Metric', 'type labels')): <NEW_LINE> <INDENT> __slots__ = () <NEW_LINE> @classmethod <NEW_LINE> def _from_dict(cls, info): <NEW_LINE> <INDENT> return cls( type=info['type'], labels=info.get('labels', {}), ) <NEW_LINE> <DEDENT> def _to_dict(self): <NEW_LINE> <INDENT> return { 'type':... | A specific metric identified by specifying values for all labels.
The preferred way to construct a metric object is using the
:meth:`~google.cloud.monitoring.client.Client.metric` factory method
of the :class:`~google.cloud.monitoring.client.Client` class.
:type type: string
:param type: The metric type name.
:type ... | 6259902a30c21e258be997e4 |
class _BaseColumnFormat(str): <NEW_LINE> <INDENT> def __eq__(self, other): <NEW_LINE> <INDENT> if not other: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if isinstance(other, str): <NEW_LINE> <INDENT> if not isinstance(other, self.__class__): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> other = self.__class__(o... | Base class for binary table column formats (just called _ColumnFormat)
and ASCII table column formats (_AsciiColumnFormat). | 6259902a50485f2cf55dbf53 |
class VersionR: <NEW_LINE> <INDENT> allow_origin, rest_url = get_allowed.get_allowed() <NEW_LINE> def GET(self): <NEW_LINE> <INDENT> web.header("Content-Type","text/plain") <NEW_LINE> web.header('Access-Control-Allow-Origin', self.allow_origin) <NEW_LINE> version = {} <NEW_LINE> file_path = None <NEW_LINE> try: <NEW_LI... | This endpoint is for returning the current running version of vcontrol | 6259902a0a366e3fb87dd9c0 |
class matrixTile: <NEW_LINE> <INDENT> def __init__(self,dim): <NEW_LINE> <INDENT> self.tiles_matrix = configShisen.load('tiles-matrix') <NEW_LINE> self.tiles_list = {} <NEW_LINE> self.matrix_board= None <NEW_LINE> self.initTilesPos() <NEW_LINE> self.createMatrix(dim) <NEW_LINE> <DEDENT> def initTilesPos(self): <NEW_LIN... | manage resolving algorithms to validate for example
if game could be won or if a movement is valid in rules game.
Changed by:
Manage the matrix of tiles used to fill the board | 6259902a23e79379d538d4e4 |
class TestSpecificationSerializer(APITestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> maturity = self.create( Maturity, slug='WD', name={'en': 'Working Draft'}) <NEW_LINE> self.spec = self.create( Specification, maturity=maturity, slug="css3-animations", mdn_key='CSS3 Animations', name={'en': "CSS An... | Test SpecificationSerializer through the view. | 6259902ad10714528d69ee79 |
class ExtensionError(SphinxError): <NEW_LINE> <INDENT> def __init__(self, message: str, orig_exc: Exception = None, modname: str = None) -> None: <NEW_LINE> <INDENT> super().__init__(message) <NEW_LINE> self.message = message <NEW_LINE> self.orig_exc = orig_exc <NEW_LINE> self.modname = modname <NEW_LINE> <DEDENT> @pro... | Extension error. | 6259902a8a349b6b43687213 |
class GenerateSpin1StatesTestCase(unittest.TestCase): <NEW_LINE> <INDENT> def test_some_generated_spin1_states(self): <NEW_LINE> <INDENT> gs = generate_spin1_states(4, 2) <NEW_LINE> self.assertEqual(np.size(gs), 10) <NEW_LINE> self.assertEqual(gs[0], 5) <NEW_LINE> self.assertEqual(gs[1], 17) <NEW_LINE> self.assertEqual... | Tests for the generate spin 1 states function. | 6259902a63f4b57ef008655f |
class FtdiEepromError(FtdiError): <NEW_LINE> <INDENT> pass | FTDI EEPROM error. | 6259902a15baa72349462f73 |
@register_resource <NEW_LINE> class v1_BuildConfigList(Resource): <NEW_LINE> <INDENT> __kind__ = 'v1.BuildConfigList' <NEW_LINE> __fields__ = { 'api_version': 'apiVersion', 'items': 'items', 'kind': 'kind', 'metadata': 'metadata', } <NEW_LINE> __types__ = { 'items': 'v1.BuildConfig', 'metadata': 'unversioned.ListMeta',... | BuildConfigList is a collection of BuildConfigs. | 6259902a1d351010ab8f4af2 |
class OpenThread(Threader): <NEW_LINE> <INDENT> def __exit__(self,type,value,traceback): <NEW_LINE> <INDENT> pass | Same as above, but lets a thread keep running
after exiting the `with` statement. | 6259902a26238365f5fadb2d |
class ShardedDB(object): <NEW_LINE> <INDENT> def __init__(self, filebase, num_shards, create_if_missing): <NEW_LINE> <INDENT> self.filebase = filebase <NEW_LINE> self.num_shards = num_shards <NEW_LINE> self._shards = [] <NEW_LINE> os.system('mkdir -p "%s"' % filebase) <NEW_LINE> for i in range(num_shards): <NEW_LINE> <... | Manages a number of leveldb "shards" (partitions).
LevelDB does not support concurrent writers, so we create a separate output
shard for each reducer. `ShardedDB` provides a unified interface to
multiple shards. | 6259902abe8e80087fbc0055 |
class ConfigurableWrapper(object): <NEW_LINE> <INDENT> def __init__(self, cls): <NEW_LINE> <INDENT> self._cls = cls <NEW_LINE> <DEDENT> def setup(self, *args, **kwargs): <NEW_LINE> <INDENT> instance = self._cls(*args, **kwargs) <NEW_LINE> self.__class__ = instance.__class__ <NEW_LINE> self.__dict__ = instance.__dict__ | This is a little trick I just made up.
Allow a reference to the object you want to create to be created later all while referencing the object before hand
This is mostly useful when creating web applications that need access to something like the db object, but the db object isn't configured until later in the applic... | 6259902a8a349b6b43687215 |
class SelectWidget(BaseSelectWidget): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def render_option(cls, value, label, mixed): <NEW_LINE> <INDENT> if isinstance(label, (list, tuple)): <NEW_LINE> <INDENT> children = [] <NEW_LINE> for item_value, item_label in label: <NEW_LINE> <INDENT> item_html = cls.render_option(item... | Add support of choices with 'optgroup' to the 'Select' widget. | 6259902a796e427e5384f759 |
class ReportGenerationError(object): <NEW_LINE> <INDENT> pass | The coverage report cannot be generated. | 6259902a5166f23b2e2443b2 |
class Mailbox(Drawable): <NEW_LINE> <INDENT> def __init__(self, flagUp=False, doorOpen=False, color='white'): <NEW_LINE> <INDENT> Drawable.__init__(self) <NEW_LINE> self._post = Rectangle(16, 80, Point(0,-40)) <NEW_LINE> self._post.setFillColor('brown') <NEW_LINE> self._box = Rectangle(50, 30, Point(-3,-95)) <NEW_LINE>... | A graphical primitive representing a Mailbox.
The user can choose the color, open and close the door, and raise and lower the flag. | 6259902a8a43f66fc4bf3160 |
class UserBodyweightTestCase(WgerTestCase): <NEW_LINE> <INDENT> def test_bodyweight_new(self): <NEW_LINE> <INDENT> user = User.objects.get(pk=2) <NEW_LINE> count_before = WeightEntry.objects.filter(user=user).count() <NEW_LINE> entry = user.userprofile.user_bodyweight(80) <NEW_LINE> count_after = WeightEntry.objects.fi... | Tests the body weight generation/update function | 6259902a3eb6a72ae038b642 |
class stack_node: <NEW_LINE> <INDENT> def __init__(self, data): <NEW_LINE> <INDENT> self.key = data <NEW_LINE> self.next = None | create the node for stack | 6259902a8a349b6b43687217 |
class Shiftexp(object): <NEW_LINE> <INDENT> def __init__(self, parameter): <NEW_LINE> <INDENT> assert 0 < parameter < math.inf <NEW_LINE> self.parameter = parameter <NEW_LINE> return <NEW_LINE> <DEDENT> def pdf(self, value): <NEW_LINE> <INDENT> assert 0 <= value <= math.inf <NEW_LINE> if value < self.parameter: <NEW_LI... | Shifted exponential distributed random variable. | 6259902a1f5feb6acb163bce |
class ajaxSetRemarks(BrowserView): <NEW_LINE> <INDENT> def __call__(self): <NEW_LINE> <INDENT> plone.protect.CheckAuthenticator(self.request) <NEW_LINE> field = self.context.Schema()["Remarks"] <NEW_LINE> value = self.request['value'].strip() + "\n\n" <NEW_LINE> existing = self.context.getRemarks(mimetype='text/x-web-i... | Modify Remarks field and return new rendered field value
| 6259902aa8ecb033258721fc |
class TableFlavors(_ui.Table): <NEW_LINE> <INDENT> columns = {'name': 2} <NEW_LINE> row_cls = RowFlavor | Flavors table. | 6259902a6fece00bbaccc98d |
class Monitor(object): <NEW_LINE> <INDENT> def __init__(self, log_file_name): <NEW_LINE> <INDENT> self.log_file = open(log_file_name, 'w') <NEW_LINE> self.pop_name = "" <NEW_LINE> <DEDENT> def write(self, tag, msg): <NEW_LINE> <INDENT> self.log_file.write("%s\t%s\t%s\n" % (self.pop_name, tag, msg)) <NEW_LINE> self.log_... | A class to record events in the course of evolution.
| 6259902bd6c5a102081e3105 |
class TestParse(unittest.TestCase): <NEW_LINE> <INDENT> def testParse(self): <NEW_LINE> <INDENT> adag = parse(DAX33TEST_DAX) <NEW_LINE> <DEDENT> def testParseString(self): <NEW_LINE> <INDENT> txt = open(DAX33TEST_DAX).read() <NEW_LINE> adag = parseString(txt) | This doesn't really do a thorough job of testing the parser | 6259902bbf627c535bcb2496 |
class ModuleTest(TestCase): <NEW_LINE> <INDENT> fixtures = ['users'] <NEW_LINE> def test_update_module_using_save(self): <NEW_LINE> <INDENT> author = User.objects.get(username='john') <NEW_LINE> mod = Module.objects.create( filename='test_filename', author=author ) <NEW_LINE> self.assertRaises(UpdateDeniedException, mo... | Testing module methods | 6259902b50485f2cf55dbf5a |
class Ring(Graph): <NEW_LINE> <INDENT> def __init__(self, N=64, k=1, **kwargs): <NEW_LINE> <INDENT> self.k = k <NEW_LINE> if 2*k > N: <NEW_LINE> <INDENT> raise ValueError('Too many neighbors requested.') <NEW_LINE> <DEDENT> if 2*k == N: <NEW_LINE> <INDENT> num_edges = N * (k - 1) + k <NEW_LINE> <DEDENT> else: <NEW_LINE... | K-regular ring graph.
Parameters
----------
N : int
Number of vertices.
k : int
Number of neighbors in each direction.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> G = graphs.Ring(N=10)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = axes[0].spy(G.W)
>>> G.plot(ax=axes[1]) | 6259902b1d351010ab8f4af6 |
class itkLog10ImageFilterIF3IF3_Superclass(itkInPlaceImageFilterAPython.itkInPlaceImageFilterIF3IF3): <NEW_LINE> <INDENT> thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') <NEW_LINE> def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")... | Proxy of C++ itkLog10ImageFilterIF3IF3_Superclass class | 6259902be76e3b2f99fd99ec |
class Control: <NEW_LINE> <INDENT> def __init__(self, *args): <NEW_LINE> <INDENT> if len(args) > 0: <NEW_LINE> <INDENT> raise DeprecationWarning( 'p0 and epsilon now live in config') <NEW_LINE> <DEDENT> self.gold_getter = GoldGetter() <NEW_LINE> self.swap = None <NEW_LINE> <DEDENT> def run(self, amount=None): <NEW_LINE... | Gets classifications from database and feeds them to SWAP | 6259902b8c3a8732951f7537 |
class CalendarManager(models.Manager): <NEW_LINE> <INDENT> def get_calendar_for_object(self, obj, distinction=None): <NEW_LINE> <INDENT> calendar_list = self.get_calendars_for_object(obj, distinction) <NEW_LINE> if len(calendar_list) == 0: <NEW_LINE> <INDENT> raise Calendar.DoesNotExist("Calendar does not exist.") <NEW... | >>> user1 = User(username='tony')
>>> user1.save() | 6259902b30c21e258be997ec |
class Movies(object): <NEW_LINE> <INDENT> def __init__(self, name, rate, cate, loca, info_link, cover_link): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.rate = rate <NEW_LINE> self.cate = cate <NEW_LINE> self.loca = loca <NEW_LINE> self.info_link = info_link <NEW_LINE> self.cover_link = cover_link <NEW_LINE> <... | create the instance of movies | 6259902b6e29344779b0162f |
class equalizeContrast(CVwrapped): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(equalizeContrast, self).__init__(cv2.equalizeHist) | Automatic contrast correction.
Note: Only works for grayscale images! | 6259902b50485f2cf55dbf5b |
class Light(DefaultInstance): <NEW_LINE> <INDENT> def __init__(self, lightpos=(10, -10, 20), lightcol=(1.0, 1.0, 1.0), lightamb=(0.1, 0.1, 0.2), is_point=False): <NEW_LINE> <INDENT> super(Light, self).__init__() <NEW_LINE> self.lightpos = lightpos <NEW_LINE> self.lightcol = lightcol <NEW_LINE> self.lightamb = lightamb ... | Holds information about lighting to be used in shaders | 6259902bd6c5a102081e3107 |
class ContainerTraverser(Traverser): <NEW_LINE> <INDENT> component.adapts(IContainer, IHTTPRequest) <NEW_LINE> def traverse(self, name): <NEW_LINE> <INDENT> traverse = getattr(self.context, 'traverse', None) <NEW_LINE> if traverse: <NEW_LINE> <INDENT> result = traverse(name) <NEW_LINE> if result is not None: <NEW_LINE>... | Base class for container traversers in Grok applications.
A container traverser is like a normal `grok.Traverser` but, instead
of supplying its own ``traverse()`` method, Grok will either call
the ``traverse()`` method on the context itself, if any, else call
``get()`` on the container (a getitem-style lookup) in orde... | 6259902b8c3a8732951f7539 |
class Nauru(DstTzInfo): <NEW_LINE> <INDENT> _zone = 'Pacific/Nauru' <NEW_LINE> _utc_transition_times = [ d(1,1,1,0,0,0), d(1921,1,14,12,52,20), d(1942,3,14,12,30,0), d(1944,8,14,15,0,0), d(1979,4,30,12,30,0), ] <NEW_LINE> _transition_info = [ i(40080,0,'LMT'), i(41400,0,'NRT'), i(32400,0,'JST'), i(41400,0,'NRT'), i(432... | Pacific/Nauru timezone definition. See datetime.tzinfo for details | 6259902b6fece00bbaccc990 |
class ZipPkgReader(object): <NEW_LINE> <INDENT> _CONTENT_TYPES_MEMBERNAME = '[Content_Types].xml' <NEW_LINE> def __init__(self, pkg_file): <NEW_LINE> <INDENT> super(ZipPkgReader, self).__init__() <NEW_LINE> self._zipf = ZipFile(pkg_file, 'r') <NEW_LINE> <DEDENT> def blob_for(self, pack_uri): <NEW_LINE> <INDENT> return ... | Implements |PhysPkgReader| interface for a zip file OPC package. | 6259902b30c21e258be997ee |
class RobotArm(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.pfrp = PiFaceRelayPlus(RELAY) <NEW_LINE> <DEDENT> def set_direction(self, direction): <NEW_LINE> <INDENT> self.pfrp.relays[DIRECTION_INDEX].value = direction <NEW_LINE> <DEDENT> def set_relay_for_period(self, index, delay, directio... | Robot Arm controlled by PiFace Relay Plus. | 6259902b1f5feb6acb163bd2 |
class FunctionFieldMappedValuation_base(FunctionFieldValuation_base, MappedValuation_base): <NEW_LINE> <INDENT> def __init__(self, parent, base_valuation, to_base_valuation_domain, from_base_valuation_domain): <NEW_LINE> <INDENT> FunctionFieldValuation_base.__init__(self, parent) <NEW_LINE> MappedValuation_base.__init_... | A valuation on a function field which relies on a ``base_valuation`` on an
isomorphic function field.
EXAMPLES::
sage: K.<x> = FunctionField(GF(2))
sage: v = K.valuation(1/x); v
Valuation at the infinite place | 6259902b63f4b57ef0086563 |
class Source(Node, Publisher, threading.Thread, Stoppable): <NEW_LINE> <INDENT> def __init__(self, name): <NEW_LINE> <INDENT> threading.Thread.__init__(self, name=name) <NEW_LINE> Node.__init__(self, name) <NEW_LINE> Publisher.__init__(self) <NEW_LINE> Stoppable.__init__(self) <NEW_LINE> <DEDENT> def initialize(self): ... | Represents a node that is a source of data in the graph.
The node is only publishing data and has its own thread within which the
notification of subscribers should take place. | 6259902bec188e330fdf9875 |
class GetConnection(): <NEW_LINE> <INDENT> def obtain_connection(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if os.environ.get('DATABASE_URL'): <NEW_LINE> <INDENT> conn = psycopg2.connect(os.environ.get('DATABASE_URL')) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> conn = psycopg2.connect(os.environ.get('ECOM_D... | Connect to postgres DB | 6259902b507cdc57c63a5d89 |
class OrderedResponseElasticSearch(ElasticSearch): <NEW_LINE> <INDENT> def _decode_response(self, response): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> json_response = json.loads(response.text, object_pairs_hook=OrderedDict) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise InvalidJsonResponseError(res... | Extension of pyelasticsearch.ElasticSearch that decodes responses using an
OrderedDict instead of a plain dict. | 6259902bc432627299fa3fd6 |
class TestApiKeyWorksFail(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> API.app.app.config['TESTING'] = True <NEW_LINE> self.app = API.app.app.test_client() <NEW_LINE> API.database_manager.conn = psycopg2.connect(db_credentials) <NEW_LINE> API.database_manager.create_tables() <NEW_LINE> A... | Tests the request to URL/post returns a message that the api_key was invalid. User cannot proceed. | 6259902b6fece00bbaccc991 |
class GVG_104: <NEW_LINE> <INDENT> events = Play(CONTROLLER, MINION + (ATK == 1)).on(Buff(Play.CARD, "GVG_104a")) | Hobgoblin | 6259902b711fe17d825e148b |
class WeakQubitRef(BasicQubit): <NEW_LINE> <INDENT> pass | WeakQubitRef objects are used inside the Command object.
Qubits feature automatic deallocation when destroyed. WeakQubitRefs, on the
other hand, do not share this feature, allowing to copy them and pass them
along the compiler pipeline, while the actual qubit objects may be garbage-
collected (and, thus, cleaned up ea... | 6259902b5166f23b2e2443b8 |
class NoneToEmptyString(Rule): <NEW_LINE> <INDENT> def apply(self, value): <NEW_LINE> <INDENT> if value is None: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> return value | Replace None values with an empty string. This is useful in cases
where legacy software uses None to create an empty cell, but your
other checks require a string. | 6259902bd18da76e235b793f |
class Track(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.context = DictStack() <NEW_LINE> self.registered_events = {} <NEW_LINE> <DEDENT> def clear_context(self): <NEW_LINE> <INDENT> self.context = DictStack() <NEW_LINE> <DEDENT> def push_context(self, more_context): <NEW_LINE> <INDENT> sel... | Event tracking host. | 6259902bd53ae8145f919446 |
class Bbdd: <NEW_LINE> <INDENT> def __init__(self, ruta): <NEW_LINE> <INDENT> self.con = None <NEW_LINE> self.conectar(ruta) <NEW_LINE> <DEDENT> def conectar(self, ruta): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.con = sqlite3.connect(ruta) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> notifica... | Abstrae la base de datos sqlite | 6259902b5e10d32532ce40f5 |
class Seq: <NEW_LINE> <INDENT> def __init__(self, strbases): <NEW_LINE> <INDENT> print("New sequence is already created!") <NEW_LINE> self.strbases = strbases <NEW_LINE> <DEDENT> def len(self): <NEW_LINE> <INDENT> return len(self.strbases) | A class for representing sequences | 6259902b8e05c05ec3f6f64d |
class KeyServer(object): <NEW_LINE> <INDENT> def __init__(self, host, port=11371, proxies=None, headers=None, verify=True): <NEW_LINE> <INDENT> if host.startswith('hkp://') or host.startswith('hkps://'): <NEW_LINE> <INDENT> host = host.replace("hkp", "http", 1) <NEW_LINE> if host.startswith('https'): <NEW_LINE> <INDENT... | Keyserver object used for search queries. | 6259902b8a349b6b4368721d |
class UrlListParseAction(argparse.Action): <NEW_LINE> <INDENT> def __call__(self, parser, namespace, urls, option_string=None): <NEW_LINE> <INDENT> dest = getattr(namespace, self.dest) <NEW_LINE> if dest is urls: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for url in urls: <NEW_LINE> <INDENT> dest.append(url) | Custom action to avoid having the --file argument overwrite regular URLs, or vice versa.
Instead, this action will simply merge regular URLs with file URLs. | 6259902b6fece00bbaccc992 |
class Formatter(metaclass=FormatterRegistry): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.can_preview = False <NEW_LINE> self.can_export = False <NEW_LINE> <DEDENT> def format(self, article, subscriber, codes=None): <NEW_LINE> <INDENT> raise NotImplementedError() <NEW_LINE> <DEDENT> def export(self... | Base Formatter class for all types of Formatters like News ML 1.2, News ML G2, NITF, etc. | 6259902bec188e330fdf9877 |
class Category(db.Model): <NEW_LINE> <INDENT> __tablename__ = 'categories' <NEW_LINE> id = db.Column(db.Integer, primary_key=True) <NEW_LINE> name = db.Column(db.Unicode(50), nullable=False) <NEW_LINE> @classmethod <NEW_LINE> def get_all(cls, ids: Set[int]): <NEW_LINE> <INDENT> categories = db.session.query(Category).f... | Category db class. | 6259902b5166f23b2e2443ba |
class PromptHelp(CmdErr): <NEW_LINE> <INDENT> def __init__(self, error): <NEW_LINE> <INDENT> CmdErr.__init__(self, error) <NEW_LINE> self.prefix = "Prompt Help:" | PromptHelp covers prompt help conditions. | 6259902b8e05c05ec3f6f64e |
class LookupForm(gsoc_forms.GSoCModelForm): <NEW_LINE> <INDENT> class Meta: <NEW_LINE> <INDENT> model = None <NEW_LINE> <DEDENT> def __init__(self, request_data=None, **kwargs): <NEW_LINE> <INDENT> super(LookupForm, self).__init__(**kwargs) <NEW_LINE> self.request_data = request_data <NEW_LINE> <DEDENT> user_id = djang... | Django form for the lookup profile page. | 6259902b6fece00bbaccc994 |
@Registry.register_sub_command <NEW_LINE> class ShowSubCommand(AbstractBaseSubCommand): <NEW_LINE> <INDENT> sub_command = "show" <NEW_LINE> sub_command_help = "show notes" <NEW_LINE> def invoke_on_note(self, args, note): <NEW_LINE> <INDENT> print_colored("%s%s" % (note.path, linesep), interactive_only=True) <NEW_LINE> ... | A simple plugin that prints the contents of notes found to stdout. | 6259902b6fece00bbaccc995 |
class Kepq3(Mast): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(Kepq3, self).__init__() <NEW_LINE> self.dicttname = 'stars' <NEW_LINE> self.t = {'id' : 1, 'RA' : 2, 'DEC' : 3, 'KEPMAG' : 14} <NEW_LINE> self.dictcols = ['KIC', 'RA', 'DEC', 'PMRA', 'PMDEC', 'GMAG', 'RMAG', 'IMAG', 'ZMAG', 'D... | class wrapper for Kepler Q3 data | 6259902b796e427e5384f763 |
class MediaTranscodeItem(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.OutputStorage = None <NEW_LINE> self.Path = None <NEW_LINE> self.Definition = None <NEW_LINE> self.Bitrate = None <NEW_LINE> self.Height = None <NEW_LINE> self.Width = None <NEW_LINE> self.Size = None <NEW_LINE> se... | 转码信息
| 6259902b21a7993f00c66f64 |
class HashedCredentials(Credentials): <NEW_LINE> <INDENT> def password_match(self, password): <NEW_LINE> <INDENT> return match_token256(password, self.auth.password) | Credentials where the password is hashed. | 6259902b8a349b6b43687221 |
class AcceptedListenChannel(RecvChannel): <NEW_LINE> <INDENT> def __init__(self, name=None, binding=None, parent_channel=None, **kwargs): <NEW_LINE> <INDENT> RecvChannel.__init__(self, name=name, binding=binding, **kwargs) <NEW_LINE> self._delivery_tags = set() <NEW_LINE> self._parent_channel = parent_channel <NEW_LINE... | The type of channel returned by accept. | 6259902b3eb6a72ae038b64c |
class Common(object): <NEW_LINE> <INDENT> BOT_FIRST_NAME = 'Wizzy Viktorovich' <NEW_LINE> BOT_NICKNAME = 'wizzy' <NEW_LINE> ADMINS = ['UM35HE6R5'] <NEW_LINE> TRIGGERS = ['cah', 'c!'] <NEW_LINE> _v = get_versions() <NEW_LINE> VERSION = _v['version'] <NEW_LINE> UPDATE_DATE = _v['date'] <NEW_LINE> DB_PATH = os.path.join(o... | Configuration items common across all config types | 6259902bd4950a0f3b111631 |
class ObjectNotFoundError(GitPathError, FileNotFoundError): <NEW_LINE> <INDENT> pass | Git object not found | 6259902b8c3a8732951f7540 |
class GraphicsSocket(QGraphicsItem): <NEW_LINE> <INDENT> def __init__(self, socket: "Socket") -> None: <NEW_LINE> <INDENT> super(GraphicsSocket, self).__init__(socket.node.graphicsNode) <NEW_LINE> self.socket = socket <NEW_LINE> self.initUI() <NEW_LINE> self.hovered = False <NEW_LINE> <DEDENT> def initUI(self) -> None:... | :class:`~nodedge.graphics_socket.GraphicsSocket` class.
The graphics socket is the graphical representation of the
:class:`~nodedge.socket.Socket`. | 6259902b925a0f43d25e902f |
class CardAction(Model): <NEW_LINE> <INDENT> _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, 'title': {'key': 'title', 'type': 'str'}, 'image': {'key': 'image', 'type': 'str'}, 'text': {'key': 'text', 'type': 'str'}, 'display_text': {'key': 'displayText', 'type': 'str'}, 'value': {'key': 'value', 'type': 'ob... | A clickable action.
:param type: The type of action implemented by this button. Possible
values include: 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo',
'showImage', 'downloadFile', 'signin', 'call', 'payment', 'messageBack'
:type type: str or ~botframework.connector.models.ActionTypes
:param title: Text ... | 6259902b21bff66bcd723c4b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.