code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
class DictRegistry(RegistryBase, MutableMapping): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(DictRegistry, self).__init__() <NEW_LINE> self.registry = {} <NEW_LINE> <DEDENT> def __iter__(self): <NEW_LINE> <INDENT> return iter(self.registry) <NEW_LINE> <DEDENT> def __len__(self): <NEW_LINE> <INDEN... | Basic registry that just keeps a key, value pairs.
Provides normal dict-style access to the registry:
.. doctest::
>>> from flask import Flask
>>> from flask_registry import Registry, DictRegistry
>>> app = Flask('myapp')
>>> r = Registry(app=app)
>>> r['myns'] = DictRegistry()
>>> r['myns'].... | 62598f8321bff66bcd7226e6 |
class HyperParams(object): <NEW_LINE> <INDENT> def __init__(self, print_every=10, early_stopping_reward_thresh=0.50): <NEW_LINE> <INDENT> self.print_every = print_every <NEW_LINE> self.K = 5 <NEW_LINE> self.early_stopping_reward_thresh = early_stopping_reward_thresh <NEW_LINE> self.early_stopping_n_mean = 50 <NEW_LINE>... | Sets the experiment hyperparameters | 62598f839b70327d1c57e81a |
class ClientCredentialsGrant(GrantTypeBase): <NEW_LINE> <INDENT> def create_token_response(self, request, token_handler): <NEW_LINE> <INDENT> headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', 'Pragma': 'no-cache', } <NEW_LINE> try: <NEW_LINE> <INDENT> log.debug('Validating access token reques... | `Client Credentials Grant`_
The client can request an access token using only its client
credentials (or other supported means of authentication) when the
client is requesting access to the protected resources under its
control, or those of another resource owner that have been previously
arranged with the authorizati... | 62598f830a366e3fb87dc449 |
class MyWitch(Layer): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(MyWitch, self).__init__(*args, **kwargs) <NEW_LINE> self.add(ColorLayer(100, 100, 100, 255)) <NEW_LINE> scroller = ScrollingManager() <NEW_LINE> self.fullmap = cocos.tiles.load('maps/platformer-map.xml') <NEW_LINE> ... | Simple platformer example with walls, decoration and a player.
- Left/right : move the player
- Space : jump | 62598f83d4950a0f3b110b73 |
class Movie: <NEW_LINE> <INDENT> def __init__(self, id, title, overview, poster, vote_average, vote_count): <NEW_LINE> <INDENT> self.id = id <NEW_LINE> self.title = title <NEW_LINE> self.overview = overview <NEW_LINE> self.poster = 'https://image.tmdb.org/t/p/w500' + poster <NEW_LINE> self.vote_average = vote_average <... | Movie class to define Movie Objects | 62598f83d99f1b3c44d0512a |
class SerialDialog(ConfigDialog): <NEW_LINE> <INDENT> def _createControls(self): <NEW_LINE> <INDENT> self.addToLayout(wx.TextCtrl(self, validator=TextValidator(self, "portname"), size=(200, 26)), "Serial port") <NEW_LINE> self.addToLayout(wx.TextCtrl(self, validator=TextValidator(self, "portspeed")), "Serial baud rate ... | Serial port configuration dialog | 62598f83d53ae8145f917f0b |
class MyInt(int): <NEW_LINE> <INDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return int(self) != int(other) <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return int(self) == int(other) | MyInt - class that inherits from int | 62598f8315fb5d323ce7e7a8 |
class Asin(TrigonometricUnary): <NEW_LINE> <INDENT> pass | Returns the arc sine of x | 62598f8338b623060ffa8b13 |
class ToTensorVideo(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def __call__(self, clip): <NEW_LINE> <INDENT> return F.to_tensor(clip) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return self.__class__.__name__ | Convert tensor data type from uint8 to float, divide value by 255.0 and
permute the dimensions of clip tensor | 62598f831d351010ab8f35ba |
class Database(object): <NEW_LINE> <INDENT> connection = None <NEW_LINE> cursor = None <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> parse.uses_netloc.append("postgres") <NEW_LINE> url = parse.urlparse(DATABASE_URL) <NEW_LINE> self.connection = psycopg2.connect( database=url.path[1:], user=url.username, password=u... | This Database class wraps a SQL database with utility functions
that are exposed to our main app. This abstraction makes interacting with the Database
very easy and allows us to change the database if necessary. | 62598f8345492302aabfbf5b |
@ewrap.Wrapper.base_pvm_type <NEW_LINE> class _STDevMethods(ewrap.ElementWrapper): <NEW_LINE> <INDENT> def _set_stg_and_tgt(self, adapter, stg_ref, lua=None, target_name=None): <NEW_LINE> <INDENT> self.backing_storage = stg_ref <NEW_LINE> if lua is not None or target_name is not None: <NEW_LINE> <INDENT> self._target_d... | Methods for storage and target common to STDev and VSCSIMapping. | 62598f831f5feb6acb1626b1 |
class Graph(Generic[T]): <NEW_LINE> <INDENT> def __init__(self, val: T, nodes: List[Graph]=[]): <NEW_LINE> <INDENT> self.val = val <NEW_LINE> self.nodes = nodes <NEW_LINE> <DEDENT> def __repr__(self) -> str: <NEW_LINE> <INDENT> return self.val | Class for a undirected graph. | 62598f8373bcbd0ca4bc9ccf |
class SlidingWindowBase: <NEW_LINE> <INDENT> datatype = None <NEW_LINE> def __init__(self, window_size=1, n_windows=10): <NEW_LINE> <INDENT> self.window_size = window_size <NEW_LINE> self.n_windows = n_windows <NEW_LINE> self.head = None <NEW_LINE> self.history = [self.datatype() for _ in range(self.n_windows)] <NEW_LI... | Data structure that keeps track of the total number of events that have
occurred in a given time frame. Events are binned into time windows based
on their timestamps, and the most recent N windows are kept in a rotating
queue. This allows for monitoring the moving average of a time series
data stream in real time. | 62598f8329b78933be269e19 |
class INamedBlobImageField(INamedImageField): <NEW_LINE> <INDENT> pass | Field for storing INamedBlobImage objects. | 62598f838a349b6b43685cc3 |
class PayPalConfig(object): <NEW_LINE> <INDENT> _valid_= { 'API_ENVIRONMENT' : ['sandbox','production'], 'API_AUTHENTICATION_MODE' : ['3TOKEN','CERTIFICATE'], } <NEW_LINE> _API_ENDPOINTS= { '3TOKEN': { 'sandbox' : 'https://api-3t.sandbox.paypal.com/nvp', 'production' : 'https://api-3t.paypal.com/nvp', } } <NEW_LINE> _P... | The PayPalConfig object is used to allow the developer to perform API
queries with any number of different accounts or configurations. This
is done by instantiating paypal.interface.PayPalInterface, passing config
directives as keyword args. | 62598f839b70327d1c57e81c |
class OraServ(callbacks.Plugin): <NEW_LINE> <INDENT> threaded = True | An oragonoIRCd specific toolkit for IRCops | 62598f83d4950a0f3b110b74 |
class MapAbsoluteToRelativeNumberField(NumberFieldIsomorphism): <NEW_LINE> <INDENT> r <NEW_LINE> def __init__(self, A, R): <NEW_LINE> <INDENT> NumberFieldIsomorphism.__init__(self, Hom(A, R)) <NEW_LINE> <DEDENT> def _call_(self, x): <NEW_LINE> <INDENT> R = self.codomain() <NEW_LINE> f = x.polynomial() <NEW_LINE> return... | See :class:`~MapRelativeToAbsoluteNumberField` for examples. | 62598f8376d4e153a661c692 |
class Loader12(Reader, Scanner12, Parser, Composer, Constructor, Resolver): <NEW_LINE> <INDENT> def __init__(self, stream): <NEW_LINE> <INDENT> Reader.__init__(self, stream) <NEW_LINE> Scanner12.__init__(self) <NEW_LINE> Parser.__init__(self) <NEW_LINE> Composer.__init__(self) <NEW_LINE> SafeConstructor.__init__(self) ... | This is a version of the loader that uses Scanner12. | 62598f8315baa723494619fe |
class User(db.Model): <NEW_LINE> <INDENT> id = db.Column(db.Integer, primary_key=True) <NEW_LINE> username = db.Column(db.String(7), unique=True, nullable=False) <NEW_LINE> email = db.Column(db.String(21), unique=True, nullable=False) <NEW_LINE> faculty = db.Column(db.String(25), n... | Create user database fields
Fields:
id -- provides each row entry with a unique id.
student_number -- store users 7 character student number (e.g 1342556).
email -- store users UOB email (e.g af23467@bristol.ac.uk).
faculty -- store users faculty (e.g Engineering).
password_hash -- store sha256 hash of users password. | 62598f831d351010ab8f35bd |
class PerfectTenseConversion(object): <NEW_LINE> <INDENT> to_passive_voice_obj = to_passive_voice.ConversionToPassive() <NEW_LINE> aux_list = ["has", "have", "had"] <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def perfect_tense_con(self, sent_list): <NEW_LINE> <INDENT> for i in range(len(... | class for the tense conversion of perfect tense sentences | 62598f8326238365f5fac5ee |
class upscaleLayer(nn.Module): <NEW_LINE> <INDENT> def __init__(self, conv_dim, next_conv_dim, size): <NEW_LINE> <INDENT> super(upscaleLayer, self).__init__() <NEW_LINE> self.conv_dim = conv_dim <NEW_LINE> self.next_conv_dim = next_conv_dim <NEW_LINE> self.layer1 = nn.Conv2d(conv_dim, 2*next_conv_dim, 3, padding=1) <NE... | upscales by 2x | 62598f83e76e3b2f99fd84b5 |
class ListTags(TagCommand): <NEW_LINE> <INDENT> SYNOPSIS = (None, 'tag/list', 'tag/list', '[<wanted>|!<wanted>] [...]') <NEW_LINE> ORDER = ('Tagging', 0) <NEW_LINE> HTTP_STRICT_VARS = False <NEW_LINE> class CommandResult(TagCommand.CommandResult): <NEW_LINE> <INDENT> def as_text(self): <NEW_LINE> <INDENT> if not self.r... | List tags | 62598f83a4f1c619b294e06c |
class EncodingReader(object): <NEW_LINE> <INDENT> def __iter__(self): <NEW_LINE> <INDENT> for where, data in super().__iter__(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data = data.decode('utf-8') <NEW_LINE> <DEDENT> except UnicodeDecodeError: <NEW_LINE> <INDENT> E_FILE_UTF8_BAD(where) <NEW_LINE> data = data.decod... | Decodes lines from UTF-8, the one true encoding. | 62598f8316aa5153ce3fff81 |
class DemoUserLog(BaseModel): <NEW_LINE> <INDENT> user = models.OneToOneField(User, unique=True) <NEW_LINE> class Meta: <NEW_LINE> <INDENT> verbose_name = 'Demo User Log' <NEW_LINE> verbose_name_plural = 'Demo User Logs' <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.user.username | Create a log of all demo users that are generated. That way all demo users
can be periodically purged, but still offer a good experience for people
interested in trying out features | 62598f83d53ae8145f917f0e |
class PositionEmbeddingSine_highfreq(nn.Module): <NEW_LINE> <INDENT> def __init__(self, num_pos_feats=64, temperature=10000, normalize=False, scale=None): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.num_pos_feats = num_pos_feats <NEW_LINE> self.temperature = temperature <NEW_LINE> self.normalize = normalize ... | This is a more standard version of the position embedding, very similar to the one
used by the Attention is all you need paper, generalized to work on images. | 62598f83c432627299fa2a4e |
class AGOLSearch: <NEW_LINE> <INDENT> def __init__(self, iface): <NEW_LINE> <INDENT> self.iface = iface <NEW_LINE> self.plugin_dir = os.path.dirname(__file__) <NEW_LINE> locale = QSettings().value('locale/userLocale')[0:2] <NEW_LINE> locale_path = os.path.join( self.plugin_dir, 'i18n', 'AGOLSearch_{}.qm'.format(locale)... | QGIS Plugin Implementation. | 62598f8363d6d428bbee2238 |
class RepresentationGenerator(_RepresentationHandler): <NEW_LINE> <INDENT> def run(self, data_element): <NEW_LINE> <INDENT> raise NotImplementedError('Abstract method.') | Abstract base class for classes that generate representations. | 62598f8329b78933be269e1a |
class TestSwitch(object): <NEW_LINE> <INDENT> def test_unpack(self): <NEW_LINE> <INDENT> controller = Controller(address='unix:abstract=abcde') <NEW_LINE> controller.establish_connection = Mock(return_value=None) <NEW_LINE> controller.connection = MockConnection(True) <NEW_LINE> with pytest.raises(ConnectionReturnError... | Test the switch method | 62598f83442bda511e95bedb |
class GaussianPosture(Posture): <NEW_LINE> <INDENT> def __init__(self, posture, symbols, parameters, target_covariance=None, transition_variance=1., duration_variance=1.): <NEW_LINE> <INDENT> self.posture = posture <NEW_LINE> self.symbol = posture.symbol <NEW_LINE> self.categories = posture.categories <NEW_LINE> self.s... | A statistical model that wraps a posture in a multivariate gaussian. | 62598f8338b623060ffa8b17 |
class LevelFormatter(logging.Formatter): <NEW_LINE> <INDENT> def __init__(self, formatters=None, fmt=None, datefmt=None, style='%'): <NEW_LINE> <INDENT> self._formatters = {} <NEW_LINE> if formatters is None: <NEW_LINE> <INDENT> style = '%' <NEW_LINE> self._formatters[logging.DEBUG] = logging.Formatter( fmt='[%(asctime... | This class allows to have different logging formats based on the level. | 62598f83baa26c4b54d4ed32 |
class VisualizeData(): <NEW_LINE> <INDENT> def __init__(self, data): <NEW_LINE> <INDENT> self.data = data <NEW_LINE> logging.debug('VisualizedData - initialize') <NEW_LINE> <DEDENT> def plot_graph(self, dataset): <NEW_LINE> <INDENT> data = self.data <NEW_LINE> diagrams = [] <NEW_LINE> for time_stamp, data_tag in datase... | Plot data on the diagram (plot.ly) | 62598f833eb6a72ae038a0b8 |
class NotificationSubscriptionTemplate(Model): <NEW_LINE> <INDENT> _attribute_map = { 'description': {'key': 'description', 'type': 'str'}, 'filter': {'key': 'filter', 'type': 'ISubscriptionFilter'}, 'id': {'key': 'id', 'type': 'str'}, 'notification_event_information': {'key': 'notificationEventInformation', 'type': 'N... | NotificationSubscriptionTemplate.
:param description:
:type description: str
:param filter:
:type filter: :class:`ISubscriptionFilter <notification.v4_0.models.ISubscriptionFilter>`
:param id:
:type id: str
:param notification_event_information:
:type notification_event_information: :class:`NotificationEventType <noti... | 62598f83097d151d1a2c0aa6 |
class TestGetOpenObsActivity(TransactionCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> super(TestGetOpenObsActivity, self).setUp() <NEW_LINE> self.activity_model = self.env['nh.activity'] <NEW_LINE> self.activity_pool = self.registry('nh.activity') <NEW_LINE> self.ews_model = self.env['nh.clinical.pati... | Test class for the :method:`get_open_obs_activity` method. | 62598f836aa9bd52df0d495d |
class ReadStatsSerializers(serializers.ModelSerializer): <NEW_LINE> <INDENT> article = serializers.SerializerMethodField() <NEW_LINE> class Meta: <NEW_LINE> <INDENT> model = ReadStats <NEW_LINE> fields = '__all__' <NEW_LINE> <DEDENT> def get_article(self, stats): <NEW_LINE> <INDENT> return { "article": stats.article.ti... | "
Serializer class for our ReadStats model | 62598f8330dc7b766599f2da |
class TestFunctions(unittest.TestCase): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def _RunTests(mock_runner, tests): <NEW_LINE> <INDENT> results = [] <NEW_LINE> tests = test_dispatcher._TestCollection( [test_dispatcher._Test(t) for t in tests]) <NEW_LINE> test_dispatcher._RunTestsFromQueue(mock_runner, tests, result... | Tests test_dispatcher._RunTestsFromQueue. | 62598f8345492302aabfbf5f |
class AwardViewSet(viewsets.ModelViewSet): <NEW_LINE> <INDENT> queryset = models.Award.objects.all() <NEW_LINE> serializer_class = dgs.api.serializers.AwardSerializer | A generic Award model to capture awards for a Contestant such as Ace (hole in one)
or CTP (closest to pin). Event objects relate to one or more Awards. | 62598f83d164cc61758209f9 |
class TextualBugTaskSearchListingView(BugTaskSearchListingView): <NEW_LINE> <INDENT> def render(self): <NEW_LINE> <INDENT> self.request.response.setHeader( 'Content-type', 'text/plain') <NEW_LINE> search_params = self.buildSearchParams() <NEW_LINE> if (IDistroSeries.providedBy(self.context) or IProductSeries.providedBy... | View that renders a list of bug IDs for a given set of search criteria.
| 62598f8330c21e258be9828b |
class MSGraphProtocol(Protocol): <NEW_LINE> <INDENT> _protocol_url = 'https://graph.microsoft.com/' <NEW_LINE> _oauth_scope_prefix = 'https://graph.microsoft.com/' <NEW_LINE> _oauth_scopes = DEFAULT_SCOPES <NEW_LINE> def __init__(self, api_version='v1.0', default_resource=None, **kwargs): <NEW_LINE> <INDENT> super().__... | A Microsoft Graph Protocol Implementation
https://docs.microsoft.com/en-us/outlook/rest/compare-graph-outlook | 62598f83e76e3b2f99fd84b7 |
class CommandMainMenuItem(plugin.MainMenuPlugin): <NEW_LINE> <INDENT> def __init__(self, commandxmlfile): <NEW_LINE> <INDENT> plugin.MainMenuPlugin.__init__(self) <NEW_LINE> self.cmd_xml = commandxmlfile <NEW_LINE> <DEDENT> def config(self): <NEW_LINE> <INDENT> return [ ('COMMAND_SPAWN_WM', '', 'command to start window... | A small plugin to put a command in the main menu.
Uses the command.py fxd file format to say which command to run.
All output is logged in the freevo logdir.
to activate it, put the following in your local_conf.py:
| plugin.activate('command.CommandMainMenuItem', args=(/usr/local/freevo_data/Commands/Mozilla.fxd',), l... | 62598f837c178a314d78cf2d |
class ReviewInfo(Info): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.labels = None <NEW_LINE> <DEDENT> def tokenize(self): <NEW_LINE> <INDENT> for label, score in self.labels: <NEW_LINE> <INDENT> if score in (1, 2): <NEW_LINE> <INDENT> token = Token.Review.OK <NEW_LINE> score = '+%d' % score <NEW_LI... | A review object | 62598f8316aa5153ce3fff83 |
class UserSession(Session): <NEW_LINE> <INDENT> def __init__(self) -> None: <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> retry_strategy = Retry( total=config.max_retries, status_forcelist=config.allowed_retry_status, raise_on_status=False, **{_ALLOWED_METHODS: config.allowed_retry_methods}, ) <NEW_LINE> self.mount... | This class defines UserSession. | 62598f8350485f2cf55da9f4 |
class runner(SuprocBenchmarks): <NEW_LINE> <INDENT> def setup(self): <NEW_LINE> <INDENT> self.runner = Runner() <NEW_LINE> try: <NEW_LINE> <INDENT> from datalad.cmd import GitRunner <NEW_LINE> self.git_runner = GitRunner() <NEW_LINE> <DEDENT> except ImportError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> def... | Some rudimentary tests to see if there is no major slowdowns from Runner
| 62598f83a4f1c619b294e06f |
class Interface(object): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def is_implemented_by(cls, instance): <NEW_LINE> <INDENT> return implements(instance, cls) | Base class for interfaces. | 62598f8321bff66bcd7226ec |
class Lexer(object): <NEW_LINE> <INDENT> def __init__(self, text): <NEW_LINE> <INDENT> self.text = text <NEW_LINE> self.pos = 0 <NEW_LINE> self.current_token = None <NEW_LINE> self.current_char = self.text[self.pos] <NEW_LINE> <DEDENT> def error(self): <NEW_LINE> <INDENT> raise Exception("Error parsing input") <NEW_LIN... | Lexical analysis: the process of breaking the input string into tokens. | 62598f8363b5f9789fe84bf3 |
class Identifiable(object, metaclass=ABCMeta): <NEW_LINE> <INDENT> @property <NEW_LINE> def id(self) -> str: <NEW_LINE> <INDENT> if not hasattr(self, '_id'): <NEW_LINE> <INDENT> self._id = str(uuid.uuid4()) <NEW_LINE> objects[self._id] = self <NEW_LINE> <DEDENT> return self._id <NEW_LINE> <DEDENT> @id.setter <NEW_LINE>... | Identifiable mixin for adding a unique `id` property to instances of a class.
| 62598f83442bda511e95bedd |
class LineAlterer(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self._changes = deque() <NEW_LINE> <DEDENT> def delete(self, start, end): <NEW_LINE> <INDENT> self._changes.append(('delete', start, end)) <NEW_LINE> <DEDENT> def insert(self, start, text): <NEW_LINE> <INDENT> self._changes.append(('... | Caches the changes made to a Metaline so triggers don't step on each
others' feet. | 62598f83379a373c97d98a94 |
class Alpha: <NEW_LINE> <INDENT> def __init__(self, max_points_num = 10): <NEW_LINE> <INDENT> self.Time = 0 <NEW_LINE> self.reporter = AccuracyBufferedReporter() <NEW_LINE> self.models = {} <NEW_LINE> self.max_points_num = max_points_num <NEW_LINE> <DEDENT> def classify_using_mean_distance(self, query): <NEW_LINE> <IND... | plan a | 62598f838e71fb1e983bb53d |
class WorkerProcess(ApplicationSession): <NEW_LINE> <INDENT> def onConnect(self): <NEW_LINE> <INDENT> self.debug = self.factory.options.debug <NEW_LINE> self._pid = os.getpid() <NEW_LINE> self._node_name = '918234' <NEW_LINE> if self.debug: <NEW_LINE> <INDENT> log.msg("Connected to node router.") <NEW_LINE> <DEDENT> se... | A Crossbar.io worker process connects back to the node router
via WAMP-over-stdio. | 62598f83b5575c28eb712a08 |
class KeyData(object): <NEW_LINE> <INDENT> def __init__(self, keys, module_hash, key_pkl, entry): <NEW_LINE> <INDENT> self.keys = keys <NEW_LINE> self.module_hash = module_hash <NEW_LINE> self.key_pkl = key_pkl <NEW_LINE> self.entry = entry <NEW_LINE> <DEDENT> def add_key(self, key, save_pkl=True): <NEW_LINE> <INDENT> ... | Used to store the key information in the cache.
Parameters
----------
keys
Set of keys that are associated to the exact same module.
module_hash
Hash identifying the module (it should hash both the code and the
compilation options).
key_pkl
Path to the file in which this KeyData object should be
pi... | 62598f83c432627299fa2a51 |
class LocalRequirementsRepository(BaseRepository): <NEW_LINE> <INDENT> def __init__(self, existing_pins, proxied_repository): <NEW_LINE> <INDENT> self.repository = proxied_repository <NEW_LINE> self.existing_pins = existing_pins <NEW_LINE> <DEDENT> @property <NEW_LINE> def finder(self): <NEW_LINE> <INDENT> return self.... | The LocalRequirementsRepository proxied the _real_ repository by first
checking if a requirement can be satisfied by existing pins (i.e. the
result of a previous compile step).
In effect, if a requirement can be satisfied with a version pinned in the
requirements file, we prefer that version over the best match found ... | 62598f83711fe17d825e016b |
class MockElastic(object): <NEW_LINE> <INDENT> nodes = MockElasticNodes() | Mock of Elasticsearch client | 62598f8315baa72349461a01 |
class LoaderRequiredError(VersionSpecificRequirementUnmetError): <NEW_LINE> <INDENT> def __init__(self, path: str) -> None: <NEW_LINE> <INDENT> super().__init__( f"To extract ZiX archives, the “{loader_name}” file is required alongside the archive (we looked for it at " f"“{path}”). You can find this file in the game y... | An error where the user needs to provide `loader.pyo` to extract this type of archive. | 62598f8315fb5d323ce7e7ae |
class RolesView(APIView): <NEW_LINE> <INDENT> authentication_classes = [] <NEW_LINE> permission_classes = [] <NEW_LINE> def get(self, request, *args, **kwargs): <NEW_LINE> <INDENT> role = Role.objects.all().first() <NEW_LINE> ser = RolesSerializer(instance=role, many=False) <NEW_LINE> return JsonResponse(ser.data) | 序列化 | 62598f833eb6a72ae038a0ba |
class AbstractProvider: <NEW_LINE> <INDENT> __metaclass__ = ABCMeta <NEW_LINE> @abstractmethod <NEW_LINE> def delete_object(self, path): <NEW_LINE> <INDENT> return NotImplemented <NEW_LINE> <DEDENT> @abstractmethod <NEW_LINE> def list_dir(self, path): <NEW_LINE> <INDENT> return NotImplemented <NEW_LINE> <DEDENT> @abstr... | This class defines a contract for all our different storage sources
e.g: Amazon S3, Local Files, Openstack Swift etc. etc. | 62598f838da39b475be02c69 |
class QueryParser(object): <NEW_LINE> <INDENT> def __init__(self, query_string=None): <NEW_LINE> <INDENT> self.query = parse_qs( query_string or '', keep_blank_values=True) <NEW_LINE> <DEDENT> def get(self, name, default=None, last_only=True): <NEW_LINE> <INDENT> v = self.query.get(name) <NEW_LINE> if v is None: <NEW_L... | Provides convenient retrieval methods for query parameter values.
:param query_string: The HTTP query string, such as in WSGI's
``env['QUERY_STRING']``. If using something other than WSGI's
QUERY_STRING, be sure to **not** include the question mark that
separates the path?query string as it would be transl... | 62598f83596a8972361276f5 |
class Category(models.Model): <NEW_LINE> <INDENT> name = models.CharField(max_length=100) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return self.name | Blog post categories. | 62598f83d99f1b3c44d05131 |
class X509_Stack: <NEW_LINE> <INDENT> m2_sk_x509_free = m2.sk_x509_free <NEW_LINE> def __init__(self, stack=None, _pyfree=0, _pyfree_x509=0): <NEW_LINE> <INDENT> if stack is not None: <NEW_LINE> <INDENT> self.stack = stack <NEW_LINE> self._pyfree = _pyfree <NEW_LINE> self.pystack = [] <NEW_LINE> num = m2.sk_x509_num(se... | X509 Stack
:warning: Do not modify the underlying OpenSSL stack
except through this interface, or use any OpenSSL
functions that do so indirectly. Doing so will get the
OpenSSL stack and the internal pystack of this class out
of sync, leading to python memory leaks, exceptions o... | 62598f8373bcbd0ca4bc9cd4 |
class Net(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> raise RuntimeError('This class should not be instantiated.') <NEW_LINE> <DEDENT> getHostname = None | Net class | 62598f83b830903b9686e1b3 |
class AbstractDarwinCachedProducer(plugin.CachedProducer, AbstractDarwinCommand): <NEW_LINE> <INDENT> __abstract = True | Base class for Darwin producers backed by a session param hook. | 62598f833eb6a72ae038a0bb |
class ApiKeyFactory(BaseFactory): <NEW_LINE> <INDENT> name = Sequence(lambda n: "api_key_{0}".format(n)) <NEW_LINE> revoked = False <NEW_LINE> ttl = -1 <NEW_LINE> issued_at = 1 <NEW_LINE> class Meta: <NEW_LINE> <INDENT> model = ApiKey <NEW_LINE> <DEDENT> @post_generation <NEW_LINE> def user(self, create, extracted, **k... | Api Key Factory. | 62598f8330c21e258be9828d |
class Strategy(object): <NEW_LINE> <INDENT> def algorithm(self): <NEW_LINE> <INDENT> raise NotImplementedError | Declares an interface common to all supported algorithms. Context uses this
interface to call the algorithm defined by a ConcreteStrategy. | 62598f83f8510a7c17d7deb9 |
class Wrapper(object): <NEW_LINE> <INDENT> name = None <NEW_LINE> def __init__(self, data, name=None): <NEW_LINE> <INDENT> self.data = data <NEW_LINE> if name is not None: <NEW_LINE> <INDENT> self.name = name <NEW_LINE> <DEDENT> <DEDENT> def record(self, data): <NEW_LINE> <INDENT> if 'type' not in data: <NEW_LINE> <IND... | Wraps methods and logs the results | 62598f83596a8972361276f6 |
class PageHandler(RequestHandler): <NEW_LINE> <INDENT> def get(self, op, action): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.authed() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> self.write(u'没有权限,请<a href="/">登录</a>后再查看该页!') <NEW_LINE> return <NEW_LINE> <DEDENT> if hasattr(self, op): <NEW_LINE> <INDENT> geta... | Return some page.
| 62598f83e76e3b2f99fd84b9 |
class BuildDebianCommand(GradleCommandProcessor): <NEW_LINE> <INDENT> def __init__(self, factory, options, upstream_repositories=None, **kwargs): <NEW_LINE> <INDENT> upstream_repositories = upstream_repositories or SPINNAKER_BOM_REPOSITORIES <NEW_LINE> super(BuildDebianCommand, self).__init__( factory, options, upstrea... | Implements the build_debians command. | 62598f83442bda511e95bedf |
class ProfileBean(object): <NEW_LINE> <INDENT> def __init__(self, p_id=None, create_date=None, label=None, description=None, overridable=None, active=None, deleted=None, profile_data=None, modify_date=None, policy_id=None, plugin=None, username=None): <NEW_LINE> <INDENT> self.id = p_id <NEW_LINE> self.create_date = cre... | docstring for Profile | 62598f8363b5f9789fe84bf5 |
class Schnorr(Groups.PrimeOrder, ZeroKnowledgeProof): <NEW_LINE> <INDENT> def __init__(self, security, confidence): <NEW_LINE> <INDENT> super(Schnorr, self).__init__(security, False, 'Schnorr\'s') <NEW_LINE> self.params['confidence'] = self.confidence = confidence <NEW_LINE> self.randomness = {} <NEW_LINE> <DEDENT> def... | Single value x that x is not a very small number. | 62598f836fb2d068a7693b70 |
class _Config(collections.namedtuple('_Config', 'replacements')): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def defaults(cls): <NEW_LINE> <INDENT> return _Config(replacements=None) | High-level representation of the configuration file.
Fields:
replacements: collection(tuple(str, str)). List of pairs representing
a regular expression to match text and its corresponding
replacement. The replacement can use backreferences. | 62598f83379a373c97d98a96 |
class StaticRoute(Base): <NEW_LINE> <INDENT> __tablename__ = _TN <NEW_LINE> _class_label = 'Static Route' <NEW_LINE> id = Column(Integer, Sequence('%s_id_seq' % _TN), primary_key=True) <NEW_LINE> gateway_ip = Column(IPV4, nullable=False) <NEW_LINE> network_id = Column(Integer, ForeignKey('network.id', name='%s_network_... | Represents a router address on a network. | 62598f838a349b6b43685cc9 |
class Variable(models.Model): <NEW_LINE> <INDENT> code = models.CharField(max_length=20) <NEW_LINE> short_name = models.CharField(max_length=8) <NEW_LINE> category = models.CharField(max_length=255) <NEW_LINE> long_name = models.CharField(max_length=80) <NEW_LINE> raw = models.CharField(max_length=800, unique=True) <NE... | An IPEDS report variable. | 62598f833c8af77a43b67c76 |
class FmtDates(FmtToString): <NEW_LINE> <INDENT> def __init__(self, fmt_string, rows=None, columns=None, apply_to_header_and_index=True): <NEW_LINE> <INDENT> super(FmtDates, self).__init__(fmt_string, rows, columns, apply_to_header_and_index) <NEW_LINE> return <NEW_LINE> <DEDENT> def _modify_cell_content(self, data): <... | Apply formatting string if cell content is date. Changes cell content from date to string. | 62598f833eb6a72ae038a0bc |
class CategoryToNumeric(object): <NEW_LINE> <INDENT> def __init__(self, categorical_features, metric='mean'): <NEW_LINE> <INDENT> self.categorical_features = categorical_features <NEW_LINE> self.metric = metric <NEW_LINE> self.feature_map_ = {} <NEW_LINE> <DEDENT> def fit(self, X, y): <NEW_LINE> <INDENT> for i in self.... | Transform class that replaces a categorical value with a representative target value
for instances that belong to that category. This technique is useful as a method to
turn categorical features into numeric values for use in an estimator, and can be
viewed as an alternative approach to one-hot encoding. Only suitabl... | 62598f8394891a1f408b9431 |
class COORD(ctypes.Structure): <NEW_LINE> <INDENT> _fields_ = [('X', SHORT), ('Y', SHORT)] | Win32 COORD Struct. | 62598f83a79ad16197769ae6 |
class TestInsurancePolicy(TestCase): <NEW_LINE> <INDENT> pass | Ensures the insurance policy works.
| 62598f83d99f1b3c44d05133 |
class ContactInformation(gtk.Window, gui.base.ContactInformation): <NEW_LINE> <INDENT> def __init__(self, session, account): <NEW_LINE> <INDENT> gui.base.ContactInformation.__init__(self, session, account) <NEW_LINE> gtk.Window.__init__(self) <NEW_LINE> self.set_default_size(640, 350) <NEW_LINE> self.set_title(_('Conta... | a window that displays information about a contact | 62598f83dc8b845886d5303b |
class Flatten(nn.Module): <NEW_LINE> <INDENT> def forward(self, x): <NEW_LINE> <INDENT> return x.flatten(1) | Flattens the input tensor such that the dimension 0 is the batch.
Equivalent to ``x.flatten(1)``. | 62598f83a05bb46b3848a300 |
class BulletDataOverride(_BulletData): <NEW_LINE> <INDENT> @typecheck <NEW_LINE> def __new__(cls, *args, **kwargs): <NEW_LINE> <INDENT> kwargs_tmp = dict(zip(_BulletData._fields, args)) <NEW_LINE> kwargs_tmp = {k: v for (k, v) in kwargs_tmp.items() if v is not None} <NEW_LINE> for key, value in kwargs.items(): <NEW_LIN... | Create a ``_BulletData`` named tuple.
The only difference between this class and ``bullet_data.BulletData`` is
that this class permits *None* values. | 62598f83004d5f362081ed3d |
class Atbash(Cipher): <NEW_LINE> <INDENT> ALPHA = string.ascii_uppercase <NEW_LINE> REV_ALPHA = ALPHA[::-1] <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> self.ALPHA = string.ascii_uppercase <NEW_LINE> <DEDENT> def encrypt(self, text): <NEW_LINE> <INDENT> output_string = "" <NEW_LINE> text = text.upper() <NEW_LINE>... | The Atbash Cipher. | 62598f83596a8972361276f8 |
class TestZaimIncomeRow: <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> @pytest.mark.usefixtures("yaml_config_load", "database_session_stores_item") <NEW_LINE> def test_all() -> None: <NEW_LINE> <INDENT> account_context = Account.MUFG.value <NEW_LINE> csv_record_processor = CsvRecordProcessor(account_context.input_row_fa... | Tests for ZaimIncomeRow. | 62598f8363d6d428bbee223e |
class SublimeTextTests(LargeFrameworkTests): <NEW_LINE> <INDENT> TIMEOUT_INSTALL_PROGRESS = 120 <NEW_LINE> TIMEOUT_START = 20 <NEW_LINE> TIMEOUT_STOP = 20 <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> super().setUp() <NEW_LINE> self.installed_path = os.path.join(self.install_base_path, "ide", "sublime-text") <NEW_LIN... | Tests for Sublime Text | 62598f836e29344779b000e9 |
class CoordinatedTPLinkEntity(CoordinatorEntity): <NEW_LINE> <INDENT> coordinator: TPLinkDataUpdateCoordinator <NEW_LINE> def __init__( self, device: SmartDevice, coordinator: TPLinkDataUpdateCoordinator ) -> None: <NEW_LINE> <INDENT> super().__init__(coordinator) <NEW_LINE> self.device: SmartDevice = device <NEW_LINE>... | Common base class for all coordinated tplink entities. | 62598f83656771135c489101 |
class RegisterError(Error): <NEW_LINE> <INDENT> pass | Raised when registration fails. | 62598f8321bff66bcd7226f0 |
class TestPredictionResourceRelationshipsAlertsLinks(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 testPredictionResourceRelationshipsAlertsLinks(self): <NEW_LINE> <INDENT> pass | PredictionResourceRelationshipsAlertsLinks unit test stubs | 62598f8363b5f9789fe84bf7 |
class Grp70No70(base_tests.SimpleDataPlane): <NEW_LINE> <INDENT> @wireshark_capture <NEW_LINE> def runTest(self): <NEW_LINE> <INDENT> logging = get_logger() <NEW_LINE> logging.info("Running Grp70No70 Forward_Inport test") <NEW_LINE> of_ports = config["port_map"].keys() <NEW_LINE> of_ports.sort() <NEW_LINE> self.assertT... | ForwardInPort : Packet sent to virtual port IN_PORT
If the output.port = OFPP.INPORT then the packet is sent to the input port itself | 62598f833c8af77a43b67c77 |
class UserViewSet(viewsets.ModelViewSet): <NEW_LINE> <INDENT> queryset = User.objects.all() <NEW_LINE> serializer_class = UserSerializer <NEW_LINE> def get_permissions(self): <NEW_LINE> <INDENT> return (AllowAny() if self.request.method == 'POST' else IsStaffOrTargetUser()), | This viewset automatically provides `list` and `detail` actions. | 62598f83d4950a0f3b110b78 |
class AcquaintanceOpportunityGate( ops.Gate, ops.InterchangeableQubitsGate): <NEW_LINE> <INDENT> def __init__(self, num_qubits: int): <NEW_LINE> <INDENT> self._num_qubits = num_qubits <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return ('cirq.contrib.acquaintance.AcquaintanceOpportunityGate(' 'num_qubits... | Represents an acquaintance opportunity. An acquaintance opportunity is
essentially a placeholder in a swap network that may later be replaced with
a logical gate. | 62598f83507cdc57c63a4813 |
class ISlice3D(ISlice): <NEW_LINE> <INDENT> fillColorShaded = attr.Color( title='Fill Color Shade', description='The shade used for the fill color.', required=False) | A 3-D slice of a 3-D pie chart. | 62598f83b5575c28eb712a0a |
class FunctionProfile(Profile): <NEW_LINE> <INDENT> def __init__(self, ppk, nodeId, contextId, threadId, functionId): <NEW_LINE> <INDENT> self.functionId = functionId <NEW_LINE> self.event = ppk.events[functionId] <NEW_LINE> self.groups = self.event.groups <NEW_LINE> self.shortname = self.event.shortname <NEW_LINE> sel... | Raw profile data container, which could be a genuine data or
derived data.
Genuine data:
1. All data collected by instrumentation
2. For sampling:
A => ... => [CONTEXT] B => ... => [SAMPLE] C
A => ... => [CONTEXT] B => ... => 0x01234567
Derived data:
[SAMPLE] A
[UNWIND] A
A => ... => [CONTEXT] B
... | 62598f8315baa72349461a05 |
class Sentiment(): <NEW_LINE> <INDENT> def __init__(self, scraper): <NEW_LINE> <INDENT> self.api = Reddit() <NEW_LINE> if scraper: <NEW_LINE> <INDENT> self.api = Scraper() <NEW_LINE> <DEDENT> self.score = 0 <NEW_LINE> self.sentiment = "¯\_(ツ)_/¯" <NEW_LINE> self.headers = {'User-agent': "Reddit Sentiment Analyzer"} <NE... | Performs the sentiment analysis on a given set of Reddit Objects. | 62598f8307d97122c421672a |
class TestEditPdfApi(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.api = cloudmersive_convert_api_client.api.edit_pdf_api.EditPdfApi() <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def test_edit_pdf_encrypt(self): <NEW_LINE> <INDENT> pass <NEW_L... | EditPdfApi unit test stubs | 62598f83d164cc61758209ff |
class OwnerRequiredMixin(object): <NEW_LINE> <INDENT> @method_decorator(owner_required(('id', 'id'))) <NEW_LINE> def dispatch(self, *args, **kwargs): <NEW_LINE> <INDENT> return super(OwnerRequiredMixin, self).dispatch(*args, **kwargs) | View mixin checking if the user has
the permission to see the songbook | 62598f83b830903b9686e1b5 |
class FractionFieldEmbedding(DefaultConvertMap_unique): <NEW_LINE> <INDENT> def is_surjective(self): <NEW_LINE> <INDENT> return self.domain().is_field() <NEW_LINE> <DEDENT> def is_injective(self): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> def section(self): <NEW_LINE> <INDENT> from sage.categories.sets_with_p... | The embedding of an integral domain into its field of fractions.
EXAMPLES::
sage: R.<x> = QQ[]
sage: f = R.fraction_field().coerce_map_from(R); f
Coercion map:
From: Univariate Polynomial Ring in x over Rational Field
To: Fraction Field of Univariate Polynomial Ring in x over Rational Field
... | 62598f83f8510a7c17d7debb |
class BaseType(object): <NEW_LINE> <INDENT> __metaclass__ = BaseTypeMetaClass <NEW_LINE> def __init__(self, uniq_field=None, field_name=None, required=False, default=None, id_field=False, validation=None, choices=None, description=None, minimized_field_name=None): <NEW_LINE> <INDENT> self.uniq_field = '_id' if id_field... | A base class for Types in a Schematics model. Instances of this
class may be added to subclasses of `Model` to define a model schema. | 62598f8330c21e258be98291 |
class ZeroUpsample2D(BaseModel): <NEW_LINE> <INDENT> scale_factor: Tuple[int, int] <NEW_LINE> def __init__(self, scale_factor: Union[Tuple[int, int], List[int], int]): <NEW_LINE> <INDENT> super(ZeroUpsample2D, self).__init__() <NEW_LINE> if type(scale_factor) == int: <NEW_LINE> <INDENT> scale_factor = (scale_factor, sc... | Basic layer for zero-upsampling of 2D images (4D tensors). | 62598f8326238365f5fac5f6 |
class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): <NEW_LINE> <INDENT> def __init__(self, parent): <NEW_LINE> <INDENT> QtGui.QDialog.__init__(self, parent) <NEW_LINE> self.setupUi(self) <NEW_LINE> self._main_window = parent <NEW_LINE> self._project_settings = parent.projectSettings().copy() <NEW_LINE> default_... | New project dialog. | 62598f8316aa5153ce3fff89 |
class Semeval_QA_M_Processor(DataProcessor): <NEW_LINE> <INDENT> def get_train_examples(self, data_dir): <NEW_LINE> <INDENT> train_data = pd.read_csv(os.path.join(data_dir, "train_QA_M.csv"),header=None,sep="\t").values <NEW_LINE> return self._create_examples(train_data, "train") <NEW_LINE> <DEDENT> def get_dev_example... | Processor for the Semeval 2014 data set. | 62598f83d53ae8145f917f16 |
class User(AbstractBaseUser, PermissionsMixin): <NEW_LINE> <INDENT> username = models.CharField(max_length=30, unique=True) <NEW_LINE> name = models.CharField(max_length=255) <NEW_LINE> mobile = models.CharField(max_length=15, blank=True) <NEW_LINE> is_active = models.BooleanField(default=True) <NEW_LINE> is_staff = mo... | User model | 62598f8329b78933be269e1e |
class DiscoveryList(DAList): <NEW_LINE> <INDENT> def init(self, *pargs, **kwargs): <NEW_LINE> <INDENT> self.object_type = DiscoveryRequest <NEW_LINE> return super(DiscoveryList, self).init(*pargs, **kwargs) | Represents a list of Discovery Requests in a case. The default object
type for items in the list is DiscoveryRequest. | 62598f83a4f1c619b294e075 |
class LoadTournamentDatabase: <NEW_LINE> <INDENT> def __init__(self, viewer): <NEW_LINE> <INDENT> self.viewer = viewer <NEW_LINE> <DEDENT> def exe_command(self): <NEW_LINE> <INDENT> from app.models.tournament import Tournament <NEW_LINE> Tournament.load_fromtinyDB() <NEW_LINE> self.viewer.warning = "" <NEW_LINE> return... | Project load_tournament_database command class. | 62598f83656771135c489103 |
class CallLimitExceeded(Exception): <NEW_LINE> <INDENT> pass | Exception for daily call limit being exceeded | 62598f8326068e7796d4c3e4 |
class CNN_Stastics(APIView): <NEW_LINE> <INDENT> def post(self, request, pk, format=None): <NEW_LINE> <INDENT> return Response("post") <NEW_LINE> <DEDENT> def get(self, pk): <NEW_LINE> <INDENT> return Response("get") <NEW_LINE> <DEDENT> def put(self, request, pk, format=None): <NEW_LINE> <INDENT> return Response("put")... | TO-DO : Dev Rest Services for CNN Accuracy , Data, Response, etc | 62598f8391af0d3eaad39884 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.