code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
class ControlFrame(NamedTuple): <NEW_LINE> <INDENT> label_types: Tuple[ValType, ...] <NEW_LINE> end_types: Tuple[ValType, ...] <NEW_LINE> height: int <NEW_LINE> is_unreachable: bool <NEW_LINE> def mark_unreachable(self) -> 'ControlFrame': <NEW_LINE> <INDENT> return type(self)( self.label_types, self.end_types, self.hei... | Represents the equivalent of a label during expression validation. | 625990311d351010ab8f4bd8 |
class HeatmapMaxDetBlock(nn.Layer): <NEW_LINE> <INDENT> def __init__(self, tune=True, data_format="channels_last", **kwargs): <NEW_LINE> <INDENT> super(HeatmapMaxDetBlock, self).__init__(**kwargs) <NEW_LINE> self.tune = tune <NEW_LINE> self.data_format = data_format <NEW_LINE> <DEDENT> def call(self, x, training=None):... | Heatmap maximum detector block (for human pose estimation task).
Parameters:
----------
tune : bool, default True
Whether to tune point positions.
data_format : str, default 'channels_last'
The ordering of the dimensions in tensors. | 62599031a8ecb033258722dd |
class GameNumPyLight(BaseGameNumPy): <NEW_LINE> <INDENT> def _step(self): <NEW_LINE> <INDENT> con = convolve(self.cells, self.WEIGHTS, mode='wrap') <NEW_LINE> self.cells.fill(0) <NEW_LINE> self.cells[(con == 3) | (con == 12) | (con == 13)] = 1 <NEW_LINE> <DEDENT> def fate(self, row, col): <NEW_LINE> <INDENT> line = sel... | Light version of the NumPy/SciPy-based implementation of the Game of
Life. | 6259903150485f2cf55dc03e |
class ExperimentUnit(AuthUserDetail, CreateUpdateTime): <NEW_LINE> <INDENT> slug = models.SlugField(max_length=250, unique=True, blank=True) <NEW_LINE> exp_unit_code = models.CharField(max_length=20, unique=True, verbose_name='Experiment unit code') <NEW_LINE> experimentunitcategory = models.ForeignKey( ExperimentUnitC... | Experiment unit model. Creates experiment unit entity. | 6259903173bcbd0ca4bcb352 |
class TorchServable(BaseServable): <NEW_LINE> <INDENT> def _build(self): <NEW_LINE> <INDENT> self.model = torch.load(self.dlhub['files']['model'], map_location='cpu') <NEW_LINE> self.model.eval() <NEW_LINE> self.input_type = self.servable['methods']['run']['input'] <NEW_LINE> self.is_multiinput = self.input_type['type'... | Servable for Torch models | 62599031e76e3b2f99fd9acd |
class DynamicDocument(mongoengine.DynamicDocument): <NEW_LINE> <INDENT> meta = {'abstract': True, 'queryset_class': BaseQuerySet} <NEW_LINE> test = 1 | Abstract Dynamic document with extra helpers in the queryset class | 6259903123e79379d538d5cb |
class ZCatalogIndexes(IFAwareObjectManager, Folder, Persistent, Implicit): <NEW_LINE> <INDENT> _product_interfaces = (IPluggableIndex, ) <NEW_LINE> meta_type = "ZCatalogIndex" <NEW_LINE> manage_options = () <NEW_LINE> security = ClassSecurityInfo() <NEW_LINE> security.declareObjectProtected(manage_zcatalog_indexes) <NE... | A mapping object, responding to getattr requests by looking up
the requested indexes in an object manager. | 62599031711fe17d825e14fb |
@dataclass(frozen=True) <NEW_LINE> class Carrier: <NEW_LINE> <INDENT> carrier_id: str <NEW_LINE> name: str | Класс с данными о перевозчике. | 62599031ac7a0e7691f735a9 |
class PreSubmitEnterprise(models.Model): <NEW_LINE> <INDENT> content_id = models.CharField(max_length=50, primary_key=True, default=lambda: str(uuid.uuid4()), verbose_name="初审报告唯一ID") <NEW_LINE> project_id = models.ForeignKey(ProjectSingle) <NEW_LINE> original = models.ForeignKey(ProjectEnterpriseOrigin, blank=False, n... | inheribit table, which use ProjectSingle to show pre-submit content for Enterprise project | 625990318a43f66fc4bf3249 |
class UndoWrongStateError(UndoError): <NEW_LINE> <INDENT> pass | Exception related to the current state of the undo/redo stack. | 625990318c3a8732951f761a |
class DescriptorSetHeader(usb_descriptors.DescriptorContainer): <NEW_LINE> <INDENT> pass | Microsoft OS 2.0 descriptor set header.
| 62599031d18da76e235b79af |
class ExperienceReplay(object): <NEW_LINE> <INDENT> memory = 1000 <NEW_LINE> def __init__(self, model, experiences=[]): <NEW_LINE> <INDENT> self.experiences = experiences <NEW_LINE> self.model = model <NEW_LINE> <DEDENT> def collect(self, strategy, epochs=10, verbose=False): <NEW_LINE> <INDENT> max_score = 0 <NEW_LINE>... | Class to encapsulate functions acting on a batch of experiences. | 62599031d164cc6175822034 |
class Chromecast(object): <NEW_LINE> <INDENT> def __init__(self, host): <NEW_LINE> <INDENT> self.logger = logging.getLogger(__name__) <NEW_LINE> self.host = host <NEW_LINE> self.logger.info("Querying device status") <NEW_LINE> self.device = get_device_status(self.host) <NEW_LINE> if not self.device: <NEW_LINE> <INDENT>... | Class to interface with a ChromeCast. | 625990316fece00bbaccca71 |
@implementer(IOrdering) <NEW_LINE> @adapter(IOrderableFolder) <NEW_LINE> class UnorderedOrdering(object): <NEW_LINE> <INDENT> def __init__(self, context): <NEW_LINE> <INDENT> self.context = context <NEW_LINE> <DEDENT> def notifyAdded(self, obj_id): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def notifyRemoved(self, ob... | This implementation provides no ordering. | 625990315e10d32532ce4164 |
class TestSetDiscountEffectProps(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def make_instance(self, include_optional): <NEW_LINE> <INDENT> if include_optional : <NEW_LINE> <INDENT> return SetDisco... | SetDiscountEffectProps unit test stubs | 6259903163f4b57ef00865d4 |
class PoemSerializer(serializers.ModelSerializer): <NEW_LINE> <INDENT> genre = serializers.SlugRelatedField(queryset=Genre.objects.all(), slug_field='name') <NEW_LINE> user = UserSerializer(read_only=True) <NEW_LINE> categories = serializers.SlugRelatedField(queryset=Category.objects.all(), slug_field='name', many=True... | Serializer for creating a poem | 625990319b70327d1c57fe47 |
class _LegacyRebatchDataset(dataset_ops.UnaryDataset): <NEW_LINE> <INDENT> def __init__(self, input_dataset, num_replicas): <NEW_LINE> <INDENT> def recalculate_batch_size(type_spec): <NEW_LINE> <INDENT> output_shape = type_spec._to_legacy_output_shapes() <NEW_LINE> if not isinstance(output_shape, tensor_shape.TensorSha... | A `Dataset` that divides its input batches into `num_replicas` sub-batches.
For each batch in the input dataset, _LegacyRebatchDataset will produce
`num_replicas` smaller batches whose sizes add up to the original batch size.
For example:
```python
ds = tf.data.Dataset.range(8)
ds = ds.batch(4)
ds = _LegacyRebatchDa... | 6259903191af0d3eaad3aef0 |
class QtWindowLayout(QLayout): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(QtWindowLayout, self).__init__(*args, **kwargs) <NEW_LINE> self._layout_item = None <NEW_LINE> <DEDENT> def addItem(self, item): <NEW_LINE> <INDENT> self._layout_item = item <NEW_LINE> self.update() <NEW_LI... | A QLayout subclass which can have at most one layout item. This
layout item is expanded to fit the allowable space, regardless of its
size policy settings. This is similar to how central widgets behave
in a QMainWindow.
The class is designed for use by QtWindow/QtDialog, other uses are at
the user's own risk. | 62599032ac7a0e7691f735ab |
class LatestDiscussions(DiscussionFeed): <NEW_LINE> <INDENT> def items(self): <NEW_LINE> <INDENT> content_type = ContentType.objects.get_for_model(Entry) <NEW_LINE> return comments.get_model().objects.filter( content_type=content_type, is_public=True).order_by( '-submit_date')[:FEEDS_MAX_ITEMS] <NEW_LINE> <DEDENT> def ... | Feed for the latest discussions. | 62599032ec188e330fdf9957 |
class HDAExtended(HDADetailed): <NEW_LINE> <INDENT> tool_version: str = Field( ..., title="Tool Version", description="The version of the tool that produced this dataset.", ) <NEW_LINE> parent_id: Optional[EncodedDatabaseIdField] = Field( None, title="Parent ID", description="TODO", ) <NEW_LINE> designation: Optional[s... | History Dataset Association extended information. | 62599032d10714528d69eeed |
class CustomerModelAdmin(admin.ModelAdmin): <NEW_LINE> <INDENT> pass | Customer admin class. | 6259903296565a6dacd2d7ef |
@add_common_get_method <NEW_LINE> class WorksService(ServiceBase): <NEW_LINE> <INDENT> path = 'works' <NEW_LINE> allowed_params = ['fields', 'filter_ids', 'filter_season', 'filter_title', 'page', 'per_page', 'sort_id' 'sort_season', 'sort_watchers_count'] <NEW_LINE> payload_type = 'work' | :reference: https://annict.wikihub.io/wiki/api/works | 625990328a349b6b43687301 |
class GetXlsxStylesResponse(object): <NEW_LINE> <INDENT> swagger_types = { 'successful': 'bool', 'cell_styles': 'list[DocxCellStyle]' } <NEW_LINE> attribute_map = { 'successful': 'Successful', 'cell_styles': 'CellStyles' } <NEW_LINE> def __init__(self, successful=None, cell_styles=None): <NEW_LINE> <INDENT> self._succe... | NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. | 62599032d53ae8145f919527 |
class ReflexAgent(Agent): <NEW_LINE> <INDENT> def getAction(self, gameState): <NEW_LINE> <INDENT> legalMoves = gameState.getLegalActions() <NEW_LINE> scores = [self.evaluationFunction(gameState, action) for action in legalMoves] <NEW_LINE> bestScore = max(scores) <NEW_LINE> bestIndices = [index for index in range(len(s... | A reflex agent chooses an action at each choice point by examining
its alternatives via a state evaluation function.
The code below is provided as a guide. You are welcome to change
it in any way you see fit, so long as you don't touch our method
headers. | 625990321d351010ab8f4bdc |
class AASTexHeader(LatexHeader): <NEW_LINE> <INDENT> header_start = r'\tablehead' <NEW_LINE> splitter_class = AASTexHeaderSplitter <NEW_LINE> def start_line(self, lines): <NEW_LINE> <INDENT> return find_latex_line(lines, r'\tablehead') <NEW_LINE> <DEDENT> def write(self, lines): <NEW_LINE> <INDENT> if not 'col_align' i... | In a `deluxetable
<http://fits.gsfc.nasa.gov/standard30/deluxetable.sty>`_ some header
keywords differ from standard LaTeX.
This header is modified to take that into account. | 62599032cad5886f8bdc58dd |
class IGeoTrackViewLayer(Interface): <NEW_LINE> <INDENT> pass | A layer specific to collective.geo.trackview | 625990326fece00bbaccca73 |
class Case_Construct(BlockBase): <NEW_LINE> <INDENT> subclass_names = [] <NEW_LINE> use_names = ['Select_Case_Stmt', 'Case_Stmt', 'End_Select_Stmt', 'Execution_Part_Construct'] <NEW_LINE> @staticmethod <NEW_LINE> def match(reader): <NEW_LINE> <INDENT> return BlockBase.match(Select_Case_Stmt, [Case_Stmt, Execution_Part_... | <case-construct> = <select-case-stmt>
[ <case-stmt>
<block> == [<execution-part-construct>]..
]..
<end-select-stmt> | 625990325166f23b2e24449b |
class EventCategory(SimpleTranslationMixin, models.Model): <NEW_LINE> <INDENT> position = models.PositiveIntegerField( verbose_name=_('Position'), null=True, blank=True, ) <NEW_LINE> slug = models.CharField( max_length=32, verbose_name=_('Slug'), ) <NEW_LINE> def __unicode__(self): <NEW_LINE> <INDENT> return self.get_t... | Events are grouped in categories.
For translateable fields see ``EventCategoryTitle``.
:position: Use this if you want to change the ordering of categories. | 62599032b57a9660fecd2b49 |
class State(Base): <NEW_LINE> <INDENT> __tablename__ = 'states' <NEW_LINE> id = Column(Integer, primary_key=True, autoincrement=True, nullable=False) <NEW_LINE> name = Column(String(128), nullable=False) | make base | 6259903207d97122c4217d6d |
class TestForexPair(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def testForexPair(self): <NEW_LINE> <INDENT> pass | ForexPair unit test stubs | 625990321d351010ab8f4bde |
class Enforcer(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.default_rule = CONF.policy_default_rule <NEW_LINE> self.policy_path = self._find_policy_file() <NEW_LINE> self.policy_file_mtime = None <NEW_LINE> self.policy_file_contents = None <NEW_LINE> <DEDENT> def set_rules(self, rules): <NE... | Responsible for loading and enforcing rules | 62599032b830903b9686ecdd |
class geo_app(): <NEW_LINE> <INDENT> gmaps = googlemaps.Client(key=maps_token) <NEW_LINE> def __init__(self, filename="../data/database.csv"): <NEW_LINE> <INDENT> self.data = pd.read_csv(filename) <NEW_LINE> self.name = "DisAtBot - Report database" <NEW_LINE> <DEDENT> def append_data(self, lat, lon): <NEW_LINE> <INDENT... | Geolocation application class to interact with VIObot, making
him able to access and append data from the report database. | 625990328c3a8732951f761f |
class TestStateNeedsDirectorReview(UWOshOIETestCase): <NEW_LINE> <INDENT> def afterSetUp(self): <NEW_LINE> <INDENT> self.acl_users = self.portal.acl_users <NEW_LINE> self.portal_workflow = self.portal.portal_workflow <NEW_LINE> self.portal_registration = self.portal.portal_registration <NEW_LINE> self.mockMailHost() <N... | Ensure product is properly installed | 6259903296565a6dacd2d7f1 |
class CNNText_plus(CNNText): <NEW_LINE> <INDENT> def __init__(self,num_classes,embed=None,bert_model =bert_model_real, input_dims =config.hidden_size,kernel_nums=(30, 40, 50),kernel_sizes=(1, 3, 5),dpot =0.5): <NEW_LINE> <INDENT> super(CNNText_plus, self).__init__(embed =embed, num_classes=num_classes, bert_model=bert_... | 基于
使用CNN进行文本分类的模型
'Yoon Kim. 2014. Convolution Neural Networks for Sentence Classification.'
更改了CNNText模型的初始化参数,变为bert+CNNText模型 | 625990321f5feb6acb163cb8 |
class TestKiraSensor(unittest.TestCase): <NEW_LINE> <INDENT> DEVICES = [] <NEW_LINE> def add_devices(self, devices): <NEW_LINE> <INDENT> for device in devices: <NEW_LINE> <INDENT> self.DEVICES.append(device) <NEW_LINE> <DEDENT> <DEDENT> def setUp(self): <NEW_LINE> <INDENT> self.hass = get_test_home_assistant() <NEW_LIN... | Tests the Kira Sensor platform. | 62599032d18da76e235b79b2 |
class TopicContinuumIterator(GenIterator): <NEW_LINE> <INDENT> def __init__(self, topic_continuum): <NEW_LINE> <INDENT> self.__objs = [] <NEW_LINE> self.__topic_continuum = topic_continuum <NEW_LINE> for vcs_id in topic_continuum.get_vcs_commit_ids(): <NEW_LINE> <INDENT> self.__objs.append([vcs_id, topic_continuum.get_... | This class provides an iterator interface for all the subelements
of a topic continuum. | 625990321d351010ab8f4be0 |
class HelperTests(UnitTest): <NEW_LINE> <INDENT> def test_logErrorsInThreads(self): <NEW_LINE> <INDENT> self.pool, self.doThreadWork = deterministicPool() <NEW_LINE> def divideByZero(): <NEW_LINE> <INDENT> return 1 / 0 <NEW_LINE> <DEDENT> self.pool.callInThread(divideByZero) <NEW_LINE> self.doThreadWork() <NEW_LINE> se... | Tests for error cases of helpers used in this module. | 6259903226238365f5fadc1a |
class Ship(Sprite): <NEW_LINE> <INDENT> def __init__(self, filename): <NEW_LINE> <INDENT> super(Ship, self).__init__(filename) <NEW_LINE> self.bullets = [] <NEW_LINE> for i in range(0, 10): <NEW_LINE> <INDENT> self.bullets.append(Bullet('shot.png')) <NEW_LINE> <DEDENT> self.cool_down = 0.15 <NEW_LINE> self.cool_down_t ... | The Player class | 6259903266673b3332c314b9 |
class SmartItem(base.ItemBase): <NEW_LINE> <INDENT> def __init__(self, key, value, host): <NEW_LINE> <INDENT> super(SmartItem, self).__init__(key, value, host) <NEW_LINE> self._data = {} <NEW_LINE> self._generate() <NEW_LINE> <DEDENT> @property <NEW_LINE> def data(self): <NEW_LINE> <INDENT> return self._data <NEW_LINE>... | Enqued item. | 625990323eb6a72ae038b72f |
class AIController(Controller): <NEW_LINE> <INDENT> def __init__(self,mode="AlphaBeta",max_depth=5): <NEW_LINE> <INDENT> super().__init__(is_ai = True) <NEW_LINE> self.__engine = SearchEngine(mode = mode, max_depth = max_depth) <NEW_LINE> self.average_time = 0 <NEW_LINE> self.average_nodes = 0 <NEW_LINE> self.moves = 0... | Utilizes AlphaBeta pruning to determine the next state | 625990329b70327d1c57fe4d |
class Magic(BaseField): <NEW_LINE> <INDENT> def __init__(self, expected_sequence, **kwargs): <NEW_LINE> <INDENT> BaseField.__init__(self, **kwargs) <NEW_LINE> self.expected_sequence = expected_sequence <NEW_LINE> self.bytes_required = len(self.expected_sequence) <NEW_LINE> <DEDENT> def getval(self): <NEW_LINE> <INDENT>... | Represent Byte Magic (fixed, expected sequence of bytes) | 625990320a366e3fb87ddaaf |
class ChannelAttn(nn.Module): <NEW_LINE> <INDENT> def __init__(self, in_channels, reduction_rate=16): <NEW_LINE> <INDENT> super(ChannelAttn, self).__init__() <NEW_LINE> assert in_channels%reduction_rate == 0 <NEW_LINE> self.conv1 = ConvBlock(in_channels, in_channels // reduction_rate, 1) <NEW_LINE> self.conv2 = ConvBlo... | Channel Attention (Sec. 3.1.I.2) | 62599032ec188e330fdf995d |
class IsAuthenticatedAndOwner(BasePermission): <NEW_LINE> <INDENT> def has_object_permission(self, request, view, obj): <NEW_LINE> <INDENT> return bool(request.user and request.user.is_authenticated and (obj.user == request.user)) | Разрешает доступ только аутентифицированным пользователям и владельцам. | 62599032d6c5a102081e31ef |
class InventoryResponse(Response): <NEW_LINE> <INDENT> def __init__(self, address, command, status, tags): <NEW_LINE> <INDENT> super().__init__(address, command, status, None) <NEW_LINE> self.tags = tags <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return "<%s %s tags>" % (self.__class__.__name__, len(se... | Handles decoding data properly, and also potentially errors or multiple returns. | 6259903276d4e153a661dad5 |
class PlottingView(QWidget): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(PlottingView, self).__init__() <NEW_LINE> self.setWindowIcon(QIcon('viraclogo.png')) <NEW_LINE> self.center() <NEW_LINE> self.grid = QGridLayout() <NEW_LINE> <DEDENT> def add_widget(self, widget, row, colomn): <NEW_LINE> <IND... | Base class for all views | 62599032d10714528d69eef0 |
class BooleanToolParameter(ToolParameter): <NEW_LINE> <INDENT> def __init__(self, tool, input_source): <NEW_LINE> <INDENT> input_source = ensure_input_source(input_source) <NEW_LINE> ToolParameter.__init__(self, tool, input_source) <NEW_LINE> self.truevalue = input_source.get('truevalue', 'true') <NEW_LINE> self.falsev... | Parameter that takes one of two values.
>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = BooleanToolParameter(None, XML('<param name="_name" type="boolean" checked="yes" truevalue="_truevalue" falsevalue="_falsevalue" />'))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans)... | 625990328c3a8732951f7622 |
class DNAME(dns.rdtypes.nsbase.UncompressedNS): <NEW_LINE> <INDENT> pass | DNAME record | 6259903207d97122c4217d71 |
class ProofRequest(IndyServiceRep): <NEW_LINE> <INDENT> _fields = ( ("data", dict), ("wql_filters", dict, None), ) | A message representing an Indy proof request | 62599032d164cc617582203c |
class TargetLessTestCase(TestCaseWithFactory): <NEW_LINE> <INDENT> layer = DatabaseFunctionalLayer <NEW_LINE> def test_project_group_structural_subscription(self): <NEW_LINE> <INDENT> subscriber = self.factory.makePerson() <NEW_LINE> product = self.factory.makeProduct() <NEW_LINE> self.factory.makeBug(target=product) <... | Test that do not call setTarget() in the BugTaskSearchParams. | 62599032be8e80087fbc0146 |
class PipeToLoggerMixin(): <NEW_LINE> <INDENT> from logging import DEBUG, INFO <NEW_LINE> DEFAULT_LINE_TIMEOUT = 10 * 60 <NEW_LINE> DEFAULT_STDOUT = "INFO" <NEW_LINE> DEFAULT_STDERR = "DEBUG" <NEW_LINE> def pipe(self, out_level=None, err_level=None, prefix=None, line_timeout=None, **kw): <NEW_LINE> <INDENT> class LogPi... | This mixin allows piping plumbum commands' output into a logger.
The logger must implement a ``log(level, msg)`` method, as in ``logging.Logger``
Example::
class MyLogger(logging.Logger, PipeToLoggerMixin):
pass
logger = MyLogger("example.app")
Here we send the output of an install.sh script into ou... | 62599032b830903b9686ecdf |
@ui.register_ui(field_username=ui.TextField(By.NAME, 'username'), field_password=ui.TextField(By.NAME, 'password')) <NEW_LINE> class FormLogin(_ui.Form): <NEW_LINE> <INDENT> pass | Form to login user. | 6259903230c21e258be998d7 |
@zope.interface.implementer(interfaces.IAuthenticator) <NEW_LINE> @zope.interface.provider(interfaces.IPluginFactory) <NEW_LINE> class Authenticator(dns_route53.Authenticator): <NEW_LINE> <INDENT> hidden = True <NEW_LINE> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> warnings.warn("The 'authenticator' module... | Shim around `~certbot_dns_route53.dns_route53.Authenticator` for backwards compatibility. | 625990323eb6a72ae038b731 |
class TravellingSalesmanProblem(Annealer): <NEW_LINE> <INDENT> def __init__(self, state, module, graph, coordinates): <NEW_LINE> <INDENT> self.graph = graph <NEW_LINE> self.total_pr_entropy = sum([entropy1(graph.node[node][PAGE_RANK]) for node in graph]) <NEW_LINE> self.module = [Module(module_id, mod, g... | Test annealer with a travelling salesman problem.
| 625990320a366e3fb87ddab1 |
class BaseError(Exception): <NEW_LINE> <INDENT> def __init__(self, message: typing.Optional[str] = None) -> None: <NEW_LINE> <INDENT> self.msg = message <NEW_LINE> <DEDENT> def __str__(self) -> str: <NEW_LINE> <INDENT> return repr(self.msg) | For generic errors not covered by other exceptions | 62599032e76e3b2f99fd9ad7 |
class TestsPerfilesConsumo(TestCase): <NEW_LINE> <INDENT> def test_0_perfiles_estimados_2017(self): <NEW_LINE> <INDENT> from esiosdata.perfilesconsumopvpc import get_data_perfiles_estimados_2017, get_data_perfiles_finales_mes <NEW_LINE> perfiles_2017 = get_data_perfiles_estimados_2017(force_download=False) <NEW_LINE> p... | Tests para el cálculo de los perfiles de consumo. | 6259903291af0d3eaad3aef8 |
class AuthTokenSerializer(serializers.Serializer): <NEW_LINE> <INDENT> def create(self, validated_data): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def update(self, instance, validated_data): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> username = serializers.CharField() <NEW_LINE> password = serializers.CharField( s... | Serializer para o objetos de autenticação de usuários | 6259903230c21e258be998d8 |
class NowProlog(IpythonCommandMagic): <NEW_LINE> <INDENT> def add_arguments(self): <NEW_LINE> <INDENT> super(NowProlog, self).add_arguments() <NEW_LINE> add_arg = self.add_argument <NEW_LINE> add_arg("--result", type=str, help="""The variable in which the result will be stored""") <NEW_LINE> add_arg("trials", nargs=arg... | Query the provenance database with Prolog
Examples
--------
::
In [1]: %%now_prolog 1
...: duration(1, z, X)
Out [1]: [{'X': 0.10173702239990234},
...: {'X': 0.10082292556762695},
...: {'X': 0.1021270751953125},
...: {'X': 0.10217714309692383}]
In [2]: %%now_prolog --r... | 6259903271ff763f4b5e8863 |
class ManagedZonesListResponse(_messages.Message): <NEW_LINE> <INDENT> header = _messages.MessageField('ResponseHeader', 1) <NEW_LINE> kind = _messages.StringField(2, default=u'dns#managedZonesListResponse') <NEW_LINE> managedZones = _messages.MessageField('ManagedZone', 3, repeated=True) <NEW_LINE> nextPageToken = _me... | A ManagedZonesListResponse object.
Fields:
header: A ResponseHeader attribute.
kind: Type of resource.
managedZones: The managed zone resources.
nextPageToken: The presence of this field indicates that there exist more
results following your last page of results in pagination order. To
fetch them, make... | 625990328a349b6b43687309 |
class DatabaseClient: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def connect(self, **args): <NEW_LINE> <INDENT> return True | Base database client | 625990328a43f66fc4bf3253 |
@total_ordering <NEW_LINE> class SavedRoll(Base): <NEW_LINE> <INDENT> __tablename__ = 'saved_rolls' <NEW_LINE> id = sqla.Column(sqla.Integer, primary_key=True) <NEW_LINE> name = sqla.Column(sqla.String(LEN_NAME)) <NEW_LINE> roll_str = sqla.Column(sqla.String(LEN_ROLLSTR)) <NEW_LINE> user_id = sqla.Column(sqla.String(LE... | Represents a saved dice roll associated to a name. | 625990326fece00bbaccca7c |
class DbIndexNameTestCase(TestCase): <NEW_LINE> <INDENT> LIMIT = 65 <NEW_LINE> def test_index_name_length(self): <NEW_LINE> <INDENT> db_name = "st2" <NEW_LINE> for model in ALL_MODELS: <NEW_LINE> <INDENT> collection_name = model._get_collection_name() <NEW_LINE> model_indexes = model._meta["index_specs"] <NEW_LINE> for... | Test which verifies that model index name are not longer than the specified limit. | 6259903226068e7796d4da17 |
class MarkdownUtil(object): <NEW_LINE> <INDENT> def head(self,text,level = 1,enter_num = 1): <NEW_LINE> <INDENT> return '{mark} {text}{enter}'.format(mark = '#' * level,text = text,enter = '\n' * enter_num) <NEW_LINE> <DEDENT> def bold(self,text,enter_num = 1): <NEW_LINE> <INDENT> return '**{text}**{enter}'.format(text... | markdown文本处理工具类 | 625990329b70327d1c57fe51 |
class BaseHandler(webapp2.RequestHandler): <NEW_LINE> <INDENT> @webapp2.cached_property <NEW_LINE> def jinja2(self): <NEW_LINE> <INDENT> return jinja2.get_jinja2(app=self.app) <NEW_LINE> <DEDENT> def render_template(self, filename, template_args): <NEW_LINE> <INDENT> self.response.write(self.jinja2.render_template(file... | The other handlers inherit from this class. Provides some helper methods
for rendering a template. | 62599032d4950a0f3b1116a4 |
class TestListenable(unittest.TestCase): <NEW_LINE> <INDENT> class _IntListenable(Listenable[int]): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def setUp(self): <NEW_LINE> <INDENT> self._listenable = TestListenable._IntListenable() <NEW_LINE> <DEDENT> def test_add_listener_and_get_update_listeners(self): <NEW_LINE> <I... | Tests for `Listenable` model. | 6259903230c21e258be998d9 |
class ProductInfoServicer(object): <NEW_LINE> <INDENT> def getProductDetails(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | Missing associated documentation comment in .proto file. | 6259903250485f2cf55dc04a |
class TransformedRNNModel(TransformedModel): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(TransformedRNNModel, self).__init__(*args, **kwargs) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def default( cls, environment, dim_hidden_state, base_model=None, model_kind="dynamics", transf... | Transformed Model computes the next state distribution. | 625990321d351010ab8f4be7 |
class Chi5Class(ResidueFixedBins): <NEW_LINE> <INDENT> _setup = _mdt.mdt_feature_chi5_class | Residue chi5 dihedral class. | 625990329b70327d1c57fe53 |
class NamespaceNotFoundError(CumulusCIUsageError): <NEW_LINE> <INDENT> pass | Raise when namespace is not found in project includes | 6259903263f4b57ef00865da |
class Evaluator: <NEW_LINE> <INDENT> def __init__(self, X, options, parameters=None, definitions=None, features=None, distances=None, precompute=None, labels=None, verbose=True): <NEW_LINE> <INDENT> self.generator = ClusterGenerator(X, options=options, parameters=parameters, definitions=definitions, features=features, ... | Evaluate given or sampled clusterings.
The Evaluator can be used in two ways. The first is to provide a list
of clustering configurations and evaluation metrics to be computed for each
one. The second way is to sample clustering configurations and score them
according to a given metric, performing a random search in t... | 62599032a8ecb033258722ec |
class DispatchProcessingHandler: <NEW_LINE> <INDENT> def __init__( self, *, messenger: 'MessengerBase', messages: Optional[List[MessageTuple]] = None ): <NEW_LINE> <INDENT> self.messenger = messenger <NEW_LINE> self.dispatches = ( chain.from_iterable(( dispatch for dispatch in (item.dispatches for item in messages) )) ... | Context manager to facilitate exception handling on various
messages processing stages. | 62599032711fe17d825e1502 |
class TestV1RBDVolumeSource(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def testV1RBDVolumeSource(self): <NEW_LINE> <INDENT> model = lib_openshift.models.v1_rbd_volume_source.V1RBDVolumeSource() | V1RBDVolumeSource unit test stubs | 625990328c3a8732951f7628 |
class LinkToOrderViewletTestCase(IntegrationTestCase): <NEW_LINE> <INDENT> def test_subclass(self): <NEW_LINE> <INDENT> from plone.app.layout.viewlets.common import ViewletBase as Base <NEW_LINE> self.assertTrue(issubclass(LinkToOrderViewlet, Base)) <NEW_LINE> from collective.base.interfaces import IViewlet as Base <NE... | TestCase for LinkToOrderViewlet | 62599032cad5886f8bdc58e3 |
class TipoLugar(models.Model): <NEW_LINE> <INDENT> nombre = models.CharField(max_length=50, blank=True) <NEW_LINE> codigo = models.CharField(max_length=50, default='', unique=True, blank=True) <NEW_LINE> def save(self): <NEW_LINE> <INDENT> self.nombre = self.nombre.lower() <NEW_LINE> self.codi... | Sirve para clasificar los lugares que encuentra el ciclista, como
talleres o biciestacionamientos | 625990323eb6a72ae038b737 |
class case_always_fail(object): <NEW_LINE> <INDENT> def test(self, handler): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> def act(self, handler): <NEW_LINE> <INDENT> raise ServerException("Unknown object '{0}'".format(handler.path[1:])) | 所有情况都不符合时的默认处理类 | 6259903223e79379d538d5da |
class MetaEgg(type): <NEW_LINE> <INDENT> accessors = { 'get': ('getter', 0), 'is': ('getter', 0), 'set': ('setter', 1), 'del': ('deller', 0), } <NEW_LINE> def __init__(cls, name, bases, dict): <NEW_LINE> <INDENT> cls.createProperties(dict) <NEW_LINE> super(MetaEgg, cls).__init__(name, bases, dict) <NEW_LINE> <DEDENT> d... | PythonEgg metaclass
| 625990328e05c05ec3f6f6c3 |
class Datetime(Field): <NEW_LINE> <INDENT> type = 'datetime' <NEW_LINE> @staticmethod <NEW_LINE> def now(*args): <NEW_LINE> <INDENT> return datetime.now().strftime(DATETIME_FORMAT) <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def context_timestamp(record, timestamp): <NEW_LINE> <INDENT> assert isinstance(timestamp, dat... | Datetime field. | 6259903230c21e258be998de |
class BERTScope_TCP(BERTScope, Mainframe, Detector, ErrorQueueImplementation, ErrorQueueInstrument, IEEE4882SubsetMixin, IORateLimiterMixin, TCPDriver): <NEW_LINE> <INDENT> ENCODING = 'latin1' | Tektronix BERTScope TCP Driver
| 62599032d53ae8145f919535 |
class TaskLocation(models.Model): <NEW_LINE> <INDENT> location = models.ForeignKey( "location.MapLocation", on_delete=models.CASCADE, related_name="tasklocation_location", ) <NEW_LINE> address = models.TextField() <NEW_LINE> zip = models.CharField(max_length=6,) | Generated Model | 6259903271ff763f4b5e886a |
class Tower: <NEW_LINE> <INDENT> def __init__(self, frequency, earth_resistivity): <NEW_LINE> <INDENT> self.freq = frequency <NEW_LINE> self.ro = earth_resistivity <NEW_LINE> self.lines = list() <NEW_LINE> self.conductors = list() <NEW_LINE> self.positions = list() <NEW_LINE> self.neutral = None <NEW_LINE> self.neutral... | Tower that can contain many parallel circuits | 62599032a4f1c619b294f6c9 |
class BaseSeries: <NEW_LINE> <INDENT> is_2Dline = False <NEW_LINE> is_3Dline = False <NEW_LINE> is_3Dsurface = False <NEW_LINE> is_contour = False <NEW_LINE> is_implicit = False <NEW_LINE> is_parametric = False <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> <DEDENT> @property <NEW_LINE... | Base class for the data objects containing stuff to be plotted.
Explanation
===========
The backend should check if it supports the data series that it's given.
(eg TextBackend supports only LineOver1DRange).
It's the backend responsibility to know how to use the class of
data series that it's given.
Some data serie... | 625990326e29344779b01723 |
class AzureFirewallNatRule(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'source_addresses': {'key': 'sourceAddresses', 'type': '[str]'}, 'destination_addresses': {'key': 'destinationAddresses', 'type': '... | Properties of a NAT rule.
:param name: Name of the NAT rule.
:type name: str
:param description: Description of the rule.
:type description: str
:param source_addresses: List of source IP addresses for this rule.
:type source_addresses: list[str]
:param destination_addresses: List of destination IP addresses for this ... | 625990328c3a8732951f762b |
class TestTokenizationPreAuthPagedMetadata(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def testTokenizationPreAuthPagedMetadata(self): <NEW_LINE> <INDENT> model = billforward.models.tokenization_pr... | TokenizationPreAuthPagedMetadata unit test stubs | 625990328a349b6b43687311 |
class MaterialSchema(Model): <NEW_LINE> <INDENT> def __init__(self, type: str=None): <NEW_LINE> <INDENT> self.swagger_types = { 'type': str } <NEW_LINE> self.attribute_map = { 'type': 'type' } <NEW_LINE> self._type = type <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def from_dict(cls, dikt) -> 'MaterialSchema': <NEW_LIN... | NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. | 62599032c432627299fa40ca |
class SignupHandler(AreaRequestHandler): <NEW_LINE> <INDENT> def get(self, **kwargs): <NEW_LINE> <INDENT> if self.current_user is not None: <NEW_LINE> <INDENT> return redirect(request.args.get('redirect', '/')) <NEW_LINE> <DEDENT> current_user = users.get_current_user() <NEW_LINE> values = {} <NEW_LINE> if current_user... | Performs signup after first login or creates a new account. The
difference is that new accounts require a password and extenal auth not. | 625990321d351010ab8f4bed |
class ZWSwitch(ZWDevice): <NEW_LINE> <INDENT> async def __init__(self, id_, zwid, endpoint=1, mqtt_prefix="zwave"): <NEW_LINE> <INDENT> await super().__init__(id_, zwid, mqtt_prefix) <NEW_LINE> await super().init_state({'switch': False, "power": 0}) <NEW_LINE> self.zwstates["switch"] = f"37/{endpoint}/0" <NEW_LINE> sel... | ZWave Switch. | 6259903291af0d3eaad3af02 |
class TCPStream(): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.src_addr = None <NEW_LINE> self.src_port = None <NEW_LINE> self.dest_addr = None <NEW_LINE> self.dest_port = None <NEW_LINE> self.packets = [] <NEW_LINE> self.first_timestamp = 0 <NEW_LINE> self.last_timestamp = 0 <NEW_LINE> self.packet... | TCP packet allocation | 625990325e10d32532ce416d |
class RemoveDatatype: <NEW_LINE> <INDENT> def filter(self, node): <NEW_LINE> <INDENT> return is_operator_app(node, 'declare-datatypes') <NEW_LINE> <DEDENT> def mutations(self, node): <NEW_LINE> <INDENT> if len(node) != 3 or len(node[1]) != len(node[2]): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for i in range(len(... | Remove a datatype from a recursive datatype declaration. | 625990328c3a8732951f762d |
class DBController(): <NEW_LINE> <INDENT> def __init__(self, host="localhost", user="root", passwd="root", port=3306, db="spider_data"): <NEW_LINE> <INDENT> import pymysql <NEW_LINE> from pymysql.err import IntegrityError <NEW_LINE> self._conn = pymysql.connect(host=host,port=port,user=user, passwd=passwd,db=db,charset... | 数据库操作模块
可访问成员(函数):
- cur
- IntegrityError
- execute(sql)
- close | 6259903230c21e258be998e2 |
@datatasks("information retrieval") <NEW_LINE> class Adhoc(Base): <NEW_LINE> <INDENT> documents: Param[AdhocDocuments] <NEW_LINE> topics: Param[AdhocTopics] <NEW_LINE> assessments: Param[AdhocAssessments] | An Adhoc IR collection | 625990328c3a8732951f762e |
class AnnouncementFeed(Feed): <NEW_LINE> <INDENT> def get_object(self, request, course_slug): <NEW_LINE> <INDENT> return get_object_or_404(Course, slug=course_slug) <NEW_LINE> <DEDENT> def title(self, obj): <NEW_LINE> <INDENT> return _("Announcements of %(course_title)s") % {"course_title": obj.name} <NEW_LINE> <DEDENT... | Default RSS feed for the course announcements.
:returns: RSS Feed
.. versionadded:: 0.1 | 625990326fece00bbaccca85 |
class EvenStShotCt(ShotEventTallyBase): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(EvenStShotCt, self).__init__( count_play=lambda play: isinstance(play.event, EV.Shot) and play.strength == St.Even ) | Tallies even strength shots on goal for each team. Increments if
* the play event inherits from :py:class:`.Shot`
* play happened at even strength | 62599032d18da76e235b79b9 |
class SwarmMissingNodeError(Exception): <NEW_LINE> <INDENT> pass | Raised if some nodes have not joined the cluster | 62599032d164cc6175822048 |
class ImportManager: <NEW_LINE> <INDENT> def __init__(self, imports): <NEW_LINE> <INDENT> self.dynamic_registration = any( statement.module == '__gin__.dynamic_registration' for statement in imports) <NEW_LINE> self.imports = [] <NEW_LINE> self.module_selectors = {} <NEW_LINE> self.names = set() <NEW_LINE> for statemen... | Manages imports required when writing out a full config string.
This class does bookkeeping to ensure each import is only output once, and
that each import receives a unique name/alias to avoid collisions. | 62599032ac7a0e7691f735be |
class CloakMiddleware(inherit_from): <NEW_LINE> <INDENT> def process_request(self, request): <NEW_LINE> <INDENT> request.user.is_cloaked = False <NEW_LINE> if SESSION_USER_KEY in request.session: <NEW_LINE> <INDENT> User = get_user_model() <NEW_LINE> try: <NEW_LINE> <INDENT> user = User._default_manager.get(pk=request.... | This middleware class checks to see if a cloak session variable is
set, and overrides the request.user object with the cloaked user | 62599032d6c5a102081e31fd |
class App_fltk(App_base): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> import fltk as fl <NEW_LINE> import types <NEW_LINE> def dummyrun(*args, **kwargs): <NEW_LINE> <INDENT> print_mainloop_warning() <NEW_LINE> <DEDENT> fl.Fl.run = types.MethodType(dummyrun, fl.Fl) <NEW_LINE> self.app = fl.Fl <NEW_LINE> ... | Hijack fltk 1.
This one is easy. Just call fl.wait(0.0) now and then.
Note that both tk and fltk try to bind to PyOS_InputHook. Fltk
will warn about not being able to and Tk does not, so we should
just hijack (import) fltk first. The hook that they try to fetch
is not required in pyzo, because the pyzo interpreter will... | 62599032d53ae8145f91953b |
class RainCommand(commands.Command): <NEW_LINE> <INDENT> def __init__(self, callback: Callable, **kwargs: Any) -> None: <NEW_LINE> <INDENT> super().__init__(callback, **kwargs) <NEW_LINE> self.perm_level = kwargs.get('perm_level', 0) <NEW_LINE> self.checks.append(check_perm_level) <NEW_LINE> <DEDENT> @property <NEW_LIN... | Overwrites the default Command to use permission levels,
overwrites signature to hide aliases | 625990326fece00bbaccca87 |
class LibraryImportManager(ImportManager): <NEW_LINE> <INDENT> store_class = LibraryXMLModuleStore <NEW_LINE> def get_dest_id(self, courselike_key): <NEW_LINE> <INDENT> if self.target_id is not None: <NEW_LINE> <INDENT> dest_id = self.target_id <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dest_id = LibraryLocator(self... | Import manager for Libraries | 62599032d99f1b3c44d0677a |
class ObjectCategories(): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> fname = "ModelCategoryMapping.csv" <NEW_LINE> self.model_to_categories = {} <NEW_LINE> root_dir = os.path.dirname(os.path.abspath(__file__)) <NEW_LINE> model_cat_file = f"{root_dir}/{fname}" <NEW_LINE> with open(model_cat_file, "r") a... | Determine which categories does each object belong to | 625990321d351010ab8f4bf0 |
class GhdlPragmaHandler: <NEW_LINE> <INDENT> _PRAGMA = re.compile( r"\s*--\s*ghdl\s+translate_off[\r\n].*?[\n\r]\s*--\s*ghdl\s+translate_on", flags=re.DOTALL | re.I | re.MULTILINE, ) <NEW_LINE> def run(self, code, file_name): <NEW_LINE> <INDENT> for word in ("ghdl", "translate_on", "translate_off"): <NEW_LINE> <INDENT>... | Removes code between arbitraty pragmas
-- ghdl translate_off
this is ignored
-- ghdl translate_on | 625990321f5feb6acb163cc8 |
class UpdateSession(VapiInterface): <NEW_LINE> <INDENT> RESOURCE_TYPE = "com.vmware.content.library.item.UpdateSession" <NEW_LINE> def __init__(self, config): <NEW_LINE> <INDENT> VapiInterface.__init__(self, config, _UpdateSessionStub) <NEW_LINE> <DEDENT> def create(self, create_spec, client_token=None, ): <NEW_LINE> <... | The ``UpdateSession`` class manipulates sessions that are used to upload
content into the Content Library Service, and/or to remove files from a
library item.
An update session is a resource which tracks changes to content. An update
session is created with a set of files that are intended to be uploaded to
a specifi... | 6259903226238365f5fadc2a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.