code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
class ImageProcessorSettings(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.filter = dict(min_width = 1, min_height = 1, max_width = 10000, max_height = 10000, max_size_bytes = 2*4*1024*1024, remove_flickr_placeholders = False) <NEW_LINE> self.conversion = dict(format = 'jpg', suffix = '-clean', max_width = 10000, max_height = 10000, subdir = '') <NEW_LINE> self.thumbnail = dict(format = 'jpg', suffix = '-thumb', subdir = '', width = 90, height = 90, pad_to_size = True)
Settings class for ImageProcessor Defines the following setting groups: filter - settings related to filtering out of images from further processing conversion - settings related to the standardization and re-writing of downloaded images thumbnail - settings related to the generation of thumbnails for downloaded images
6259901dd18da76e235b7859
class ConcurrentChange(Error): <NEW_LINE> <INDENT> _qualname = 'ConcurrentChange' <NEW_LINE> def __init__(self, messages=None, data=None, ): <NEW_LINE> <INDENT> Error.__init__( self, messages=messages, data=data, )
The ``ConcurrentChange`` exception indicates that a data structure, entity, or resource has been modified since some earlier point in time. Typically this happens when the client is doing the *write* portion of a read-modify-write sequence and indicates that it wants the server to notify it if the data in the server has changed after it did the *read*, so that it can avoid overwriting that change inadvertantly. .. tip:: The arguments are used to initialize data attributes with the same names.
6259901d56b00c62f0fb36d6
class EventManageTest(TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> User.objects.create_user('admin', 'admin@dj.com', 'admin123456') <NEW_LINE> Event.objects.create(id=1, name="Moto X", attendees_limit="1000", address="Sunnyvale", status=1, start_time="2014-8-12 12:30:00") <NEW_LINE> self.login_user = {'username': 'admin', 'password': 'admin123456'} <NEW_LINE> <DEDENT> def test_event_manage_success(self): <NEW_LINE> <INDENT> response = self.client.post('/login_action/', data=self.login_user) <NEW_LINE> response = self.client.post('/event_manage/') <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertIn(b"Moto X", response.content) <NEW_LINE> self.assertIn(b"Sunnyvale", response.content) <NEW_LINE> <DEDENT> def test_event_manage_search_success(self): <NEW_LINE> <INDENT> response = self.client.post('/login_action/', data=self.login_user) <NEW_LINE> response = self.client.post('/search_name/', {"name": "Moto"}) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertIn(b"Moto X", response.content) <NEW_LINE> self.assertIn(b"Sunnyvale", response.content)
test event manage
6259901da8ecb03325872036
class LoginHandle(BaseHandle): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.login_page = LoginPage() <NEW_LINE> <DEDENT> def input_username(self, username): <NEW_LINE> <INDENT> self.input_text(self.login_page.find_username(), username) <NEW_LINE> <DEDENT> def input_pwd(self, pwd): <NEW_LINE> <INDENT> self.input_text(self.login_page.find_pwd(), pwd) <NEW_LINE> <DEDENT> def input_code(self, code): <NEW_LINE> <INDENT> self.input_text(self.login_page.find_code(), code) <NEW_LINE> <DEDENT> def click_login_btn(self): <NEW_LINE> <INDENT> self.click_func(self.login_page.find_login_btn())
登录-操作层
6259901d462c4b4f79dbc822
class DataRecord: <NEW_LINE> <INDENT> def __init__(self, output_value, attribute_values: List): <NEW_LINE> <INDENT> self.output_value = output_value <NEW_LINE> self.attribute_values = attribute_values <NEW_LINE> <DEDENT> def summary(self): <NEW_LINE> <INDENT> attribute_values = [round(x, 3) if isinstance(x, float) else x for x in self.attribute_values] <NEW_LINE> return f'({repr(self.output_value)}, {attribute_values})' <NEW_LINE> <DEDENT> def __getitem__(self, index): <NEW_LINE> <INDENT> return self.attribute_values[index] <NEW_LINE> <DEDENT> def __setitem__(self, index, value): <NEW_LINE> <INDENT> self.attribute_values[index] = value <NEW_LINE> <DEDENT> def __delitem__(self, index): <NEW_LINE> <INDENT> del self.attribute_values[index] <NEW_LINE> <DEDENT> def __len__(self): <NEW_LINE> <INDENT> return len(self.attribute_values) <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return f'({repr(self.output_value)}, {self.attribute_values})' <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return self.__str__() <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, DataRecord): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if self.attribute_values != other.attribute_values: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if self.output_value != other.output_value: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> def __hash__(self): <NEW_LINE> <INDENT> return hash(self.__repr__())
Class that stores a class name, and a list of attribute values.
6259901dd164cc6175821d98
class ColoredManhole(Manhole): <NEW_LINE> <INDENT> def getSource(self): <NEW_LINE> <INDENT> return (b'\n'.join(self.interpreter.buffer) + b'\n' + b''.join(self.lineBuffer)) <NEW_LINE> <DEDENT> def characterReceived(self, ch, moreCharactersComing): <NEW_LINE> <INDENT> if self.mode == 'insert': <NEW_LINE> <INDENT> self.lineBuffer.insert(self.lineBufferIndex, ch) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.lineBuffer[self.lineBufferIndex:self.lineBufferIndex+1] = [ch] <NEW_LINE> <DEDENT> self.lineBufferIndex += 1 <NEW_LINE> if moreCharactersComing: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if ch == b' ': <NEW_LINE> <INDENT> self.terminal.write(ch) <NEW_LINE> return <NEW_LINE> <DEDENT> source = self.getSource() <NEW_LINE> try: <NEW_LINE> <INDENT> coloredLine = lastColorizedLine(source) <NEW_LINE> <DEDENT> except tokenize.TokenError: <NEW_LINE> <INDENT> self.terminal.write(ch) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.terminal.eraseLine() <NEW_LINE> self.terminal.cursorBackward(len(self.lineBuffer) + len(self.ps[self.pn]) - 1) <NEW_LINE> self.terminal.write(self.ps[self.pn] + coloredLine) <NEW_LINE> n = len(self.lineBuffer) - self.lineBufferIndex <NEW_LINE> if n: <NEW_LINE> <INDENT> self.terminal.cursorBackward(n)
A REPL which syntax colors input as users type it.
6259901da8ecb03325872038
class _SwaggerParameterStore: <NEW_LINE> <INDENT> definitions = {}
Singleton with parameter definitions
6259901d925a0f43d25e8e5d
class FoodInventory: <NEW_LINE> <INDENT> def food_grains(self): <NEW_LINE> <INDENT> with open("inventory_data.json", "r") as file: <NEW_LINE> <INDENT> file_read = file.read() <NEW_LINE> file.close() <NEW_LINE> items = json.loads(file_read) <NEW_LINE> <DEDENT> print(items, "\n") <NEW_LINE> print("rice price details") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "\/") <NEW_LINE> for rice in items["Rice"]: <NEW_LINE> <INDENT> rice_total_price = int(rice["price per kg"]) * int(rice["weight"]) <NEW_LINE> print(rice["name"], " = ", rice_total_price) <NEW_LINE> <DEDENT> print("\n") <NEW_LINE> print("wheat price details") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "\/") <NEW_LINE> for wheat in items["Wheat"]: <NEW_LINE> <INDENT> wheat_total_price = int(wheat["price per kg"]) * int(wheat["weight"]) <NEW_LINE> print(wheat["name"], " = ", wheat_total_price) <NEW_LINE> <DEDENT> print("\n") <NEW_LINE> print("pulse price details") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "||") <NEW_LINE> print(" ", " ", " ", "\/") <NEW_LINE> for pulse in items["Pulse"]: <NEW_LINE> <INDENT> pulse_total_price = int(pulse["price per kg"] * int(pulse["weight"])) <NEW_LINE> print(pulse["name"], " = ", pulse_total_price)
This class is created to display the details of the inventory data which is containing the grains.
6259901dd164cc6175821d9a
class BuildScriptTests(TestCase): <NEW_LINE> <INDENT> def test_usage_error_status(self): <NEW_LINE> <INDENT> fake_sys_module = FakeSysModule(argv=[]) <NEW_LINE> script = BuildScript(sys_module=fake_sys_module) <NEW_LINE> exception = self.assertRaises(SystemExit, script.main) <NEW_LINE> self.assertEqual(1, exception.code) <NEW_LINE> <DEDENT> def test_usage_error_message(self): <NEW_LINE> <INDENT> fake_sys_module = FakeSysModule(argv=[]) <NEW_LINE> script = BuildScript(sys_module=fake_sys_module) <NEW_LINE> try: <NEW_LINE> <INDENT> script.main() <NEW_LINE> <DEDENT> except SystemExit: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self.assertEqual( 'Wrong number of arguments.', fake_sys_module.stderr.getvalue().splitlines()[-1] ) <NEW_LINE> <DEDENT> def test_build_command(self): <NEW_LINE> <INDENT> self.assertIs(build_in_docker, BuildScript.build_command) <NEW_LINE> <DEDENT> def test_run(self): <NEW_LINE> <INDENT> expected_destination_path = FilePath(self.mktemp()) <NEW_LINE> expected_distribution = 'centos7' <NEW_LINE> expected_package_uri = 'http://www.example.com/foo/bar.whl' <NEW_LINE> fake_sys_module = FakeSysModule( argv=[ 'build-command-name', '--destination-path', expected_destination_path.path, '--distribution=%s' % (expected_distribution,), expected_package_uri] ) <NEW_LINE> script = BuildScript(sys_module=fake_sys_module) <NEW_LINE> build_step = SpyStep() <NEW_LINE> arguments = [] <NEW_LINE> def record_arguments(*args, **kwargs): <NEW_LINE> <INDENT> arguments.append((args, kwargs)) <NEW_LINE> return build_step <NEW_LINE> <DEDENT> script.build_command = record_arguments <NEW_LINE> script.main() <NEW_LINE> expected_build_arguments = [( (), dict(destination_path=expected_destination_path, distribution=expected_distribution, package_uri=expected_package_uri, top_level=None) )] <NEW_LINE> self.assertEqual(expected_build_arguments, arguments) <NEW_LINE> self.assertTrue(build_step.ran)
Tests for ``BuildScript``.
6259901d5e10d32532ce4013
class mdsConnector(object): <NEW_LINE> <INDENT> def __init__(self, host=None, user=None, port=None, keyfile=None, password=None, python_executable='python', ssh_opts=[], hop=None, hop_user=None, hop_port=None, hop_keyfile=None, hop_password=None, hop_python_executable='python'): <NEW_LINE> <INDENT> if host is None: <NEW_LINE> <INDENT> self.local=True <NEW_LINE> import MDSplus <NEW_LINE> self.mdsplus=MDSplus <NEW_LINE> self.connection=None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if python_executable == 'python': <NEW_LINE> <INDENT> import sys <NEW_LINE> if sys.version_info[0] == 3: <NEW_LINE> <INDENT> python_executable='python3' <NEW_LINE> <DEDENT> <DEDENT> self.local=False <NEW_LINE> self.mach=SshMachine(host,user=user,port=port,keyfile=keyfile,password=password,ssh_opts=ssh_opts) <NEW_LINE> self.server=DeployedServer(self.mach,python_executable=python_executable) <NEW_LINE> self.connection=self.server.classic_connect() <NEW_LINE> if hop is None: <NEW_LINE> <INDENT> self.mdsplus=self.connection.modules['MDSplus'] <NEW_LINE> try: <NEW_LINE> <INDENT> self.dill=self.connection.modules['dill'] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> self.dill=None <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.hop_connection=self.connection.modules['mdsconnector'].mdsConnector(hop, user=hop_user, port=hop_port, keyfile=hop_keyfile, password=hop_password, python_executable=hop_python_executable) <NEW_LINE> self.mdsplus=self.hop_connection.mdsplus <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def __getattr__(self,name): <NEW_LINE> <INDENT> if self.connection: <NEW_LINE> <INDENT> return mdsNetref(self,self.mdsplus.__dict__[name]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.mdsplus.__dict__[name]
The mdsConnector class enables the use of MDSplus objects over an SSH connection to a remote host. All MDSplus objects are available and the data associated with MDSplus objects remain on the remote host until they are converted into native python objects or numpy data types. An application written based on the mdsConnector class can be used using the local MDSplus objects simply by not specifying a host when constructing the mdsConnector so those applications can work on local or remote data. One particularly interesting feature of the mdsConnector class is that unless you do not specify a host, the mdsConnector class works without the need to have any MDSplus packages or software installed on the local computer. The following is an example on its use: >>> from mdsconnector import mdsConnector >>> c=mdsConnector('remote-hostname') >>> t=c.Tree('treename',shotnum) >>> n=t.getNode('node-spec') >>> d1=n.record ##### data remains on remote host >>> d2=n.execute('$ + 10',d1) ##### data remains on remote host >>> d3=d2.data() ##### d3 is a numpy array on local host >>> d4=c.Data.execute('$ + 10',d3) ### d3 is sent to remote data remains on remote >>> d5=d4.data() ##### d5 is a numpy array on local host
6259901d63f4b57ef008647f
class Dummy(object): <NEW_LINE> <INDENT> def __init__(self, **kw): <NEW_LINE> <INDENT> self.__dict__.update(kw)
dummy class that allows setting attributes
6259901dac7a0e7691f73305
class FilePublisher(Publisher): <NEW_LINE> <INDENT> def __init__(self, publish_dir): <NEW_LINE> <INDENT> self.publish_dir = publish_dir <NEW_LINE> self.tmp_dir = None <NEW_LINE> self.staged = False <NEW_LINE> <DEDENT> def publish(self, units): <NEW_LINE> <INDENT> parent_path = os.path.normpath(os.path.join(self.publish_dir, '../')) <NEW_LINE> pathlib.mkdir(parent_path) <NEW_LINE> self.tmp_dir = mkdtemp(dir=parent_path) <NEW_LINE> with UnitWriter(self.tmp_dir) as writer: <NEW_LINE> <INDENT> for unit in units: <NEW_LINE> <INDENT> self.publish_unit(unit) <NEW_LINE> writer.add(unit) <NEW_LINE> <DEDENT> <DEDENT> manifest_id = str(uuid4()) <NEW_LINE> manifest = Manifest(self.tmp_dir, manifest_id) <NEW_LINE> manifest.units_published(writer) <NEW_LINE> manifest.write() <NEW_LINE> self.staged = True <NEW_LINE> return manifest.path <NEW_LINE> <DEDENT> def publish_unit(self, unit): <NEW_LINE> <INDENT> storage_path = unit.get(constants.STORAGE_PATH) <NEW_LINE> if not storage_path: <NEW_LINE> <INDENT> return unit, None <NEW_LINE> <DEDENT> relative_path = unit[constants.RELATIVE_PATH] <NEW_LINE> published_path = pathlib.join(self.tmp_dir, relative_path) <NEW_LINE> pathlib.mkdir(os.path.dirname(published_path)) <NEW_LINE> unit[constants.FILE_SIZE] = os.path.getsize(storage_path) <NEW_LINE> if os.path.isdir(storage_path): <NEW_LINE> <INDENT> tar_dir(storage_path, tar_path(published_path)) <NEW_LINE> unit[constants.TARBALL_PATH] = tar_path(relative_path) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> os.symlink(storage_path, published_path) <NEW_LINE> <DEDENT> <DEDENT> def commit(self): <NEW_LINE> <INDENT> if not self.staged: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> os.system('rm -rf %s' % self.publish_dir) <NEW_LINE> os.rename(self.tmp_dir, self.publish_dir) <NEW_LINE> self.staged = False <NEW_LINE> <DEDENT> def unstage(self): <NEW_LINE> <INDENT> os.system('rm -rf %s' % self.tmp_dir) <NEW_LINE> self.staged = False <NEW_LINE> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> def __exit__(self, *unused): <NEW_LINE> <INDENT> self.unstage()
The file-based publisher. :ivar publish_dir: full path to the publish_dir directory for this repository. :type publish_dir: str :ivar tmp_dir: The absolute path to the temporary publishing directory. :type tmp_dir: str :ivar staged: A flag indicating that publishing has been staged and needs commit. :type staged: bool
6259901d56b00c62f0fb36da
class BURSt(SCPINode, SCPIQuery): <NEW_LINE> <INDENT> __slots__ = () <NEW_LINE> _cmd = "BURSt" <NEW_LINE> args = []
READ:SCALar:POWer:BURSt Arguments:
6259901d9b70327d1c57fb9c
@dataclass(eq=False, repr=False) <NEW_LINE> class CWChannel(Message): <NEW_LINE> <INDENT> channel_index: int = 0 <NEW_LINE> rf_output_frequency: Optional[int] = 1000000000 <NEW_LINE> rf_output_power: Optional[float] = 0.0e+0 <NEW_LINE> rf_output_enabled: Optional[bool] = True
Configuration for a single CW Generator Channel.
6259901d5166f23b2e2441f0
class MultichainClient(object): <NEW_LINE> <INDENT> def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.rpcuser = kwargs.get('rpcuser', 'multichainrpc') <NEW_LINE> self.rpcpasswd = kwargs.get('rpcpasswd', 'HFzmag67bJg2f4YuExgVDqQK5VfnvXRS5SKrByuCgiXm') <NEW_LINE> try: <NEW_LINE> <INDENT> rpchost = os.environ['RPC_HOST'] <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> rpchost = 'localhost' <NEW_LINE> <DEDENT> self.rpchost = kwargs.get('rpchost', rpchost) <NEW_LINE> self.rpcport = kwargs.get('rpcport', '4416') <NEW_LINE> self.chainname = kwargs.get('chainname', 'chain1') <NEW_LINE> <DEDENT> def connect(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> api = Savoir(self.rpcuser, self.rpcpasswd, self.rpchost, self.rpcport, self.chainname) <NEW_LINE> return api <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> return False
multichain client driver to access rpc wrapper of python
6259901dbf627c535bcb22cf
class FlowSequential(nn.Sequential): <NEW_LINE> <INDENT> def forward(self, inputs, cond_inputs=None, mode='direct', logdets=None): <NEW_LINE> <INDENT> if logdets is None: <NEW_LINE> <INDENT> logdets = torch.zeros(inputs.size(0), 1, device=inputs.device) <NEW_LINE> <DEDENT> assert mode in ['direct', 'inverse'] <NEW_LINE> if mode == 'direct': <NEW_LINE> <INDENT> for module in self._modules.values(): <NEW_LINE> <INDENT> inputs, logdet = module(inputs, cond_inputs, mode) <NEW_LINE> logdets += logdet <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> for module in reversed(self._modules.values()): <NEW_LINE> <INDENT> inputs, logdet = module(inputs, cond_inputs, mode) <NEW_LINE> logdets += logdet <NEW_LINE> <DEDENT> <DEDENT> return inputs, logdets
A sequential container for flows. In addition to a forward pass it implements a backward pass and computes log jacobians.
6259901dbe8e80087fbbfe92
class FunctionDef(models.Model): <NEW_LINE> <INDENT> name = models.CharField("Short function name", max_length=MAX_NAME_LEN) <NEW_LINE> title = models.CharField("Function title", max_length=MAX_TEXT_LEN) <NEW_LINE> argnum = models.IntegerField("Number of arguments", default=1) <NEW_LINE> type = models.CharField("Type", blank=True, choices=build_choice_list(SEARCH_TYPE), max_length=5, help_text=get_help(SEARCH_TYPE)) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return "{} ({} args)".format(self.name, self.argnum) <NEW_LINE> <DEDENT> def get_list(): <NEW_LINE> <INDENT> return FunctionDef.objects.all().order_by('name') <NEW_LINE> <DEDENT> def get_function_count(self): <NEW_LINE> <INDENT> cnt = Function.objects.filter(functiondef=self).count() <NEW_LINE> return cnt <NEW_LINE> <DEDENT> def get_arguments(self): <NEW_LINE> <INDENT> qs = self.arguments.all().select_related().order_by('order') <NEW_LINE> return qs <NEW_LINE> <DEDENT> def get_functions_with_type(obltype): <NEW_LINE> <INDENT> query = Q(type=choice_value(SEARCH_TYPE, obltype)) <NEW_LINE> query |= Q(type="") <NEW_LINE> if obltype == 'str': <NEW_LINE> <INDENT> query |= Q(type=choice_value(SEARCH_TYPE,'int')) <NEW_LINE> query |= Q(type=choice_value(SEARCH_TYPE,'bool')) <NEW_LINE> <DEDENT> elif obltype == 'clist': <NEW_LINE> <INDENT> query |= Q(type=choice_value(SEARCH_TYPE,'cnst')) <NEW_LINE> <DEDENT> elif obltype == 'cnst': <NEW_LINE> <INDENT> query |= Q(type=choice_value(SEARCH_TYPE,'clist')) <NEW_LINE> <DEDENT> qs = FunctionDef.objects.filter(query).select_related().order_by('name') <NEW_LINE> return qs
Definition of one function
6259901d5166f23b2e2441f2
class extpictform(models.Model): <NEW_LINE> <INDENT> value = models.CharField(u'Variable', max_length = 150) <NEW_LINE> enable = models.BooleanField(u'Enabled', default = True) <NEW_LINE> def __unicode__(self): <NEW_LINE> <INDENT> return self.value
Componente cartográfico Extensión de las fotografías
6259901d63f4b57ef0086481
class VirtualNetworkUsage(Model): <NEW_LINE> <INDENT> _validation = { 'current_value': {'readonly': True}, 'id': {'readonly': True}, 'limit': {'readonly': True}, 'name': {'readonly': True}, 'unit': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'current_value': {'key': 'currentValue', 'type': 'float'}, 'id': {'key': 'id', 'type': 'str'}, 'limit': {'key': 'limit', 'type': 'float'}, 'name': {'key': 'name', 'type': 'VirtualNetworkUsageName'}, 'unit': {'key': 'unit', 'type': 'str'}, } <NEW_LINE> def __init__(self, **kwargs) -> None: <NEW_LINE> <INDENT> super(VirtualNetworkUsage, self).__init__(**kwargs) <NEW_LINE> self.current_value = None <NEW_LINE> self.id = None <NEW_LINE> self.limit = None <NEW_LINE> self.name = None <NEW_LINE> self.unit = None
Usage details for subnet. Variables are only populated by the server, and will be ignored when sending a request. :ivar current_value: Indicates number of IPs used from the Subnet. :vartype current_value: float :ivar id: Subnet identifier. :vartype id: str :ivar limit: Indicates the size of the subnet. :vartype limit: float :ivar name: The name containing common and localized value for usage. :vartype name: ~azure.mgmt.network.v2018_01_01.models.VirtualNetworkUsageName :ivar unit: Usage units. Returns 'Count' :vartype unit: str
6259901d5e10d32532ce4015
class AdatWritingTest(TestCase): <NEW_LINE> <INDENT> filename = './tests/data/control_data_written.adat' <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> self.adat = canopy.read_adat('./tests/data/control_data.adat') <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> if os.path.exists(self.filename): <NEW_LINE> <INDENT> os.remove(self.filename) <NEW_LINE> <DEDENT> <DEDENT> def test_adat_write(self): <NEW_LINE> <INDENT> self.adat.to_adat(self.filename) <NEW_LINE> self.assertTrue(os.path.exists(self.filename)) <NEW_LINE> <DEDENT> @mock.patch('pkg_resources.require', require_side_effect) <NEW_LINE> def test_adat_md5(self): <NEW_LINE> <INDENT> self.adat.to_adat(self.filename) <NEW_LINE> hash_md5 = hashlib.md5() <NEW_LINE> with open(self.filename, 'rb') as f: <NEW_LINE> <INDENT> hash_md5.update(f.read()) <NEW_LINE> <DEDENT> self.assertEqual(hash_md5.hexdigest(), '58d675e7e43cc4e142ff94ac6efdfd94')
Tests if writing can occur and if the written file matches expectation (via md5).
6259901d9b70327d1c57fba0
class NBestList: <NEW_LINE> <INDENT> def __init__(self, sentrep, parses, sentence_id=None): <NEW_LINE> <INDENT> self._parses = parses <NEW_LINE> self._sentrep = sentrep <NEW_LINE> self.parses = [] <NEW_LINE> for index, (score, parse) in enumerate(parses): <NEW_LINE> <INDENT> parse.this.acquire() <NEW_LINE> scored_parse = ScoredParse(Tree(parse), score, parser_rank=index) <NEW_LINE> self.parses.append(scored_parse) <NEW_LINE> <DEDENT> self.sentence_id = sentence_id <NEW_LINE> self._reranked = False <NEW_LINE> <DEDENT> def __getattr__(self, key): <NEW_LINE> <INDENT> return getattr(self.parses, key) <NEW_LINE> <DEDENT> def sort_by_reranker_scores(self): <NEW_LINE> <INDENT> self.parses.sort(key=lambda parse: (parse.reranker_score, parse.parser_score), reverse=True) <NEW_LINE> <DEDENT> def sort_by_parser_scores(self): <NEW_LINE> <INDENT> self.parses.sort(key=lambda parse: -parse.parser_score) <NEW_LINE> <DEDENT> def get_parser_best(self): <NEW_LINE> <INDENT> if len(self.parses): <NEW_LINE> <INDENT> return min(self, key=lambda parse: parse.parser_rank) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> def get_reranker_best(self): <NEW_LINE> <INDENT> return min(self, key=lambda parse: parse.reranker_rank) <NEW_LINE> <DEDENT> def tokens(self): <NEW_LINE> <INDENT> return self._sentrep.tokens() <NEW_LINE> <DEDENT> def rerank(self, reranker_instance, lowercase=True): <NEW_LINE> <INDENT> assert reranker_instance <NEW_LINE> if not self.parses: <NEW_LINE> <INDENT> self._reranked = True <NEW_LINE> return <NEW_LINE> <DEDENT> if isinstance(reranker_instance, RerankingParser): <NEW_LINE> <INDENT> reranker_instance = reranker_instance.reranker_model <NEW_LINE> <DEDENT> reranker_input = self.as_reranker_input() <NEW_LINE> scores = reranker_instance.scoreNBestList(reranker_input) <NEW_LINE> for (score, nbest_list_item) in zip(scores, self.parses): <NEW_LINE> <INDENT> nbest_list_item.reranker_score = score <NEW_LINE> <DEDENT> self.sort_by_reranker_scores() <NEW_LINE> for index, nbest_list_item in enumerate(self.parses): <NEW_LINE> <INDENT> nbest_list_item.reranker_rank = index <NEW_LINE> <DEDENT> self._reranked = True <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> sentence_id = self.sentence_id or 'x' <NEW_LINE> if self._reranked: <NEW_LINE> <INDENT> from cStringIO import StringIO <NEW_LINE> combined = StringIO() <NEW_LINE> combined.write('%d %s\n' % (len(self.parses), sentence_id)) <NEW_LINE> for parse in self.parses: <NEW_LINE> <INDENT> combined.write('%s %s\n%s\n' % (parse.reranker_score, parse.parser_score, parse.ptb_parse)) <NEW_LINE> <DEDENT> combined.seek(0) <NEW_LINE> return combined.read() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return parser.asNBestList(self._parses, str(sentence_id)) <NEW_LINE> <DEDENT> <DEDENT> def as_reranker_input(self, lowercase=True): <NEW_LINE> <INDENT> return reranker.readNBestList(str(self), lowercase)
Represents an n-best list of parses of the same sentence.
6259901d287bf620b6272a0b
class FlashSubVolUbiLinux26(BASESTORAGE.X_CATAWAMPUS_ORG_FlashMedia.SubVolume): <NEW_LINE> <INDENT> def __init__(self, ubivol): <NEW_LINE> <INDENT> BASESTORAGE.X_CATAWAMPUS_ORG_FlashMedia.SubVolume.__init__(self) <NEW_LINE> self.ubivol = ubivol <NEW_LINE> <DEDENT> @property <NEW_LINE> def DataMBytes(self): <NEW_LINE> <INDENT> bytesiz = IntFromFile(os.path.join(SYS_UBI, self.ubivol, 'data_bytes')) <NEW_LINE> return int(bytesiz / 1024 / 1024) <NEW_LINE> <DEDENT> @property <NEW_LINE> def Name(self): <NEW_LINE> <INDENT> return _ReadOneLine(os.path.join(SYS_UBI, self.ubivol, 'name'), self.ubivol) <NEW_LINE> <DEDENT> @property <NEW_LINE> def Status(self): <NEW_LINE> <INDENT> corr = IntFromFile(os.path.join(SYS_UBI, self.ubivol, 'corrupted')) <NEW_LINE> return 'OK' if corr == 0 else 'Corrupted'
Catawampus Storage Flash SubVolume implementation for UBI volumes.
6259901d21a7993f00c66d9e
class ApplicationGatewayBackendAddressPool(SubResource): <NEW_LINE> <INDENT> _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'backend_ip_configurations': {'key': 'properties.backendIPConfigurations', 'type': '[NetworkInterfaceIPConfiguration]'}, 'backend_addresses': {'key': 'properties.backendAddresses', 'type': '[ApplicationGatewayBackendAddress]'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } <NEW_LINE> def __init__( self, *, id: Optional[str] = None, name: Optional[str] = None, etag: Optional[str] = None, type: Optional[str] = None, backend_ip_configurations: Optional[List["NetworkInterfaceIPConfiguration"]] = None, backend_addresses: Optional[List["ApplicationGatewayBackendAddress"]] = None, provisioning_state: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(ApplicationGatewayBackendAddressPool, self).__init__(id=id, **kwargs) <NEW_LINE> self.name = name <NEW_LINE> self.etag = etag <NEW_LINE> self.type = type <NEW_LINE> self.backend_ip_configurations = backend_ip_configurations <NEW_LINE> self.backend_addresses = backend_addresses <NEW_LINE> self.provisioning_state = provisioning_state
Backend Address Pool of an application gateway. :param id: Resource ID. :type id: str :param name: Resource that is unique within a resource group. This name can be used to access the resource. :type name: str :param etag: A unique read-only string that changes whenever the resource is updated. :type etag: str :param type: Type of the resource. :type type: str :param backend_ip_configurations: Collection of references to IPs defined in network interfaces. :type backend_ip_configurations: list[~azure.mgmt.network.v2018_02_01.models.NetworkInterfaceIPConfiguration] :param backend_addresses: Backend addresses. :type backend_addresses: list[~azure.mgmt.network.v2018_02_01.models.ApplicationGatewayBackendAddress] :param provisioning_state: Provisioning state of the backend address pool resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. :type provisioning_state: str
6259901d462c4b4f79dbc82c
class APIResource(api.APIResourceWrapper): <NEW_LINE> <INDENT> _attrs = ['foo', 'bar', 'baz'] <NEW_LINE> @staticmethod <NEW_LINE> def get_instance(innerObject=None): <NEW_LINE> <INDENT> if innerObject is None: <NEW_LINE> <INDENT> class InnerAPIResource(object): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> innerObject = InnerAPIResource() <NEW_LINE> innerObject.foo = 'foo' <NEW_LINE> innerObject.bar = 'bar' <NEW_LINE> <DEDENT> return APIResource(innerObject)
Simple APIResource for testing
6259901d925a0f43d25e8e65
class TStage7(_CaseInsensitiveEnum): <NEW_LINE> <INDENT> t0 = 'T0' <NEW_LINE> t1 = 'T1' <NEW_LINE> t1a = 'T1a' <NEW_LINE> t1b = 'T1b' <NEW_LINE> t2 = 'T2' <NEW_LINE> t2a = 'T2a' <NEW_LINE> t2b = 'T2b' <NEW_LINE> t3 = 'T3' <NEW_LINE> t4 = 'T4' <NEW_LINE> t4a = 'T4a' <NEW_LINE> t4b = 'T4b' <NEW_LINE> t4c = 'T4c' <NEW_LINE> t4d = 'T4d' <NEW_LINE> tis = 'Tis' <NEW_LINE> tis_pagets = "Tis (Paget's)" <NEW_LINE> tis_lcis = 'Tis (LCIS)' <NEW_LINE> tis_dcis = 'Tis (DCIS)' <NEW_LINE> tx = 'TX' <NEW_LINE> unknown = 'Unknown' <NEW_LINE> not_reported = 'Not reported'
American Joint Committee on Cancer (AJCC) edition 7's pathological tumor "T Stage"
6259901dbf627c535bcb22d5
class PutLeveltest(Process): <NEW_LINE> <INDENT> def run(self,level): <NEW_LINE> <INDENT> yield put,self,level,1
Used in testPutLevel.
6259901d91af0d3eaad3ac47
class DummyBiNode(IdentityBiNode): <NEW_LINE> <INDENT> def _execute(self, x, data1, data2): <NEW_LINE> <INDENT> self.data1 = data1 <NEW_LINE> self.data2 = data2 <NEW_LINE> return x <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def is_trainable(): <NEW_LINE> <INDENT> return False
Dummy class for CloneBiLayer tests.
6259901d8c3a8732951f7386
class Reader(): <NEW_LINE> <INDENT> def read(self): <NEW_LINE> <INDENT> field = [] <NEW_LINE> data = fileinput.input() <NEW_LINE> for line in data: <NEW_LINE> <INDENT> field.append(line.strip('\n')) <NEW_LINE> <DEDENT> data.close() <NEW_LINE> self.validate(field) <NEW_LINE> return field <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def validate(field): <NEW_LINE> <INDENT> header = field[0] <NEW_LINE> if len(header) < 3 or not any(char.isdigit() for char in header): <NEW_LINE> <INDENT> raise BadInputFile("Bad field header; format is <w><space><h>") <NEW_LINE> <DEDENT> width, height = (int(x) for x in field[0].split(' ')) <NEW_LINE> for line in field[-1:]: <NEW_LINE> <INDENT> if len(line) != width: <NEW_LINE> <INDENT> raise BadInputFile("Bad field body; a line length was wrong") <NEW_LINE> <DEDENT> <DEDENT> if len(field) - 1 != height: <NEW_LINE> <INDENT> raise BadInputFile("Bad field body; field height was wrong")
validates, converts to internal repr raw particle field from STDIN
6259901dbf627c535bcb22d7
class dotdict(dict): <NEW_LINE> <INDENT> __getattr__ = dict.get <NEW_LINE> __setattr__ = dict.__setitem__ <NEW_LINE> __delattr__ = dict.__delitem__
dot.notation access to dictionary attributes source: https://stackoverflow.com/a/23689767
6259901d287bf620b6272a0f
class DeviceReading: <NEW_LINE> <INDENT> time: int <NEW_LINE> value: float
A reading from a device
6259901d6fece00bbaccc7dc
class Context(object): <NEW_LINE> <INDENT> CTYPE = Util.create_enum( "CONDITION", "CONFIG" ) <NEW_LINE> def __init__(self, manifest_parser, prev_context, line_info, ctype): <NEW_LINE> <INDENT> self.manifest_parser = manifest_parser <NEW_LINE> self.ctype = ctype <NEW_LINE> if prev_context is None: <NEW_LINE> <INDENT> self.level = 0 <NEW_LINE> self.line_info = "<invalid>" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.level = prev_context.level + 1 <NEW_LINE> self.line_info = line_info <NEW_LINE> <DEDENT> self.prev_context = prev_context <NEW_LINE> <DEDENT> def get_ctype(self): <NEW_LINE> <INDENT> return self.ctype <NEW_LINE> <DEDENT> def has_parameters(self): <NEW_LINE> <INDENT> if self.ctype == Context.CTYPE.CONDITION: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True
Base class for parsing contexts
6259901d462c4b4f79dbc830
class UserInfo(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'first_name': {'max_length': 50, 'min_length': 0}, 'last_name': {'max_length': 50, 'min_length': 0}, 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, 'phone_number': {'max_length': 40, 'min_length': 0}, } <NEW_LINE> _attribute_map = { 'first_name': {'key': 'firstName', 'type': 'str'}, 'last_name': {'key': 'lastName', 'type': 'str'}, 'email_address': {'key': 'emailAddress', 'type': 'str'}, 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, } <NEW_LINE> def __init__( self, *, first_name: Optional[str] = None, last_name: Optional[str] = None, email_address: Optional[str] = None, phone_number: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(UserInfo, self).__init__(**kwargs) <NEW_LINE> self.first_name = first_name <NEW_LINE> self.last_name = last_name <NEW_LINE> self.email_address = email_address <NEW_LINE> self.phone_number = phone_number
UserInfo. :param first_name: First Name of the user. :type first_name: str :param last_name: Last Name of the user. :type last_name: str :param email_address: Email of the user used by Logz for contacting them if needed. :type email_address: str :param phone_number: Phone number of the user used by Logz for contacting them if needed. :type phone_number: str
6259901dd164cc6175821da6
class DeprecationTests(unittest.SynchronousTestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.reactor = DummyProcessReactor() <NEW_LINE> self.pm = ProcessMonitor(reactor=self.reactor) <NEW_LINE> <DEDENT> def test_toTuple(self): <NEW_LINE> <INDENT> self.pm.addProcess("foo", ["foo"]) <NEW_LINE> myprocesses = self.pm.processes <NEW_LINE> self.assertEquals(len(myprocesses), 1) <NEW_LINE> warnings = self.flushWarnings() <NEW_LINE> foundToTuple = False <NEW_LINE> for warning in warnings: <NEW_LINE> <INDENT> self.assertIs(warning['category'], DeprecationWarning) <NEW_LINE> if 'toTuple' in warning['message']: <NEW_LINE> <INDENT> foundToTuple = True <NEW_LINE> <DEDENT> <DEDENT> self.assertTrue(foundToTuple, "no tuple deprecation found:{}".format(repr(warnings))) <NEW_LINE> <DEDENT> def test_processes(self): <NEW_LINE> <INDENT> myProcesses = self.pm.processes <NEW_LINE> self.assertEquals(myProcesses, {}) <NEW_LINE> warnings = self.flushWarnings() <NEW_LINE> first = warnings.pop(0) <NEW_LINE> self.assertIs(first['category'], DeprecationWarning) <NEW_LINE> self.assertEquals(warnings, []) <NEW_LINE> <DEDENT> def test_getstate(self): <NEW_LINE> <INDENT> pickle.dumps(self.pm) <NEW_LINE> warnings = self.flushWarnings() <NEW_LINE> for warning in warnings: <NEW_LINE> <INDENT> self.assertIs(warning['category'], DeprecationWarning)
Tests that check functionality that should be deprecated is deprecated.
6259901d63f4b57ef0086485
class Commands(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.arithmetic = ["add", "sub", "neg", "eq", "gt", "lt", "and", "or", "not"] <NEW_LINE> self.functionCall = ["function", "call", "return"] <NEW_LINE> self.memCommand = ["push", "pop"] <NEW_LINE> self.programFlow = ["if-goto", "goto", "label"] <NEW_LINE> <DEDENT> def type(self, command): <NEW_LINE> <INDENT> if command in self.arithmetic: <NEW_LINE> <INDENT> return "arithmetic" <NEW_LINE> <DEDENT> if command in self.functionCall: <NEW_LINE> <INDENT> return "function" <NEW_LINE> <DEDENT> if command in self.memCommand: <NEW_LINE> <INDENT> return "memory" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return "program"
An object that holds lookup tables that map commands to their type.
6259901d30c21e258be9963c
class WindowedStream(object): <NEW_LINE> <INDENT> def __init__(self, keyed_stream: KeyedStream, window_assigner: WindowAssigner): <NEW_LINE> <INDENT> self._keyed_stream = keyed_stream <NEW_LINE> self._window_assigner = window_assigner <NEW_LINE> self._allowed_lateness = 0 <NEW_LINE> self._window_trigger = None <NEW_LINE> <DEDENT> def get_execution_environment(self): <NEW_LINE> <INDENT> return self._keyed_stream.get_execution_environment() <NEW_LINE> <DEDENT> def get_input_type(self): <NEW_LINE> <INDENT> return self._keyed_stream.get_type() <NEW_LINE> <DEDENT> def trigger(self, trigger: Trigger): <NEW_LINE> <INDENT> self._window_trigger = trigger <NEW_LINE> return self <NEW_LINE> <DEDENT> def allowed_lateness(self, time_ms: int): <NEW_LINE> <INDENT> self._allowed_lateness = time_ms <NEW_LINE> return self <NEW_LINE> <DEDENT> def apply(self, window_function: WindowFunction, result_type: TypeInformation = None) -> DataStream: <NEW_LINE> <INDENT> internal_window_function = InternalIterableWindowFunction( window_function) <NEW_LINE> return self._get_result_data_stream(internal_window_function, result_type) <NEW_LINE> <DEDENT> def process(self, process_window_function: ProcessWindowFunction, result_type: TypeInformation = None): <NEW_LINE> <INDENT> internal_window_function = InternalIterableProcessWindowFunction( process_window_function) <NEW_LINE> return self._get_result_data_stream(internal_window_function, result_type) <NEW_LINE> <DEDENT> def _get_result_data_stream( self, internal_window_function: InternalWindowFunction, result_type): <NEW_LINE> <INDENT> if self._window_trigger is None: <NEW_LINE> <INDENT> self._window_trigger = self._window_assigner.get_default_trigger( self.get_execution_environment()) <NEW_LINE> <DEDENT> window_serializer = self._window_assigner.get_window_serializer() <NEW_LINE> window_state_descriptor = ListStateDescriptor( "window-contents", self.get_input_type()) <NEW_LINE> window_operation_descriptor = WindowOperationDescriptor( self._window_assigner, self._window_trigger, self._allowed_lateness, window_state_descriptor, window_serializer, internal_window_function) <NEW_LINE> from pyflink.fn_execution import flink_fn_execution_pb2 <NEW_LINE> j_python_data_stream_function_operator, j_output_type_info = _get_one_input_stream_operator( self._keyed_stream, window_operation_descriptor, flink_fn_execution_pb2.UserDefinedDataStreamFunction.WINDOW, result_type) <NEW_LINE> return DataStream(self._keyed_stream._j_data_stream.transform( "WINDOW", j_output_type_info, j_python_data_stream_function_operator))
A WindowedStream represents a data stream where elements are grouped by key, and for each key, the stream of elements is split into windows based on a WindowAssigner. Window emission is triggered based on a Trigger. The windows are conceptually evaluated for each key individually, meaning windows can trigger at different points for each key. Note that the WindowedStream is purely an API construct, during runtime the WindowedStream will be collapsed together with the KeyedStream and the operation over the window into one single operation.
6259901d63f4b57ef0086486
class DynamicsValidator(object): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def validate_componentclass(cls, componentclass): <NEW_LINE> <INDENT> TypesDynamicsValidator(componentclass) <NEW_LINE> NoDuplicatedObjectsDynamicsValidator(componentclass) <NEW_LINE> DuplicateRegimeNamesDynamicsValidator(componentclass) <NEW_LINE> LocalNameConflictsDynamicsValidator(componentclass) <NEW_LINE> DimensionNameConflictsDynamicsValidator(componentclass) <NEW_LINE> EventPortsDynamicsValidator(componentclass) <NEW_LINE> OutputAnalogPortsDynamicsValidator(componentclass) <NEW_LINE> TimeDerivativesAreDeclaredDynamicsValidator(componentclass) <NEW_LINE> StateAssignmentsAreOnStateVariablesDynamicsValidator(componentclass) <NEW_LINE> AliasesAreNotRecursiveDynamicsValidator(componentclass) <NEW_LINE> NoUnresolvedSymbolsDynamicsValidator(componentclass) <NEW_LINE> PortConnectionsDynamicsValidator(componentclass) <NEW_LINE> RegimeGraphDynamicsValidator(componentclass) <NEW_LINE> RegimeOnlyHasOneHandlerPerEventDynamicsValidator(componentclass) <NEW_LINE> CheckNoLHSAssignmentsToMathsNamespaceDynamicsValidator(componentclass)
Class for grouping all the component-validations tests together
6259901dbf627c535bcb22db
class TasksView(APIView): <NEW_LINE> <INDENT> permission_classes = (IsAuthenticated,) <NEW_LINE> def get(self, request, pk=None): <NEW_LINE> <INDENT> if "username" in request.query_params: <NEW_LINE> <INDENT> if pk is None: <NEW_LINE> <INDENT> user = User.objects.get(username=request.query_params["username"]) <NEW_LINE> todo_items = Tasks.objects.filter(user=user) <NEW_LINE> serializer = TasksSerializer(todo_items, many=True) <NEW_LINE> serialized_data = serializer.data <NEW_LINE> return Response(serialized_data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> todo = Tasks.objects.get(id=pk) <NEW_LINE> serializer = TasksSerializer(todo) <NEW_LINE> serialized_data = serializer.data <NEW_LINE> return Response(serialized_data) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def post(self, request): <NEW_LINE> <INDENT> serializer = TasksSerializer(data=request.data) <NEW_LINE> if not serializer.is_valid(): <NEW_LINE> <INDENT> return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> data = serializer.data <NEW_LINE> user = User.objects.get(username=data["username"]) <NEW_LINE> Tasks.objects.create(user=user, title=data["title"], description=data["description"], status=data["status"]) <NEW_LINE> return Response(serializer.data, status=status.HTTP_201_CREATED) <NEW_LINE> <DEDENT> <DEDENT> def put(self, request, pk): <NEW_LINE> <INDENT> todo = Tasks.objects.get(id=pk) <NEW_LINE> serializer = TasksSerializer(todo, data=request.data) <NEW_LINE> if not serializer.is_valid(): <NEW_LINE> <INDENT> return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> serializer.save() <NEW_LINE> return Response(serializer.data) <NEW_LINE> <DEDENT> <DEDENT> def delete(self, request, pk): <NEW_LINE> <INDENT> todo = Tasks.objects.get(id=pk) <NEW_LINE> todo.delete() <NEW_LINE> return Response(status=status.HTTP_204_NO_CONTENT)
TasksView used to handle the incoming requests relating to `todo` items
6259901d796e427e5384f5a9
class Plugin_1: <NEW_LINE> <INDENT> @hookimpl <NEW_LINE> def myhook(self, arg1, arg2): <NEW_LINE> <INDENT> print("inside Plugin_1.myhook()") <NEW_LINE> return arg1 + arg2
A hook implementation namespace.
6259901d462c4b4f79dbc834
class GraphicsView(Widget): <NEW_LINE> <INDENT> CPP_CLASS = 'QGraphicsView' <NEW_LINE> def gitems(self): <NEW_LINE> <INDENT> data = self.client.send_command('graphicsitems', oid=self.oid) <NEW_LINE> return GItems.create(self.client, data) <NEW_LINE> <DEDENT> def dump_gitems(self, stream='gitems.json'): <NEW_LINE> <INDENT> data = self.client.send_command('graphicsitems', oid=self.oid) <NEW_LINE> if isinstance(stream, basestring): <NEW_LINE> <INDENT> stream = open(stream, 'w') <NEW_LINE> <DEDENT> json.dump(data, stream, sort_keys=True, indent=4, separators=(',', ': ')) <NEW_LINE> <DEDENT> def grab_scene(self, stream, format_="PNG"): <NEW_LINE> <INDENT> data = self.client.send_command('grab_graphics_view', format=format_, oid=self.oid) <NEW_LINE> has_to_be_closed = False <NEW_LINE> if isinstance(stream, basestring): <NEW_LINE> <INDENT> stream = open(stream, 'wb') <NEW_LINE> has_to_be_closed = True <NEW_LINE> <DEDENT> raw = base64.standard_b64decode(data['data']) <NEW_LINE> stream.write(raw) <NEW_LINE> if has_to_be_closed: <NEW_LINE> <INDENT> stream.close()
Allow to manipulate an instance of QGraphicsView.
6259901dd18da76e235b7862
class Bool(Variable): <NEW_LINE> <INDENT> def __init__(self, default_value=False, iotype=None, desc=None, **metadata): <NEW_LINE> <INDENT> if iotype is not None: <NEW_LINE> <INDENT> metadata['iotype'] = iotype <NEW_LINE> <DEDENT> if desc is not None: <NEW_LINE> <INDENT> metadata['desc'] = desc <NEW_LINE> <DEDENT> self._validator = Enthought_Bool(value=default_value, **metadata) <NEW_LINE> super(Bool, self).__init__(default_value=default_value, **metadata) <NEW_LINE> <DEDENT> def validate(self, obj, name, value): <NEW_LINE> <INDENT> return self._validator.validate(obj, name, value) <NEW_LINE> <DEDENT> def create_editor(self): <NEW_LINE> <INDENT> return self._validator.create_editor() <NEW_LINE> <DEDENT> def get_attribute(self, name, value, trait, meta): <NEW_LINE> <INDENT> attr = {} <NEW_LINE> attr['name'] = name <NEW_LINE> attr['type'] = type(value).__name__ <NEW_LINE> attr['value'] = str(value) <NEW_LINE> for field in meta: <NEW_LINE> <INDENT> if field not in gui_excludes: <NEW_LINE> <INDENT> attr[field] = meta[field] <NEW_LINE> <DEDENT> <DEDENT> return attr, None
A variable wrapper for a boolean variable.
6259901dd18da76e235b7863
class ReviewSubmissionPagination(LimitOffsetPagination): <NEW_LINE> <INDENT> default_limit = 10 <NEW_LINE> max_limit = 1000 <NEW_LINE> facets = {} <NEW_LINE> def paginate_queryset(self, queryset, request, view=None): <NEW_LINE> <INDENT> self.facets = self.get_facets(queryset) <NEW_LINE> return super().paginate_queryset(queryset, request, view=view) <NEW_LINE> <DEDENT> def get_paginated_response(self, data): <NEW_LINE> <INDENT> return Response( OrderedDict( [ ("count", self.count), ("next", self.get_next_link()), ("previous", self.get_previous_link()), ("results", data), ("facets", self.facets), ] ) ) <NEW_LINE> <DEDENT> def get_facets(self, queryset): <NEW_LINE> <INDENT> statuses = ( queryset.values("review_status") .annotate(count=Count("review_status")) .order_by("count") ) <NEW_LINE> qs = ( queryset.values("bootcamp_application__bootcamp_run") .filter(bootcamp_application__bootcamp_run=OuterRef("pk")) .order_by() .annotate(count=Count("*")) .values("count") ) <NEW_LINE> bootcamp_runs = ( BootcampRun.objects.values("id", "title", "start_date", "end_date") .annotate(count=Subquery(qs, output_field=IntegerField())) .filter(count__gte=1) .distinct() ) <NEW_LINE> return {"review_statuses": statuses, "bootcamp_runs": bootcamp_runs}
Pagination class for ReviewSubmissionViewSet
6259901d507cdc57c63a5bd1
class File(object): <NEW_LINE> <INDENT> def __init__(self, file_name, path): <NEW_LINE> <INDENT> self.id = file_name[:-4] <NEW_LINE> self.records = [] <NEW_LINE> with open(path + file_name, 'r') as content: <NEW_LINE> <INDENT> for l in content: <NEW_LINE> <INDENT> r = Record(l) <NEW_LINE> if len(self.records) > 0: <NEW_LINE> <INDENT> if(self.records[-1].timestamp != r.timestamp or self.records[-1].word.word != r.word.word): <NEW_LINE> <INDENT> self.records.append(r) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.records.append(r)
docstring for File
6259901d30c21e258be99642
class HistoryButton(Button): <NEW_LINE> <INDENT> def __del__(self, *args, **kwargs): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def on_press(self): <NEW_LINE> <INDENT> root = findparent(self, RepoHistoryItem) <NEW_LINE> for l in root.parent.children: <NEW_LINE> <INDENT> if hasattr(l, 'pressed') and l.pressed: <NEW_LINE> <INDENT> l.pressed = False <NEW_LINE> <DEDENT> <DEDENT> button1 = root.button1 <NEW_LINE> button2 = root.button2 <NEW_LINE> button3 = root.button3 <NEW_LINE> button4 = root.button4 <NEW_LINE> button1.text = button1.text.replace('=777777', '=000000') <NEW_LINE> button2.text = button2.text.replace('=777777', '=000000') <NEW_LINE> button3.text = button3.text.replace('=777777', '=000000') <NEW_LINE> button4.text = button4.text.replace('=777777', '=000000') <NEW_LINE> root.pressed = True <NEW_LINE> for l in root.parent.children: <NEW_LINE> <INDENT> if hasattr(l, 'button1'): <NEW_LINE> <INDENT> buttons = [l.button1, l.button2, l.button3, l.button4] <NEW_LINE> if hasattr(l, 'pressed') and l.pressed: <NEW_LINE> <INDENT> for b in buttons: <NEW_LINE> <INDENT> b.text = b.text.replace('=777777', '=000000') <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> for b in buttons: <NEW_LINE> <INDENT> b.text = b.text.replace('=000000', '=777777') <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> <DEDENT> def on_release(self): <NEW_LINE> <INDENT> sub_root = findparent(self, RepoHistoryItem) <NEW_LINE> self.branch_path = sub_root.branch_path <NEW_LINE> self.branch_logid = sub_root.branch_logid <NEW_LINE> root = findparent(self, HistoryBox) <NEW_LINE> root.load_diff(self.branch_path, self.branch_logid)
HistoryButton; to manage user input on history screen, the button is used on list items of repository logs one box of log data contains at least four button.
6259901d287bf620b6272a19
class HBNodes(object): <NEW_LINE> <INDENT> def __init__(self, pulseIds=None,): <NEW_LINE> <INDENT> self.pulseIds = pulseIds <NEW_LINE> <DEDENT> def read(self, iprot): <NEW_LINE> <INDENT> if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: <NEW_LINE> <INDENT> iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) <NEW_LINE> return <NEW_LINE> <DEDENT> iprot.readStructBegin() <NEW_LINE> while True: <NEW_LINE> <INDENT> (fname, ftype, fid) = iprot.readFieldBegin() <NEW_LINE> if ftype == TType.STOP: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if fid == 1: <NEW_LINE> <INDENT> if ftype == TType.LIST: <NEW_LINE> <INDENT> self.pulseIds = [] <NEW_LINE> (_etype862, _size859) = iprot.readListBegin() <NEW_LINE> for _i863 in range(_size859): <NEW_LINE> <INDENT> _elem864 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() <NEW_LINE> self.pulseIds.append(_elem864) <NEW_LINE> <DEDENT> iprot.readListEnd() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> iprot.readFieldEnd() <NEW_LINE> <DEDENT> iprot.readStructEnd() <NEW_LINE> <DEDENT> def write(self, oprot): <NEW_LINE> <INDENT> if oprot._fast_encode is not None and self.thrift_spec is not None: <NEW_LINE> <INDENT> oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) <NEW_LINE> return <NEW_LINE> <DEDENT> oprot.writeStructBegin('HBNodes') <NEW_LINE> if self.pulseIds is not None: <NEW_LINE> <INDENT> oprot.writeFieldBegin('pulseIds', TType.LIST, 1) <NEW_LINE> oprot.writeListBegin(TType.STRING, len(self.pulseIds)) <NEW_LINE> for iter865 in self.pulseIds: <NEW_LINE> <INDENT> oprot.writeString(iter865.encode('utf-8') if sys.version_info[0] == 2 else iter865) <NEW_LINE> <DEDENT> oprot.writeListEnd() <NEW_LINE> oprot.writeFieldEnd() <NEW_LINE> <DEDENT> oprot.writeFieldStop() <NEW_LINE> oprot.writeStructEnd() <NEW_LINE> <DEDENT> def validate(self): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> L = ['%s=%r' % (key, value) for key, value in self.__dict__.items()] <NEW_LINE> return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other)
Attributes: - pulseIds
6259901dbf627c535bcb22e2
class TestRoundTripPGPosition(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.position = Position( "SLD", "PG", Decimal('100'), Decimal("77.69"), Decimal("1.00"), Decimal('77.68'), Decimal('77.70') ) <NEW_LINE> <DEDENT> def test_calculate_round_trip(self): <NEW_LINE> <INDENT> self.position.transact_shares( "SLD", Decimal('100'), Decimal('77.68'), Decimal('1.00') ) <NEW_LINE> self.position.transact_shares( "SLD", Decimal('50'), Decimal('77.70'), Decimal('1.00') ) <NEW_LINE> self.position.transact_shares( "BOT", Decimal('100'), Decimal('77.77'), Decimal('1.00') ) <NEW_LINE> self.position.transact_shares( "BOT", Decimal('150'), Decimal('77.73'), Decimal('1.00') ) <NEW_LINE> self.position.update_market_value(Decimal("77.72"), Decimal("77.72")) <NEW_LINE> self.assertEqual(self.position.action, "SLD") <NEW_LINE> self.assertEqual(self.position.ticker, "PG") <NEW_LINE> self.assertEqual(self.position.quantity, Decimal("0")) <NEW_LINE> self.assertEqual(self.position.buys, Decimal("250")) <NEW_LINE> self.assertEqual(self.position.sells, Decimal("250")) <NEW_LINE> self.assertEqual(self.position.net, Decimal("0")) <NEW_LINE> self.assertEqual(self.position.avg_bot, Decimal("77.746")) <NEW_LINE> self.assertEqual(self.position.avg_sld, Decimal("77.688")) <NEW_LINE> self.assertEqual(self.position.total_bot, Decimal("19436.50")) <NEW_LINE> self.assertEqual(self.position.total_sld, Decimal("19422.00")) <NEW_LINE> self.assertEqual(self.position.net_total, Decimal("-14.50")) <NEW_LINE> self.assertEqual(self.position.total_commission, Decimal("5.00")) <NEW_LINE> self.assertEqual(self.position.net_incl_comm, Decimal("-19.50")) <NEW_LINE> self.assertEqual(self.position.avg_price, Decimal("77.67600")) <NEW_LINE> self.assertEqual(self.position.cost_basis, Decimal("0.00")) <NEW_LINE> self.assertEqual(self.position.market_value, Decimal("0.00")) <NEW_LINE> self.assertEqual(self.position.unrealised_pnl, Decimal("0.00")) <NEW_LINE> self.assertEqual(self.position.realised_pnl, Decimal("-19.50"))
Test a round-trip trade in Proctor & Gamble where the initial trade is a sell/short of 100 shares of PG, at a price of $77.69, with $1.00 commission.
6259901d462c4b4f79dbc83a
class Config(dict): <NEW_LINE> <INDENT> def __init__(self, f): <NEW_LINE> <INDENT> super(Config, self).__init__(**self.load_config(f)) <NEW_LINE> self.__dict__ = self <NEW_LINE> <DEDENT> def load_config(self, f): <NEW_LINE> <INDENT> return yaml.load(open(get_path(f),"r"))
A storage class for the yaml-defined network configuration
6259901dac7a0e7691f7331b
class EntityOutputTypesResource(Resource): <NEW_LINE> <INDENT> @jwt_required <NEW_LINE> def get(self, entity_id): <NEW_LINE> <INDENT> entity = entities_service.get_entity(entity_id) <NEW_LINE> user_service.check_project_access(entity["project_id"]) <NEW_LINE> return files_service.get_output_types_for_entity(entity_id)
Return all types of output generated for given entity.
6259901d21a7993f00c66dae
class Calendar(object): <NEW_LINE> <INDENT> def __init__(self, semester=None): <NEW_LINE> <INDENT> self.semester = semester <NEW_LINE> <DEDENT> def iter_by_weekdays(self): <NEW_LINE> <INDENT> week1, week2 = AppendedWeeks( Subject.objects.iter_by_weekdays(week=1, semester=self.semester), Subject.objects.iter_by_weekdays(week=2, semester=self.semester) ).get() <NEW_LINE> result = [list(izip_longest(w1, w2)) for w1, w2 in list(izip_longest(week1, week2))] <NEW_LINE> return zip(WEEKDAYS, result)
E.g.: >>> Calendar().iter_by_weekdays() [(u'Пон', []), (u'Вт', []), (u'Ср', []), (u'Чет', [ (<Subject: ТАУ | IA-62 | Четверг 12:00 | 2012>, <Subject: ТАУ | IA-62 | Четверг 12:00 | 2012>)]), (u'Пят', []), (u'Суб', []), (u'Вос', [])]
6259901dbe8e80087fbbfea6
class FlightInvoiceOCRRequest(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.ImageBase64 = None <NEW_LINE> self.ImageUrl = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> self.ImageBase64 = params.get("ImageBase64") <NEW_LINE> self.ImageUrl = params.get("ImageUrl") <NEW_LINE> memeber_set = set(params.keys()) <NEW_LINE> for name, value in vars(self).items(): <NEW_LINE> <INDENT> if name in memeber_set: <NEW_LINE> <INDENT> memeber_set.remove(name) <NEW_LINE> <DEDENT> <DEDENT> if len(memeber_set) > 0: <NEW_LINE> <INDENT> warnings.warn("%s fileds are useless." % ",".join(memeber_set))
FlightInvoiceOCR请求参数结构体
6259901d925a0f43d25e8e75
class S3DynamoDBTable(object): <NEW_LINE> <INDENT> def __init__(self, table, region): <NEW_LINE> <INDENT> self.table = table <NEW_LINE> self.ddb = boto3.client('dynamodb', region_name=region) <NEW_LINE> <DEDENT> def put(self, item): <NEW_LINE> <INDENT> self.ddb.put_item(TableName = self.table, Item = item, ReturnConsumedCapacity = 'NONE', ReturnItemCollectionMetrics = 'NONE') <NEW_LINE> <DEDENT> def exists(self, key): <NEW_LINE> <INDENT> resp = self.ddb.get_item(TableName = self.table, Key = key, ConsistentRead=True, ReturnConsumedCapacity='NONE') <NEW_LINE> return 'Item' in resp
Wrapper for calls to DynamoDB Wraps boto3 calls to create and update DynamoDB entries. Supports updates for S3 Index tables
6259901dbf627c535bcb22e6
class DensePop(Pop): <NEW_LINE> <INDENT> def __init__(self, input_size, output_size, W=init.Uniform(), b=init.Constant(0.), nonlinearity=nonlinearities.rectify, **kwargs): <NEW_LINE> <INDENT> super(DensePop, self).__init__(1, 1, **kwargs) <NEW_LINE> if nonlinearity is None: <NEW_LINE> <INDENT> self.nonlinearity = nonlinearities.identity <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.nonlinearity = nonlinearity <NEW_LINE> <DEDENT> self.W = self.create_param(W, (input_size, output_size), name="W") <NEW_LINE> self.b = (self.create_param(b, (output_size,), name="b") if b is not None else None) <NEW_LINE> <DEDENT> def get_params(self): <NEW_LINE> <INDENT> return [self.W] + self.get_bias_params() <NEW_LINE> <DEDENT> def get_bias_params(self): <NEW_LINE> <INDENT> return [self.b] if self.b is not None else [] <NEW_LINE> <DEDENT> def symbolic_call(self, inp, **kwargs): <NEW_LINE> <INDENT> if inp.ndim > 2: <NEW_LINE> <INDENT> inp = inp.flatten(2) <NEW_LINE> <DEDENT> activation = T.dot(inp, self.W) <NEW_LINE> if self.b is not None: <NEW_LINE> <INDENT> activation = activation + self.b.dimshuffle('x', 0) <NEW_LINE> <DEDENT> return self.nonlinearity(activation)
A fully connected layer. :parameters: - input_layer : `Layer` instance The layer from which this layer will obtain its input - num_units : int The number of units of the layer - W : Theano shared variable, numpy array or callable An initializer for the weights of the layer. If a Theano shared variable is provided, it is used unchanged. If a numpy array is provided, a shared variable is created and initialized with the array. If a callable is provided, a shared variable is created and the callable is called with the desired shape to generate suitable initial values. The variable is then initialized with those values. - b : Theano shared variable, numpy array, callable or None An initializer for the biases of the layer. If a Theano shared variable is provided, it is used unchanged. If a numpy array is provided, a shared variable is created and initialized with the array. If a callable is provided, a shared variable is created and the callable is called with the desired shape to generate suitable initial values. The variable is then initialized with those values. If None is provided, the layer will have no biases. - nonlinearity : callable or None The nonlinearity that is applied to the layer activations. If None is provided, the layer will be linear. :usage: >>> from lasagne.layers import InputLayer, DenseLayer >>> l_in = InputLayer((100, 20)) >>> l1 = DenseLayer(l_in, num_units=50)
6259901d507cdc57c63a5bd7
class _PropertyComponent(_BaseComponent): <NEW_LINE> <INDENT> def _get_prop_names(self): <NEW_LINE> <INDENT> raise NotImplementedError
A component that operates on a specific set of properties.
6259901d30c21e258be99648
class FieldworkModelSourceStep(WorkflowStepMountPoint): <NEW_LINE> <INDENT> def __init__(self, location): <NEW_LINE> <INDENT> super(FieldworkModelSourceStep, self).__init__('Fieldwork Model Source', location) <NEW_LINE> self._state = FieldworkModelData() <NEW_LINE> self._icon = QtGui.QImage(':/zincmodelsource/images/zinc_model_icon.png') <NEW_LINE> self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'ju#fieldworkmodel')) <NEW_LINE> <DEDENT> def configure(self): <NEW_LINE> <INDENT> d = ConfigureDialog(self._state) <NEW_LINE> d.setModal(True) <NEW_LINE> if d.exec_(): <NEW_LINE> <INDENT> self._state = d.getState() <NEW_LINE> self.serialize(self._location) <NEW_LINE> <DEDENT> self._configured = d.validate() <NEW_LINE> if self._configured and self._configuredObserver: <NEW_LINE> <INDENT> self._configuredObserver() <NEW_LINE> <DEDENT> <DEDENT> def getIdentifier(self): <NEW_LINE> <INDENT> return self._state._identifier <NEW_LINE> <DEDENT> def setIdentifier(self, identifier): <NEW_LINE> <INDENT> self._state._identifier = identifier <NEW_LINE> <DEDENT> def serialize(self, location): <NEW_LINE> <INDENT> configuration_file = os.path.join(location, getConfigFilename(self._state._identifier)) <NEW_LINE> s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat) <NEW_LINE> s.beginGroup('state') <NEW_LINE> s.setValue('identifier', self._state._identifier) <NEW_LINE> s.setValue('geometricfield', self._state._geometricFieldLocation) <NEW_LINE> s.setValue('ensemble', self._state._ensembleLocation) <NEW_LINE> s.setValue('mesh', self._state._meshLocation) <NEW_LINE> s.endGroup() <NEW_LINE> <DEDENT> def deserialize(self, location): <NEW_LINE> <INDENT> configuration_file = os.path.join(location, getConfigFilename(self._state._identifier)) <NEW_LINE> s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat) <NEW_LINE> s.beginGroup('state') <NEW_LINE> self._state._identifier = s.value('identifier', '') <NEW_LINE> self._state._geometricFieldLocation = s.value('geometricField', '') <NEW_LINE> self._state._ensembleLocation = s.value('ensemble', '') <NEW_LINE> self._state._meshLocation = s.value('mesh', '') <NEW_LINE> s.endGroup() <NEW_LINE> d = ConfigureDialog(self._state) <NEW_LINE> self._configured = d.validate() <NEW_LINE> <DEDENT> def portOutput(self): <NEW_LINE> <INDENT> geometricField = fieldwork.geometric_field.load_geometric_field(self._state._geometricFieldLocation, self._state._ensembleLocation, self._state._meshLocation, ) <NEW_LINE> return geometricField
fieldwork model source step supplies fieldwork model source files from a location on disk.
6259901d9b70327d1c57fbb5
class M5P(AbstractWekaModelVisitor): <NEW_LINE> <INDENT> wekaCommand = "weka.classifiers.trees.M5P"
Weka M5P for predicting numeric responses.
6259901d5e10d32532ce4020
class ShortenedLinkCreateView(View): <NEW_LINE> <INDENT> http_method_names = ['post'] <NEW_LINE> def post(self, request, *args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data = json.loads(request.body) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return HttpResponse(json.dumps({'error': True, 'message': 'Invalid request data.'}), status=400) <NEW_LINE> <DEDENT> data['key'] = LinkShortener().generate_key(data['destination']) <NEW_LINE> link_form = ShortenedLinkForm(data) <NEW_LINE> if link_form.is_valid(): <NEW_LINE> <INDENT> shortened = link_form.save() <NEW_LINE> short_path = reverse('shortlinks:dereference-shortened', kwargs={'key': shortened.key}) <NEW_LINE> short_url = request.build_absolute_uri(short_path) <NEW_LINE> return HttpResponse(json.dumps({'shortenedUrl': short_url}), status=201) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return HttpResponse(json.dumps(link_form.errors), status=400)
Handle creating shortened URLs
6259901eac7a0e7691f73320
class _FileFormatter(logging.Formatter): <NEW_LINE> <INDENT> _LOG_MESSAGE_BEGIN = ( '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s ') <NEW_LINE> _LOG_MESSAGE_CONTEXT = '[%(cloud)s %(username)s %(project)s] ' <NEW_LINE> _LOG_MESSAGE_END = '%(message)s' <NEW_LINE> _LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S' <NEW_LINE> def __init__(self, options=None, config=None, **kwargs): <NEW_LINE> <INDENT> context = {} <NEW_LINE> if options: <NEW_LINE> <INDENT> context = { 'cloud': getattr(options, 'cloud', ''), 'project': getattr(options, 'os_project_name', ''), 'username': getattr(options, 'username', ''), } <NEW_LINE> <DEDENT> elif config: <NEW_LINE> <INDENT> context = { 'cloud': config.config.get('cloud', ''), 'project': config.auth.get('project_name', ''), 'username': config.auth.get('username', ''), } <NEW_LINE> <DEDENT> if context: <NEW_LINE> <INDENT> self.fmt = (self._LOG_MESSAGE_BEGIN + (self._LOG_MESSAGE_CONTEXT % context) + self._LOG_MESSAGE_END) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.fmt = self._LOG_MESSAGE_BEGIN + self._LOG_MESSAGE_END <NEW_LINE> <DEDENT> logging.Formatter.__init__(self, self.fmt, self._LOG_DATE_FORMAT)
Customize the logging format for logging handler
6259901ebf627c535bcb22ea
class GBCountySelect(Select): <NEW_LINE> <INDENT> def __init__(self, attrs=None): <NEW_LINE> <INDENT> super(GBCountySelect, self).__init__(attrs, choices=GB_REGION_CHOICES)
A Select widget that uses a list of UK Counties/Regions as its choices.
6259901e287bf620b6272a21
class Master(object): <NEW_LINE> <INDENT> def __init__(self, opts): <NEW_LINE> <INDENT> self.opts = opts <NEW_LINE> <DEDENT> def _clear_old_jobs(self): <NEW_LINE> <INDENT> if self.opts['keep_jobs'] == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> diff = self.opts['keep_jobs'] * 60 * 60 <NEW_LINE> keep = int(time.time()) - diff <NEW_LINE> jid_root = os.path.join(self.opts['cachedir'], 'jobs') <NEW_LINE> for jid in os.listdir(jid_root): <NEW_LINE> <INDENT> if int(jid.split('.')[0]) < keep: <NEW_LINE> <INDENT> shutil.rmtree(os.path.join(jid_root, jid)) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def start(self): <NEW_LINE> <INDENT> self.opts['logger'].info('Starting the Salt Master') <NEW_LINE> reqserv = ReqServer(self.opts) <NEW_LINE> reqserv.run() <NEW_LINE> while True: <NEW_LINE> <INDENT> self._clear_old_jobs() <NEW_LINE> time.sleep(60)
The salt master server
6259901e5e10d32532ce4021
class NoSuchKey(PKCS11Error): <NEW_LINE> <INDENT> pass
No key matching the parameters was found.
6259901e8c3a8732951f7391
class Bead: <NEW_LINE> <INDENT> def __init__(self, index=0): <NEW_LINE> <INDENT> self.index = int(index) <NEW_LINE> self.color = color.Color() <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return "Bead(index={}, color={})".format(self.index, self.color) <NEW_LINE> <DEDENT> def copy_color(self, color): <NEW_LINE> <INDENT> self.color = copy.copy(color)
Bead represents a single rosary bead.
6259901e925a0f43d25e8e7b
class MyClass: <NEW_LINE> <INDENT> def say(): <NEW_LINE> <INDENT> print("Hello") <NEW_LINE> <DEDENT> def instance_say(self): <NEW_LINE> <INDENT> print('Hello') <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def static_say(): <NEW_LINE> <INDENT> print("Hello") <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def class_say(cls): <NEW_LINE> <INDENT> print('Hello')
Class method: One use people have found for class methods is to create inheritable alternative constructors. @classmethod function is callable without instantiating the class, but its definition follows Sub class, not Parent class, via inheritance. That’s because the first argument for @classmethod function must always be cls Static method: @staticmethod function is nothing more than a function defined inside a class. It is callable without instantiating the class first. It’s definition is immutable via inheritance. Neither self (the object instance) nor cls (the class) is implicitly passed as the first argument. They behave like regular python functions except that you can call them from an instance or the class. The difference between a static method and a class method is: Static method knows nothing about the class and just deals with the parameters(behave like regular function) Class method works with the class since its parameter is always the class itself.
6259901e507cdc57c63a5bdd
@base.ReleaseTracks(base.ReleaseTrack.ALPHA) <NEW_LINE> class CreateAlpha(Create): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def Args(parser): <NEW_LINE> <INDENT> Create.disks_arg = disks_flags.MakeDiskArg(plural=True) <NEW_LINE> _CommonArgs( parser, disks_flags.SOURCE_SNAPSHOT_ARG, include_physical_block_size_support=True) <NEW_LINE> image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.ALPHA) <NEW_LINE> _AddReplicaZonesArg(parser) <NEW_LINE> resource_flags.AddResourcePoliciesArgs(parser, 'added to', 'disk') <NEW_LINE> kms_resource_args.AddKmsKeyResourceArg( parser, 'disk', region_fallthrough=True) <NEW_LINE> <DEDENT> def Run(self, args): <NEW_LINE> <INDENT> return self._Run(args, supports_kms_keys=True, supports_physical_block=True)
Create Google Compute Engine persistent disks.
6259901e8c3a8732951f7393
class Camera(object): <NEW_LINE> <INDENT> __metaclass__ = ABCMeta <NEW_LINE> def __init__(self, camera_to_world, s_open, s_close, film): <NEW_LINE> <INDENT> self.camera_to_world = camera_to_world <NEW_LINE> self.shutter_open = s_open <NEW_LINE> self.shutter_close = s_close <NEW_LINE> self.film = film <NEW_LINE> if camera_to_world.has_scale(): <NEW_LINE> <INDENT> logger.warning( "Scaling detected in world-to-camera transformation!\n" "The system has numerous assumptions, implicit and explicit,\n" "that this transform will have no scale factors in it.\n" "Proceed at your own risk; your image may have errors or\n" "the system may crash as a result of this.") <NEW_LINE> <DEDENT> <DEDENT> @abstractmethod <NEW_LINE> def generate_ray(self, sample): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def generate_ray_differential(self, sample): <NEW_LINE> <INDENT> weight, ray = self.generate_ray(sample) <NEW_LINE> ray_diff = RayDifferential.from_ray(ray) <NEW_LINE> sshift = CameraSample.from_sample(sample) <NEW_LINE> sshift.image_x += 1 <NEW_LINE> weight_x, ray_x = self.generate_ray(sshift) <NEW_LINE> ray_diff.rx_origin = ray_x.o <NEW_LINE> ray_diff.rx_direction = ray_x.d <NEW_LINE> sshift.image_x -= 1 <NEW_LINE> sshift.image_y += 1 <NEW_LINE> weight_y, ray_y = self.generate_ray(sshift) <NEW_LINE> ray_diff.ry_origin = ray_y.o <NEW_LINE> ray_diff.ry_direction = ray_y.d <NEW_LINE> if (weight_x == 0.0) or (weight_y == 0.0): <NEW_LINE> <INDENT> return 0.0, ray_diff <NEW_LINE> <DEDENT> ray_diff.has_differentials = True <NEW_LINE> return weight, ray_diff
Interface Class for all cameras.
6259901ea8ecb0332587205a
class Connector(GenericConnector): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> GenericConnector.__init__(self) <NEW_LINE> <DEDENT> def connect(self): <NEW_LINE> <INDENT> self.initConnection() <NEW_LINE> try: <NEW_LINE> <INDENT> msg = "what's the location of 'hsqldb.jar'? " <NEW_LINE> jar = readInput(msg) <NEW_LINE> checkFile(jar) <NEW_LINE> args = "-Djava.class.path=%s" % jar <NEW_LINE> jvm_path = jpype.getDefaultJVMPath() <NEW_LINE> jpype.startJVM(jvm_path, args) <NEW_LINE> <DEDENT> except Exception as msg: <NEW_LINE> <INDENT> raise SqlmapConnectionException(msg[0]) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> driver = 'org.hsqldb.jdbc.JDBCDriver' <NEW_LINE> connection_string = 'jdbc:hsqldb:mem:.' <NEW_LINE> self.connector = jaydebeapi.connect(driver, connection_string, str(self.user), str(self.password)) <NEW_LINE> <DEDENT> except Exception as msg: <NEW_LINE> <INDENT> raise SqlmapConnectionException(msg[0]) <NEW_LINE> <DEDENT> self.initCursor() <NEW_LINE> self.printConnected() <NEW_LINE> <DEDENT> def fetchall(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.cursor.fetchall() <NEW_LINE> <DEDENT> except Exception as msg: <NEW_LINE> <INDENT> logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> def execute(self, query): <NEW_LINE> <INDENT> retVal = False <NEW_LINE> try: <NEW_LINE> <INDENT> self.cursor.execute(query) <NEW_LINE> retVal = True <NEW_LINE> <DEDENT> except Exception as msg: <NEW_LINE> <INDENT> logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) <NEW_LINE> <DEDENT> self.connector.commit() <NEW_LINE> return retVal <NEW_LINE> <DEDENT> def select(self, query): <NEW_LINE> <INDENT> retVal = None <NEW_LINE> upper_query = query.upper() <NEW_LINE> if query and not (upper_query.startswith("SELECT ") or upper_query.startswith("VALUES ")): <NEW_LINE> <INDENT> query = "VALUES %s" % query <NEW_LINE> <DEDENT> if query and upper_query.startswith("SELECT ") and " FROM " not in upper_query: <NEW_LINE> <INDENT> query = "%s FROM (VALUES(0))" % query <NEW_LINE> <DEDENT> self.cursor.execute(query) <NEW_LINE> retVal = self.cursor.fetchall() <NEW_LINE> return retVal
Homepage: https://pypi.python.org/pypi/JayDeBeApi/ & http://jpype.sourceforge.net/ User guide: https://pypi.python.org/pypi/JayDeBeApi/#usage & http://jpype.sourceforge.net/doc/user-guide/userguide.html API: - Debian package: - License: LGPL & Apache License 2.0
6259901e925a0f43d25e8e7f
class ClientThread (threading.Thread): <NEW_LINE> <INDENT> def __init__ (self, client, addr): <NEW_LINE> <INDENT> threading.Thread.__init__(self) <NEW_LINE> self.client = client <NEW_LINE> self.addr = addr <NEW_LINE> <DEDENT> def run (self): <NEW_LINE> <INDENT> data = self.client.recv(4).decode('utf-8') <NEW_LINE> if data == '0000': <NEW_LINE> <INDENT> write_master_log('Get connection with client %s.' % str(self.addr)) <NEW_LINE> self.client.send(turn_bytes('1111')) <NEW_LINE> handle_client_connection(self.client, self.addr) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> write_master_log('Not identified client %s.' % str(self.addr)) <NEW_LINE> <DEDENT> self.client.close()
Thread for each client connect
6259901ed18da76e235b786b
@utils.use_signature(core.TopLevelLayerSpec) <NEW_LINE> class LayerChart(TopLevelMixin, EncodingMixin, core.TopLevelLayerSpec): <NEW_LINE> <INDENT> def __init__(self, data=Undefined, layer=(), **kwargs): <NEW_LINE> <INDENT> for spec in layer: <NEW_LINE> <INDENT> _check_if_valid_subspec(spec, 'LayerChart') <NEW_LINE> <DEDENT> super(LayerChart, self).__init__(data=data, layer=list(layer), **kwargs) <NEW_LINE> <DEDENT> def __iadd__(self, other): <NEW_LINE> <INDENT> _check_if_valid_subspec(other, 'LayerChart') <NEW_LINE> self.layer.append(other) <NEW_LINE> return self <NEW_LINE> <DEDENT> def __add__(self, other): <NEW_LINE> <INDENT> copy = self.copy() <NEW_LINE> copy.layer.append(other) <NEW_LINE> return copy <NEW_LINE> <DEDENT> def add_layers(self, *layers): <NEW_LINE> <INDENT> copy = self.copy() <NEW_LINE> for layer in layers: <NEW_LINE> <INDENT> copy += layer <NEW_LINE> <DEDENT> return copy <NEW_LINE> <DEDENT> def interactive(self, name=None, bind_x=True, bind_y=True): <NEW_LINE> <INDENT> if not self.layer: <NEW_LINE> <INDENT> raise ValueError("LayerChart: cannot call interactive() until a " "layer is defined") <NEW_LINE> <DEDENT> copy = self.copy() <NEW_LINE> copy.layer[0] = copy.layer[0].interactive(name=name, bind_x=bind_x, bind_y=bind_y) <NEW_LINE> return copy <NEW_LINE> <DEDENT> def facet(self, row=Undefined, column=Undefined, data=Undefined, **kwargs): <NEW_LINE> <INDENT> if data is Undefined: <NEW_LINE> <INDENT> data = self.data <NEW_LINE> self = self.copy() <NEW_LINE> self.data = Undefined <NEW_LINE> <DEDENT> return FacetChart(spec=self, facet=FacetMapping(row=row, column=column), data=data, **kwargs)
A Chart with layers within a single panel
6259901e30c21e258be99652
class VideoPlugin(BasePlugin): <NEW_LINE> <INDENT> ATTRIBUTE_NAMES = ['topicName', 'height', 'width', 'alwaysOn', 'updateRate'] <NEW_LINE> def __init__(self, name=None, filename=None, topic_name=None, height=None, width=None, always_on=None, update_rate=None): <NEW_LINE> <INDENT> super(VideoPlugin, self).__init__(name, filename, {'topicName': topic_name, 'height': height, 'width': width, 'alwaysOn': always_on, 'updateRate': update_rate})
Class defining the plugin used to simulate video on a robot plugin topicName height width alwaysOn updateRate
6259901e56b00c62f0fb36fe
class FetchApprovalTest(TestBase): <NEW_LINE> <INDENT> def create_several_approvals_for_course(self, number_of_courses = 1): <NEW_LINE> <INDENT> teacher = self.create_and_return_local_user() <NEW_LINE> for N in range(number_of_courses): <NEW_LINE> <INDENT> course_id = new_course({ 'teacher' : teacher.key.id(), 'title' : 'foo course', 'body' : 'hey look mom', }) <NEW_LINE> list_of_ids_to_approve = [1,2,3,4,5] <NEW_LINE> course = get_course_by_id(course_id) <NEW_LINE> for i in list_of_ids_to_approve: <NEW_LINE> <INDENT> new_approval_request( course = course, googleID=i, formalName='John Doe %s' % i, email='j%s@example.com' % i ) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def test_get_approved_users(self): <NEW_LINE> <INDENT> self.create_several_approvals_for_course(1) <NEW_LINE> course = Curriculum.query().get() <NEW_LINE> self.assertEqual( course.content['pending_approval'], [1,2,3,4,5], )
test the implementation of the controllers which fetch approvals
6259901ed18da76e235b786d
class Related(factory.Factory): <NEW_LINE> <INDENT> FACTORY_FOR = ckan.model.Related <NEW_LINE> type = 'idea' <NEW_LINE> description = 'Look, a description!' <NEW_LINE> url = 'http://example.com' <NEW_LINE> title = factory.Sequence(lambda n: 'test title {n}'.format(n=n)) <NEW_LINE> @classmethod <NEW_LINE> def _build(cls, target_class, *args, **kwargs): <NEW_LINE> <INDENT> raise NotImplementedError(".build() isn't supported in CKAN") <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def _create(cls, target_class, *args, **kwargs): <NEW_LINE> <INDENT> if args: <NEW_LINE> <INDENT> assert False, "Positional args aren't supported, use keyword args." <NEW_LINE> <DEDENT> context = {'user': _get_action_user_name(kwargs)} <NEW_LINE> related_dict = helpers.call_action('related_create', context=context, **kwargs) <NEW_LINE> return related_dict
A factory class for creating related items.
6259901e63f4b57ef0086492
class Cell(): <NEW_LINE> <INDENT> def __init__(self, row_num, col_num, number): <NEW_LINE> <INDENT> self.RowNum = row_num <NEW_LINE> self.ColNum = col_num <NEW_LINE> self.Number = number <NEW_LINE> self.Neighbours = CellRelationships() <NEW_LINE> <DEDENT> def describe(self): <NEW_LINE> <INDENT> description = ['#:{}'.format(self.Number)] <NEW_LINE> if self.Neighbours.Above is not None: <NEW_LINE> <INDENT> description.append("Above is {} ".format(self.Neighbours.Above.Name)) <NEW_LINE> <DEDENT> if self.Neighbours.Below is not None: <NEW_LINE> <INDENT> description.append("Below is {} ".format(self.Neighbours.Below.Name)) <NEW_LINE> <DEDENT> if self.Neighbours.Left is not None: <NEW_LINE> <INDENT> description.append("Left is {} ".format(self.Neighbours.Left.Name)) <NEW_LINE> <DEDENT> if self.Neighbours.Right is not None: <NEW_LINE> <INDENT> description.append("Right is {} ".format(self.Neighbours.Right.Name)) <NEW_LINE> <DEDENT> return ' '.join(description)
Structure to represent a cell, with connected cells..
6259901e30c21e258be99656
class ListFollowers(ListAPIView): <NEW_LINE> <INDENT> serializer_class = UserSerializer <NEW_LINE> def get_queryset(self): <NEW_LINE> <INDENT> return self.request.user.followers.all()
get: Get a list of all followers of the logged in user (authentication required)
6259901e8c3a8732951f739b
@ddt.ddt <NEW_LINE> class FilenameGeneratorTestCase(TestCase): <NEW_LINE> <INDENT> NOW = datetime.strptime('1974-06-22T01:02:03', '%Y-%m-%dT%H:%M:%S').replace(tzinfo=UTC) <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> super(FilenameGeneratorTestCase, self).setUp() <NEW_LINE> datetime_patcher = patch.object( common.djangoapps.util.file, 'datetime', Mock(wraps=datetime) ) <NEW_LINE> mocked_datetime = datetime_patcher.start() <NEW_LINE> mocked_datetime.now.return_value = self.NOW <NEW_LINE> self.addCleanup(datetime_patcher.stop) <NEW_LINE> <DEDENT> @ddt.data(CourseLocator(org='foo', course='bar', run='baz'), CourseKey.from_string('foo/bar/baz')) <NEW_LINE> def test_filename_generator(self, course_key): <NEW_LINE> <INDENT> self.assertEqual( u'foo_bar_baz_file_1974-06-22-010203', course_and_time_based_filename_generator(course_key, 'file') ) <NEW_LINE> self.assertEqual( u'foo_bar_baz_base_name_ø_1974-06-22-010203', course_and_time_based_filename_generator(course_key, ' base` name ø ') )
Tests for course_and_time_based_filename_generator
6259901e462c4b4f79dbc84c
class SMORMS3(Optimizer): <NEW_LINE> <INDENT> def __init__(self, lr=0.001, epsilon=1e-16, decay=0., **kwargs): <NEW_LINE> <INDENT> super(SMORMS3, self).__init__(**kwargs) <NEW_LINE> self.__dict__.update(locals()) <NEW_LINE> with K.name_scope(self.__class__.__name__): <NEW_LINE> <INDENT> self.lr = K.variable(lr) <NEW_LINE> self.decay = K.variable(decay) <NEW_LINE> self.inital_decay = decay <NEW_LINE> self.iterations = K.variable(0.) <NEW_LINE> <DEDENT> self.epsilon = epsilon <NEW_LINE> self.initial_decay = decay <NEW_LINE> <DEDENT> def get_updates(self, loss, params): <NEW_LINE> <INDENT> grads = self.get_gradients(loss, params) <NEW_LINE> shapes = [K.get_variable_shape(p) for p in params] <NEW_LINE> self.updates.append(K.update_add(self.iterations, 1)) <NEW_LINE> g1s = [K.zeros(shape) for shape in shapes] <NEW_LINE> g2s = [K.zeros(shape) for shape in shapes] <NEW_LINE> mems = [K.ones(shape) for shape in shapes] <NEW_LINE> lr = self.lr <NEW_LINE> if self.inital_decay > 0: <NEW_LINE> <INDENT> lr *= (1. / (1. + self.decay * self.iterations)) <NEW_LINE> <DEDENT> self.weights = [self.iterations] + g1s + g2s + mems <NEW_LINE> for p, g, g1, g2, m in zip(params, grads, g1s, g2s, mems): <NEW_LINE> <INDENT> r = 1. / (m + 1) <NEW_LINE> new_g1 = (1. - r) * g1 + r * g <NEW_LINE> new_g2 = (1. - r) * g2 + r * K.square(g) <NEW_LINE> self.updates.append(K.update(g1, new_g1)) <NEW_LINE> self.updates.append(K.update(g2, new_g2)) <NEW_LINE> new_p = p - g * K.minimum(lr, K.square(new_g1) / (new_g2 + self.epsilon)) / ( K.sqrt(new_g2) + self.epsilon) <NEW_LINE> new_m = 1 + m * (1 - K.square(new_g1) / (new_g2 + self.epsilon)) <NEW_LINE> self.updates.append(K.update(m, new_m)) <NEW_LINE> if getattr(p, 'constraint', None) is not None: <NEW_LINE> <INDENT> new_p = p.constraint(new_p) <NEW_LINE> <DEDENT> self.updates.append(K.update(p, new_p)) <NEW_LINE> <DEDENT> return self.updates <NEW_LINE> <DEDENT> def get_config(self): <NEW_LINE> <INDENT> config = {'lr': float(K.get_value(self.lr)), 'decay': float(K.get_value(self.decay)), 'epsilon': self.epsilon} <NEW_LINE> base_config = super(SMORMS3, self).get_config() <NEW_LINE> return dict(list(base_config.items()) + list(config.items()))
SMORMS3 optimizer. Implemented based on http://sifter.org/~simon/journal/20150420.html # Arguments lr: float >= 0. Learning rate. epsilon: float >= 0. Fuzz factor. decay: float >= 0. Learning rate decay over each update.
6259901e8c3a8732951f739d
class DescribePolicyConditionListConfigManual(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.CalcType = None <NEW_LINE> self.CalcValue = None <NEW_LINE> self.ContinueTime = None <NEW_LINE> self.Period = None <NEW_LINE> self.PeriodNum = None <NEW_LINE> self.StatType = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> if params.get("CalcType") is not None: <NEW_LINE> <INDENT> self.CalcType = DescribePolicyConditionListConfigManualCalcType() <NEW_LINE> self.CalcType._deserialize(params.get("CalcType")) <NEW_LINE> <DEDENT> if params.get("CalcValue") is not None: <NEW_LINE> <INDENT> self.CalcValue = DescribePolicyConditionListConfigManualCalcValue() <NEW_LINE> self.CalcValue._deserialize(params.get("CalcValue")) <NEW_LINE> <DEDENT> if params.get("ContinueTime") is not None: <NEW_LINE> <INDENT> self.ContinueTime = DescribePolicyConditionListConfigManualContinueTime() <NEW_LINE> self.ContinueTime._deserialize(params.get("ContinueTime")) <NEW_LINE> <DEDENT> if params.get("Period") is not None: <NEW_LINE> <INDENT> self.Period = DescribePolicyConditionListConfigManualPeriod() <NEW_LINE> self.Period._deserialize(params.get("Period")) <NEW_LINE> <DEDENT> if params.get("PeriodNum") is not None: <NEW_LINE> <INDENT> self.PeriodNum = DescribePolicyConditionListConfigManualPeriodNum() <NEW_LINE> self.PeriodNum._deserialize(params.get("PeriodNum")) <NEW_LINE> <DEDENT> if params.get("StatType") is not None: <NEW_LINE> <INDENT> self.StatType = DescribePolicyConditionListConfigManualStatType() <NEW_LINE> self.StatType._deserialize(params.get("StatType"))
DescribePolicyConditionList.ConfigManual
6259901ed164cc6175821dc4
class RecipeDetailSerializer(RecipeSerializer): <NEW_LINE> <INDENT> ingredients = IngredientSerializer(many=True, read_only=True) <NEW_LINE> tags = TagSerializer(many=True, read_only=True)
Create recipe detail.
6259901e21a7993f00c66dc2
class ValueViewSet(DefaultMixin,viewsets.ModelViewSet): <NEW_LINE> <INDENT> queryset = Value.objects.all() <NEW_LINE> serializer_class = ValueSerializer
Endpoint da API para listar e criar Inspections
6259901e30c21e258be9965a
class PubDetail(restful.Resource): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def get(): <NEW_LINE> <INDENT> parser = reqparse.RequestParser() <NEW_LINE> parser.add_argument('pub_id', type=str, required=True, help=u'酒吧pub_id必须。') <NEW_LINE> parser.add_argument('user_id', type=str, required=True, help=u'登录用户id必须。') <NEW_LINE> args = parser.parse_args() <NEW_LINE> resp_suc = {} <NEW_LINE> resp_suc['picture_list'] = [] <NEW_LINE> resp_suc['pub_list'] = [] <NEW_LINE> pub_id = int(args['pub_id']) <NEW_LINE> resp_suc['county'] = [] <NEW_LINE> user_id = args['user_id'] <NEW_LINE> if pub_id: <NEW_LINE> <INDENT> collect = Collect.query.filter(Collect.user_id == user_id, Collect.pub_id == pub_id).first() <NEW_LINE> resp_suc['is_collect'] = False <NEW_LINE> if collect: <NEW_LINE> <INDENT> resp_suc['is_collect'] = True <NEW_LINE> <DEDENT> pub = Pub.query.filter(Pub.id == pub_id).first() <NEW_LINE> pub_picture = PubPicture.query.filter(PubPicture.pub_id == pub_id).first() <NEW_LINE> resp_suc['county'] = get_address(pub.province_id, pub.city_id, pub.county_id) <NEW_LINE> pub_pic = to_pub_longitude_latitude(pub, pub_picture) <NEW_LINE> to_pub_type(pub, pub_pic) <NEW_LINE> resp_suc['pub_list'].append(pub_pic) <NEW_LINE> view_check = View.query.filter(View.user_id == user_id, View.pub_id == pub_id).first() <NEW_LINE> if view_check: <NEW_LINE> <INDENT> view_check.view_number = view_check.view_number + 1 <NEW_LINE> db.commit() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> user = User.query.filter(User.id == user_id).first() <NEW_LINE> if user: <NEW_LINE> <INDENT> view = View(user_id, pub_id, 1) <NEW_LINE> db.add(view) <NEW_LINE> db.commit() <NEW_LINE> <DEDENT> <DEDENT> view_count = View.query.filter(View.pub_id == pub_id).count() <NEW_LINE> result_count = db.query(UserInfo). join(User). join(View). filter(View.pub_id == pub_id).order_by(View.time.desc()).count() <NEW_LINE> if result_count > 1: <NEW_LINE> <INDENT> results = db.query(UserInfo). join(User). join(View). filter(View.pub_id == pub_id).order_by(View.time.desc()).all() <NEW_LINE> user_list_picture(results, resp_suc) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result = db.query(UserInfo). join(User). join(View). filter(View.pub_id == pub_id).order_by(View.time.desc()).first() <NEW_LINE> user_picture_only(result, resp_suc) <NEW_LINE> <DEDENT> resp_suc['activity'] = get_activity_by_pub_id(pub_id, user_id) <NEW_LINE> resp_suc['show_count'] = view_count <NEW_LINE> resp_suc['status'] = 0 <NEW_LINE> resp_suc['message'] = 'success' <NEW_LINE> return resp_suc <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> resp_suc['status'] = 1 <NEW_LINE> resp_suc['message'] = 'error' <NEW_LINE> return resp_suc
酒吧详细
6259901eac7a0e7691f73330
class ConjugateTranspose(Operator): <NEW_LINE> <INDENT> name = "^H" <NEW_LINE> arity = matchpy.Arity.unary <NEW_LINE> infix = False <NEW_LINE> def __init__(self, *operands, variable_name=None): <NEW_LINE> <INDENT> super().__init__(*operands, variable_name=variable_name) <NEW_LINE> <DEDENT> @property <NEW_LINE> def size(self): <NEW_LINE> <INDENT> return tuple(reversed(self.operands[0].size)) <NEW_LINE> <DEDENT> @property <NEW_LINE> def rows(self): <NEW_LINE> <INDENT> return self.operands[0].columns <NEW_LINE> <DEDENT> @property <NEW_LINE> def columns(self): <NEW_LINE> <INDENT> return self.operands[0].rows <NEW_LINE> <DEDENT> @property <NEW_LINE> def operand(self): <NEW_LINE> <INDENT> return self.operands[0] <NEW_LINE> <DEDENT> @property <NEW_LINE> def bandwidth(self): <NEW_LINE> <INDENT> lb, ub = self.operands[0].bandwidth <NEW_LINE> return (ub, lb) <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return "{0}{1}".format(self.operands[0], self.name) <NEW_LINE> <DEDENT> def to_matlab_expression(self): <NEW_LINE> <INDENT> raise NotImplementedError() <NEW_LINE> <DEDENT> def to_julia_expression(self): <NEW_LINE> <INDENT> return "ctranspose({0})".format(self.operands[0].to_julia_expression()) <NEW_LINE> <DEDENT> def to_cpp_expression(self, lib): <NEW_LINE> <INDENT> template_str = None <NEW_LINE> if lib is CppLibrary.Blaze: <NEW_LINE> <INDENT> template_str = "blaze::ctrans({0})" <NEW_LINE> <DEDENT> elif lib is CppLibrary.Eigen: <NEW_LINE> <INDENT> template_str = "({0}).adjoint()" <NEW_LINE> <DEDENT> elif lib is CppLibrary.Armadillo: <NEW_LINE> <INDENT> template_str = "({0}).t()" <NEW_LINE> <DEDENT> return template_str.format(self.operands[0].to_cpp_expression(lib))
docstring for ConjugateTranspose
6259901e287bf620b6272a31
class ExposeServiceRequest(AbstractModel): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.ServiceId = None <NEW_LINE> self.ExposeType = None <NEW_LINE> self.VpcId = None <NEW_LINE> self.SubnetId = None <NEW_LINE> <DEDENT> def _deserialize(self, params): <NEW_LINE> <INDENT> self.ServiceId = params.get("ServiceId") <NEW_LINE> self.ExposeType = params.get("ExposeType") <NEW_LINE> self.VpcId = params.get("VpcId") <NEW_LINE> self.SubnetId = params.get("SubnetId")
ExposeService请求参数结构体
6259901e925a0f43d25e8e8b
@registry.register_problem <NEW_LINE> class ImageCelebahq256Dmol(ImageCelebahq256): <NEW_LINE> <INDENT> def eval_metrics(self): <NEW_LINE> <INDENT> return [ metrics.Metrics.DMOL_PERPLEXITY ]
CelebA-HQ dataset with discretized mixture of logistics for evaluation.
6259901e30c21e258be9965e
@dataclass <NEW_LINE> class Dataset: <NEW_LINE> <INDENT> train: pd.DataFrame <NEW_LINE> test: pd.DataFrame <NEW_LINE> target: str <NEW_LINE> def __post_init__(self): <NEW_LINE> <INDENT> self._split_x_y() <NEW_LINE> self._register_feature_names() <NEW_LINE> self._impute_and_encode() <NEW_LINE> <DEDENT> def _split_x_y(self): <NEW_LINE> <INDENT> self.X_train, self.y_train = ( self.train.drop(columns=[self.target]), self.train[self.target], ) <NEW_LINE> self.X_test, self.y_test = ( self.test.drop(columns=[self.target]), self.test[self.target], ) <NEW_LINE> <DEDENT> def _register_feature_names(self): <NEW_LINE> <INDENT> self.cat_features = [ c for c in self.X_train.columns if pd.api.types.is_object_dtype(self.X_train[c]) ] <NEW_LINE> self.num_features = [ c for c in self.X_train.columns if c not in self.cat_features ] <NEW_LINE> <DEDENT> def _impute_and_encode(self): <NEW_LINE> <INDENT> cat_pipe = Pipeline( [ ("imputer", SimpleImputer(strategy="constant", fill_value="missing")), ("onehot", OneHotEncoder(sparse=False, handle_unknown="ignore")), ] ) <NEW_LINE> transfomer = ColumnTransformer( [ ("cat", cat_pipe, self.cat_features), ( "num", SimpleImputer(strategy="mean"), self.num_features, ), ], sparse_threshold=0, ) <NEW_LINE> X_train_trans = transfomer.fit_transform(self.X_train) <NEW_LINE> X_test_trans = transfomer.transform(self.X_test) <NEW_LINE> if len(self.cat_features) > 0: <NEW_LINE> <INDENT> cat_features_transformed = ( transfomer.named_transformers_["cat"] .named_steps["onehot"] .get_feature_names(input_features=self.cat_features) ) <NEW_LINE> self.feature_names = np.r_[cat_features_transformed, self.num_features] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.feature_names = np.array(self.num_features) <NEW_LINE> <DEDENT> self.X_train = pd.DataFrame(X_train_trans, columns=self.feature_names) <NEW_LINE> self.X_test = pd.DataFrame(X_test_trans, columns=self.feature_names) <NEW_LINE> <DEDENT> @property <NEW_LINE> def sample(self): <NEW_LINE> <INDENT> return self.test.head(100)
A container for convenient access to raw and preprocessed data.
6259901ed164cc6175821dca
class DCAImpl(LDAImpl): <NEW_LINE> <INDENT> def __init__(self,scaledData,labels,rho=0,rho_prime=0): <NEW_LINE> <INDENT> LDAImpl.__init__(self,scaledData,labels); <NEW_LINE> self.rho = rho; <NEW_LINE> self.rho_prime = rho_prime; <NEW_LINE> <DEDENT> def setRhoAndRho_prime(self,rho,rho_prime): <NEW_LINE> <INDENT> self.rho = rho; <NEW_LINE> self.rho_prime = rho_prime; <NEW_LINE> <DEDENT> def getPCs(self,n_components): <NEW_LINE> <INDENT> print("DCA Implementation."); <NEW_LINE> S_prime = self.Sw+self.Sb+(self.rho+self.rho_prime)*np.ones(self.Sw.shape); <NEW_LINE> discriminantMatrix = np.dot(self.SwInv,S_prime); <NEW_LINE> n_components = min(n_components,self.numOfClass-1); <NEW_LINE> w,v = scipySvdSolver(discriminantMatrix,n_components); <NEW_LINE> eigenEnergySum = np.sum(w); <NEW_LINE> print("The first eigenvector of DCA takes %f variance." % (w[0]/eigenEnergySum)); <NEW_LINE> self.projMatrix = v;
Self-implemented Discriminant Analysis, which is inherited from LDA. Comparint to LDA, DCA has two ridge parameters, rho and rho_prime, the scatter matrix is different from LDA.
6259901e91af0d3eaad3ac6f
class PostTagAdmin(admin.ModelAdmin): <NEW_LINE> <INDENT> list_display = ('post_title', 'tag_name')
Post tag admin
6259901e5166f23b2e24421e
class ShelfSimIndex(MapSimIndex): <NEW_LINE> <INDENT> def __init__(self, filename, flag): <NEW_LINE> <INDENT> name_to_docid_map = StrKeyMap(DBShelf(filename + '_n2d', flag)) <NEW_LINE> docid_to_name_map = StrKeyMap(DBShelf(filename + '_d2n', flag)) <NEW_LINE> docid_to_feature_map = StrKeyMap(DBShelf(filename + '_feat', flag)) <NEW_LINE> term_index = StrKeyMap(DBShelf(filename + '_term', flag)) <NEW_LINE> doc_vectors = StrKeyMap(DBShelf(filename + '_doc_vec', flag)) <NEW_LINE> df_map = StrKeyMap(DBShelf(filename + '_df', flag)) <NEW_LINE> doc_len_map = StrKeyMap(DBShelf(filename + '_dl', flag)) <NEW_LINE> self._maps = dict(name_to_docid_map=name_to_docid_map, docid_to_name_map=docid_to_name_map, docid_to_feature_map=docid_to_feature_map, term_index=term_index, doc_vectors=doc_vectors, df_map=df_map, doc_len_map=doc_len_map) <NEW_LINE> super(ShelfSimIndex, self).__init__(**self._maps) <NEW_LINE> self._N = len(docid_to_name_map) <NEW_LINE> <DEDENT> def close(self): <NEW_LINE> <INDENT> for (mapname, map) in self._maps.items(): <NEW_LINE> <INDENT> map.close()
Inherits from :class:`pysimsearch.sim_index.MapSimIndex`. Shelf-based implementation of :class:`SimIndex`. Indexes are backed with persistent :class:`shelve.DbfilenameShelf` objects.
6259901e462c4b4f79dbc855
class ProductLog(LogBaseModel): <NEW_LINE> <INDENT> class Meta: <NEW_LINE> <INDENT> db_table = "product_log" <NEW_LINE> verbose_name = "货品日志" <NEW_LINE> verbose_name_plural = verbose_name <NEW_LINE> <DEDENT> @property <NEW_LINE> def operate_module(self): <NEW_LINE> <INDENT> return OperateLogModule.PRODUCT <NEW_LINE> <DEDENT> @property <NEW_LINE> def operate_type_text(self): <NEW_LINE> <INDENT> return PRODUCT_LOG_TYPE.get(self.operate_type)
货品日志模型类
6259901e507cdc57c63a5bef
class LruDict(collections.MutableMapping): <NEW_LINE> <INDENT> def __init__(self, data=None, **kwargs): <NEW_LINE> <INDENT> self._store = collections.OrderedDict() <NEW_LINE> if data is None: <NEW_LINE> <INDENT> data = {} <NEW_LINE> <DEDENT> self.update(data, **kwargs) <NEW_LINE> <DEDENT> def __getitem__(self, key): <NEW_LINE> <INDENT> self._hit(key) <NEW_LINE> return self._store[key] <NEW_LINE> <DEDENT> def __setitem__(self, key, value): <NEW_LINE> <INDENT> self._store[key] = value <NEW_LINE> self._hit(key) <NEW_LINE> <DEDENT> def _hit(self, key): <NEW_LINE> <INDENT> value = self._store[key] <NEW_LINE> del self._store[key] <NEW_LINE> self._store[key] = value <NEW_LINE> <DEDENT> def __delitem__(self, key): <NEW_LINE> <INDENT> del self._store[key] <NEW_LINE> <DEDENT> def least_to_most_iter(self): <NEW_LINE> <INDENT> return self.__iter__() <NEW_LINE> <DEDENT> def __iter__(self): <NEW_LINE> <INDENT> for k in self._store: <NEW_LINE> <INDENT> yield k <NEW_LINE> <DEDENT> <DEDENT> def most_to_least_iter(self): <NEW_LINE> <INDENT> return self.__reversed__() <NEW_LINE> <DEDENT> def __reversed__(self): <NEW_LINE> <INDENT> return reversed(self._store) <NEW_LINE> <DEDENT> def __len__(self): <NEW_LINE> <INDENT> return len(self._store) <NEW_LINE> <DEDENT> def has_key(self, key): <NEW_LINE> <INDENT> return self._store.has_key(key) <NEW_LINE> <DEDENT> def items(self): <NEW_LINE> <INDENT> for k, v in self._store.items(): <NEW_LINE> <INDENT> yield k, v <NEW_LINE> <DEDENT> <DEDENT> def least_to_most_items(self): <NEW_LINE> <INDENT> return self._store.items() <NEW_LINE> <DEDENT> def victim_key(self): <NEW_LINE> <INDENT> return self.least_recent() <NEW_LINE> <DEDENT> def most_recent(self): <NEW_LINE> <INDENT> it = self.most_to_least_iter() <NEW_LINE> return it.next() <NEW_LINE> <DEDENT> def least_recent(self): <NEW_LINE> <INDENT> it = self.least_to_most_iter() <NEW_LINE> return it.next() <NEW_LINE> <DEDENT> def peek(self, key): <NEW_LINE> <INDENT> return self._store[key]
All [] operations will change order of the key WARNING: If used with simpy, OrderedDict.items() and related functions are very slow (5 secs for a few thousands of items).
6259901e8c3a8732951f73a6
class Log(object): <NEW_LINE> <INDENT> def __init__(self, stats=default_stats()): <NEW_LINE> <INDENT> self.stats = stats <NEW_LINE> self.logbook = deap.tools.Logbook() <NEW_LINE> self.logbook.header = ['gen', 'nevals'] + (self.stats.fields if self.stats else []) <NEW_LINE> <DEDENT> def record(self, pop, gen, nevals, verbose=False): <NEW_LINE> <INDENT> record = self.stats.compile(pop) if self.stats else {} <NEW_LINE> self.logbook.record(gen=gen, nevals=nevals, **record) <NEW_LINE> if verbose: <NEW_LINE> <INDENT> print(self.logbook.stream)
Attributes ---------- stats: deap.tools.Statistics The statistics to be logged. logbook: deap.tools.Logbook
6259901e6fece00bbaccc807
class MultiplexDepthCacheManager(object): <NEW_LINE> <INDENT> _default_refresh = 60 * 30 <NEW_LINE> def __init__( self, client: AsyncClient, loop: asyncio.AbstractEventLoop, symbols: List[str], coro: Optional[Callable] = None, coro_throttle_count: int = 0, refresh_interval: int = _default_refresh, ) -> None: <NEW_LINE> <INDENT> self._client = client <NEW_LINE> self._loop = loop <NEW_LINE> self._symbols = symbols <NEW_LINE> self._coro = coro <NEW_LINE> self._coro_throttle_count = coro_throttle_count <NEW_LINE> self._depth_cache = { symbol: DepthCache(client, symbol) for symbol in self._symbols } <NEW_LINE> self._depth_message_buffer = [] <NEW_LINE> self._bm = None <NEW_LINE> self._refresh_interval = refresh_interval <NEW_LINE> self._refresh_time = None <NEW_LINE> <DEDENT> async def connect(self) -> None: <NEW_LINE> <INDENT> await self._start_socket() <NEW_LINE> await self._init_cache() <NEW_LINE> <DEDENT> async def _init_cache(self) -> None: <NEW_LINE> <INDENT> self._depth_message_buffer = [] <NEW_LINE> for symbol in self._symbols: <NEW_LINE> <INDENT> await self._depth_cache[symbol].init_from_rest() <NEW_LINE> <DEDENT> if self._refresh_interval: <NEW_LINE> <INDENT> self._refresh_time = int(time.time()) + self._refresh_interval <NEW_LINE> <DEDENT> for msg in self._depth_message_buffer: <NEW_LINE> <INDENT> await self._process_depth_message(msg) <NEW_LINE> <DEDENT> del self._depth_message_buffer <NEW_LINE> <DEDENT> async def _start_socket(self) -> None: <NEW_LINE> <INDENT> self._bm = BinanceSocketManager(self._client, self._loop) <NEW_LINE> streams = [f'{s.lower()}@depth' for s in self._symbols] <NEW_LINE> await self._bm.start_multiplex_socket(streams, self._handle_depth_event) <NEW_LINE> while not len(self._depth_message_buffer): <NEW_LINE> <INDENT> await asyncio.sleep(1) <NEW_LINE> <DEDENT> <DEDENT> async def _handle_depth_event(self, msg: Dict[str, Union[str, Any]]) -> None: <NEW_LINE> <INDENT> if 'e' in msg['data'] and msg['data']['e'] == 'error': <NEW_LINE> <INDENT> await self.close() <NEW_LINE> <DEDENT> if self._refresh_time is None: <NEW_LINE> <INDENT> self._depth_message_buffer.append(msg['data']) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> await self._process_depth_message(msg['data']) <NEW_LINE> <DEDENT> <DEDENT> async def _process_depth_message(self, msg: Dict[str, Any]) -> None: <NEW_LINE> <INDENT> if not (await self._depth_cache[msg['s']].update(msg)): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if ( self._coro and self._depth_cache[msg['s']].throttle_counter == self._coro_throttle_count ): <NEW_LINE> <INDENT> await self._coro(self._depth_cache[msg['s']]) <NEW_LINE> self._depth_cache[msg['s']].throttle_counter = 0 <NEW_LINE> <DEDENT> self._depth_cache[msg['s']].throttle_counter += 1 <NEW_LINE> if self._refresh_interval and int(time.time()) > self._refresh_time: <NEW_LINE> <INDENT> await self._init_cache() <NEW_LINE> <DEDENT> <DEDENT> def get_depth_cache(self) -> Dict[str, DepthCache]: <NEW_LINE> <INDENT> return self._depth_cache <NEW_LINE> <DEDENT> async def close(self) -> None: <NEW_LINE> <INDENT> await self._bm.close() <NEW_LINE> self._depth_cache = None
Connect to multiple depth streams with one ws connection
6259901e8c3a8732951f73a8
class _KexServerStub(_KexConnectionStub): <NEW_LINE> <INDENT> def __init__(self, alg, gss_host, peer): <NEW_LINE> <INDENT> gss = GSSServer(gss_host) if gss_host else None <NEW_LINE> super().__init__(alg, gss, peer, True) <NEW_LINE> if gss_host and 'no_host_key' in gss_host: <NEW_LINE> <INDENT> self._server_host_key = None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> priv_key = asyncssh.generate_private_key('ssh-rsa') <NEW_LINE> self._server_host_key = asyncssh.load_keypairs(priv_key)[0] <NEW_LINE> <DEDENT> <DEDENT> def connection_lost(self, exc): <NEW_LINE> <INDENT> if self._peer: <NEW_LINE> <INDENT> self._peer.connection_lost(exc) <NEW_LINE> <DEDENT> self.close() <NEW_LINE> <DEDENT> def get_server_host_key(self): <NEW_LINE> <INDENT> return self._server_host_key
Stub class for server connection
6259901e5166f23b2e244224
class UpdateInstallationInputSet(InputSet): <NEW_LINE> <INDENT> def set_Installation(self, value): <NEW_LINE> <INDENT> super(UpdateInstallationInputSet, self)._set_input('Installation', value) <NEW_LINE> <DEDENT> def set_ApplicationID(self, value): <NEW_LINE> <INDENT> super(UpdateInstallationInputSet, self)._set_input('ApplicationID', value) <NEW_LINE> <DEDENT> def set_ObjectID(self, value): <NEW_LINE> <INDENT> super(UpdateInstallationInputSet, self)._set_input('ObjectID', value) <NEW_LINE> <DEDENT> def set_RESTAPIKey(self, value): <NEW_LINE> <INDENT> super(UpdateInstallationInputSet, self)._set_input('RESTAPIKey', value)
An InputSet with methods appropriate for specifying the inputs to the UpdateInstallation Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
6259901ebf627c535bcb2304
class V1VolumeMount(object): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.swagger_types = { 'mount_path': 'str', 'name': 'str', 'read_only': 'bool', 'sub_path': 'str' } <NEW_LINE> self.attribute_map = { 'mount_path': 'mountPath', 'name': 'name', 'read_only': 'readOnly', 'sub_path': 'subPath' } <NEW_LINE> self._mount_path = None <NEW_LINE> self._name = None <NEW_LINE> self._read_only = None <NEW_LINE> self._sub_path = None <NEW_LINE> <DEDENT> @property <NEW_LINE> def mount_path(self): <NEW_LINE> <INDENT> return self._mount_path <NEW_LINE> <DEDENT> @mount_path.setter <NEW_LINE> def mount_path(self, mount_path): <NEW_LINE> <INDENT> self._mount_path = mount_path <NEW_LINE> <DEDENT> @property <NEW_LINE> def name(self): <NEW_LINE> <INDENT> return self._name <NEW_LINE> <DEDENT> @name.setter <NEW_LINE> def name(self, name): <NEW_LINE> <INDENT> self._name = name <NEW_LINE> <DEDENT> @property <NEW_LINE> def read_only(self): <NEW_LINE> <INDENT> return self._read_only <NEW_LINE> <DEDENT> @read_only.setter <NEW_LINE> def read_only(self, read_only): <NEW_LINE> <INDENT> self._read_only = read_only <NEW_LINE> <DEDENT> @property <NEW_LINE> def sub_path(self): <NEW_LINE> <INDENT> return self._sub_path <NEW_LINE> <DEDENT> @sub_path.setter <NEW_LINE> def sub_path(self, sub_path): <NEW_LINE> <INDENT> self._sub_path = sub_path <NEW_LINE> <DEDENT> def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <DEDENT> elif hasattr(value, "to_dict"): <NEW_LINE> <INDENT> result[attr] = value.to_dict() <NEW_LINE> <DEDENT> elif isinstance(value, dict): <NEW_LINE> <INDENT> result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result[attr] = value <NEW_LINE> <DEDENT> <DEDENT> return result <NEW_LINE> <DEDENT> def to_str(self): <NEW_LINE> <INDENT> return pformat(self.to_dict()) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return self.to_str() <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return self.__dict__ == other.__dict__ <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return not self == other
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
6259901e1d351010ab8f496b
class TestX264(unittest.TestCase): <NEW_LINE> <INDENT> def test_instantiation(self): <NEW_LINE> <INDENT> x264 = X264() <NEW_LINE> self.assertEqual(x264.codec_name, 'libx264') <NEW_LINE> self.assertEqual(x264.crf, 20.0) <NEW_LINE> self.assertIsNone(x264.qp) <NEW_LINE> self.assertIsNone(x264.bitrate) <NEW_LINE> self.assertEqual(x264.profile, 0) <NEW_LINE> self.assertEqual(x264.preset, 0) <NEW_LINE> self.assertEqual(x264.level, 0) <NEW_LINE> self.assertEqual(x264.tune, 0) <NEW_LINE> self.assertFalse(x264.advanced_enabled) <NEW_LINE> self.assertEqual(x264.keyint, 250) <NEW_LINE> self.assertEqual(x264.min_keyint, 25) <NEW_LINE> self.assertIsNone(x264.scenecut) <NEW_LINE> self.assertEqual(x264.bframes, 3) <NEW_LINE> self.assertEqual(x264.b_adapt, 0) <NEW_LINE> self.assertEqual(x264.b_pyramid, 0) <NEW_LINE> self.assertFalse(x264.no_cabac) <NEW_LINE> self.assertEqual(x264.ref, 3) <NEW_LINE> self.assertFalse(x264.no_deblock) <NEW_LINE> self.assertTupleEqual(x264.deblock, (0, 0)) <NEW_LINE> self.assertEqual(x264.vbv_maxrate, 2500) <NEW_LINE> self.assertEqual(x264.vbv_bufsize, 2500) <NEW_LINE> self.assertEqual(x264.aq_mode, 0) <NEW_LINE> self.assertEqual(x264.aq_strength, 1.0) <NEW_LINE> self.assertIsNone(x264.encode_pass) <NEW_LINE> self.assertIsNone(x264.stats) <NEW_LINE> self.assertIsNone(x264.partitions) <NEW_LINE> self.assertEqual(x264.direct, 0) <NEW_LINE> self.assertFalse(x264.weightb) <NEW_LINE> self.assertEqual(x264.me, 0) <NEW_LINE> self.assertEqual(x264.me_range, 16) <NEW_LINE> self.assertEqual(x264.subme, 0) <NEW_LINE> self.assertTupleEqual(x264.psy_rd, (1.0, 0.0)) <NEW_LINE> self.assertFalse(x264.mixed_refs) <NEW_LINE> self.assertFalse(x264.dct8x8) <NEW_LINE> self.assertEqual(x264.trellis, 0) <NEW_LINE> self.assertFalse(x264.no_fast_pskip) <NEW_LINE> self.assertFalse(x264.no_dct_decimate) <NEW_LINE> self.assertFalse(x264.constant_bitrate) <NEW_LINE> self.assertEqual(x264.weightp, 0) <NEW_LINE> self.assertIsNone(x264.get_ffmpeg_advanced_args()['-x264-params'])
Tests all X264 initial options.
6259901ed18da76e235b7875
class Intersection: <NEW_LINE> <INDENT> def __init__(self, max_cars): <NEW_LINE> <INDENT> self.semaphore_times = [] <NEW_LINE> self.num_cars = [] <NEW_LINE> self.flags = [] <NEW_LINE> for i in range(4): <NEW_LINE> <INDENT> self.semaphore_times.append(randint(1,8)*15) <NEW_LINE> self.max_cars = randint(0, max_cars) <NEW_LINE> self.num_cars.append(randint(0,self.max_cars)) <NEW_LINE> self.flags.append(0)
Common base class for all intersection
6259901e796e427e5384f5d0
class Person(object): <NEW_LINE> <INDENT> def __init__(self, name=None, rel=None, contact=None, newperson=True): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.rel = rel <NEW_LINE> self.contact = contact <NEW_LINE> self.newperson = newperson <NEW_LINE> <DEDENT> def add_name(self, name): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> <DEDENT> def add_rel(self, rel): <NEW_LINE> <INDENT> self.rel = rel <NEW_LINE> <DEDENT> def add_contact(self, contact): <NEW_LINE> <INDENT> self.contact = contact <NEW_LINE> <DEDENT> def del_person(self): <NEW_LINE> <INDENT> self.__init__()
Class implemented to create a person and add it to the database. A person is someone relevant to the user (relative, friend, ...). At the moment the person has 3 fields into it: name, relationship status and contact number.
6259901e507cdc57c63a5bf5
class PercentileMetricValue(MetricValue): <NEW_LINE> <INDENT> _validation = { '_count': {'readonly': True}, 'average': {'readonly': True}, 'maximum': {'readonly': True}, 'minimum': {'readonly': True}, 'timestamp': {'readonly': True}, 'total': {'readonly': True}, 'p10': {'readonly': True}, 'p25': {'readonly': True}, 'p50': {'readonly': True}, 'p75': {'readonly': True}, 'p90': {'readonly': True}, 'p95': {'readonly': True}, 'p99': {'readonly': True}, } <NEW_LINE> _attribute_map = { '_count': {'key': '_count', 'type': 'float'}, 'average': {'key': 'average', 'type': 'float'}, 'maximum': {'key': 'maximum', 'type': 'float'}, 'minimum': {'key': 'minimum', 'type': 'float'}, 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, 'total': {'key': 'total', 'type': 'float'}, 'p10': {'key': 'P10', 'type': 'float'}, 'p25': {'key': 'P25', 'type': 'float'}, 'p50': {'key': 'P50', 'type': 'float'}, 'p75': {'key': 'P75', 'type': 'float'}, 'p90': {'key': 'P90', 'type': 'float'}, 'p95': {'key': 'P95', 'type': 'float'}, 'p99': {'key': 'P99', 'type': 'float'}, } <NEW_LINE> def __init__(self, **kwargs) -> None: <NEW_LINE> <INDENT> super(PercentileMetricValue, self).__init__(**kwargs) <NEW_LINE> self.p10 = None <NEW_LINE> self.p25 = None <NEW_LINE> self.p50 = None <NEW_LINE> self.p75 = None <NEW_LINE> self.p90 = None <NEW_LINE> self.p95 = None <NEW_LINE> self.p99 = None
Represents percentile metrics values. Variables are only populated by the server, and will be ignored when sending a request. :ivar _count: The number of values for the metric. :vartype _count: float :ivar average: The average value of the metric. :vartype average: float :ivar maximum: The max value of the metric. :vartype maximum: float :ivar minimum: The min value of the metric. :vartype minimum: float :ivar timestamp: The metric timestamp (ISO-8601 format). :vartype timestamp: datetime :ivar total: The total value of the metric. :vartype total: float :ivar p10: The 10th percentile value for the metric. :vartype p10: float :ivar p25: The 25th percentile value for the metric. :vartype p25: float :ivar p50: The 50th percentile value for the metric. :vartype p50: float :ivar p75: The 75th percentile value for the metric. :vartype p75: float :ivar p90: The 90th percentile value for the metric. :vartype p90: float :ivar p95: The 95th percentile value for the metric. :vartype p95: float :ivar p99: The 99th percentile value for the metric. :vartype p99: float
6259901e21a7993f00c66dce
class Shenliao_Test(Mytest): <NEW_LINE> <INDENT> def test1(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.switch_to_toupiao() <NEW_LINE> sleep(3) <NEW_LINE> self.assertEqual(self.driver.current_url,'http: // bbs.0513.org / forum.php?mod = post & action = newthread & special = 1 & fid = 407 & cedit = yes & extra =') <NEW_LINE> <DEDENT> def test2(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft(flag=True) <NEW_LINE> po.switch_to_tiezi() <NEW_LINE> sleep(3) <NEW_LINE> self.assertEqual(self.driver.current_url,'http: // bbs.0513.org / forum.php?mod = post & action = newthread & fid = 407 & cedit = yes & extra =') <NEW_LINE> <DEDENT> def test3(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.select_fenlei(index='2') <NEW_LINE> fl_class_loc = po.get_class_loc('2') <NEW_LINE> cls = po.find_element(*fl_class_loc).get_attribute('class') <NEW_LINE> self.assertEqual(cls,'current select') <NEW_LINE> <DEDENT> def test4(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.input_subject(subjects='测试输入lalala') <NEW_LINE> text = po.find_element(*po.bbs_neirong_loc).text <NEW_LINE> self.assertEqual(text,'测试输入lalala') <NEW_LINE> <DEDENT> def test5(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.input_subject(subjects='测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala测试输入lalala') <NEW_LINE> po.submit() <NEW_LINE> text = po.find_element(*po.bbs_neirong_loc).text <NEW_LINE> self.assertEqual(text,'输入字符串超出限制') <NEW_LINE> <DEDENT> def test6(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.input_subject(subjects='') <NEW_LINE> po.submit() <NEW_LINE> text = po.find_element(*po.bbs_neirong_loc).text <NEW_LINE> self.assertEqual(text, '请输入主题内容') <NEW_LINE> <DEDENT> def test7(self): <NEW_LINE> <INDENT> po = Shenliao(self.driver) <NEW_LINE> po.open_ft() <NEW_LINE> po.upload_img() <NEW_LINE> text = po.find_element(*po.bbs_neirong_loc).text <NEW_LINE> self.assertEqual(text,'[image]Chrysanthemum.img[/image]')
发帖测试
6259901e5166f23b2e244226
class Estimator: <NEW_LINE> <INDENT> def __init__(self, z, conf_str): <NEW_LINE> <INDENT> self.k = 0 <NEW_LINE> self.sum = 0.0 <NEW_LINE> self.v = 0.0 <NEW_LINE> self.z = float(z) <NEW_LINE> self.conf_str = conf_str <NEW_LINE> <DEDENT> def reset(self): <NEW_LINE> <INDENT> self.k = 0 <NEW_LINE> self.sum = 0 <NEW_LINE> self.v = 0 <NEW_LINE> <DEDENT> def process_next_val(self, value): <NEW_LINE> <INDENT> self.k += 1 <NEW_LINE> if self.k > 1: <NEW_LINE> <INDENT> diff = self.sum - (self.k - 1) * value <NEW_LINE> self.v += diff/self.k * diff/(self.k-1) <NEW_LINE> <DEDENT> self.sum += value <NEW_LINE> <DEDENT> def get_variance(self): <NEW_LINE> <INDENT> if self.k > 1: <NEW_LINE> <INDENT> var = self.v/(self.k-1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> var = 0 <NEW_LINE> <DEDENT> return var <NEW_LINE> <DEDENT> def get_mean(self): <NEW_LINE> <INDENT> return self.sum/self.k if self.k > 1 else 0 <NEW_LINE> <DEDENT> def get_conf_interval(self): <NEW_LINE> <INDENT> hw = self.z * sqrt(self.get_variance()/self.k) <NEW_LINE> point_est = self.get_mean() <NEW_LINE> c_low = point_est - hw <NEW_LINE> c_high = point_est + hw <NEW_LINE> return self.conf_str + " Confidence Interval [ %.4f" %c_low + ", %.4f" %c_high + "]" <NEW_LINE> <DEDENT> def get_num_trials(self, epsilon, relative=True): <NEW_LINE> <INDENT> var = self.get_variance() <NEW_LINE> width = self.get_mean() * epsilon if relative else epsilon <NEW_LINE> return int((var * self.z * self.z)/(width * width))
Computes point estimates and confidence intervals
6259901e462c4b4f79dbc85d
class PageMeasurementUnitTestBase(unittest.TestCase): <NEW_LINE> <INDENT> def CreatePageSetFromFileInUnittestDataDir(self, test_filename): <NEW_LINE> <INDENT> return self.CreatePageSet('file:///' + os.path.join( '..', '..', 'unittest_data', test_filename)) <NEW_LINE> <DEDENT> def CreatePageSet(self, test_filename): <NEW_LINE> <INDENT> base_dir = os.path.dirname(__file__) <NEW_LINE> ps = page_set.PageSet(file_path=os.path.join(base_dir, 'foo.json')) <NEW_LINE> page = page_module.Page(test_filename, ps, base_dir=base_dir) <NEW_LINE> setattr(page, 'smoothness', {'action': 'scroll'}) <NEW_LINE> ps.pages.append(page) <NEW_LINE> return ps <NEW_LINE> <DEDENT> def RunMeasurement(self, measurement, ps, options=None): <NEW_LINE> <INDENT> if options is None: <NEW_LINE> <INDENT> options = options_for_unittests.GetCopy() <NEW_LINE> <DEDENT> assert options <NEW_LINE> temp_parser = options.CreateParser() <NEW_LINE> measurement.AddCommandLineOptions(temp_parser) <NEW_LINE> defaults = temp_parser.get_default_values() <NEW_LINE> for k, v in defaults.__dict__.items(): <NEW_LINE> <INDENT> if hasattr(options, k): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> setattr(options, k, v) <NEW_LINE> <DEDENT> measurement.CustomizeBrowserOptions(options) <NEW_LINE> possible_browser = browser_finder.FindBrowser(options) <NEW_LINE> results = page_measurement_results.PageMeasurementResults() <NEW_LINE> with page_runner.PageRunner(ps) as runner: <NEW_LINE> <INDENT> runner.Run(options, possible_browser, measurement, results) <NEW_LINE> <DEDENT> return results
unittest.TestCase-derived class to help in the construction of unit tests for a measurement.
6259901e1d351010ab8f496c
class SubprocVecMAEnv(VecEnv): <NEW_LINE> <INDENT> def __init__(self, env_fns, spaces=None): <NEW_LINE> <INDENT> self.waiting = False <NEW_LINE> self.closed = False <NEW_LINE> nenvs = len(env_fns) <NEW_LINE> self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)]) <NEW_LINE> self.ps = [Process(target=worker, args=(work_remote, remote, CloudpickleWrapper(env_fn))) for (work_remote, remote, env_fn) in zip(self.work_remotes, self.remotes, env_fns)] <NEW_LINE> for p in self.ps: <NEW_LINE> <INDENT> p.daemon = True <NEW_LINE> p.start() <NEW_LINE> <DEDENT> for remote in self.work_remotes: <NEW_LINE> <INDENT> remote.close() <NEW_LINE> <DEDENT> self.remotes[0].send(('get_spaces', None)) <NEW_LINE> observation_space, action_space = self.remotes[0].recv() <NEW_LINE> self.viewer = None <NEW_LINE> self.specs = [f().spec for f in env_fns] <NEW_LINE> VecEnv.__init__(self, len(env_fns), observation_space, action_space) <NEW_LINE> <DEDENT> def step_async(self, actions): <NEW_LINE> <INDENT> self._assert_not_closed() <NEW_LINE> for remote, action in zip(self.remotes, actions): <NEW_LINE> <INDENT> remote.send(('step', action)) <NEW_LINE> <DEDENT> self.waiting = True <NEW_LINE> <DEDENT> def step_wait(self): <NEW_LINE> <INDENT> self._assert_not_closed() <NEW_LINE> results = [remote.recv() for remote in self.remotes] <NEW_LINE> self.waiting = False <NEW_LINE> obs, rews, dones, infos = zip(*results) <NEW_LINE> return _flatten_obs(obs), np.stack(rews), np.stack(dones), infos <NEW_LINE> <DEDENT> def reset(self): <NEW_LINE> <INDENT> self._assert_not_closed() <NEW_LINE> for remote in self.remotes: <NEW_LINE> <INDENT> remote.send(('reset', None)) <NEW_LINE> <DEDENT> return _flatten_obs([remote.recv() for remote in self.remotes]) <NEW_LINE> <DEDENT> def close_extras(self): <NEW_LINE> <INDENT> self.closed = True <NEW_LINE> if self.waiting: <NEW_LINE> <INDENT> for remote in self.remotes: <NEW_LINE> <INDENT> remote.recv() <NEW_LINE> <DEDENT> <DEDENT> for remote in self.remotes: <NEW_LINE> <INDENT> remote.send(('close', None)) <NEW_LINE> <DEDENT> for p in self.ps: <NEW_LINE> <INDENT> p.join() <NEW_LINE> <DEDENT> <DEDENT> def get_images(self): <NEW_LINE> <INDENT> self._assert_not_closed() <NEW_LINE> for pipe in self.remotes: <NEW_LINE> <INDENT> pipe.send(('render', None)) <NEW_LINE> <DEDENT> imgs = [pipe.recv() for pipe in self.remotes] <NEW_LINE> return imgs <NEW_LINE> <DEDENT> def _assert_not_closed(self): <NEW_LINE> <INDENT> assert not self.closed, "Trying to operate on a SubprocVecMAEnv after calling close()"
VecEnv that runs multiple environments in parallel in subproceses and communicates with them via pipes. Recommended to use when num_envs > 1 and step() can be a bottleneck.
6259901eac7a0e7691f7333c
class BufCombN(PureUGen): <NEW_LINE> <INDENT> __documentation_section__ = 'Delay UGens' <NEW_LINE> __slots__ = () <NEW_LINE> _ordered_input_names = ( 'buffer_id', 'source', 'maximum_delay_time', 'delay_time', 'decay_time', ) <NEW_LINE> def __init__( self, buffer_id=None, calculation_rate=None, decay_time=1.0, delay_time=0.2, maximum_delay_time=0.2, source=None, ): <NEW_LINE> <INDENT> PureUGen.__init__( self, buffer_id=int(buffer_id), calculation_rate=calculation_rate, decay_time=decay_time, delay_time=delay_time, maximum_delay_time=maximum_delay_time, source=source, ) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def ar( cls, buffer_id=None, decay_time=1.0, delay_time=0.2, maximum_delay_time=0.2, source=None, ): <NEW_LINE> <INDENT> from supriya.tools import synthdeftools <NEW_LINE> calculation_rate = synthdeftools.CalculationRate.AUDIO <NEW_LINE> source = cls._as_audio_rate_input(source) <NEW_LINE> ugen = cls._new_expanded( buffer_id=buffer_id, calculation_rate=calculation_rate, decay_time=decay_time, delay_time=delay_time, maximum_delay_time=maximum_delay_time, source=source, ) <NEW_LINE> return ugen <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def kr( cls, buffer_id=None, decay_time=1.0, delay_time=0.2, maximum_delay_time=0.2, source=None, ): <NEW_LINE> <INDENT> from supriya.tools import synthdeftools <NEW_LINE> calculation_rate = synthdeftools.CalculationRate.AUDIO <NEW_LINE> ugen = cls._new_expanded( buffer_id=buffer_id, calculation_rate=calculation_rate, decay_time=decay_time, delay_time=delay_time, maximum_delay_time=maximum_delay_time, source=source, ) <NEW_LINE> return ugen <NEW_LINE> <DEDENT> @property <NEW_LINE> def buffer_id(self): <NEW_LINE> <INDENT> index = self._ordered_input_names.index('buffer_id') <NEW_LINE> return self._inputs[index] <NEW_LINE> <DEDENT> @property <NEW_LINE> def decay_time(self): <NEW_LINE> <INDENT> index = self._ordered_input_names.index('decay_time') <NEW_LINE> return self._inputs[index] <NEW_LINE> <DEDENT> @property <NEW_LINE> def delay_time(self): <NEW_LINE> <INDENT> index = self._ordered_input_names.index('delay_time') <NEW_LINE> return self._inputs[index] <NEW_LINE> <DEDENT> @property <NEW_LINE> def maximum_delay_time(self): <NEW_LINE> <INDENT> index = self._ordered_input_names.index('maximum_delay_time') <NEW_LINE> return self._inputs[index] <NEW_LINE> <DEDENT> @property <NEW_LINE> def source(self): <NEW_LINE> <INDENT> index = self._ordered_input_names.index('source') <NEW_LINE> return self._inputs[index]
A buffer-based non-interpolating comb delay line unit generator. :: >>> buffer_id = 0 >>> source = ugentools.In.ar(bus=0) >>> ugentools.BufCombN.ar( ... buffer_id=buffer_id, ... source=source, ... ) BufCombN.ar()
6259901e6fece00bbaccc80b