code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def secondary_structure_pairs(self): <NEW_LINE> <INDENT> self.H1 = [i for i in itertools.combinations(self.alpha1, 2)] <NEW_LINE> self.H2 = [i for i in itertools.combinations(self.alpha2, 2)] <NEW_LINE> self.B = [i for i in itertools.combinations(self.beta, 2)] | defines the sequence pairs for R/L Alpha Helix and Beta Sheet | 625941c182261d6c526ab426 |
@pytest.fixture <NEW_LINE> def p_chris(): <NEW_LINE> <INDENT> chris = BasicGame.Player(20, "chris", "blue") <NEW_LINE> return chris | This is BOB. He is a player of the game.
Does THIS docstring get shown?
YES yes it does! | 625941c13cc13d1c6d3c7305 |
def get_cached_bottlenecks_and_converted_labels(sess, image_path_list, batch_size, bottleneck_dir, converted_label_dir, jpeg_data_placeholder, decoded_image_tensor, resized_image_placeholder, bottleneck_tensor, architecture): <NEW_LINE> <INDENT> bottlenecks = [] <NEW_LINE> loss_feed_vals = {} <NEW_LINE> NUM_IMAGES = le... | Retrieves bottleneck values for cached images.
If no distortions are being applied, this function can retrieve the cached
bottleneck values directly from disk for images. It picks a random set of
images from the specified category.
Args:
sess: Current TensorFlow Session.
image_lists: Dictionary of training images... | 625941c1a219f33f346288f6 |
def load_user_file(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> json_file = open(self.user_file) <NEW_LINE> <DEDENT> except FileNotFoundError: <NEW_LINE> <INDENT> print('User configuration file not found. Creating default.') <NEW_LINE> self.create_default_json() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> json... | does a quick test to see if we have a user file. if not, we create one.
this should use an if not a try though... | 625941c1d164cc6175782cd7 |
def __init__(self, master, controller): <NEW_LINE> <INDENT> ttk.Frame.__init__(self, master) <NEW_LINE> self.logger = logging.getLogger(__name__) <NEW_LINE> self.master = master <NEW_LINE> self.controller = controller <NEW_LINE> self.master_frame = ttk.Frame(self.master) <NEW_LINE> self.top_frame = ttk.Frame(self.maste... | Initialize Main page | 625941c1a79ad161976cc0cf |
def __ne__(self, other): <NEW_LINE> <INDENT> return bool() | bool KFileItem.__ne__(KFileItem other) | 625941c145492302aab5e24b |
def shapefile_to_geodataframe(infile): <NEW_LINE> <INDENT> gpd_data = gpd.GeoDataFrame.from_file(infile) <NEW_LINE> return gpd_data | Convert shapefile into geopandas dataframe | 625941c185dfad0860c3ade3 |
def dispatch(self, mode, queries): <NEW_LINE> <INDENT> if mode not in self.func_registry: <NEW_LINE> <INDENT> message = 'Error: Attempt to invoke unregistered mode |%s|' % (mode) <NEW_LINE> raise Exception(message) <NEW_LINE> <DEDENT> args = [] <NEW_LINE> kwargs = {} <NEW_LINE> unused_args = queries.copy() <NEW_LINE> i... | Dispatch function to execute function registered for the provided mode
mode: the string that the function was associated with
queries: a dictionary of the parameters to be passed to the called function | 625941c17c178a314d6ef3e6 |
def create_area(self): <NEW_LINE> <INDENT> data = AREADATA[self.__id] <NEW_LINE> i = 0 <NEW_LINE> tileinfo = {} <NEW_LINE> while data[i] != "MAP" and i <= len(data): <NEW_LINE> <INDENT> row = data[i].split("=") <NEW_LINE> tileinfo[row[0]] = row[1].split(",") <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> i += 1 <NEW_LINE> while... | The function creates the area from the data previously read from
input files.
:return: None | 625941c18a349b6b435e80fd |
def destroy_unit(self, unit): <NEW_LINE> <INDENT> if isinstance(unit, Unit): <NEW_LINE> <INDENT> unit = unit.name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> unit = str(unit) <NEW_LINE> <DEDENT> self._single_request('Units.Delete', unitName=unit) <NEW_LINE> return True | Delete a unit from the cluster
Args:
unit (str, Unit): The Unit, or name of the unit to delete
Returns:
True: The unit was deleted
Raises:
fleet.v1.errors.APIError: Fleet returned a response code >= 400 | 625941c1656771135c3eb7f6 |
@api_1.route('/auth/register/', methods=['POST']) <NEW_LINE> def new_user(): <NEW_LINE> <INDENT> username = request.json.get('username') <NEW_LINE> password = request.json.get('password') <NEW_LINE> if username is None or password is None: <NEW_LINE> <INDENT> return errors.bad_request(400) <NEW_LINE> <DEDENT> if User.q... | Register a new user | 625941c1e8904600ed9f1eb4 |
def masked_cross_entropy(logits, target, length, is_logit=True): <NEW_LINE> <INDENT> logits_flat = logits.view(-1, logits.size(-1)) <NEW_LINE> if is_logit: <NEW_LINE> <INDENT> log_probs_flat = functional.log_softmax(logits_flat, dim=1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> log_probs_flat = torch.log(logits_flat... | Args:
logits: A Variable containing a FloatTensor of size
(batch, max_len, num_classes) which contains the
unnormalized probability for each class.
target: A Variable containing a LongTensor of size
(batch, max_len) which contains the index of the true
class for each correspondin... | 625941c130c21e258bdfa426 |
def test_simple(self): <NEW_LINE> <INDENT> m=IMP.Model() <NEW_LINE> p1=IMP.Particle(m) <NEW_LINE> d1=IMP.core.XYZR.setup_particle(p1) <NEW_LINE> d1.set_coordinates((0,0,0)) <NEW_LINE> d1.set_radius(1.0) <NEW_LINE> p2=IMP.Particle(m) <NEW_LINE> d2=IMP.core.XYZR.setup_particle(p2) <NEW_LINE> d2.set_coordinates((10,0,0)) ... | simple test | 625941c167a9b606de4a7e45 |
def hint_desc(self, qfield): <NEW_LINE> <INDENT> return self.__hint(qfield, DESCENDING) | Applies a hint for the query that it should use a
(``qfield``, DESCENDING) index when performing the query.
:param qfield: the instance of :class:`mongoalchemy.QueryField` to use as the key. | 625941c19c8ee82313fbb6fe |
def getSum(self, a: int, b: int) -> int: <NEW_LINE> <INDENT> pass | put solution here | 625941c1507cdc57c6306c60 |
def options(self, context, module_options): <NEW_LINE> <INDENT> self.met_payload = 'reverse_https' <NEW_LINE> self.procid = None <NEW_LINE> if not 'LHOST' in module_options or not 'LPORT' in module_options: <NEW_LINE> <INDENT> context.log.error('LHOST and LPORT options are required!') <NEW_LINE> exit(1) <NEW_LINE> <DED... | LHOST IP hosting the handler
LPORT Handler port
PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https)
PROCID Process ID to inject into (default: current powershell process) | 625941c12c8b7c6e89b3574c |
@event.listens_for(Index.thumbnail, 'set') <NEW_LINE> @event.listens_for(CommonName.thumbnail, 'set') <NEW_LINE> @event.listens_for(Section.thumbnail, 'set') <NEW_LINE> @event.listens_for(Cultivar.thumbnail, 'set') <NEW_LINE> @event.listens_for(BulkSeries.thumbnail, 'set') <NEW_LINE> @event.listens_for(BulkItem.thumbna... | Add `thumbnail` to `images` when setting it. | 625941c126238365f5f0edf5 |
def event_m10_18_x90(z17=10181301, z18=10181300, z19=900000): <NEW_LINE> <INDENT> call = event_m10_18_x66(z17=z17, z18=z18, z19=z19) <NEW_LINE> if call.Get() == 1: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif call.Get() == 0: <NEW_LINE> <INDENT> assert event_m10_18_x67(z18=z18) <NEW_LINE> assert event_m10_18_x68(z... | [Preset] Iron fence opened with lever
z17: Instance ID of iron fence OBJ
z18: Lever OBJ instance ID
z19: Point ID for Navimesh change | 625941c15fc7496912cc3908 |
def build_mlp(f_input_layer, hidden_units_per_layer): <NEW_LINE> <INDENT> num_f_inputs = f_input_layer.get_shape().as_list()[1] <NEW_LINE> mlp_weights = { 'h1': tf.Variable(tf.random_uniform([num_f_inputs, hidden_units_per_layer], **_weight_init_range(num_f_inputs, hidden_units_per_layer))), 'b1': tf.Variable(tf.zeros(... | Builds a feed-forward NN (MLP) with 3 hidden layers. | 625941c1baa26c4b54cb10ac |
def parse_args() -> Union[argparse.Namespace, int]: <NEW_LINE> <INDENT> parser = init_parser() <NEW_LINE> args = parser.parse_args() <NEW_LINE> global VERBOSE <NEW_LINE> VERBOSE = args.verbose or 0 <NEW_LINE> if args.quiet: <NEW_LINE> <INDENT> VERBOSE = -1 <NEW_LINE> <DEDENT> tiles = args.tiles.lower().split('x') <NEW_... | Returns:
argparse.Namespace: The parsed cli arguments.
int: The exit code if the script should exit. | 625941c1004d5f362079a2bf |
def _maybe_extract_attached_key(self, attachments, address): <NEW_LINE> <INDENT> MIME_KEY = "application/pgp-keys" <NEW_LINE> def log_key_added(ignored): <NEW_LINE> <INDENT> logger.debug('Added key found in attachment for %s' % address) <NEW_LINE> return True <NEW_LINE> <DEDENT> def failed_put_key(failure): <NEW_LINE> ... | Import keys from the attachments
:param attachments: email attachment list
:type attachments: list(email.Message)
:param address: email address in the from header
:type address: str
:return: A Deferred that will be fired when all the keys are stored
with a boolean: True if there was a valid key attached, or
... | 625941c1d7e4931a7ee9dea7 |
def create_db_file(filename="CDPO.sqlite"): <NEW_LINE> <INDENT> conn = sqlite3.connect(filename) <NEW_LINE> c = conn.cursor() <NEW_LINE> c.execute("CREATE TABLE metadata (collection_name VARCHAR(40),brand_stats VARCHAR(100),track_stats VARCHAR(40)," "exp_date_stats VARCHAR(40),pan_stats VARCHAR(100),collection_type VAR... | Creates database file | 625941c124f1403a92600af2 |
def read_input(self, inputs): <NEW_LINE> <INDENT> delta = inputs.findFirst('delta') <NEW_LINE> if delta: <NEW_LINE> <INDENT> self._allowable = delta.value <NEW_LINE> <DEDENT> tol = inputs.findFirst('tolerance') <NEW_LINE> if tol: <NEW_LINE> <INDENT> self._tolerance = tol.value | Loads settings based on provided inputs
@ In, inputs, InputData.InputSpecs, input specifications
@ Out, None | 625941c1cb5e8a47e48b7a37 |
def train(q, graph, train_data, test_data, trainer_args, metric, loss, verbose, path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> model = graph.produce_model() <NEW_LINE> loss, metric_value = ModelTrainer(model=model, path=path, train_data=train_data, test_data=test_data, metric=metric, loss_function=loss, verbose=ve... | Train the neural architecture. | 625941c18a43f66fc4b53ff1 |
def width(dct): <NEW_LINE> <INDENT> values = [ value for value in dct.itervalues() if isinstance(value, dict) ] <NEW_LINE> return sum(width(value) for value in values) + len(dct) - len(values) | Width of a dictionary.
:param dct: dictionary
:type dct: dict
:rtype: int | 625941c1dc8b845886cb54be |
def isHomogeneous(self): <NEW_LINE> <INDENT> m,n = self.size() <NEW_LINE> if m != 4 or n != 4: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> test = self[0:3,0:3]; <NEW_LINE> test = test*test.tr() <NEW_LINE> test[0,0] = test[0,0] - 1.0 <NEW_LINE> test[1,1] = test[1,1] - 1.0 <NEW_LINE> test[2,2] = test[2,2] - 1.0 ... | returns 1 if it is a Homogeneous matrix | 625941c199cbb53fe6792b71 |
def _try_dump(cnf, outpath, otype, fmsg): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> API.dump(cnf, outpath, otype) <NEW_LINE> <DEDENT> except API.UnknownFileTypeError: <NEW_LINE> <INDENT> _exit_with_output(fmsg % outpath, 1) <NEW_LINE> <DEDENT> except API.UnknownParserTypeError: <NEW_LINE> <INDENT> _exit_with_output(... | :param cnf: Configuration object to print out
:param outpath: Output file path or None
:param otype: Output type or None
:param fmsg: message if it cannot detect otype by `inpath` | 625941c1442bda511e8be3a5 |
def test_sequential_writer(tmp_path): <NEW_LINE> <INDENT> bag_path = str(tmp_path / 'tmp_write_test') <NEW_LINE> storage_options, converter_options = get_rosbag_options(bag_path) <NEW_LINE> writer = rosbag2_py.SequentialWriter() <NEW_LINE> writer.open(storage_options, converter_options) <NEW_LINE> topic_name = '/chatte... | Test for sequential writer.
:return: | 625941c19b70327d1c4e0d5e |
def Reroll(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | Missing associated documentation comment in .proto file. | 625941c19f2886367277a819 |
def backward_D(self): <NEW_LINE> <INDENT> if self.args.cgan==False: <NEW_LINE> <INDENT> pred_fake=self.netD(self.fake_B.detach()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> fake_AB=torch.cat((self.real_A, self.fake_B), 1) <NEW_LINE> pred_fake=self.netD(fake_AB.detach()) <NEW_LINE> <DEDENT> self.loss_D_fake = self.cr... | Calculate GAN loss for the discriminator | 625941c1b830903b967e9897 |
def palette(self, alpha='natural'): <NEW_LINE> <INDENT> if not self.plte: <NEW_LINE> <INDENT> raise FormatError( "Required PLTE chunk is missing in colour type 3 image.") <NEW_LINE> <DEDENT> plte = group(array('B', self.plte), 3) <NEW_LINE> if self.trns or alpha == 'force': <NEW_LINE> <INDENT> trns = array('B', self.tr... | Returns a palette that is a sequence of 3-tuples or 4-tuples,
synthesizing it from the ``PLTE`` and ``tRNS`` chunks. These
chunks should have already been processed (for example, by
calling the :meth:`preamble` method). All the tuples are the
same size: 3-tuples if there is no ``tRNS`` chunk, 4-tuples when
there is a... | 625941c10a366e3fb873e7a3 |
def test_get(self): <NEW_LINE> <INDENT> response = self.client.get( reverse("wagtailimages:generate_url", args=(self.image.id, "fill-800x600")) ) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertEqual(response["Content-Type"], "application/json") <NEW_LINE> content_json = json.loads(response... | This tests that the view responds correctly for a user with edit permissions on this image | 625941c107d97122c4178812 |
def validate_self(self): <NEW_LINE> <INDENT> self._validate_input_symbol_subset() <NEW_LINE> self._validate_transitions() <NEW_LINE> self._validate_initial_state() <NEW_LINE> self._validate_initial_state_transitions() <NEW_LINE> self._validate_nonfinal_initial_state() <NEW_LINE> self._validate_final_states() <NEW_LINE>... | Return True if this DTM is internally consistent. | 625941c1851cf427c661a49c |
def subfields_to_dict(self, subfields): <NEW_LINE> <INDENT> subfields_list = [] <NEW_LINE> for idx in range(0, len(subfields), 2): <NEW_LINE> <INDENT> if idx + 1 < len(subfields): <NEW_LINE> <INDENT> subfields_list.append({"code": subfields[idx], "value": subfields[idx+1]}) <NEW_LINE> <DEDENT> <DEDENT> return subfields... | muuntaa pymarc-kirjaston käyttämän osakenttälistan, jossa joka toinen alkio on osakenttäkoodi ja joka toinen osakenttä,
konversio-ohjelmalle helpommin käsiteltävään muotoon listaksi, jossa on avainarvopareja {osakenttäkoodi, osakenttä} | 625941c1a17c0f6771cbdfdd |
def reindex(self): <NEW_LINE> <INDENT> call_command('rebuild_index', interactive=False) | Re-index the search database for the unit tests. | 625941c11b99ca400220aa3b |
def mouse_click(self, event): <NEW_LINE> <INDENT> if event.button == 1: <NEW_LINE> <INDENT> self.left_click(event) <NEW_LINE> <DEDENT> elif event.button == 3: <NEW_LINE> <INDENT> self.right_click(event) | deal with mouse input
:param event:
:return: | 625941c1187af65679ca50a9 |
def copyRandomList(self, head): <NEW_LINE> <INDENT> if not head: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if self.hashmap.has_key(head.label): <NEW_LINE> <INDENT> return self.hashmap[head.label] <NEW_LINE> <DEDENT> copyhead = RandomListNode(head.label) <NEW_LINE> self.hashmap[head.label] = copyhead <NEW_LINE... | :type head: RandomListNode
:rtype: RandomListNode | 625941c13eb6a72ae02ec462 |
def check_uniqueness(keys=UNIQUES, data=None, *, ignore_self=False): <NEW_LINE> <INDENT> user_files = fetch_user_files() <NEW_LINE> if ignore_self: <NEW_LINE> <INDENT> user_files.remove('{}.txt'.format(data['id'])) <NEW_LINE> <DEDENT> for user_file in user_files: <NEW_LINE> <INDENT> with open(user_file, 'r') as f: <NEW... | Check if the given data is unique in the DB for the provided keys. | 625941c18a43f66fc4b53ff2 |
def fake_decimal(self, digits, right_digits, flag=None, min_value=None, max_value=None): <NEW_LINE> <INDENT> if flag is None: <NEW_LINE> <INDENT> flag = random.randint(0, 1) <NEW_LINE> <DEDENT> number = self.faker.pyfloat(left_digits=(digits - right_digits), right_digits=right_digits, positive=True, min_value=min_value... | mysql中DECIMAL(6,2);
最多可以存储6位数字,小数位数为2位; 因此范围是从-9999.99到9999.99
而pyfloat left_digits, right_digits 表示小数点左右数字位数
:param args:
:return: | 625941c121a7993f00bc7c77 |
def __delattr__(self, k): <NEW_LINE> <INDENT> del self[k] | Remove attribute. | 625941c1379a373c97cfaace |
@experimental(as_of="0.4.0") <NEW_LINE> def esty_ci(counts): <NEW_LINE> <INDENT> counts = _validate_counts_vector(counts) <NEW_LINE> f1 = singles(counts) <NEW_LINE> f2 = doubles(counts) <NEW_LINE> n = counts.sum() <NEW_LINE> z = 1.959963985 <NEW_LINE> W = (f1 * (n - f1) + 2 * n * f2) / (n ** 3) <NEW_LINE> return f1 / n... | Calculate Esty's CI.
Esty's CI is defined as
.. math::
F_1/N \pm z\sqrt{W}
where :math:`F_1` is the number of singleton OTUs, :math:`N` is the total
number of individuals (sum of abundances for all OTUs), and :math:`z` is a
constant that depends on the targeted confidence and based on the normal
distribution.
:... | 625941c1091ae35668666eed |
def test_util(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> res = parse_qs_dict("http://example.org/?foo=1&bar=2") <NEW_LINE> assert res['foo'] == '1' <NEW_LINE> assert res['bar'] == '2' <NEW_LINE> parse_qs_dict("http://example.org/?foo=1&foo=2") <NEW_LINE> assert False <NEW_LINE> <DEDENT> except ValueError: <NEW_LIN... | Test the utility function for dictionaries. | 625941c15e10d32532c5eeb2 |
def do_datamodel(self, arg): <NEW_LINE> <INDENT> self.__checkConnection() <NEW_LINE> parser = self.parser_datamodel() <NEW_LINE> options, args = parser.parse_args(arg) <NEW_LINE> pysqlgraphics.datamodel(self.db, options.user.upper(), tableFilter=" ".join(args), withColumns=options.columns) | Exports a datamodel as a picture | 625941c176e4537e8c3515fb |
def format_player_scores(self, player_scores): <NEW_LINE> <INDENT> player_score_list = player_scores.split(',') <NEW_LINE> for i in range(len(player_score_list)): <NEW_LINE> <INDENT> player_score_list[i] = player_score_list[i].split(':') <NEW_LINE> player_score_list[i][0] = int(player_score_list[i][0]) <NEW_LINE> playe... | take player scores from state string and reformat to be used | 625941c163d6d428bbe4447a |
def get_logger(): <NEW_LINE> <INDENT> logger = logging.getLogger('parky_bot') <NEW_LINE> return logger | This function returns a single logging object.
Returns:
Logger: logger object. | 625941c17b25080760e393e5 |
def __init__(self, storage: Storage, read_handle: ReadHandle, config: dict): <NEW_LINE> <INDENT> async def run(): <NEW_LINE> <INDENT> self.server = await aio.start_server(self.startReceive, server_addr, server_port) <NEW_LINE> addr = self.server.sockets[0].getsockname() <NEW_LINE> logging.info(f'TCP insertion handle se... | TCP bulk insertion handle need to keep a reference to ReadHandle to register new prefixes. | 625941c155399d3f0558863e |
def removeProperty(self, object, name): <NEW_LINE> <INDENT> raise NotImplementedError | Remove the property 'name' from an object.
| 625941c1442bda511e8be3a6 |
def __init__(self, spatial_size=50 * 8 + 8, dimension=3, num_input_features=1, block_reps=1, m=32, num_planes_coeffs=[1, 2, 3, 4, 5], num_planes=None, residual_blocks=False, downsample=[2, 2], bias=False, mode=3, num_classes=50, ): <NEW_LINE> <INDENT> self.spatial_size = spatial_size <NEW_LINE> self.dimension = dimensi... | Parameters
----------
dimension: int
reps: int
Conv block repetition factor
m: int
Unet number of features
num_planes_coeffs: array of int
num_planes=None: array of int
UNet number of features per level
residual_blocks: bool
mode: int
mode == 0 if the input is guaranteed to have no duplicates
mode ... | 625941c1a219f33f346288f7 |
def _write_nlu_to_file( export_nlu_path: Text, evts: List[Dict[Text, Any]] ) -> None: <NEW_LINE> <INDENT> msgs = _collect_messages(evts) <NEW_LINE> try: <NEW_LINE> <INDENT> previous_examples = load_data(export_nlu_path) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> logger.exception("An exception occurr... | Write the nlu data of the sender_id to the file paths. | 625941c116aa5153ce362403 |
def __GetExtensionSettings(self, project_path): <NEW_LINE> <INDENT> for folderName, subfoldersName, fileNames in os.walk(project_path): <NEW_LINE> <INDENT> for fileName in fileNames: <NEW_LINE> <INDENT> ind = 0 <NEW_LINE> for item in self.__ExtensionList: <NEW_LINE> <INDENT> if self.__MarkerName.find("*") == 0: <NEW_LI... | Метод автоматического определения настроек конвертации | 625941c1377c676e91272134 |
def _Create(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Create an Apache Spark cluster. | 625941c166673b3332b9201c |
def __init__(self, learning_rate=0.001, discount=0.99, batch_size=64, state_size=4, action_size=2, use_huber_loss=False, state_process_fn=None, action_process_fn=None, action_post_process_fn=None, model_dir=None): <NEW_LINE> <INDENT> self.learning_rate = learning_rate <NEW_LINE> self.gamma = discount <NEW_LINE> self.on... | Initialize the double dqn agent.
Args:
learning_rate: learning rate of the optimizer
discount: future discount of the agent
batch_size: size of the batch
state_size: size of the observation
action_size: size of the action
use_huber_loss: whether to use huber loss or l2 loss
state_process_fn: function tha... | 625941c182261d6c526ab427 |
def generic_compare(self, builder, key, argtypes, args): <NEW_LINE> <INDENT> at, bt = argtypes <NEW_LINE> av, bv = args <NEW_LINE> ty = self.typing_context.unify_types(at, bt) <NEW_LINE> assert ty is not None <NEW_LINE> cav = self.cast(builder, av, at, ty) <NEW_LINE> cbv = self.cast(builder, bv, bt, ty) <NEW_LINE> fnty... | Compare the given LLVM values of the given Numba types using
the comparison *key* (e.g. '=='). The values are first cast to
a common safe conversion type. | 625941c17d43ff24873a2c2a |
def _validate_callbacks(self, a, b, anum, bnum): <NEW_LINE> <INDENT> f_a, f_b = self._get_method(a), self._get_method(b) <NEW_LINE> has_a, has_b = f_a != None, f_b != None <NEW_LINE> if has_a and has_b: <NEW_LINE> <INDENT> raise AssertionError("Cannot define both " + a + " and " + b + ".") <NEW_LINE> <DEDENT> elif has_... | Makes sure that only one of methods a and b are defined. Makes sure that
the method defined has the correct number of arguments (anum, bnum). | 625941c1d18da76e2353245f |
def fetch(self): <NEW_LINE> <INDENT> return self._proxy.fetch() | Fetch the MemberInstance
:returns: The fetched MemberInstance
:rtype: twilio.rest.ip_messaging.v1.service.channel.member.MemberInstance | 625941c1d6c5a10208143fd4 |
def build(self) -> 'TableSchema': <NEW_LINE> <INDENT> return TableSchema(self._field_names, self._field_data_types) | Returns a :class:`TableSchema` instance.
:return: The :class:`TableSchema` instance. | 625941c163f4b57ef00010a9 |
def to_dict(self): <NEW_LINE> <INDENT> d = {'filename': self.filename, 'sections': self.sections} <NEW_LINE> for section in self.sections: <NEW_LINE> <INDENT> d[section] = copy.deepcopy(getattr(self, section)) <NEW_LINE> <DEDENT> return d | Serializes the instance as dict. | 625941c18da39b475bd64efc |
def test_get_comment(self): <NEW_LINE> <INDENT> pass | Test case for get_comment
Gets a Comment of a Defect | 625941c1925a0f43d2549e00 |
def time_to_td(ti): <NEW_LINE> <INDENT> return datetime.timedelta(hours=ti.hour, minutes=ti.minute, seconds=ti.second) | Convert from datetime.time object to timedelta object | 625941c18e71fb1e9831d735 |
def CreateUpload(self, archive=None, manifest=None, **kwargs): <NEW_LINE> <INDENT> if archive is not None: <NEW_LINE> <INDENT> url = archive.upload <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> url = self._top_resource_url('uploads') <NEW_LINE> <DEDENT> kwargs['data'] = model_to_json(manifest) <NEW_LINE> body, headers ... | Create a new upload for an archive
:param archive: the archive model instance
:param manifest: the upload manifest | 625941c1099cdd3c635f0be7 |
def load_data(): <NEW_LINE> <INDENT> wiki_data = read_from_wiki(topics) <NEW_LINE> write_to_json(wiki_data) | Loads data from Wikipedia | 625941c1eab8aa0e5d26dae3 |
def get(self, uuid): <NEW_LINE> <INDENT> if uuid in model.AccessPoints: <NEW_LINE> <INDENT> return model.AccessPoints[uuid].marshal() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ResourceNotFoundError | Return details of access point taken from configuration file. | 625941c1004d5f362079a2c0 |
def calculate_metrics(self, metric_df, dose): <NEW_LINE> <INDENT> roi_exists = self.roi_mask.max(axis=(0, 1, 2)) <NEW_LINE> voxels_in_tenth_of_cc = np.maximum(1, np.round(100/self.voxel_size)) <NEW_LINE> for roi_idx, roi in enumerate(self.data_loader.dataset.defdataset.full_roi_list): <NEW_LINE> <INDENT> if roi_exists[... | Calculate the competition metrics
:param metric_df: A DataFrame with columns indexed by the metric name and the structure name
:param dose: the dose to be evaluated
:return: the same metric_df that is input, but now with the metrics for the provided dose | 625941c1d10714528d5ffc6c |
def bool_to_string(bool): <NEW_LINE> <INDENT> string = str(bool) <NEW_LINE> string = string.lower() <NEW_LINE> return string | Convert a boolean to a string
:param bool: provide boolean to be converted | 625941c1d7e4931a7ee9dea8 |
def friend_by_public_key(self, public_key): <NEW_LINE> <INDENT> tox_err_friend_by_public_key = c_int() <NEW_LINE> result = Tox.libtoxcore.tox_friend_by_public_key(self._tox_pointer, string_to_bin(public_key), byref(tox_err_friend_by_public_key)) <NEW_LINE> tox_err_friend_by_public_key = tox_err_friend_by_public_key.val... | Return the friend number associated with that Public Key.
:param public_key: A byte array containing the Public Key.
:return: friend number | 625941c1a8ecb033257d3059 |
def tostr(self): <NEW_LINE> <INDENT> if len(self.items) != 2: <NEW_LINE> <INDENT> raise InternalError( "Cray_Pointer_Decl.tostr(). 'Items' should be of size 2 but " "found '{0}'.".format(len(self.items))) <NEW_LINE> <DEDENT> if not self.items[0]: <NEW_LINE> <INDENT> raise InternalError("Cray_Pointer_Decl_Stmt.tostr(). ... | :return: this Cray-pointee declaration as a string
:rtype: str
:raises InternalError: if the internal items list variable is not the expected size.
:raises InternalError: if the first element of the internal items list is None or is empty.
:raises InternalError: if the second element of the internal ... | 625941c126068e7796caec67 |
def print_page_cb(self, print_op, print_context, page_nb, keep_refs={}): <NEW_LINE> <INDENT> raise NotImplementedError() | Arguments:
keep_refs --- Workaround ugly as fuck to keep some object alive
(--> non-garbage-collected) during the whole
printing process | 625941c199fddb7c1c9de31d |
def get_performance_logs(self): <NEW_LINE> <INDENT> files = os.listdir(self.performance_logs_dir) <NEW_LINE> for i, f in enumerate(files): <NEW_LINE> <INDENT> files[i] = 'file://{0}/{1}'.format(self.performance_logs_dir, f) <NEW_LINE> <DEDENT> return files | Returns a list of full paths to performance log files | 625941c115baa723493c3eff |
def dumps(self, objects): <NEW_LINE> <INDENT> if len(objects) == 0: <NEW_LINE> <INDENT> objects = list(self._models.values()) <NEW_LINE> <DEDENT> if len(objects) == 1 and isinstance(objects[0], Plot): <NEW_LINE> <INDENT> the_plot = objects[0] <NEW_LINE> objects = list(self._models.values()) <NEW_LINE> <DEDENT> else: <N... | Returns the HTML contents as a string
FIXME : signature different than other dumps
FIXME: should consolidate code between this one and that one. | 625941c1ff9c53063f47c180 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, LbClientCertificateSubjectDnCondition): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941c110dbd63aa1bd2b30 |
def train(self, env_name): <NEW_LINE> <INDENT> timestr = time.strftime("%Y%m%d-%H%M%S") + "_" + str(env_name) <NEW_LINE> tensorboard = TensorBoard(log_dir='./Graph/{}'.format(timestr), histogram_freq=0, write_graph=True, write_images=False) <NEW_LINE> self.dqn.fit(self.env, nb_max_start_steps=nb_max_start_steps, nb_ste... | Train a model | 625941c1b7558d58953c4ea4 |
def clean(self, value): <NEW_LINE> <INDENT> value = super(ModelNameFormField, self).clean(value) <NEW_LINE> if value == u'': <NEW_LINE> <INDENT> return value <NEW_LINE> <DEDENT> if not ModelNameFormField.get_model_from_string(value): <NEW_LINE> <INDENT> raise forms.ValidationError(self.error_messages['invalid']) <NEW_L... | Validates that the input matches the regular expression. Returns a
Unicode object. | 625941c157b8e32f52483425 |
def __init__(self, segments, linewidths = None, colors = None, antialiaseds = None, linestyles = 'solid', offsets = None, transOffset = None, norm = None, cmap = None, pickradius = 5, **kwargs ): <NEW_LINE> <INDENT> if colors is None: colors = mpl.rcParams['lines.color'] <NEW_LINE> if linewidths is None: line... | *segments*
a sequence of (*line0*, *line1*, *line2*), where::
linen = (x0, y0), (x1, y1), ... (xm, ym)
or the equivalent numpy array with two columns. Each line
can be a different length.
*colors*
must be a sequence of RGBA tuples (eg arbitrary color
strings, etc, not allowed).
*antialia... | 625941c1009cb60464c6333f |
def propose_beta(self, beta_prev, beta_jump_length): <NEW_LINE> <INDENT> sigma_prop = np.eye(self.beta_dim) * beta_jump_length <NEW_LINE> return multivariate_normal(mean=beta_prev, cov=sigma_prop).rvs() | Proposes a perturbed beta based on a jump length hyperparameter.
Args:
beta_prev:
beta_jump_length:
Returns: | 625941c1460517430c394116 |
def affine_forward(x, w, b): <NEW_LINE> <INDENT> out = None <NEW_LINE> N = x.shape[0] <NEW_LINE> D = w.shape[0] <NEW_LINE> out = np.dot(np.reshape(x, [N, D]), w) + b <NEW_LINE> cache = (x, w, b) <NEW_LINE> return out, cache | Computes the forward pass for an affine (fully-connected) layer.
The input x has shape (N, d_1, ..., d_k) and contains a minibatch of N
examples, where each example x[i] has shape (d_1, ..., d_k). We will
reshape each input into a vector of dimension D = d_1 * ... * d_k, and
then transform it to an output vector of di... | 625941c1293b9510aa2c3224 |
def _dataframe_to_db(self): <NEW_LINE> <INDENT> self._dataframe = pickle.dumps(self.dataframe, protocol=pickle.HIGHEST_PROTOCOL) | This is basically the same code from pandas 0.18 pandas.io.pickle.to_pickle
but keeping the bytes in memory. Since that method does not allow passing the
pickle in memory (only via file on file system) the logic is duplicated. | 625941c15166f23b2e1a50e5 |
def do_scheme(self, out=sys.stdout): <NEW_LINE> <INDENT> self.logger.info("Modular input: scheme requested") <NEW_LINE> out.write(self.get_scheme()) <NEW_LINE> return True | Get the scheme and write it out to standard output.
Arguments:
out -- The stream to write the message to (defaults to standard output) | 625941c171ff763f4b549613 |
def _Populate(self, info: Dict[str, Any], warnings: Dict[str, Any]) -> None: <NEW_LINE> <INDENT> info.update({ 'Name': self._object.Name(), 'Image': self._object.Image(), 'Mounts': self._object.VolumeMounts(), }) <NEW_LINE> (warnings if self._object.IsPrivileged() else info)['Privileged'] = self._object.IsPrivileged() ... | Method override. | 625941c14f6381625f1149c7 |
def image_scaner(): <NEW_LINE> <INDENT> print(f'正在扫描 {base_img_dir} 文件夹下的图片') <NEW_LINE> print('*' * 50) <NEW_LINE> for root, dirs, files in os.walk(base_img_dir): <NEW_LINE> <INDENT> for file in files: <NEW_LINE> <INDENT> file_path = os.path.join(root, file) <NEW_LINE> for dimension in dimensions: <NEW_LINE> <INDENT> ... | 扫描图片路径 | 625941c185dfad0860c3ade5 |
def reload(plugin): <NEW_LINE> <INDENT> unload(plugin) <NEW_LINE> load(plugin) | Reload plugin | 625941c166656f66f7cbc136 |
def testYAMLErrorParser(self): <NEW_LINE> <INDENT> document = ('item1: string1\n' '- item2\n') <NEW_LINE> expected_event_list = [ (yaml.events.StreamStartEvent,), (yaml.events.DocumentStartEvent,), (yaml.events.MappingStartEvent,), (yaml.events.ScalarEvent, 'item1'), (yaml.events.ScalarEvent, 'string1'), ] <NEW_LINE> h... | Test handling of YAML error from Parser. | 625941c191af0d3eaac9b9a2 |
def _create_fluents(self): <NEW_LINE> <INDENT> self.fluents = set([]) <NEW_LINE> for p in self.predicates: <NEW_LINE> <INDENT> var_names, val_generator = self._create_valuations(p.args) <NEW_LINE> for valuation in val_generator: <NEW_LINE> <INDENT> assignment = {var_name: val for var_name, val in zip(var_names, valuati... | Create the set of fluents by grounding the predicates. | 625941c156ac1b37e626415f |
def concat_tparams(self, tparams): <NEW_LINE> <INDENT> types = [", ".join(p) for p in tparams] <NEW_LINE> return "[{}]".format(types) | Return a valid signature from a list of type parameters. | 625941c1e1aae11d1e749c41 |
def is_import(line): <NEW_LINE> <INDENT> return js_module_re.search(line) is not None | Determines if a selected line contains an import statement. | 625941c1e8904600ed9f1eb7 |
def set(self, attrname, value): <NEW_LINE> <INDENT> if attrname in self.attributes: <NEW_LINE> <INDENT> self.attributes[attrname].value = value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.attributes[attrname] = AlarmAttribute(attrname, value) | Setter for attributes
:param attrname: attribute name
:param value: value | 625941c1f8510a7c17cf9687 |
def step(self, action): <NEW_LINE> <INDENT> self.shapely_obj = None <NEW_LINE> if action is None: <NEW_LINE> <INDENT> action = [0, 0] <NEW_LINE> <DEDENT> delta_f, a = action <NEW_LINE> delta_f, rad_angle = np.radians(10*delta_f), np.radians(self.angle) <NEW_LINE> if a > self.max_vel - self.vel: <NEW_LINE> <INDENT> a = ... | Updates the car for one timestep.
Args:
action: 1x2 array, steering / acceleration action.
info_dict: dict, contains information about the environment. | 625941c17047854f462a1398 |
def set_password(self, data: dict) -> dict: <NEW_LINE> <INDENT> if data is None or 'username' not in data or not isinstance(data['username'], str) or 'password' not in data or not isinstance(data['password'], str): <NEW_LINE> <INDENT> return {'error': {'code': -10001, 'message': 'invalid_data'}} <NEW_LIN... | Set the password for a user
:param dict data: The data from the call
:return: Response dictionary
:rtype: dict | 625941c185dfad0860c3ade6 |
def test_filter_input_subsample_vocab(self): <NEW_LINE> <INDENT> random_seed.set_random_seed(42) <NEW_LINE> input_tensor = constant_op.constant([ b"the", b"answer", b"to", b"life", b"and", b"universe" ]) <NEW_LINE> keys = constant_op.constant([b"and", b"life", b"the", b"to", b"universe"]) <NEW_LINE> values = constant_o... | Tests input filtering based on vocab subsampling. | 625941c1a4f1c619b28affca |
def expectation( p: ProbabilityDistributionLike, obj1: PackedExpectationObject, obj2: PackedExpectationObject = None, nghp: Optional[int] = None, ) -> tf.Tensor: <NEW_LINE> <INDENT> p, obj1, feat1, obj2, feat2 = _init_expectation(p, obj1, obj2) <NEW_LINE> try: <NEW_LINE> <INDENT> return dispatch.expectation(p, obj1, fe... | Compute the expectation <obj1(x) obj2(x)>_p(x)
Uses multiple-dispatch to select an analytical implementation,
if one is available. If not, it falls back to quadrature.
:type p: (mu, cov) tuple or a `ProbabilityDistribution` object
:type obj1: kernel, mean function, (kernel, inducing_variable), or None
:type obj2: kern... | 625941c11f5feb6acb0c4adf |
def toml_url(url): <NEW_LINE> <INDENT> response = requests.get(url) <NEW_LINE> return tomlkit.parse(response.text) | Grab a TOML file from URL and return the parsed object | 625941c1c432627299f04bd0 |
def deserialize(self, data): <NEW_LINE> <INDENT> return self._level_deserial(data) | Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode | 625941c130dc7b76659018f4 |
def onHdenChange(self,value): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> self.lineEditHden.setStyleSheet("QLineEdit { background-color: rgb(255, 170, 170) }") <NEW_LINE> self._set_expression_error('H[Den](s)', True, '[{}] is not a valid expression'.format(value)) <NEW_LINE> return <NEW_LINE> <DEDENT> Hden =... | When user enters a character. | 625941c191af0d3eaac9b9a3 |
def buble_sort(arr): <NEW_LINE> <INDENT> print("Пузырьковая сортировка:") <NEW_LINE> swap = 0 <NEW_LINE> for i in range(len(arr), -1, -1): <NEW_LINE> <INDENT> for j in range(0, i-1): <NEW_LINE> <INDENT> if arr[j] > arr[j+1]: <NEW_LINE> <INDENT> arr[j], arr[j+1] = arr[j+1], arr[j] <NEW_LINE> swap += 1 <NEW_LINE> print("... | функция сортировки методов "Пузырька" | 625941c1d7e4931a7ee9dea9 |
def json_load_bean_list(s, t, l=None): <NEW_LINE> <INDENT> j = json.loads(s) <NEW_LINE> if j is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> elif not isinstance(j, list): <NEW_LINE> <INDENT> logging.error("s: (%s) is not list", s) <NEW_LINE> raise ValueError("not list") <NEW_LINE> <DEDENT> if l is None: <N... | @:param t type, should be subclass of BaseBean | 625941c1498bea3a759b9a3c |
def set_signature(self, signature: str): <NEW_LINE> <INDENT> if (signature is not None) & (len(signature) > 0): <NEW_LINE> <INDENT> self.signature = True <NEW_LINE> self.email.attach(MIMEText(signature, 'plain')) | In this method we add the clients signature to the email
@signature: Email signature | 625941c123e79379d52ee4f2 |
def set_connects(self, _workspace): <NEW_LINE> <INDENT> self.proj_combo_box.currentIndexChanged.connect(self.proj_combo_box_changed) <NEW_LINE> self.proj_spin_box.valueChanged.connect(self.proj_spin_box_changed) <NEW_LINE> self.field_combo_box.currentIndexChanged.connect(self.field_type_changed) <NEW_LINE> self.screens... | connects signals and slots
:param _workspace:
:return: | 625941c107f4c71912b1140d |
def make_marshal_error(marshal_result): <NEW_LINE> <INDENT> error = None <NEW_LINE> if marshal_result[1]: <NEW_LINE> <INDENT> message = None <NEW_LINE> source = marshal_result[1] <NEW_LINE> error = make_error(common.errors.MissingParameterError(message, source)) <NEW_LINE> <DEDENT> return error | Creates a JSON response if the provided marshal_result contains
an error message by creating a MissingParameterError with that message.
If no error message is present, then None is returned to the caller
:marshal_result the tuple returned by marshal_request | 625941c1be8e80087fb20bd2 |
def defineVirtualDevice(parent="string", clear=bool, axis=int, undefine=bool, device="string", usage="string", channel="string", create=bool): <NEW_LINE> <INDENT> pass | defineVirtualDevice is undoable, queryable, and NOT editable.
This command defines a virtual device. Virtual devices act like real devices and are useful to manipulate/playback data when an command device is not connected to the computer.
| 625941c17d43ff24873a2c2b |
def backtrack(board, i, j, trie, pre, used, result): <NEW_LINE> <INDENT> if '#' in trie: <NEW_LINE> <INDENT> result.add(pre) <NEW_LINE> <DEDENT> if i < 0 or i >= len(board) or j < 0 or j >= len(board[0]): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not used[i][j] and board[i][j] in trie: <NEW_LINE> <INDENT> used[... | backtrack tries to build each words from
the board and return all words found
@param: board, the passed in board of characters
@param: i, the row index
@param: j, the column index
@param: trie, a trie of the passed in words
@param: pre, a buffer of currently build string that differs
by recursion stack
@param:... | 625941c166673b3332b9201d |
def navigate(self, name): <NEW_LINE> <INDENT> return self.getDeclaration(name) | Same as self.getDeclaration | 625941c130dc7b76659018f5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.