code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
class PolicyEstimator(): <NEW_LINE> <INDENT> def __init__(self, num_outputs, reuse=False, trainable=True): <NEW_LINE> <INDENT> self.num_outputs = num_outputs <NEW_LINE> self.states = tf.placeholder(shape=[None, 84, 84, 4], dtype=tf.uint8, name="X") <NEW_LINE> self.targets = tf.placeholder(shape=[None], dtype=tf.float32...
Policy Function approximator. Given a observation, returns probabilities over all possible actions. Args: num_outputs: Size of the action space. reuse: If true, an existing shared network will be re-used. trainable: If true we add train ops to the network. Actor threads that don't update their local models a...
62598f7b82261d6c5272fb92
class InstanceExists(Exception): <NEW_LINE> <INDENT> def __init__(self, type_: str, id_: Union[str, None]=None) -> None: <NEW_LINE> <INDENT> self.type_ = type_ <NEW_LINE> self.id_ = id_ <NEW_LINE> <DEDENT> def get_HTTP(self) -> Tuple[int, Dict[str, str]]: <NEW_LINE> <INDENT> if str(self.id_) is None: <NEW_LINE> <INDENT...
Error when the Instance already exists.
62598f7b10dbd63aa1c7052e
class Player(): <NEW_LINE> <INDENT> def __init__(self, marker): <NEW_LINE> <INDENT> self.marker = marker <NEW_LINE> <DEDENT> def _place_marker(self, co_ord, board, marker=None): <NEW_LINE> <INDENT> if marker is None: <NEW_LINE> <INDENT> marker = self.marker <NEW_LINE> <DEDENT> if board.grid[co_ord[0]][co_ord[1]] == '.'...
A Base class to be extended to create specifc player types.
62598f7b66673b3332c2fd42
class AggregatedExpression(IdentExpression): <NEW_LINE> <INDENT> def __init__(self, t): <NEW_LINE> <INDENT> super().__init__(t) <NEW_LINE> logger.debug('AggregatedExpression::__init__(%s)' % t) <NEW_LINE> <DEDENT> def evaluate(self, env): <NEW_LINE> <INDENT> q, a = self.operands[0].identifier.evaluate(env) <NEW_LINE> f...
select on value of aggregated function this one looks like ident.binop.value, but the ident is an aggregating function, so that the query has to be altered differently: not filter, but group_by and having.
62598f7bd99f1b3c44d0502b
class AtomicFileCreate(object): <NEW_LINE> <INDENT> def __init__(self, dirname, filename): <NEW_LINE> <INDENT> self.dirname = dirname <NEW_LINE> self.filename = filename <NEW_LINE> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> fd, self.tmppath = tempfile.mkstemp( prefix=self.filename + '.tmp_', dir=self.dirname, ) ...
A context manager for writing a file atomically. Uses a temporary file to write to If the context block is exited with an exception, deletes
62598f7b07f4c71912baedcb
class LoginForm(urwid.WidgetWrap): <NEW_LINE> <INDENT> def __init__(self, login_callback): <NEW_LINE> <INDENT> self.login_callback = login_callback <NEW_LINE> self.bottom_w = tcfg.loop.widget <NEW_LINE> self.username = urwid.Edit(caption="McGill short username: ") <NEW_LINE> self.password = urwid.Edit(caption="Password...
Popup login form
62598f7b38b623060ffa8a16
class Solver2D(AbstractSolver): <NEW_LINE> <INDENT> def __init__(self, model): <NEW_LINE> <INDENT> super(Solver2D, self).__init__(model) <NEW_LINE> <DEDENT> def solve(self, *args, **kwargs): <NEW_LINE> <INDENT> return nls.solve_nls_2d(*args, **kwargs) <NEW_LINE> <DEDENT> def chemicalPotentialRoutine(self, *args, **kwar...
One dimensional solver that call native Fortran routine that solves NLS equation on a squared grid.
62598f7b3eb6a72ae0389fc0
class Project(models.Model): <NEW_LINE> <INDENT> id = models.UUIDField('id', default=uuid.uuid4(), primary_key=True) <NEW_LINE> name = models.CharField('name', max_length=50) <NEW_LINE> summary = models.CharField('summary', max_length=300) <NEW_LINE> created = models.DateTimeField('created', auto_now=False, auto_now_ad...
Model definition for Project.
62598f7b8a43f66fc4bf1afd
class EZOViewController(CementBaseController): <NEW_LINE> <INDENT> class Meta: <NEW_LINE> <INDENT> label = "view" <NEW_LINE> stacked_on = "base" <NEW_LINE> stacked_type = "nested" <NEW_LINE> description = "view contracts and deployments" <NEW_LINE> arguments = [ (['term'], dict(action='store', nargs="?")) ] <NEW_LINE> ...
parent controller for all things to be generated, such as accounts and code
62598f7b9b70327d1c57e724
class DemoView(View): <NEW_LINE> <INDENT> @method_decorator(my_decorator) <NEW_LINE> def get(self, request): <NEW_LINE> <INDENT> return HttpResponse('get请求业务逻辑') <NEW_LINE> <DEDENT> def post(self, request): <NEW_LINE> <INDENT> return HttpResponse('post请求业务逻辑')
定义类视图
62598f7b8e05c05ec3f6eb06
class gbdWebsuiteDialogTest(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 test_icon_png(self): <NEW_LINE> <INDENT> path = ':/plugins/gbdWebsuite/icon.png' <NEW_LINE> icon = QIcon(path) <NEW_LINE>...
Test rerources work.
62598f7bb57a9660fecd13fd
class Card(Comparable): <NEW_LINE> <INDENT> def __init__(self, suit, rank): <NEW_LINE> <INDENT> self.__rank = rank <NEW_LINE> self.__suit = suit <NEW_LINE> <DEDENT> def get_rank(self): <NEW_LINE> <INDENT> return self.__rank <NEW_LINE> <DEDENT> def get_suit(self): <NEW_LINE> <INDENT> return self.__suit <NEW_LINE> <DEDEN...
This immutable class represents a Comparable playing Card, inheriting from the Comparable class, The private instance variables are rank and suit. The number of compares are not kept. Here Aces are low and Kings are high Only Rank is used for comparison Suit: Clubs = 0 Diamonds = 1 Hearts = 2 Spades...
62598f7ba4f1c619b294df6c
class NodeInfo(ListBox): <NEW_LINE> <INDENT> def __init__(self, height: int, model: NodeInfoModel=None, on_change: Callable=None): <NEW_LINE> <INDENT> super().__init__(height, options=[], name='NodeInfoWidget', on_change=on_change) <NEW_LINE> if model != None: <NEW_LINE> <INDENT> self.set_model(model) <NEW_LINE> <DEDEN...
Display a node info. TODO: Link to other info scene by select topic, service, action names.
62598f7bfb3f5b602db47e70
@registry.register_problem <NEW_LINE> class GymPongRandom5k(GymDiscreteProblem): <NEW_LINE> <INDENT> @property <NEW_LINE> def env_name(self): <NEW_LINE> <INDENT> return "Pong-v0" <NEW_LINE> <DEDENT> @property <NEW_LINE> def num_actions(self): <NEW_LINE> <INDENT> return 4 <NEW_LINE> <DEDENT> @property <NEW_LINE> def num...
Pong game, random actions.
62598f7ba79ad161977699df
class PersistentSegmentTree(object): <NEW_LINE> <INDENT> pass
ref: https://www.geeksforgeeks.org/persistent-segment-tree-set-1-introduction/
62598f7b45492302aabfbe5e
class ConnectionClosed(Exception): <NEW_LINE> <INDENT> pass
Exception raised when the connection is closed.
62598f7bec188e330fdf821f
class KMeansClassifiabilityIndex(ClusteringAlgorithm): <NEW_LINE> <INDENT> def __init__(self, n_cluster: int, n_init: int, rescale: bool = False) -> None: <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.param.update({"n_cluster": n_cluster, "n_init": n_init}) <NEW_LINE> <DEDENT> def fit(self, data: np.ndarray) -...
Cluster based on the k-means algorithm, and choose the best set of clusters using the classifiability index of Michelangeli (1995)
62598f7bc432627299fa2958
class ResourceId(_messages.Message): <NEW_LINE> <INDENT> id = _messages.StringField(1) <NEW_LINE> type = _messages.StringField(2)
A container to reference an id for any resource type. A `resource` in Google Cloud Platform is a generic term for something you (a developer) may want to interact with through one of our API's. Some examples are an App Engine app, a Compute Engine instance, a Cloud SQL database, and so on. Fields: id: Required field...
62598f7bd6c5a102081e1ac6
class AssetOwner(TimeTrackable, Named, WithConcurrentGetOrCreate): <NEW_LINE> <INDENT> pass
The company or other entity that are owners of assets.
62598f7b30dc7b766599f1da
class Location(atom.AtomBase): <NEW_LINE> <INDENT> _tag = 'location' <NEW_LINE> _namespace = YOUTUBE_NAMESPACE
The YouTube Location element
62598f7b82261d6c5272fb93
class PizzaSizeAdmin(admin.ModelAdmin): <NEW_LINE> <INDENT> model = PizzaSize
Admin view for :model:`product.PizzaSize`
62598f7b23e79379d538be79
class Scrollbar(Widget): <NEW_LINE> <INDENT> def __init__(self, master=None, cnf={}, **kw): <NEW_LINE> <INDENT> Widget.__init__(self, master, 'scrollbar', cnf, kw) <NEW_LINE> <DEDENT> def activate(self, index=None): <NEW_LINE> <INDENT> return self.tk.call(self._w, 'activate', index) or None <NEW_LINE> <DEDENT> def delt...
Scrollbar widget which displays a slider at a certain position.
62598f7b66673b3332c2fd44
class LogFile(file): <NEW_LINE> <INDENT> def __init__(self, name, mode="a", maxsize=360000): <NEW_LINE> <INDENT> super(LogFile, self).__init__(name, mode) <NEW_LINE> self.maxsize = maxsize <NEW_LINE> self.eol = True <NEW_LINE> try: <NEW_LINE> <INDENT> self.written = os.fstat(self.fileno())[6] <NEW_LINE> <DEDENT> except...
LogFile(name, [mode="w"], [maxsize=360000]) Opens a new file object. After writing <maxsize> bytes a SizeError will be raised.
62598f7b38b623060ffa8a18
class NeedleCaptureOverwriteTest(NeedlePluginTester, TestCase): <NEW_LINE> <INDENT> activate = '--with-needle-capture' <NEW_LINE> plugins = [NeedleCapturePlugin()] <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> self.assertFalse(os.path.exists(baseline_filename)) <NEW_LINE> create_baseline_dir() <NEW_LINE> baseline = o...
Check that an existing baseline file does NOT get overwritten, when using the --with-needle-capture option.
62598f7b3eb6a72ae0389fc2
class Registry(object): <NEW_LINE> <INDENT> def __init__(self, filelikeobject): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._buf = filelikeobject.read() <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> with open(filelikeobject, "rb") as f: <NEW_LINE> <INDENT> self._buf = f.read() <NEW_LINE> <DEDENT>...
A class for parsing and reading from a Windows Registry file.
62598f7b26238365f5fac4f1
class TestFieldEEzsignsignatureType(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 testFieldEEzsignsignatureType(self): <NEW_LINE> <INDENT> pass
FieldEEzsignsignatureType unit test stubs
62598f7be76e3b2f99fd83b2
class FixedReverser(bt.Sizer): <NEW_LINE> <INDENT> params = (('stake', 1),) <NEW_LINE> def _getsizing(self, comminfo, cash, data, isbuy): <NEW_LINE> <INDENT> position = self.strategy.getposition(data) <NEW_LINE> size = self.p.stake * (1 + (position.size != 0)) <NEW_LINE> return size
This sizer returns the needes fixed size to reverse an open position or the fixed size to open one - To open a position: return the param ``stake`` - To reverse a position: return 2 * ``stake`` Params: - ``stake`` (default: ``1``)
62598f7b50485f2cf55da8f1
class RequestContext(object): <NEW_LINE> <INDENT> def __init__(self, auth_token=None, user=None, tenant=None, is_admin=False, read_only=False, show_deleted=False, request_id=None, instance_uuid=None): <NEW_LINE> <INDENT> self.auth_token = auth_token <NEW_LINE> self.user = user <NEW_LINE> self.tenant = tenant <NEW_LINE>...
Helper class to represent useful information about a request context. Stores information about the security context under which the user accesses the system, as well as additional request information.
62598f7b7b25080760ed6e22
class CompleteChore(APIView): <NEW_LINE> <INDENT> permission_classes = (permissions.IsAuthenticated, IsAccountActivated) <NEW_LINE> def get_object(self, pk): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return Chore.objects.get(pk=pk) <NEW_LINE> <DEDENT> except Chore.DoesNotExist: <NEW_LINE> <INDENT> raise Http404 <NEW...
Complete a chore
62598f7b9b70327d1c57e726
class DataStorePickleMixin(object): <NEW_LINE> <INDENT> def __getstate__(self): <NEW_LINE> <INDENT> state = self.__dict__.copy() <NEW_LINE> del state['ds'] <NEW_LINE> if self._mode == 'w': <NEW_LINE> <INDENT> state['_mode'] = 'a' <NEW_LINE> <DEDENT> return state <NEW_LINE> <DEDENT> def __setstate__(self, state): <NEW_L...
Subclasses must define `ds`, `_opener` and `_mode` attributes. Do not subclass this class: it is not part of xarray's external API.
62598f7b50485f2cf55da8f2
class BiothingWebSettings(object): <NEW_LINE> <INDENT> def __init__(self, config='biothings.www.settings.default'): <NEW_LINE> <INDENT> self.config_mod = import_module(config) <NEW_LINE> try: <NEW_LINE> <INDENT> with open(os.path.abspath(self.config_mod.JSONLD_CONTEXT_PATH), 'r') as json_file: <NEW_LINE> <INDENT> self....
A container for the settings that configure the web API
62598f7b76d4e153a661c592
class RestKeyAuthentication(ApiKeyAuthentication): <NEW_LINE> <INDENT> def is_authenticated(self, request, **kwargs): <NEW_LINE> <INDENT> api_key = request.GET.get('api_key') or request.POST.get('api_key') <NEW_LINE> if not api_key: <NEW_LINE> <INDENT> return self._unauthorized() <NEW_LINE> <DEDENT> try: <NEW_LINE> <IN...
Authorize users based on their restkey
62598f7bcad5886f8bdc4ca5
class LoginForm(RequestForm): <NEW_LINE> <INDENT> username = forms.CharField(label=_("Username"), max_length=30) <NEW_LINE> password = forms.CharField(label=_("Password"), widget=forms.PasswordInput) <NEW_LINE> def clean_password(self): <NEW_LINE> <INDENT> username = self.cleaned_data.get('username') <NEW_LINE> passwor...
Base class for authenticating users. Extend this to get a form that accepts username/password logins. Example usage: -------------- url(r'^login/$', "dutils.utils.form_handler", { 'template': 'registration/login.html', "form_cls": "dutils.utils.LoginForm", "next": "/"...
62598f7b0383005118f6d083
class SendEmailCodeView(LoginRequiredMixin, View): <NEW_LINE> <INDENT> def get(self, request): <NEW_LINE> <INDENT> email = request.GET.get('email', '') <NEW_LINE> if UserProfile.objects.filter(email=email): <NEW_LINE> <INDENT> return HttpResponse('{"email":"邮箱已存在"}', content_type='application/json') <NEW_LINE> <DEDENT>...
发送邮箱验证码视图
62598f7b711fe17d825e0069
class RobotConfig(object): <NEW_LINE> <INDENT> c = None <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> file = open('./Config/robot_config.txt') <NEW_LINE> file_contents = file.read() <NEW_LINE> file_contents = re.sub('\s', '', file_contents) <NEW_LINE> file_contents = str(file_contents) <NEW_LINE> self.c = json.loa...
classdocs
62598f7bfb3f5b602db47e71
class BotServer: <NEW_LINE> <INDENT> def __init__(self, pk): <NEW_LINE> <INDENT> pw.setNode(node='https://testnode1.wavesnodes.com', chain='testnet') <NEW_LINE> self._wallet = pw.Address(privateKey=pk) <NEW_LINE> self._asset_cache = [] <NEW_LINE> self.users = { } <NEW_LINE> <DEDENT> def get_asset_ids(self): <NEW_LINE> ...
Bot-object has a big wallet and all in all is an awesome guy. Gives you money and all
62598f7bac7a0e7691f71e9a
class ModelFormatterIter(BaseModelFormatterIter): <NEW_LINE> <INDENT> def format_field(self, field, value): <NEW_LINE> <INDENT> if isinstance(value, (date, datetime, time)) and not isinstance(field, MultiTypeField): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return field.get_formatted_value(value) <NEW_LINE> <DEDENT>...
Iterate over model fields formatting them.
62598f7bbde94217f3707327
class TextSearchConfigToSqlTestCase(InputMapToSqlTestCase): <NEW_LINE> <INDENT> def test_create_ts_config(self): <NEW_LINE> <INDENT> inmap = self.std_map() <NEW_LINE> inmap['schema sd'].update({'text search parser tsp1': { 'start': 'prsd_start', 'gettoken': 'prsd_nexttoken', 'end': 'prsd_end', 'lextypes': 'prsd_lextype...
Test SQL generation for input text search configurations
62598f7b23e79379d538be7a
class TimesketchOAuthCredentials(TimesketchCredentials): <NEW_LINE> <INDENT> TYPE = 'oauth' <NEW_LINE> def from_bytes(self, data): <NEW_LINE> <INDENT> if not isinstance(data, bytes): <NEW_LINE> <INDENT> raise TypeError('Data needs to be bytes.') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> token_dict = json.loads(data....
OAUTH credentials for Timesketch authentication.
62598f7bc432627299fa295a
class IPMessage(object): <NEW_LINE> <INDENT> def __init__(self, ip_addr, source_port, dest_port, protocol, data): <NEW_LINE> <INDENT> if ip_addr is None: <NEW_LINE> <INDENT> raise ValueError("IP address cannot be None") <NEW_LINE> <DEDENT> if protocol is None: <NEW_LINE> <INDENT> raise ValueError("Protocol cannot be No...
This class represents an IP message containing the IP address the message belongs to, the source and destination ports, the IP protocol, and the content (data) of the message.
62598f7bbe383301e025317a
class Dummy: <NEW_LINE> <INDENT> def __init__(self, value): <NEW_LINE> <INDENT> self.value = value <NEW_LINE> <DEDENT> def double(self): <NEW_LINE> <INDENT> return self.value * 2
Testing docstring.
62598f7be76e3b2f99fd83b5
class Option: <NEW_LINE> <INDENT> def __init__(self, label, description, defaultValue="", suboptions=[], customAttribute=None): <NEW_LINE> <INDENT> self.label = label <NEW_LINE> self.description = description <NEW_LINE> self.descriptionCache = None <NEW_LINE> self.descriptionCacheArg = None <NEW_LINE> self.value = defa...
Represents a UI option on screen, and holds its attributes.
62598f7b4e696a045264dac1
class Poisson: <NEW_LINE> <INDENT> def __init__(self, p, k, n): <NEW_LINE> <INDENT> self.val = Poisson.get(p, k, n) <NEW_LINE> self.equation_str = Poisson.es(p, k, n) <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def get(p, k, n, l = None): <NEW_LINE> <INDENT> if l is not None: <NEW_LINE> <INDENT> return ((pow((l),k) / ...
Use this method if np < 9 and n > 20
62598f7b50485f2cf55da8f3
class FirmwareInfo(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.Version = None <NEW_LINE> self.Md5sum = None <NEW_LINE> self.CreateTime = None <NEW_LINE> self.ProductName = None <NEW_LINE> self.Name = None <NEW_LINE> self.Description = None <NEW_LINE> self.ProductId = None <NEW_LINE>...
设备固件详细信息
62598f7b3eb6a72ae0389fc4
class GetMetadataActivity(ExecutionActivity): <NEW_LINE> <INDENT> _validation = { 'name': {'required': True}, 'type': {'required': True}, 'dataset': {'required': True}, } <NEW_LINE> _attribute_map = { 'additional_properties': {'key': '', 'type': '{object}'}, 'name': {'key': 'name', 'type': 'str'}, 'description': {'key'...
Activity to get metadata of dataset. :param additional_properties: Unmatched properties from the message are deserialized this collection :type additional_properties: dict[str, object] :param name: Activity name. :type name: str :param description: Activity description. :type description: str :param depends_on: Activ...
62598f7b0383005118f6d084
class SubprocessExecutorBase(object): <NEW_LINE> <INDENT> def __init__(self, args, close_fds, cwd, env, pathspec): <NEW_LINE> <INDENT> self._args = args <NEW_LINE> self._close_fds = close_fds <NEW_LINE> self._cwd = cwd <NEW_LINE> self._env = env <NEW_LINE> self._pathspec = pathspec <NEW_LINE> self._popen = None <NEW_LI...
Encapsulate execution of a subprocess.
62598f7b6aa9bd52df0d485b
class TwitterSearcher(Searcher): <NEW_LINE> <INDENT> def __init__(self, driver): <NEW_LINE> <INDENT> super().__init__(driver, build_script(SEARCH_RESULT_LINKS)) <NEW_LINE> <DEDENT> def wait_user_choice(self): <NEW_LINE> <INDENT> wait = WebDriverWait(self.driver, 600) <NEW_LINE> wait.until(lambda d: (not d.cu...
Searcher implementation for twitter
62598f7b50485f2cf55da8f4
class Google(): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.service = build("customsearch", "v1", developerKey=devKey) <NEW_LINE> <DEDENT> def search(self, place): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> print('Searching images...') <NEW_LINE> results = self.service.cse().list( q=place, num=nu...
Using a Google Custom Search Engine (CSE) that returns four (4) images.
62598f7b76d4e153a661c594
class EntityTime(ElementBase): <NEW_LINE> <INDENT> name = 'time' <NEW_LINE> namespace = 'urn:xmpp:time' <NEW_LINE> plugin_attrib = 'entity_time' <NEW_LINE> interfaces = {'tzo', 'utc', 'time'} <NEW_LINE> sub_interfaces = interfaces <NEW_LINE> def set_time(self, value): <NEW_LINE> <INDENT> date = value <NEW_LINE> if not ...
The <time> element represents the local time for an XMPP agent. The time is expressed in UTC to make synchronization easier between entities, but the offset for the local timezone is also included. Example <time> stanzas: :: <iq type="result"> <time xmlns="urn:xmpp:time"> <utc>2011-07-03T11:37:12.23...
62598f7b8da39b475be02b67
@cassiopeia.type.core.common.inheritdocs <NEW_LINE> class Rune(cassiopeia.type.dto.common.CassiopeiaDto): <NEW_LINE> <INDENT> def __init__(self, dictionary): <NEW_LINE> <INDENT> self.count = dictionary.get("count", 0) <NEW_LINE> self.runeId = dictionary.get("runeId", 0)
Args: count (int): the count of this rune used by the participant runeId (int): the ID of the rune
62598f7b711fe17d825e006b
class ImageDetailView(APIView): <NEW_LINE> <INDENT> def get_object(self, pk): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return Image.objects.get(pk=pk) <NEW_LINE> <DEDENT> except Image.DoesNotExist: <NEW_LINE> <INDENT> raise http.Http404 <NEW_LINE> <DEDENT> <DEDENT> def get(self, request, pk, format=None): <NEW_LINE...
根据 pk 获取镜像 Info: GET /images/(pk)/ HTTP/1.1 Content-Type: application/json Example request: GET /images/2/ HTTP/1.1
62598f7bbde94217f3707328
@memo.thread <NEW_LINE> class QtThread(QtCore.QThread): <NEW_LINE> <INDENT> def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> super(QtThread, self).__init__(*args, **kwds)
Generic Qt thread class for testing
62598f7b1f5feb6acb1625ba
class IsOwner(permissions.BasePermission): <NEW_LINE> <INDENT> def has_object_permission(self, request, view, obj): <NEW_LINE> <INDENT> return request.user in obj.users.all()
Custom permission to only allow owners of an object to edit it.
62598f7bac7a0e7691f71e9c
class MockSFConnection(object): <NEW_LINE> <INDENT> class Bunch(object): <NEW_LINE> <INDENT> def __init__(self, **kw): <NEW_LINE> <INDENT> setattr(self, '__dict__', kw) <NEW_LINE> <DEDENT> <DEDENT> def __init__(self, force_error=False, where=None): <NEW_LINE> <INDENT> self.force_error = force_error <NEW_LINE> self.wher...
mock connection to ElementSW host
62598f7b82261d6c5272fb95
class subsuite(InstanceFilter): <NEW_LINE> <INDENT> def __init__(self, name=None): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> <DEDENT> def __call__(self, tests, values): <NEW_LINE> <INDENT> for test in tests: <NEW_LINE> <INDENT> subsuite = test.get('subsuite', '') <NEW_LINE> if ',' in subsuite: <NEW_LINE> <INDENT>...
If `name` is None, removes all tests that have a `subsuite` key. Otherwise removes all tests that do not have a subsuite matching `name`. It is possible to specify conditional subsuite keys using: subsuite = foo,condition where 'foo' is the subsuite name, and 'condition' is the same type of condition used for skip...
62598f7b71ff763f4b5e70f0
class InstrIOError(InstrError): <NEW_LINE> <INDENT> pass
Generic errors for communication errors.
62598f7b96565a6dacd2cc3c
class TeamGreenBasePredictor(IPredictor): <NEW_LINE> <INDENT> def __init__(self, nn_filename: str): <NEW_LINE> <INDENT> self.model = load_keras_sequential(RELATIVE_PATH, nn_filename) <NEW_LINE> assert self.model is not None <NEW_LINE> self.model.compile(loss='mean_squared_error', optimizer='sgd') <NEW_LINE> <DEDENT> de...
Predictor based on an already trained neural network.
62598f7b15fb5d323ce7e6ae
@dataclass <NEW_LINE> class TFDPRReaderOutput(ModelOutput): <NEW_LINE> <INDENT> start_logits: tf.Tensor = None <NEW_LINE> end_logits: tf.Tensor = None <NEW_LINE> relevance_logits: tf.Tensor = None <NEW_LINE> hidden_states: Optional[Tuple[tf.Tensor]] = None <NEW_LINE> attentions: Optional[Tuple[tf.Tensor]] = None
Class for outputs of :class:`~transformers.TFDPRReaderEncoder`. Args: start_logits: (:obj:``tf.Tensor`` of shape ``(n_passages, sequence_length)``): Logits of the start index of the span for each passage. end_logits: (:obj:``tf.Tensor`` of shape ``(n_passages, sequence_length)``): Logits of the...
62598f7b596a8972361275f7
class ContainerServiceSshConfiguration(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'public_keys': {'required': True}, } <NEW_LINE> _attribute_map = { 'public_keys': {'key': 'publicKeys', 'type': '[ContainerServiceSshPublicKey]'}, } <NEW_LINE> def __init__( self, *, public_keys: List["ContainerServi...
SSH configuration for Linux-based VMs running on Azure. All required parameters must be populated in order to send to Azure. :ivar public_keys: Required. The list of SSH public keys used to authenticate with Linux-based VMs. Only expect one key specified. :vartype public_keys: list[~azure.mgmt.containerservice.v202...
62598f7ba05bb46b3848a200
class NonscientificDecimalField(models.DecimalField): <NEW_LINE> <INDENT> def value_from_object(self, obj): <NEW_LINE> <INDENT> def remove_exponent(val): <NEW_LINE> <INDENT> context = Context(prec=self.max_digits) <NEW_LINE> return val.quantize(Decimal(1), context=context) if val == val.to_integral() else val.normalize...
Prevents values from being displayed with E notation, with trailing 0's after the decimal place truncated. (This causes precision to be lost in many cases, but is more user friendly and consistent for non-scientist users)
62598f7bd99f1b3c44d05031
class WorkerManager(IWorkerManager): <NEW_LINE> <INDENT> jobs = None <NEW_LINE> workers = None <NEW_LINE> logger = None <NEW_LINE> _jobs_lock = None <NEW_LINE> _workers_lock = None <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> self.logger = logging.getLogger(type(self).__name__) <NEW_LINE> self.jobs = [] <NEW_LINE...
Generic class that implements IWorkerManager.
62598f7bd10714528d69d852
class ZoeRoleAPI(ZoeAPIBase): <NEW_LINE> <INDENT> def get(self, role_id: int) -> dict: <NEW_LINE> <INDENT> data, status_code = self._rest_get('/role/' + str(role_id)) <NEW_LINE> if status_code == 200: <NEW_LINE> <INDENT> return data['role'] <NEW_LINE> <DEDENT> elif status_code == 404: <NEW_LINE> <INDENT> raise ZoeAPIEx...
The role API class.
62598f7bf7d966606f74796b
class cache(object): <NEW_LINE> <INDENT> def __init__(self, ttl=None): <NEW_LINE> <INDENT> self.ttl = ttl <NEW_LINE> self.cache = {} <NEW_LINE> <DEDENT> def __call__(self, func): <NEW_LINE> <INDENT> def wrap(*args): <NEW_LINE> <INDENT> now = time.time() <NEW_LINE> try: <NEW_LINE> <INDENT> rep = str(args) <NEW_LINE> if...
Caching decorator basically taken from the `Python Wiki <http://wiki.python.org/moin/PythonDecoratorLibrary>`_. >>> @cache(ttl=60) >>> def fibonacci(n): ... "Return the nth fibonacci number." ... if n in (0, 1): ... return n ... return fibonacci(n-1) + fibonacci(n-2) >>> >>> fibonacci(12) ========= ===...
62598f7b1f037a2d8b9e3a6f
class SchedulerItem: <NEW_LINE> <INDENT> def __init__(self, start: float, end: float, filter_name: str, binning: Tuple[int, int], priority: float): <NEW_LINE> <INDENT> self.start = start <NEW_LINE> self.end = end <NEW_LINE> self.filter_name = filter_name <NEW_LINE> self.binning = binning <NEW_LINE> self.priority = prio...
A single item in the flat scheduler
62598f7b07d97122c4216627
class KalmanFilter(_Filter): <NEW_LINE> <INDENT> def __init__(self, x0, P0, F = None, Q0 = None, H = None, R0 = None, Uf = None, Uh = None, _verbose:bool= False): <NEW_LINE> <INDENT> self.state = {'expected': np.array(x0), 'err_cov' : np.array(P0)} <NEW_LINE> if F is None: <NEW_LINE> <INDENT> F = np.eye(x0.shape[0]) ...
Linear Discrete Kalman Filter TODO: write docstring
62598f7b0383005118f6d087
class FuncFormatter2(ticker.Formatter): <NEW_LINE> <INDENT> def __init__(self, func, **kwargs): <NEW_LINE> <INDENT> self.func = func <NEW_LINE> self.kwargs = kwargs <NEW_LINE> <DEDENT> def __call__(self, x, pos=None): <NEW_LINE> <INDENT> return self.func(x, pos, **self.kwargs)
Use a user-defined function for formatting. The function should take in two inputs (a tick value ``x`` and a position ``pos``), and return a string containing the corresponding tick label.
62598f7ba79ad161977699e6
class Average(TwoSampleCrossover): <NEW_LINE> <INDENT> def __init__(self, n=None, delta=None, stdev=None, known_stdev=None, margin=None, alpha=None, beta=None, power=None): <NEW_LINE> <INDENT> super(Average, self).__init__(n=n, mu_1=delta, mu_2=0, stdev=stdev, known_stdev=known_stdev, hypothesis="equivalence", margin=m...
Power and Sample Size calculations for tests of average bioequivalence. This class calculates the power and sample size for testing Average Bioequivalence using a two-sequence, two-period crossover design. The hypothesis thus is the same as an equivalence test using the TwoSampleCrossover class. Attributes: n: T...
62598f7bbde94217f3707329
class ComparitorElementParent(object): <NEW_LINE> <INDENT> def child_now_true(self): <NEW_LINE> <INDENT> pass
Special methods for thing that can be a parent
62598f7b23e79379d538be7e
class LastWeekdayInMonthHoliday(OrdinaryAnnualHoliday): <NEW_LINE> <INDENT> def __init__(self, day_of_week: int, month: int, days_before: int = 1, days_after: int = 1): <NEW_LINE> <INDENT> super().__init__(days_before, days_after) <NEW_LINE> if month < 1 or month > 12: <NEW_LINE> <INDENT> raise Exception("month must be...
A holiday that occurs each year on the final weekday in a given month. For example, US Memorial Day is the last Monday in May.
62598f7b73bcbd0ca4bc9bd5
class Callback(BaseHandler): <NEW_LINE> <INDENT> _once: bool <NEW_LINE> _instream: bool <NEW_LINE> def __init__(self, name: str, matcher: MatcherBase, pointer: Callable[[StanzaBase], Any], once: bool = False, instream: bool = False, stream: Optional[XMLStream] = None): <NEW_LINE> <INDENT> BaseHandler.__init__(self, nam...
The Callback handler will execute a callback function with matched stanzas. The handler may execute the callback either during stream processing or during the main event loop. Callback functions are all executed in the same thread, so be aware if you are executing functions that will block for extended periods of tim...
62598f7b1f5feb6acb1625bc
class IfrcvaddresstypeEnum(Enum): <NEW_LINE> <INDENT> other = 1 <NEW_LINE> volatile = 2 <NEW_LINE> nonVolatile = 3 <NEW_LINE> @staticmethod <NEW_LINE> def _meta_info(): <NEW_LINE> <INDENT> from ydk.models.cisco_ios_xe._meta import _IF_MIB as meta <NEW_LINE> return meta._meta_table['IfMib.Ifrcvaddresstable.Ifrcvaddresse...
IfrcvaddresstypeEnum This object has the value nonVolatile(3) for those entries in the table which are valid and will not be deleted by the next restart of the managed system. Entries having the value volatile(2) are valid and exist, but have not been saved, so that will not exist after the next restart of the m...
62598f7b07d97122c4216628
class ModuleItem(Model): <NEW_LINE> <INDENT> def __init__(self, json, api, url, parent): <NEW_LINE> <INDENT> super().__init__(json, api, parent) <NEW_LINE> self._url = lambda: url.format(self['id']) <NEW_LINE> self._update_data = lambda: {'module_item': self._json} <NEW_LINE> self.content = None <NEW_LINE> <DEDENT> def...
Module item model
62598f7b96565a6dacd2cc3d
class ValidationException(Exception): <NEW_LINE> <INDENT> pass
Thrown when validation fails
62598f7b82261d6c5272fb96
class Execution(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self._completed = False <NEW_LINE> self._exception = None <NEW_LINE> self._result_values = () <NEW_LINE> self._result_arguments = {} <NEW_LINE> <DEDENT> @property <NEW_LINE> def completed(self): <NEW_LINE> <INDENT> return self._complet...
Object tracking the execution of a Quest. An Execution object is created for each Quest when it starts running. Therefore, each Attempt consists of a list of Executions. The Attempt is finished when an Execution fails or when the number of completed Executions is equal to the number of Quests. If an Execution fails, t...
62598f7b30dc7b766599f1df
class DCLayer(MergeLayer): <NEW_LINE> <INDENT> def __init__(self, incomings, data_shape, inv_noise_level=None, **kwargs): <NEW_LINE> <INDENT> if 'name' not in kwargs: <NEW_LINE> <INDENT> kwargs['name'] = 'dc' <NEW_LINE> <DEDENT> super(DCLayer, self).__init__(incomings, **kwargs) <NEW_LINE> self.inv_noise_level = inv_no...
Data consistency layer
62598f7b0fa83653e46f4877
class Graph(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.vertexList = {} <NEW_LINE> self.count = 0 <NEW_LINE> <DEDENT> def addVertex(self, key): <NEW_LINE> <INDENT> self.count += 1 <NEW_LINE> newVertex = Vertex(key) <NEW_LINE> self.vertexList[key] = newVertex <NEW_LINE> return newVertex <NE...
This class helps to create Graph with the help of created vertexes
62598f7bf7d966606f74796d
class DurationPerFlow(base_tests.SimpleDataPlane): <NEW_LINE> <INDENT> def runTest(self): <NEW_LINE> <INDENT> logging.info("Running DurationPerFlow test") <NEW_LINE> of_ports = config["port_map"].keys() <NEW_LINE> of_ports.sort() <NEW_LINE> self.assertTrue(len(of_ports) > 1, "Not enough ports for test") <NEW_LINE> dele...
Verify Duration_sec and Duration_nsec counters per flow varies in accordance with the amount of time the flow was alive
62598f7b8a43f66fc4bf1b05
class MemoryPagingStatsReport(SingleDevStatsReport): <NEW_LINE> <INDENT> resource = 'memory_paging' <NEW_LINE> link = 'report' <NEW_LINE> data_key = 'response_data'
Report class to return the memory paging timeseries
62598f7b6aa9bd52df0d485f
class ExpressRouteCircuitsRoutesTableSummaryListResult(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'value': {'key': 'value', 'type': '[ExpressRouteCircuitRoutesTableSummary]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } <NEW_LINE> def __init__( self, *, value: Optional[List["ExpressRoute...
Response for ListRoutesTable associated with the Express Route Circuits API. :param value: A list of the routes table. :type value: list[~azure.mgmt.network.v2017_06_01.models.ExpressRouteCircuitRoutesTableSummary] :param next_link: The URL to get the next set of results. :type next_link: str
62598f7bbe8e80087fbbe9e8
class APIServer: <NEW_LINE> <INDENT> _SERVICE_ACCOUNT_CA = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" <NEW_LINE> _SERVICE_ACCOUNT_TOKEN = "/var/run/secrets/kubernetes.io/serviceaccount/token" <NEW_LINE> def get(self, path): <NEW_LINE> <INDENT> return self.request("GET", path) <NEW_LINE> <DEDENT> def request...
Wraps the logic needed to access the k8s API server from inside a pod. It does this by reading the service account token which is mounted onto the pod.
62598f7b8a349b6b43685bc9
class RandomSaturation(object): <NEW_LINE> <INDENT> def __init__(self, distort_prob, lower=0.5, upper=1.5): <NEW_LINE> <INDENT> self.distort_prob = distort_prob <NEW_LINE> self.lower = lower <NEW_LINE> self.upper = upper <NEW_LINE> assert self.upper >= self.lower, "contrast upper must be >= lower." <NEW_LINE> assert se...
Randomly adjust the saturation of an image given a lower and upper bound, and a distortion probability. This function assumes the image is in HSV!!
62598f7b76d4e153a661c598
@enum.unique <NEW_LINE> class CostType(enum.Enum): <NEW_LINE> <INDENT> SQUARED = 'SQUARED' <NEW_LINE> ABS = 'ABS' <NEW_LINE> HINGE = 'HINGE'
Cost function types supported by TrajOpt. * SQUARED: minimize `f(x)^2` * ABS: minimize `abs(f(x))` * HINGE: minimize `f(x)` while `f(x) > 0`
62598f7b07d97122c4216629
class SetAppFieldsWithoutAppName(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.ga = GoogleAnalytics(PROPERTY_ID) <NEW_LINE> self.ga.set( app_id=APP_ID, app_version=APP_VERSION, app_installer_id=APP_INSTALLER_ID, ) <NEW_LINE> <DEDENT> def test_01_web_tracker_type(self): <NEW_LINE> <IN...
Tests for set() with app fields without app name.
62598f7b23e79379d538be81
class TestGNBC(BaseTaskTest): <NEW_LINE> <INDENT> def test_arguments(self): <NEW_LINE> <INDENT> xt = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) <NEW_LINE> yt = np.array([0, 1, 0]) <NEW_LINE> self.check_arguments(GaussianNBC, GaussianNB, xt, yt) <NEW_LINE> <DEDENT> def test_classification(self): <NEW_LINE> <INDENT> X, ...
Test case for GaussianNB classifier.
62598f7bb830903b9686e135
class OrganizationInfoSchema(MappingSchema): <NEW_LINE> <INDENT> name = SingleLine(missing=drop) <NEW_LINE> validator = OneOf(['registered_nonprofit', 'planned_nonprofit', 'support_needed', 'other', ]) <NEW_LINE> city = SingleLine(missing=drop) <NEW_LINE> country = ISOCountryCode(missing=drop) <NEW_LINE> help_request =...
Data structure for organizational information.
62598f7bfb3f5b602db47e74
class SklearnPrecisionScore(SklearnClassificationMetric): <NEW_LINE> <INDENT> def __init__(self, gt_logits=False, pred_logits=True, **kwargs): <NEW_LINE> <INDENT> super().__init__(precision_score, gt_logits, pred_logits, **kwargs)
Precision Score
62598f7b30dc7b766599f1e1
class FormsetTestCase(TestCase): <NEW_LINE> <INDENT> def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(FormsetTestCase, self).__init__(*args, **kwargs) <NEW_LINE> (dummyWin, dummyBx) = getDummyEnv() <NEW_LINE> self.uiParam=OrderedDict([ ("win", dummyWin), ("bx", dummyBx.obj), ("unFocusFxn", lambda: True) ]...
To test the Formset.
62598f7b26238365f5fac4f9
class FloorsBelowGrade(BSElement): <NEW_LINE> <INDENT> element_type = "xs:integer"
Number of floors which are fully underground.
62598f7b3eb6a72ae0389fca
class KeyValue(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'key': {'key': 'key', 'type': 'str', 'xml': {'name': 'Key', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'value': {'key': 'value', 'type': 'str', 'xml': {'name': 'Value', 'ns': 'http://schemas.microsoft....
Key Values of custom properties. :param key: :type key: str :param value: :type value: str
62598f7b07f4c71912baedd6
class KleinanzeigenEbay(Provider): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(KleinanzeigenEbay, self).__init__() <NEW_LINE> self.base_url = "https://www.ebay-kleinanzeigen.de" <NEW_LINE> self.url = "https://www.ebay-kleinanzeigen.de/s-suchanfrage.html?keywords={keywords}&categoryId=&locationStr=...
Scraper class for Kleinanzeigen-Ebay.de
62598f7b30c21e258be98191
class Unit(models.Model): <NEW_LINE> <INDENT> building = models.ForeignKey( 'buildings.Building', on_delete=models.CASCADE, verbose_name=_('copropiedad'), ) <NEW_LINE> block = models.CharField( max_length=50, null=True, blank=True, verbose_name=_('bloque'), help_text=_('Bloque o interior'), ) <NEW_LINE> unit = models.C...
This model represents an apartment, house or office that is part of a condo.
62598f7b50485f2cf55da8f9
class Light(RoleWrapper): <NEW_LINE> <INDENT> role = 'light'
Light text (Not implemented in RST spec)
62598f7b8a43f66fc4bf1b07
class _Data(object): <NEW_LINE> <INDENT> def __repr__(self): <NEW_LINE> <INDENT> attrs = [x for x in self.__dir__() if not x.startswith('__')] <NEW_LINE> cols = [self.__getattribute__(attr).columns for attr in attrs] <NEW_LINE> outputDict = dict(zip(attrs, cols)) <NEW_LINE> return str(outputDict)
Simple DataFrame container that prints neat information about all of your datasets saved to the object
62598f7b004d5f362081ecbf
class currenciesAcceptedProp(SchemaProperty): <NEW_LINE> <INDENT> _prop_schema = 'currenciesAccepted' <NEW_LINE> _expected_schema = None <NEW_LINE> _enum = False <NEW_LINE> _format_as = "TextField"
SchemaField for currenciesAccepted Usage: Include in SchemaObject SchemaFields as your_django_field = currenciesAcceptedProp() schema.org description:The currency accepted (in ISO 4217 currency format). prop_schema returns just the property without url# format_as is used by app templatetags based upon schema.org dat...
62598f7bd53ae8145f917e1f
class CauseAssertionError(CauseExceptionMixin, Question): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.exception = AssertionError <NEW_LINE> <DEDENT> def get_correct_answers(self): <NEW_LINE> <INDENT> return ['assert(False)']
Cause an AssertionError. https://docs.python.org/3.6/library/exceptions.html#AssertionError
62598f7b76d4e153a661c59a
class IsTaskOwnerOrReadOnly(permissions.IsAuthenticated): <NEW_LINE> <INDENT> def has_object_permission(self, request, view, obj): <NEW_LINE> <INDENT> if request.method in permissions.SAFE_METHODS: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return (request.user and request.user.is_staff) or request.user == obj...
Object-level permission to only allow task owner to modify a task, otherwise members are read-only
62598f7b66656f66f7d59d7b
class Emulator(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.__memory = memory.Memory() <NEW_LINE> self.__cpu = cpu.Processor(self.__memory) <NEW_LINE> <DEDENT> def load_code(self, code): <NEW_LINE> <INDENT> self.__memory.code = code <NEW_LINE> <DEDENT> def run(self): <NEW_LINE> <INDENT> if ...
This class is used to manage the entire emulation process. It is practically a wrapper which joins the CPU and the memory to a unified data structure
62598f7b0383005118f6d08b
class RvContext(Context): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def fileName(cls): <NEW_LINE> <INDENT> raise ContextFileNameError( "Could not figure out scene name" ) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def isEmpty(cls): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def hasMo...
Context implementation for rv.
62598f7b45492302aabfbe68
class Features(JsonObject): <NEW_LINE> <INDENT> hair = StringProperty(choices=['brown', ('blond', 'Blond'), 'grey']) <NEW_LINE> eyes = StringProperty()
Make sure doc string isn't treated as a property called __doc__!
62598f7bb57a9660fecd1407
class ProductImage(models.Model): <NEW_LINE> <INDENT> product = models.ForeignKey(Product, related_name="images") <NEW_LINE> image = models.ImageField(upload_to='images/') <NEW_LINE> caption = models.CharField(_("optional caption"), max_length=100, null=True, blank=True, help_text="And used as the alt text in the html....
Images for a product
62598f7b23e79379d538be82