code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def has_settings(self, name): <NEW_LINE> <INDENT> return name in self.settings_names | This function ...
:param name:
:return: | 625941d130c21e258bdfa62a |
def help(self, what=None): <NEW_LINE> <INDENT> if what is None: <NEW_LINE> <INDENT> mm = [x for x in inspect.getmembers(self, predicate=inspect.ismethod) if not x[0].startswith("_")] <NEW_LINE> lines = [self.console.slug, "="*len(self.console.slug), ""] <NEW_LINE> if self.console.description: <NEW_LINE> <INDENT> lines ... | Prints help text or provides help for specific command.
'?' is an alias for 'help'. | 625941d138b623060ff0af7a |
def cleanup(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.logger.debug('Cleaning up...\n\n') <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> if self.video_manager is not None: <NEW_LINE> <INDENT> self.video_manager.release() | Cleanup: Releases all resources acquired by the CliContext (esp. the VideoManager). | 625941d199cbb53fe6792d73 |
def save(self): <NEW_LINE> <INDENT> graph_path = os.path.join(self.data_save_path, 'dgl_graph_{}_{}.bin'.format(self.hash, self.sub)) <NEW_LINE> save_graphs(str(graph_path), self.graphs, {'labels': self.labels}) | save the graph list and the labels | 625941d1dc8b845886cb56c2 |
def findMedianSortedArrays(self, A, B): <NEW_LINE> <INDENT> m, n = len(A), len(B) <NEW_LINE> if m > n: <NEW_LINE> <INDENT> m, n, A, B = n, m, B, A <NEW_LINE> <DEDENT> if n == 0: <NEW_LINE> <INDENT> raise ValueError <NEW_LINE> <DEDENT> i_left, i_right, half_len = 0, m, (m+n+1)//2 <NEW_LINE> while i_left <= i_right: <NEW... | :type A: List[int]
:type B: List[int]
:rtype: float | 625941d1bd1bec0571d907bc |
def absolute_limits(nova_client): <NEW_LINE> <INDENT> limits = nova_client.limits.get() <NEW_LINE> return dict([(limit.name, limit.value) for limit in list(limits.absolute)]) | Return the absolute limits as a dictionary. | 625941d14f6381625f114bc8 |
def get_device_registration_summary( cmd, app_id: str, token: str, api_version: str, central_dns_suffix=CENTRAL_ENDPOINT, ) -> dict: <NEW_LINE> <INDENT> registration_summary = {status.value: 0 for status in DeviceStatus} <NEW_LINE> url = "https://{}.{}/{}?api-version={}".format( app_id, central_dns_suffix, BASE_PATH, a... | Get device registration summary for a given app
Args:
cmd: command passed into az
app_id: name of app (used for forming request URL)
token: (OPTIONAL) authorization token to fetch device details from IoTC.
MUST INCLUDE type (e.g. 'SharedAccessToken ...', 'Bearer ...')
central_dns_suffix: {centr... | 625941d1e8904600ed9f20bb |
def test_protobuf_uses_fast_cpp(self): <NEW_LINE> <INDENT> self.assertEqual(api_implementation.Type(), 'cpp') | Checks that we are using the fast cpp version of python protobufs. | 625941d1f9cc0f698b140788 |
def set_UploadSourcePassword(self, value): <NEW_LINE> <INDENT> super(PutObjectInputSet, self)._set_input('UploadSourcePassword', value) | Set the value of the UploadSourcePassword input for this Choreo. ((optional, string) The password to use when Basic Authentiation is required to access a file located at the URL specified in the UploadSourceURL input.) | 625941d1f548e778e58cd70b |
def randprime(a, b): <NEW_LINE> <INDENT> if a >= b: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> a, b = list(map(int, (a, b))) <NEW_LINE> n = random.randint(a - 1, b) <NEW_LINE> p = nextprime(n) <NEW_LINE> if p >= b: <NEW_LINE> <INDENT> p = prevprime(b) <NEW_LINE> <DEDENT> if p < a: <NEW_LINE> <INDENT> raise ValueErr... | Return a random prime number in the range [a, b).
Bertrand's postulate assures that
randprime(a, 2*a) will always succeed for a > 1.
References
==========
- http://en.wikipedia.org/wiki/Bertrand's_postulate
Examples
========
>>> from sympy import randprime, isprime
>>> randprime(1, 30) #doctest: +SKIP
13
>>> ispri... | 625941d1cb5e8a47e48b7c36 |
def randomList(n): <NEW_LINE> <INDENT> return [random.choice([-1.0, 1.0]) for _ in range(n)] | return list of len(n) of randomly generated floats in range {-1, 1} | 625941d13c8af77a43ae392e |
def _make_nodes_containers(self): <NEW_LINE> <INDENT> for variable_name in self.get_variables_names(): <NEW_LINE> <INDENT> nodeph = NodeContainer(variable_name) <NEW_LINE> self.nodes_containers.append(nodeph) | Instantiate a node container for each variable. | 625941d1b5575c28eb68e18d |
def __contains__(self, chrom): <NEW_LINE> <INDENT> return chrom in self._chroms | Return True if genome contains chromosome. | 625941d1a4f1c619b28b01c4 |
def inverse_using_eigen_decomposition(self, *args): <NEW_LINE> <INDENT> return _pypl.plFloatMatrix_inverse_using_eigen_decomposition(self, *args) | inverse_using_eigen_decomposition(plFloatMatrix self, plFloatMatrix inverse) -> plFloat
inverse_using_eigen_decomposition(plFloatMatrix self, plFloatMatrix inverse, plFloatMatrix mat_n_n_tmp1, plFloatMatrix mat_n_n_tmp2, plFloatVector vect_n_tmp) -> plFloat | 625941d15fcc89381b1e184d |
def make_value_setter(**model_kwargs): <NEW_LINE> <INDENT> def set_values(f, *args, **kwargs): <NEW_LINE> <INDENT> name = kwargs.get("name") <NEW_LINE> if name in model_kwargs: <NEW_LINE> <INDENT> kwargs["value"] = model_kwargs[name] <NEW_LINE> <DEDENT> return ed.interceptable(f)(*args, **kwargs) <NEW_LINE> <DEDENT> re... | Creates a value-setting interceptor. | 625941d1e64d504609d749cd |
def main(root): <NEW_LINE> <INDENT> config_path = os.path.abspath(os.path.join(root, 'mini_config.py')) <NEW_LINE> config = imp.load_source('mini_config', config_path) <NEW_LINE> test_data = config.test_X <NEW_LINE> test_labels = config.test_Y <NEW_LINE> cv_split = config.cross_validation_split <NEW_LINE> print("------... | Import trained model and test Minimal. | 625941d1cdde0d52a9e531c1 |
def _Bethe_system(self, c, buckets): <NEW_LINE> <INDENT> t = np.asarray([Bethe_root_phase(c, n, self.a) for n in buckets]) <NEW_LINE> return t | The first N+1 of the BA equations: roots given c. | 625941d1097d151d1a222fe6 |
def randomString(stringLength): <NEW_LINE> <INDENT> letters = string.ascii_letters <NEW_LINE> return ''.join(random.choice(letters) for i in range(stringLength)) | Generate a random string with the combination of lowercase and uppercase letters | 625941d1d268445f265b4ffb |
def __hash__(self): <NEW_LINE> <INDENT> old_options = np.get_printoptions() <NEW_LINE> np.set_printoptions(threshold=10, precision=3) <NEW_LINE> problemString = str(self) <NEW_LINE> problemString = re.sub(VARSUB, "var", problemString) <NEW_LINE> problemString = re.sub(PARAMSUB, "param", problemString) <NEW_LINE> digest... | Computes a string representation of the problem (including
truncated, reduced-precision versions of all data matrices), replaces
various variable names and parameter names, then hashes the resulting
string. | 625941d12c8b7c6e89b3594d |
def is_empty(self): <NEW_LINE> <INDENT> raise NotImplementedError | 데이터 유무 검사
있으면 False, 없으면 True | 625941d18c3a873295158549 |
def _handle_ami_connect(self, ami): <NEW_LINE> <INDENT> if (ami.id != 0): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> ami.registerEvent('Newstate', self._handle_new_state) <NEW_LINE> if AsteriskVersion() >= AsteriskVersion('12'): <NEW_LINE> <INDENT> ami.registerEvent('AttendedTransfer', self._handle_attended_transfe... | Handle AMI connect events | 625941d121bff66bcd684adf |
def khkhm(self): <NEW_LINE> <INDENT> self.orationes = [] <NEW_LINE> self.finder = [] | Clears the lists containing the names and statements of the politicians. | 625941d12c8b7c6e89b3594e |
def mergeTwoLists(self,L1,L2): <NEW_LINE> <INDENT> if not L1 and not L2: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> res=[] <NEW_LINE> q1,q2=L1.L2 <NEW_LINE> while q1: <NEW_LINE> <INDENT> res.append(q1) <NEW_LINE> q1=q1.next <NEW_LINE> <DEDENT> while q2: <NEW_LINE> <INDENT> res.append(q2) <NEW_LINE> q2=q2.next <NEW_... | :param L1:ListNode
:param L2: ListNode
:return: ListNode | 625941d1293b9510aa2c3423 |
@certificates.command(name='authorities') <NEW_LINE> def list_authorities(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> certs = client().certificates.get_authorities() <NEW_LINE> if not certs: <NEW_LINE> <INDENT> logger.info( 'ctl:cert:authorities', 'No certificate authorities found' ) <NEW_LINE> return <NEW_LINE> <D... | List all certificate authorities (CAs). | 625941d1e76e3b2f99f3a997 |
def get_roles_info(self, dbname): <NEW_LINE> <INDENT> db = self.client[dbname] <NEW_LINE> result = db.command({'rolesInfo': 1, 'showBuiltinRoles': True})['roles'] <NEW_LINE> roles_dict = {} <NEW_LINE> for elem in result: <NEW_LINE> <INDENT> roles_dict[elem['role']] = {} <NEW_LINE> for key, val in iteritems(elem): <NEW_... | Gather information about roles.
Args:
dbname (str): Database name to get role info from.
Returns a dictionary with role information for the given db. | 625941d191af0d3eaac9bba7 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> Borg.__init__(self) <NEW_LINE> secret_key = kwargs.get('secret_key', api.SECRET_KEY) <NEW_LINE> authorization = kwargs.get( 'authorization', api.HEADERS['Authorization'].format(secret_key)) <NEW_LINE> headers = dict(Authorization=authorization) <NEW_LINE> arguments = di... | Initialize Paystack with secret key. | 625941d1a8370b7717052a2c |
def copyFile(self, fromLocation, toLocation): <NEW_LINE> <INDENT> raise NotImplementedError | Copy a file from one location to another on the local filesystem.
It is not immediately obvious what the role of this fucntion for a sql storage is (although one can
think of examples, like copying an entire table within a database) and if it should be implemetned.
Requirements for this function are TBD, in the meanti... | 625941d130dc7b7665901af3 |
def fetch_url(url, ignore_errors=False, fetch_cache=fetch_cache, max_cacheable_size=1024, expected_content_type=None, opener=None, output_filename=None, post_data=None, timeout=10.0): <NEW_LINE> <INDENT> if not post_data and url in fetch_cache: <NEW_LINE> <INDENT> return fetch_cache[url] <NEW_LINE> <DEDENT> log.info("f... | Fetch given URL via HTTP
@param ignore_errors: if True, log but otherwise ignore errors, return None
@type ignore_errors: bool
@param fetch_cache: dictionary used as cache, with urls as keys and fetched
data as values
@type fetch_cache: dict
@param max_cacheable_size: max. size for responses to be cached
@type m... | 625941d1e1aae11d1e749e45 |
def _deliver_first_month_supply(self, supply: MonthSupply, major_airfields: dict, minor_airfields: dict): <NEW_LINE> <INDENT> while supply.has_aircrafts: <NEW_LINE> <INDENT> aircrafts = supply.remain_aircrafts <NEW_LINE> aircraft_name = random.choice(aircrafts) <NEW_LINE> squadron_size = self.squadron_sizes_names[aircr... | Распределить месячную поставку по тыловым аэродромам с учётом приоритета | 625941d1adb09d7d5db6c91d |
def patch(self, request, pk=None): <NEW_LINE> <INDENT> return Response({'method': 'PATCH'}) | handle updating partly | 625941d14d74a7450ccd4351 |
def addHost(self, hostname, arches, krb_principal=None, force=False): <NEW_LINE> <INDENT> context.session.assertPerm('host') <NEW_LINE> arches = " ".join(arches) <NEW_LINE> arches = koji.parse_arches(arches, strict=True) <NEW_LINE> if get_host(hostname): <NEW_LINE> <INDENT> raise koji.GenericError('host already exists:... | Add a builder host to the database.
:param str hostname: name for the host entry (fqdn recommended).
:param list arches: list of architectures this builder supports.
:param str krb_principal: (optional) a non-default kerberos principal
for the host.
:param bool force: override user type
:retu... | 625941d18a43f66fc4b541f2 |
def upset(self): <NEW_LINE> <INDENT> heap = [(self.index, self)] <NEW_LINE> push, pop = heapq.heappush, heapq.heappop <NEW_LINE> seen = -1 <NEW_LINE> while heap: <NEW_LINE> <INDENT> index, concept = pop(heap) <NEW_LINE> if index > seen: <NEW_LINE> <INDENT> seen = index <NEW_LINE> yield concept <NEW_LINE> for c in conce... | Yield implied concepts including ``self``. | 625941d1711fe17d825424f8 |
def get_gc10(self): <NEW_LINE> <INDENT> return self.__get_generic(GenotypeCalls.__ID_GC10, read_float) | Returns:
float: the GC10 (GenCall score - 10th percentile) | 625941d1dc8b845886cb56c3 |
def remove(self, item): <NEW_LINE> <INDENT> row = self.row(item) <NEW_LINE> self.takeItem(row) <NEW_LINE> self._items.remove(item) <NEW_LINE> del item | Removes item from ListWidget and deletes it. If you want to keep it use pop(item). | 625941d160cbc95b062c66d1 |
def subsample(inputs, factor, scope=None): <NEW_LINE> <INDENT> if factor == 1: <NEW_LINE> <INDENT> return inputs <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return max_pool1d(inputs, 1, stride=factor, scope=scope) | Subsamples the input along the spatial dimensions. | 625941d129b78933be1e5838 |
def get_db(): <NEW_LINE> <INDENT> if 'db' not in g: <NEW_LINE> <INDENT> print(str(os.environ)) <NEW_LINE> db_path = os.environ.get('DATABASE', APP.config.get('DATABASE', 'example.db')) <NEW_LINE> print("DB STAT: " + str(os.stat(db_path))) <NEW_LINE> print("Dtabase: " + str(db_path)) <NEW_LINE> g.db = sqlite3.connect(db... | Returns the cached database connection | 625941d14a966d76dd55119e |
def with_message(self, message): <NEW_LINE> <INDENT> self.set_message(message) <NEW_LINE> return self | 検索するメッセージテキスト文字列(部分一致)を設定
:param message: 検索するメッセージテキスト文字列(部分一致)
:type message: unicode
:return: this
:rtype: SearchLogByRoomRequest | 625941d1c432627299f04dd4 |
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_BRIDGE_SLAVE, indirect=['patch_ansible_module']) <NEW_LINE> def test_create_bridge_slave(mocked_generic_connection_create, capfd): <NEW_LINE> <INDENT> with pytest.raises(SystemExit): <NEW_LINE> <INDENT> nmcli.main() <NEW_LINE> <DEDENT> assert nmcli.Nmcli.execute... | Test if Bridge_slave created | 625941d10a366e3fb873e9a9 |
def add_basedir_options(parser): <NEW_LINE> <INDENT> parser.add_argument('--playbook-dir', default=None, dest='basedir', action='store', help="Since this tool does not use playbooks, use this as a substitute playbook directory." "This sets the relative path for many features including roles/ group_vars/ etc.") | Add options for commands which can set a playbook basedir | 625941d126238365f5f0effd |
def adadelta(lr, tparams, grads, x, y, cost): <NEW_LINE> <INDENT> zipped_grads = [theano.shared(p.get_value() * numpy_floatX(0.), name='%s_grad' % k) for k, p in tparams.items()] <NEW_LINE> running_up2 = [theano.shared(p.get_value() * numpy_floatX(0.), name='%s_rup2' % k) for k, p in tparams.items()] <NEW_LINE> running... | An adaptive learning rate optimizer
Parameters
----------
lr : Theano SharedVariable
Initial learning rate
tpramas: Theano SharedVariable
Model parameters
grads: Theano variable
Gradients of cost w.r.t to parameres
x: Theano variable
Model inputs
mask: Theano variable
Sequence mask
y: Theano variab... | 625941d1d6c5a102081441d9 |
def add_word(self, word, meta=None): <NEW_LINE> <INDENT> self._add(self.root, word, 0, meta) | Public interface used to add words to the suffice tree. | 625941d199fddb7c1c9de51e |
def connect_to_library(self, library=None): <NEW_LINE> <INDENT> logger.debug("Load uc480 library..") <NEW_LINE> if library is None: <NEW_LINE> <INDENT> if _linux: <NEW_LINE> <INDENT> self._lib = ctypes.cdll.LoadLibrary("libueye_api.so") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if (platform.architecture()[0] == "32... | Establish connection to uc480 library depending on operating system and version. If no library name is given (default), the function looks for
- **uc480.dll** on Win32
- **uc480_64.dll** on Win64
- **libueye_api.so** on Linux (check this, but appeared to be for v4.91)
:param str library: If not None, try ... | 625941d199fddb7c1c9de51f |
def set_capture_rate(self, capture_rate=0.95): <NEW_LINE> <INDENT> if 0 < capture_rate < 1: <NEW_LINE> <INDENT> self._capture_rate = capture_rate <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('ERROR:', self.__name__, 'given unrealistic capture rate.') <NEW_LINE> <DEDENT> return None | Set the percent solids capture for the final clarifier.
This function is valid only when the "final_clarifier" is treated as a perfect solids-liquid separation
without actual modeling of the settling process (for simplicity purpose at this stage).
Future update of PooPyLab will include... | 625941d1925a0f43d254a006 |
def update(path,value,timestamp=None): <NEW_LINE> <INDENT> value = float(value) <NEW_LINE> fh = open(path,'r+b') <NEW_LINE> if LOCK: fcntl.flock( fh.fileno(), fcntl.LOCK_EX ) <NEW_LINE> header = __readHeader(fh) <NEW_LINE> now = int( time.time() ) <NEW_LINE> if timestamp is None: timestamp = now <NEW_LINE> timestamp = ... | update(path,value,timestamp=None)
path is a string
value is a float
timestamp is either an int or float | 625941d18a349b6b435e8301 |
def handle_requests_ConnectionError(fn, retry=0, min_wait=1, max_wait=3): <NEW_LINE> <INDENT> def wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> res = fn(self, *args, **kwargs) <NEW_LINE> return res <NEW_LINE> <DEDENT> except requests.exceptions.ConnectionError: <NEW_LINE> <INDENT> wait_ti... | Decorates the function to prevent raising requests.exceptions.ConnectionError error. | 625941d176d4e153a657ecbf |
def import_manifest(org=None, filepath=None, deleted=True): <NEW_LINE> <INDENT> if org is None: <NEW_LINE> <INDENT> org = create_org() <NEW_LINE> <DEDENT> if filepath is None: <NEW_LINE> <INDENT> filepath = MANIFEST_URL <NEW_LINE> <DEDENT> cmd = ('provider import_manifest create --name "{0}" --org {1} ' '--file "{2}"')... | Imports a manifest
If delete is set to False, the manifest will not be deleted and the user
has to handle the deletion manually or by calling delete_manifest | 625941d130bbd722463cbf54 |
def save(path, fignum=None, close=True, width=None, height=None, ext=None, dpi=None, verbose=False): <NEW_LINE> <INDENT> if fignum is not None: <NEW_LINE> <INDENT> fig = plt.figure(fignum) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> fig = plt.gcf() <NEW_LINE> <DEDENT> if width: <NEW_LINE> <INDENT> fig.set_figwidth(wi... | Save a figure from pyplot.
Parameters:
path [string] : The path (and filename, without the extension) to
save the figure to.
fignum [integer] : The id of the figure to save. If None, saves the
current figure.
close [boolean] : (default=True) Whether to close the figure after
saving. If you want to save the figure ... | 625941d16e29344779a6279f |
def test_index_view_with_a_future_question(self): <NEW_LINE> <INDENT> create_question(question_text="Future question.", days=30) <NEW_LINE> response = self.client.get(reverse('polls:index')) <NEW_LINE> self.assertContains(response, "No polls available", status_code=200) <NEW_LINE> self.assertQuerysetEqual(response.cont... | Questions with a pub_date in the future should not be displayed on
the index page. | 625941d14e4d5625662d4565 |
def load_environment(global_conf, app_conf): <NEW_LINE> <INDENT> root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) <NEW_LINE> paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) <NEW_LINE> config.... | Configure the Pylons environment via the ``pylons.config``
object | 625941d13539df3088e2e4d9 |
def marginal_coalitions(player, order): <NEW_LINE> <INDENT> pos_player = order.index(player) <NEW_LINE> return set(order[:pos_player]), set(order[:pos_player + 1]) | :param player:
:type player: str
:param order:
:type order: list
:return:
:rtype (set, set) | 625941d1ac7a0e7691ed4259 |
def is_clicked(self): <NEW_LINE> <INDENT> mouse_click_position = Settings.mouse_click_position <NEW_LINE> if (mouse_click_position != None and mouse_click_position[0] >= self.box[0][0] and mouse_click_position[0] <= self.box[1][0] and mouse_click_position[1] >= self.box[0][1] and ... | :return: | 625941d1be383301e01b5612 |
def add_model_error(self, model, A, PSDdata): <NEW_LINE> <INDENT> Lgrid = model.Lgrid <NEW_LINE> dL = Lgrid[1]-Lgrid[0] <NEW_LINE> nens = int(self.Nens) <NEW_LINE> radius = dL*0.9 <NEW_LINE> radius = 1 <NEW_LINE> erridx = np.array([],dtype=int) <NEW_LINE> for Lval in PSDdata['Lstar']: <NEW_LINE> <INDENT> Lidx = np.wher... | this routine will add a standard error to the ensemble states
Parameters
==========
model :
A :
PSDdata :
Returns
=======
out :
Examples
======== | 625941d121bff66bcd684ae0 |
def mask_dsm(self): <NEW_LINE> <INDENT> ul, lr = self.get_upper_left_lower_right() <NEW_LINE> t = self.dsm.transform <NEW_LINE> shifted_affine = Affine(t.a, t.b, t.c + ul[1] * t.a, t.d, t.e, t.f + lr[0] * t.e) <NEW_LINE> mask = rasterio.features.rasterize( [(self.footprint, 0)], out_shape=self.dsm_data.shape, transform... | Create a mask of the dsm pixels touching the footprint by rasterizing the footprint values and masking the part
of the raster data that overlaps with the feature | 625941d199cbb53fe6792d74 |
def create_pool(self, name, disks, raid='Stripe', force="false", options=[]): <NEW_LINE> <INDENT> if not self.name_validator(name, 'pool') == 'valid': <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> cmd = [self.zpool, 'create'] <NEW_LINE> if force: <NEW_LINE> <INDENT> cmd.append('-f') <NEW_LINE> <DEDENT> if not op... | Create zpool, syntax:
zpool create <name> <raid> disks/partitions
:name: str
:disks: [list]
:raid: str
:options: [list{dict}] | 625941d1566aa707497f46f5 |
def create_light_msg(light_name, type="POINT", pose=Pose(), diffuse=ColorRGBA(0.5, 0.5, 0.5, 1.0), specular=ColorRGBA(0.1, 0.1, 0.1, 1.0), attenuation_constant=0.5, attenuation_linear=0.01, attenuation_quadratic=0.001, direction=Vector3(), range=5.0, cast_shadows=True, spot_inner_angle=0.0, spot_outer_angle=0.0, spot_f... | Creates a gazebo_ros_light/LightState message with the params provided.
:param light_name: string name of the light
:param type: string representing type of light: POINT | SPOT | DIRECTIONAL
:param pose: geometry_msgs/Pose desired pose in the reference frame of the world
:param diffuse: std_msgs/ColorRGBA with the diff... | 625941d166656f66f7cbc339 |
def get_service_type(self): <NEW_LINE> <INDENT> return self.service_type | :param data:
:return: | 625941d11f5feb6acb0c4cde |
def MetadataHasXlaOp(run_metadata): <NEW_LINE> <INDENT> return InLabels(RunMetadataLabels(run_metadata), "XlaRun") | Returns true if there are XlaRun kernels in run_metadata's timeline. | 625941d17d847024c06be44b |
def testCalendarByFullURL(self): <NEW_LINE> <INDENT> mycal = self._fixCalendar() <NEW_LINE> samecal = self.caldav.principal().calendar(cal_id=str(mycal.url)) <NEW_LINE> assert_equal(mycal.url, samecal.url) <NEW_LINE> samecal = self.caldav.principal().calendar(cal_id=mycal.url) <NEW_LINE> assert_equal(mycal.url, samecal... | ref private email, passing a full URL as cal_id works in 0.5.0 but
is broken in 0.8.0 | 625941d1d268445f265b4ffc |
def test_process_after_submission_no_delete(self): <NEW_LINE> <INDENT> self.submitter.remove_messages = False <NEW_LINE> mock_message = MockMessage( body='{{"tin": "{tin}", "npi": "{npi}"}}'.format(tin='tax_num', npi='npi_num')) <NEW_LINE> mock_provider_processed = { 'tin': 'tax_num', 'npi': 'npi_num', 'message': mock_... | Remove message after submission. | 625941d10383005118ecf770 |
def minor(): <NEW_LINE> <INDENT> import sys <NEW_LINE> p = sys.path <NEW_LINE> print(p[0]) <NEW_LINE> from base.basic_functions import get_html <NEW_LINE> print(get_html) | run in the upper folder:
python -m py_learn.arbitrary_importing | 625941d129b78933be1e5839 |
def build(self, layers_configuration): <NEW_LINE> <INDENT> self.neural_network.build(layers_configuration) <NEW_LINE> return self | Build the neural network
:param layers_configuration:
:return: | 625941d1236d856c2ad4496a |
def __init__(__self__, *, restriction_type: pulumi.Input[str], locations: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None): <NEW_LINE> <INDENT> pulumi.set(__self__, "restriction_type", restriction_type) <NEW_LINE> if locations is not None: <NEW_LINE> <INDENT> pulumi.set(__self__, "locations", locations) | :param pulumi.Input[str] restriction_type: The method that you want to use to restrict
distribution of your content by country: `none`, `whitelist`, or
`blacklist`.
:param pulumi.Input[Sequence[pulumi.Input[str]]] locations: The [ISO 3166-1-alpha-2 codes][4] for which you
want CloudFront either to ... | 625941d16e29344779a627a0 |
def f_unc(x, A, center, width, offset): <NEW_LINE> <INDENT> return A / ((x - center)**2 + (width/2)**2) | similar to the raw function call, but uses unp instead of np for uncertainties calculations.
:return: | 625941d1796e427e537b0755 |
def test_route_page_error(client): <NEW_LINE> <INDENT> response = client.get('/error', follow_redirects=True) <NEW_LINE> assert response.status_code == 500 <NEW_LINE> assert b'Internal Error' in response.data | Test the client loads the 500 page | 625941d1e64d504609d749ce |
def test_run_attach_detach_volume_for_instance(self): <NEW_LINE> <INDENT> mountpoint = "/dev/sdf" <NEW_LINE> instance_uuid = '12345678-1234-5678-1234-567812345678' <NEW_LINE> volume = tests_utils.create_volume(self.context, admin_metadata={'readonly': 'True'}, **self.volume_params) <NEW_LINE> volume_id = volume['id'] <... | Make sure volume can be attached and detached from instance. | 625941d13c8af77a43ae392f |
def p_op(p): <NEW_LINE> <INDENT> p[0] = p[1] | op : LT
| LE
| GT
| GE
| EQ
| NE | 625941d197e22403b379d128 |
def delete(self, folder_id): <NEW_LINE> <INDENT> self._client.delete('folders/%(folder_id)s', {'folder_id': folder_id}) <NEW_LINE> return True | Delete the folder.
:param folder_id: The folder ID.
:raise TenableIOApiException: When API error is encountered.
:return: True if successful. | 625941d163f4b57ef00012a6 |
def create_section(self, name, type_="undefined", oid=None): <NEW_LINE> <INDENT> if name in self.sections: <NEW_LINE> <INDENT> raise DuplicateName("create_section") <NEW_LINE> <DEDENT> sec = Section.create_new(self, self, self._metadata, name, type_, oid) <NEW_LINE> return sec | Create a new metadata section inside the file.
:param name: The name of the section to create.
:type name: str
:param type_: The type of the section.
:type type_: str
:param oid: object id, UUID string as specified in RFC 4122. If no id
is provided, an id will be generated and assigned.
:type oid: str
:re... | 625941d10a50d4780f667021 |
def solution(X, Y, D): <NEW_LINE> <INDENT> if (Y-X)%D == 0: <NEW_LINE> <INDENT> return int((Y-X)/D) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return int((Y-X)/D+1) | X+D*n >= Y
D*n >= Y-X
n >= (Y-X)/D | 625941d115fb5d323cde0c9f |
def setFilterFunc(self, func): <NEW_LINE> <INDENT> filter_proxy = self.view().model() <NEW_LINE> filter_proxy.setFilterFunc(func) | Set a filtering function. | 625941d16fb2d068a760f22d |
def assertExpectedProblemsReported(self, testcase): <NEW_LINE> <INDENT> for problem_class in self._expect_classes: <NEW_LINE> <INDENT> testcase.assert_(self.CheckReported(problem_class)) | Asserts that every expected problem class has been reported.
The assertions are done using the assert_ method of the testcase.
Args:
testcase: The unittest.TestCase instance. | 625941d1a8370b7717052a2d |
def assign_points_to_clusters(dist_matrix, medoids): <NEW_LINE> <INDENT> medoids = np.array(medoids) <NEW_LINE> distances_to_medoids = dist_matrix[:, medoids] <NEW_LINE> clusters = medoids[np.argmin(distances_to_medoids, axis=1)] <NEW_LINE> clusters[medoids] = medoids <NEW_LINE> return clusters | Assign each point to cluster with closest medoid.
:param dist_matrix
:param medoids: IDs of medoids
:return: | 625941d1596a897236089c4e |
def __ne__(self, other): <NEW_LINE> <INDENT> return not self.__eq__(other) | Inequality is simply the opposite of equality. | 625941d12eb69b55b151ca3f |
def mosaicSameDay(collection, qualityBand=None): <NEW_LINE> <INDENT> all_dates = collection.aggregate_array('system:time_start') <NEW_LINE> def overdates(d, l): <NEW_LINE> <INDENT> l = ee.List(l) <NEW_LINE> date = ee.Date(d) <NEW_LINE> day = date.get('day') <NEW_LINE> month = date.get('month') <NEW_LINE> year = date.ge... | Return a collection where images from the same day are mosaicked
:param qualityBand: the band that holds the quality score for mosaiking.
If None it will use the simplier mosaic() function
:type qualityBand: str
:return: a new image collection with 1 image per day. The only property
kept is `system:time_start`... | 625941d163b5f9789fde7274 |
def accept_charsets(self): <NEW_LINE> <INDENT> if not 'HTTP_ACCEPT_CHARSET' in self.environ: <NEW_LINE> <INDENT> return Accept(None) <NEW_LINE> <DEDENT> return parse_accept_header(self.environ['HTTP_ACCEPT_CHARSET']) | list of charsets this client supports. | 625941d1fbf16365ca6f6355 |
def CF_Gxyz_TIR_square_ubibi(parms, tau, gAAz=CF_gz_AA, gACz=CF_gz_AC, gCCz=CF_gz_CC, gxy=CF_gxy_square): <NEW_LINE> <INDENT> D_3D = parms[0] <NEW_LINE> D_2D = parms[1] <NEW_LINE> sigma = parms[2] <NEW_LINE> a = parms[3] <NEW_LINE> kappa = 1/parms[4] <NEW_LINE> Conc_3D = parms[5] <NEW_LINE> Conc_2D = parms[6] <NEW_LINE... | Two-component two- and three-dimensional diffusion
with a square-shaped lateral detection area taking into account
the size of the point spread function; and an exponential
decaying profile in axial direction. This model covers binding
and unbinding kintetics.
*parms* - a list of parameters.
Parameters (parms[i]):
[0... | 625941d1c432627299f04dd5 |
def sa_zope_wrapper(self): <NEW_LINE> <INDENT> wrapper = self._supply_z3c_sa_wrapper() <NEW_LINE> if wrapper is not None: <NEW_LINE> <INDENT> return wrapper <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> selftype = type(self) <NEW_LINE> try: <NEW_LINE> <INDENT> dsn = 'nonempty' if self.dsn else self.dsn <NEW_LINE> <DEDE... | Public API for accessing the underlying z3c.sqlalchemy `ZopeWrapper`.
The first attempt will be to lookup the wrapper via attributes
accessible in the Zope context (self.util_id); if it does not exist,
the wrapper will be created and return.
If Zope acquisition context has been lost, fall back to the module
dict regi... | 625941d14428ac0f6e5ba981 |
def match(self, cfn): <NEW_LINE> <INDENT> matches = list() <NEW_LINE> ref_conditions = list() <NEW_LINE> conditions = cfn.template.get('Conditions', {}) <NEW_LINE> if conditions: <NEW_LINE> <INDENT> iftrees = cfn.search_deep_keys('Fn::If') <NEW_LINE> for iftree in iftrees: <NEW_LINE> <INDENT> if isinstance(iftree[-1], ... | Check CloudFormation Conditions | 625941d1ab23a570cc250311 |
def get(self, bounce_id, api_key=None, secure=None, test=None, **request_args): <NEW_LINE> <INDENT> url = self._get_api_url(secure=secure, bounce_id=bounce_id) <NEW_LINE> headers = self._get_headers(api_key=api_key, test=test, request_args=request_args) <NEW_LINE> return self._request(url, headers=headers, **request_ar... | Retrieves a single bounce's data.
:param bounce_id: A bounce's ID retrieved with :class:`Bounces`.
:param api_key: Your Postmark API key. Defaults to `self.api_key`.
:param secure: Use the https scheme for Postmark API.
Defaults to `self.secure`.
:param test: Make a test request to the Postmark API.
Defaults t... | 625941d1711fe17d825424f9 |
def _get_latex_repr(self) -> str: <NEW_LINE> <INDENT> return '$PL = {0} \\log_{{10}} (d) + {1}$'.format( 10 * self._n, self._C) | Get the Latex representation (equation) for the PathLossGeneral
class.
The general equation is given by
.. math::
PL = 10 n \log_{10} (d) + C
Returns
-------
str
The Latex representation of the path loss object. | 625941d15fcc89381b1e184e |
def sine(w: float, A: float = 1, phi: float = 0, offset: float = 0) -> "partial[Callable[[], None]]": <NEW_LINE> <INDENT> from math import sin <NEW_LINE> def f(i: float) -> float: <NEW_LINE> <INDENT> return A * sin(w*i + phi) + offset <NEW_LINE> <DEDENT> return partial(force, sequence=_advance(f)) | Return a driver function that can advance a sequence of sine values.
.. code-block:: none
value = A * sin(w*i + phi) + offset
Args:
w (float) : a frequency for the sine driver
A (float) : an amplitude for the sine driver
phi (float) : a phase offset to start the sine driver with
offset (float) : ... | 625941d116aa5153ce362606 |
def update_usage(self): <NEW_LINE> <INDENT> for grp in self.groups.active_groups(): <NEW_LINE> <INDENT> jobs = self.queue.match_jobs({'group': grp.name, 'state': RUNNING}) <NEW_LINE> grp.usage = sum(self.slotweight(x) for x in jobs) <NEW_LINE> <DEDENT> for group in self.groups: <NEW_LINE> <INDENT> if group.children: <N... | Update each group's usage by counting running jobs on the farm,
each non-leaf group has it's usage set by summing it's children | 625941d116aa5153ce362607 |
def test_cx(self): <NEW_LINE> <INDENT> mat = make_densop_matrix(VECTORS_4, PROBS_4) <NEW_LINE> actual = DensOp(matrix=mat).cx(0,1) <NEW_LINE> qstate = [QState(vector=vec) for vec in VECTORS_4] <NEW_LINE> [qs.cx(0,1) for qs in qstate] <NEW_LINE> expect = DensOp(qstate=qstate, prob=PROBS_4) <NEW_LINE> ans = equal_densops... | test 'cx' gate
| 625941d1ec188e330fd5a92c |
def inc_indent(self): <NEW_LINE> <INDENT> self.indent = self.indent + B"\t" | Increase the current line indent. | 625941d1498bea3a759b9c3d |
def clear(self): <NEW_LINE> <INDENT> self._tqdm_bars.pop() | Remove the tqdm pbar from the update. | 625941d1b57a9660fec33a13 |
def test_print_lj_types(self): <NEW_LINE> <INDENT> act = PT.printLJTypes(gasparm, '@1') <NEW_LINE> for line in str(act).split('\n'): <NEW_LINE> <INDENT> if not line.startswith('ATOM'): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> words = line.split() <NEW_LINE> self.assertTrue(words[2].startswith('N')) <NEW_LINE> s... | Test printLJTypes on AmberParm | 625941d1498bea3a759b9c3e |
def get_indices_of_papers(metrics): <NEW_LINE> <INDENT> year_h, h, g, tori, i10, read10, i100 = [], [], [], [], [], [], [] <NEW_LINE> y = list(metrics['time series']['h'].keys()) <NEW_LINE> y.sort() <NEW_LINE> for i in range(len(y)): <NEW_LINE> <INDENT> k = y[i] <NEW_LINE> h.append(metrics['time series']['h'][k]) <NEW_... | Convert the metrics into a format that is easier to work with. Year-ordered
numpy arrays. | 625941d197e22403b379d129 |
def task_count(self) -> int: <NEW_LINE> <INDENT> return len(self._tasks) | :return: Number of tasks currently present in the registry. | 625941d18e7ae83300e4b15c |
def cache_items(self, system, base_block_ids, course_key, depth=0, lazy=True): <NEW_LINE> <INDENT> with self.bulk_operations(course_key): <NEW_LINE> <INDENT> new_module_data = {} <NEW_LINE> for block_id in base_block_ids: <NEW_LINE> <INDENT> new_module_data = self.descendants( system.course_entry.structure['blocks'], b... | Handles caching of items once inheritance and any other one time
per course per fetch operations are done.
Arguments:
system: a CachingDescriptorSystem
base_block_ids: list of BlockIds to fetch
course_key: the destination course providing the context
depth: how deep below these to prefetch
lazy: wh... | 625941d13617ad0b5ed68086 |
def types(self): <NEW_LINE> <INDENT> types = [] <NEW_LINE> for implementation in self.instance_type.implementations: <NEW_LINE> <INDENT> if implementation.constraint is not None: <NEW_LINE> <INDENT> types.extend(implementation.constraint.types()) <NEW_LINE> <DEDENT> <DEDENT> return types | @see DynamicStatement#types | 625941d15fc7496912cc3b0d |
def collect_keyword_dowhile(self, tokens, index): <NEW_LINE> <INDENT> token = tokens[index] <NEW_LINE> rhs1 = self.consume_block(tokens, index) <NEW_LINE> rhs2 = self.consume_keyword(tokens, token, index, 1) <NEW_LINE> rhs3 = self.consume(tokens, token, index, 1) <NEW_LINE> if rhs2.type != Token.T_KEYWORD or rhs2.value... | The resulting token has the form
Token<T_DOWHILE, _>
Token<..., body>
Token<..., test> | 625941d15fcc89381b1e184f |
def make_instance(self, include_optional): <NEW_LINE> <INDENT> if include_optional : <NEW_LINE> <INDENT> return RollbackDeductedLoyaltyPointsEffectProps( program_id = 56, sub_ledger_id = '0', value = 1.337, recipient_integration_id = '0', start_date = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M... | Test RollbackDeductedLoyaltyPointsEffectProps
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | 625941d17d43ff24873a2e30 |
def patches(self): <NEW_LINE> <INDENT> result={} <NEW_LINE> if "boundary" in self: <NEW_LINE> <INDENT> for k,d in zip(self["boundary"][0::2],self["boundary"][1::2]): <NEW_LINE> <INDENT> result[k]=[list(map(int,x)) for x in d["faces"]] <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> for i in range(1,len(self["pat... | Returns a dictionary with lists of 4-tuples that define each patch | 625941d123e79379d52ee6f2 |
def push(self, x): <NEW_LINE> <INDENT> if not self.stack: <NEW_LINE> <INDENT> self.stack.append(0) <NEW_LINE> self.min = x <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.stack.append(x - self.min) <NEW_LINE> if x < self.min: <NEW_LINE> <INDENT> self.min = x | :type x: int
:rtype: nothing | 625941d1b545ff76a8913fa5 |
def clone_fragment(self, frag, **kwargs): <NEW_LINE> <INDENT> return self._perform_query(_interface, 'clone_fragment', ForegroundRequired, frag, **kwargs) | :param frag: the fragment (and subfragments) to clone
:param kwargs: suffix (default: ' (copy)', applied to Name of top-level fragment only)
comment (override existing Comment if present; applied to all)
:return: | 625941d13eb6a72ae02ec66f |
def E(m, i, j): <NEW_LINE> <INDENT> temp = np.zeros((m, m)) <NEW_LINE> temp[i, j] = 1.0 <NEW_LINE> return temp | Returns an m by m matrix with a 1 in
the ith row, jth column. | 625941d1ec188e330fd5a92d |
def log(self, msg): <NEW_LINE> <INDENT> if msg: <NEW_LINE> <INDENT> self.cache.append(msg) | Log the message. | 625941d145492302aab5e453 |
def run(user_config_file, preview): <NEW_LINE> <INDENT> params = plot.parameter.update(user_config_file) <NEW_LINE> if len(params.keys()) == 0: <NEW_LINE> <INDENT> raise Exception( "ERROR HINT: invalid input " "configuration file {}".format(user_config_file) ) <NEW_LINE> exit() <NEW_LINE> <DEDENT> plot.work(params) <NE... | Read input and start working
Args:
user_config_file (str): file name of user configuration file
preview (bool): whether to show the preview window
Returns:
True of succeeds | 625941d1d268445f265b4ffd |
def t_TEXT(t): <NEW_LINE> <INDENT> t.value = ('TEXT', t.value) <NEW_LINE> return t | (?:(?:\\%)|(?:[^%\\]+)|(?:\\[^%])|(%[^%])|(?:%%[^\\@]))+ | 625941d15e10d32532c5f0b6 |
def undump_instance(self): <NEW_LINE> <INDENT> LOG.debug(_('Restoring action scripts from archive: %s') % self.dumpdir_tarfile) <NEW_LINE> self.untar_dumpdir() <NEW_LINE> LOG.debug(_('Restoring action scripts for %s') % self.instance['id']) <NEW_LINE> self.restore_action_scripts() <NEW_LINE> if self.unprivileged_user: ... | Take the pieces of a dump archive and put them back in place. | 625941d1a219f33f34628af8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.