sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def from_file(filename): """ load an nparray object from a json filename @parameter str filename: path to the file """ f = open(filename, 'r') j = json.load(f) f.close() return from_dict(j)
load an nparray object from a json filename @parameter str filename: path to the file
entailment
def monkeypatch(): """ monkeypath built-in numpy functions to call those provided by nparray instead. """ np.array = array np.arange = arange np.linspace = linspace np.logspace = logspace np.geomspace = geomspace np.full = full np.full_like = full_like np.zeros = zeros np...
monkeypath built-in numpy functions to call those provided by nparray instead.
entailment
def init_passbands(refresh=False): """ This function should be called only once, at import time. It traverses the passbands directory and builds a lookup table of passband names qualified as 'pbset:pbname' and corresponding files and atmosphere content within. """ global _initialized if...
This function should be called only once, at import time. It traverses the passbands directory and builds a lookup table of passband names qualified as 'pbset:pbname' and corresponding files and atmosphere content within.
entailment
def install_passband(fname, local=True): """ Install a passband from a local file. This simply copies the file into the install path - but beware that clearing the installation will clear the passband as well If local=False, you must have permissions to access the installation directory """ ...
Install a passband from a local file. This simply copies the file into the install path - but beware that clearing the installation will clear the passband as well If local=False, you must have permissions to access the installation directory
entailment
def uninstall_all_passbands(local=True): """ Uninstall all passbands, either globally or locally (need to call twice to delete ALL passbands) If local=False, you must have permission to access the installation directory """ pbdir = _pbdir_local if local else _pbdir_global for f in os.listdi...
Uninstall all passbands, either globally or locally (need to call twice to delete ALL passbands) If local=False, you must have permission to access the installation directory
entailment
def download_passband(passband, local=True): """ Download and install a given passband from the repository. If local=False, you must have permission to access the installation directory """ if passband not in list_online_passbands(): raise ValueError("passband '{}' not available".format(pas...
Download and install a given passband from the repository. If local=False, you must have permission to access the installation directory
entailment
def Inorm_bol_bb(Teff=5772., logg=4.43, abun=0.0, atm='blackbody', photon_weighted=False): """ @Teff: value or array of effective temperatures @logg: surface gravity; not used, for class compatibility only @abun: abundances; not used, for class compatibility only @atm: atmosphere model, must be blac...
@Teff: value or array of effective temperatures @logg: surface gravity; not used, for class compatibility only @abun: abundances; not used, for class compatibility only @atm: atmosphere model, must be blackbody, otherwise exception is raised @photon_weighted: intensity weighting scheme; must be False, o...
entailment
def _planck(self, lam, Teff): """ Computes monochromatic blackbody intensity in W/m^3 using the Planck function. @lam: wavelength in m @Teff: effective temperature in K Returns: monochromatic blackbody intensity """ return 2*self.h*self.c*self.c/lam**5 ...
Computes monochromatic blackbody intensity in W/m^3 using the Planck function. @lam: wavelength in m @Teff: effective temperature in K Returns: monochromatic blackbody intensity
entailment
def _planck_deriv(self, lam, Teff): """ Computes the derivative of the monochromatic blackbody intensity using the Planck function. @lam: wavelength in m @Teff: effective temperature in K Returns: the derivative of monochromatic blackbody intensity """ ...
Computes the derivative of the monochromatic blackbody intensity using the Planck function. @lam: wavelength in m @Teff: effective temperature in K Returns: the derivative of monochromatic blackbody intensity
entailment
def _planck_spi(self, lam, Teff): """ Computes the spectral index of the monochromatic blackbody intensity using the Planck function. The spectral index is defined as: B(lambda) = 5 + d(log I)/d(log lambda), where I is the Planck function. @lam: wavelength in m ...
Computes the spectral index of the monochromatic blackbody intensity using the Planck function. The spectral index is defined as: B(lambda) = 5 + d(log I)/d(log lambda), where I is the Planck function. @lam: wavelength in m @Teff: effective temperature in K Return...
entailment
def _bb_intensity(self, Teff, photon_weighted=False): """ Computes mean passband intensity using blackbody atmosphere: I_pb^E = \int_\lambda I(\lambda) P(\lambda) d\lambda / \int_\lambda P(\lambda) d\lambda I_pb^P = \int_\lambda \lambda I(\lambda) P(\lambda) d\lambda / \int_\lambda \lam...
Computes mean passband intensity using blackbody atmosphere: I_pb^E = \int_\lambda I(\lambda) P(\lambda) d\lambda / \int_\lambda P(\lambda) d\lambda I_pb^P = \int_\lambda \lambda I(\lambda) P(\lambda) d\lambda / \int_\lambda \lambda P(\lambda) d\lambda Superscripts E and P stand for energy and...
entailment
def _bindex_blackbody(self, Teff, photon_weighted=False): """ Computes the mean boosting index using blackbody atmosphere: B_pb^E = \int_\lambda I(\lambda) P(\lambda) B(\lambda) d\lambda / \int_\lambda I(\lambda) P(\lambda) d\lambda B_pb^P = \int_\lambda \lambda I(\lambda) P(\lambda) B(...
Computes the mean boosting index using blackbody atmosphere: B_pb^E = \int_\lambda I(\lambda) P(\lambda) B(\lambda) d\lambda / \int_\lambda I(\lambda) P(\lambda) d\lambda B_pb^P = \int_\lambda \lambda I(\lambda) P(\lambda) B(\lambda) d\lambda / \int_\lambda \lambda I(\lambda) P(\lambda) d\lambda ...
entailment
def compute_blackbody_response(self, Teffs=None): """ Computes blackbody intensities across the entire range of effective temperatures. It does this for two regimes, energy-weighted and photon-weighted. It then fits a cubic spline to the log(I)-Teff values and exports the interpo...
Computes blackbody intensities across the entire range of effective temperatures. It does this for two regimes, energy-weighted and photon-weighted. It then fits a cubic spline to the log(I)-Teff values and exports the interpolation functions _log10_Inorm_bb_energy and _log10_Inorm_bb_ph...
entailment
def compute_ck2004_response(self, path, verbose=False): """ Computes Castelli & Kurucz (2004) intensities across the entire range of model atmospheres. @path: path to the directory containing ck2004 SEDs @verbose: switch to determine whether computing progress should be ...
Computes Castelli & Kurucz (2004) intensities across the entire range of model atmospheres. @path: path to the directory containing ck2004 SEDs @verbose: switch to determine whether computing progress should be printed on screen Returns: n/a
entailment
def compute_ck2004_intensities(self, path, particular=None, verbose=False): """ Computes direction-dependent passband intensities using Castelli & Kurucz (2004) model atmospheres. @path: path to the directory with SEDs @particular: particular file in @path to be processed; if No...
Computes direction-dependent passband intensities using Castelli & Kurucz (2004) model atmospheres. @path: path to the directory with SEDs @particular: particular file in @path to be processed; if None, all files in the directory are processed. @verbose: set to True...
entailment
def export_legacy_ldcoeffs(self, models, filename=None, photon_weighted=True): """ @models: the path (including the filename) of legacy's models.list @filename: output filename for storing the table Exports CK2004 limb darkening coefficients to a PHOEBE legacy compatible format....
@models: the path (including the filename) of legacy's models.list @filename: output filename for storing the table Exports CK2004 limb darkening coefficients to a PHOEBE legacy compatible format.
entailment
def compute_ck2004_ldints(self): """ Computes integrated limb darkening profiles for ck2004 atmospheres. These are used for intensity-to-flux transformations. The evaluated integral is: ldint = 2 \pi \int_0^1 Imu mu dmu """ if 'ck2004_all' not in self.content: ...
Computes integrated limb darkening profiles for ck2004 atmospheres. These are used for intensity-to-flux transformations. The evaluated integral is: ldint = 2 \pi \int_0^1 Imu mu dmu
entailment
def interpolate_ck2004_ldcoeffs(self, Teff=5772., logg=4.43, abun=0.0, atm='ck2004', ld_func='power', photon_weighted=False): """ Interpolate the passband-stored table of LD model coefficients. """ if 'ck2004_ld' not in self.content: print('Castelli & Kurucz (2004) limb dark...
Interpolate the passband-stored table of LD model coefficients.
entailment
def import_wd_atmcof(self, plfile, atmfile, wdidx, Nabun=19, Nlogg=11, Npb=25, Nints=4): """ Parses WD's atmcof and reads in all Legendre polynomials for the given passband. @plfile: path and filename of atmcofplanck.dat @atmfile: path and filename of atmcof.dat @wdidx: ...
Parses WD's atmcof and reads in all Legendre polynomials for the given passband. @plfile: path and filename of atmcofplanck.dat @atmfile: path and filename of atmcof.dat @wdidx: WD index of the passed passband. This can be automated but it's not a high priority. ...
entailment
def _log10_Inorm_extern_planckint(self, Teff): """ Internal function to compute normal passband intensities using the external WD machinery that employs blackbody approximation. @Teff: effective temperature in K Returns: log10(Inorm) """ log10_Inorm = libphoebe...
Internal function to compute normal passband intensities using the external WD machinery that employs blackbody approximation. @Teff: effective temperature in K Returns: log10(Inorm)
entailment
def _log10_Inorm_extern_atmx(self, Teff, logg, abun): """ Internal function to compute normal passband intensities using the external WD machinery that employs model atmospheres and ramps. @Teff: effective temperature in K @logg: surface gravity in cgs @abun: met...
Internal function to compute normal passband intensities using the external WD machinery that employs model atmospheres and ramps. @Teff: effective temperature in K @logg: surface gravity in cgs @abun: metallicity in dex, Solar=0.0 Returns: log10(Inorm)
entailment
def set_keyspace(self, keyspace): """ switch all connections to another keyspace """ self.keyspace = keyspace dfrds = [] for p in self._protos: dfrds.append(p.submitRequest(ManagedThriftRequest( 'set_keyspace', keyspace))) return defer.gatherResults(df...
switch all connections to another keyspace
entailment
def login(self, credentials): """ authenticate all connections """ dfrds = [] for p in self._protos: dfrds.append(p.submitRequest(ManagedThriftRequest('login', ttypes.AuthenticationRequest(credentials=credentials)))) return defer.gatherResults(dfrds)
authenticate all connections
entailment
def solve(self,problem): """ Solves optimization problem. Parameters ---------- problem : Object """ # Local vars norm2 = self.norm2 norminf = self.norminf parameters = self.parameters # Parameters tol = param...
Solves optimization problem. Parameters ---------- problem : Object
entailment
def factorize(self, A): """ Factorizes A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part. """ A = csc_matrix(A) if self.prop == self.SYMMETRIC: A = (A + A.T) - triu(A) ...
Factorizes A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part.
entailment
def retry(self): """ Retry this factory's connection. It is assumed that a previous connection was attempted and failed- either before or after a successful connection. """ if self.connector is None: raise ValueError("No connector to retry") if self.s...
Retry this factory's connection. It is assumed that a previous connection was attempted and failed- either before or after a successful connection.
entailment
def prep_connection(self, creds=None, keyspace=None, node_auto_discovery=True): """ Do login and set_keyspace tasks as necessary, and also check this node's idea of the Cassandra ring. Expects that our connection is alive. Return a Deferred that will fire with the ring informati...
Do login and set_keyspace tasks as necessary, and also check this node's idea of the Cassandra ring. Expects that our connection is alive. Return a Deferred that will fire with the ring information, or be errbacked if something goes wrong.
entailment
def my_pick_non_system_keyspace(self): """ Find a keyspace in the cluster which is not 'system', for the purpose of getting a valid ring view. Can't use 'system' or null. """ d = self.my_describe_keyspaces() def pick_non_system(klist): for k in klist: ...
Find a keyspace in the cluster which is not 'system', for the purpose of getting a valid ring view. Can't use 'system' or null.
entailment
def finish_and_die(self): """ If there is a request pending, let it finish and be handled, then disconnect and die. If not, cancel any pending queue requests and just die. """ self.logstate('finish_and_die') self.stop_working_on_queue() if self.jobphase !=...
If there is a request pending, let it finish and be handled, then disconnect and die. If not, cancel any pending queue requests and just die.
entailment
def add_connection_score(self, node): """ Return a numeric value that determines this node's score for adding a new connection. A negative value indicates that no connections should be made to this node for at least that number of seconds. A value of -inf indicates no connections...
Return a numeric value that determines this node's score for adding a new connection. A negative value indicates that no connections should be made to this node for at least that number of seconds. A value of -inf indicates no connections should be made to this node for the foreseeable f...
entailment
def adjustPoolSize(self, newsize): """ Change the target pool size. If we have too many connections already, ask some to finish what they're doing and die (preferring to kill connections to the node that already has the most connections). If we have too few, create more. ...
Change the target pool size. If we have too many connections already, ask some to finish what they're doing and die (preferring to kill connections to the node that already has the most connections). If we have too few, create more.
entailment
def fill_pool(self): """ Add connections as necessary to meet the target pool size. If there are no nodes to connect to (because we maxed out connections-per-node on all active connections and any unconnected nodes have pending reconnect timers), call the on_insufficient_nodes ca...
Add connections as necessary to meet the target pool size. If there are no nodes to connect to (because we maxed out connections-per-node on all active connections and any unconnected nodes have pending reconnect timers), call the on_insufficient_nodes callback.
entailment
def resubmit(self, req, keyspace, req_d, retries): """ Push this request to the front of the line, just to be a jerk. """ self.log('resubmitting %s request' % (req.method,)) self.pushRequest_really(req, keyspace, req_d, retries) try: self.request_queue.pending...
Push this request to the front of the line, just to be a jerk.
entailment
def set_keyspace(self, keyspace): """ Change the keyspace which will be used for subsequent requests to this CassandraClusterPool, and return a Deferred that will fire once it can be verified that connections can successfully use that keyspace. If something goes wrong trying to ...
Change the keyspace which will be used for subsequent requests to this CassandraClusterPool, and return a Deferred that will fire once it can be verified that connections can successfully use that keyspace. If something goes wrong trying to change a connection to that keyspace, the Defe...
entailment
def keyspaceConnection(self, keyspace, consistency=ConsistencyLevel.ONE): """ Return a CassandraClient instance which uses this CassandraClusterPool by way of a CassandraKeyspaceConnection, so that all requests made through it are guaranteed to go to the given keyspace, no matter what ...
Return a CassandraClient instance which uses this CassandraClusterPool by way of a CassandraKeyspaceConnection, so that all requests made through it are guaranteed to go to the given keyspace, no matter what other consumers of this pool may do.
entailment
def split_by_commas(maybe_s: str) -> Tuple[str, ...]: """Split a string by commas, but allow escaped commas. - If maybe_s is falsey, returns an empty tuple - Ignore backslashed commas """ if not maybe_s: return () parts: List[str] = [] split_by_backslash = maybe_s.split(r'\,') fo...
Split a string by commas, but allow escaped commas. - If maybe_s is falsey, returns an empty tuple - Ignore backslashed commas
entailment
def login(self, auth_request): """ Parameters: - auth_request """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_login(auth_request) return d
Parameters: - auth_request
entailment
def set_keyspace(self, keyspace): """ Parameters: - keyspace """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_set_keyspace(keyspace) return d
Parameters: - keyspace
entailment
def get(self, key, column_path, consistency_level): """ Get the Column or SuperColumn at the given column_path. If no value is present, NotFoundException is thrown. (This is the only method that can throw an exception under non-failure conditions.) Parameters: - key - column_path - consi...
Get the Column or SuperColumn at the given column_path. If no value is present, NotFoundException is thrown. (This is the only method that can throw an exception under non-failure conditions.) Parameters: - key - column_path - consistency_level
entailment
def get_slice(self, key, column_parent, predicate, consistency_level): """ Get the group of columns contained by column_parent (either a ColumnFamily name or a ColumnFamily/SuperColumn name pair) specified by the given SlicePredicate. If no matching values are found, an empty list is returned. Paramete...
Get the group of columns contained by column_parent (either a ColumnFamily name or a ColumnFamily/SuperColumn name pair) specified by the given SlicePredicate. If no matching values are found, an empty list is returned. Parameters: - key - column_parent - predicate - consistency_level
entailment
def get_count(self, key, column_parent, predicate, consistency_level): """ returns the number of columns matching <code>predicate</code> for a particular <code>key</code>, <code>ColumnFamily</code> and optionally <code>SuperColumn</code>. Parameters: - key - column_parent - predicate ...
returns the number of columns matching <code>predicate</code> for a particular <code>key</code>, <code>ColumnFamily</code> and optionally <code>SuperColumn</code>. Parameters: - key - column_parent - predicate - consistency_level
entailment
def multiget_slice(self, keys, column_parent, predicate, consistency_level): """ Performs a get_slice for column_parent and predicate for the given keys in parallel. Parameters: - keys - column_parent - predicate - consistency_level """ self._seqid += 1 d = self._reqs[self._...
Performs a get_slice for column_parent and predicate for the given keys in parallel. Parameters: - keys - column_parent - predicate - consistency_level
entailment
def multiget_count(self, keys, column_parent, predicate, consistency_level): """ Perform a get_count in parallel on the given list<binary> keys. The return value maps keys to the count found. Parameters: - keys - column_parent - predicate - consistency_level """ self._seqid += 1...
Perform a get_count in parallel on the given list<binary> keys. The return value maps keys to the count found. Parameters: - keys - column_parent - predicate - consistency_level
entailment
def get_range_slices(self, column_parent, predicate, range, consistency_level): """ returns a subset of columns for a contiguous range of keys. Parameters: - column_parent - predicate - range - consistency_level """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferr...
returns a subset of columns for a contiguous range of keys. Parameters: - column_parent - predicate - range - consistency_level
entailment
def get_paged_slice(self, column_family, range, start_column, consistency_level): """ returns a range of columns, wrapping to the next rows if necessary to collect max_results. Parameters: - column_family - range - start_column - consistency_level """ self._seqid += 1 d = se...
returns a range of columns, wrapping to the next rows if necessary to collect max_results. Parameters: - column_family - range - start_column - consistency_level
entailment
def get_indexed_slices(self, column_parent, index_clause, column_predicate, consistency_level): """ Returns the subset of columns specified in SlicePredicate for the rows matching the IndexClause @deprecated use get_range_slices instead with range.row_filter specified Parameters: - column_parent ...
Returns the subset of columns specified in SlicePredicate for the rows matching the IndexClause @deprecated use get_range_slices instead with range.row_filter specified Parameters: - column_parent - index_clause - column_predicate - consistency_level
entailment
def insert(self, key, column_parent, column, consistency_level): """ Insert a Column at the given column_parent.column_family and optional column_parent.super_column. Parameters: - key - column_parent - column - consistency_level """ self._seqid += 1 d = self._reqs[self._seq...
Insert a Column at the given column_parent.column_family and optional column_parent.super_column. Parameters: - key - column_parent - column - consistency_level
entailment
def add(self, key, column_parent, column, consistency_level): """ Increment or decrement a counter. Parameters: - key - column_parent - column - consistency_level """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_add(key, column_parent, column...
Increment or decrement a counter. Parameters: - key - column_parent - column - consistency_level
entailment
def remove(self, key, column_path, timestamp, consistency_level): """ Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note that all the values in column_path besides column_path.column_family are truly optional: you can remove the entire ro...
Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note that all the values in column_path besides column_path.column_family are truly optional: you can remove the entire row by just specifying the ColumnFamily, or you can remove a SuperColumn or a si...
entailment
def remove_counter(self, key, path, consistency_level): """ Remove a counter at the specified location. Note that counters have limited support for deletes: if you remove a counter, you must wait to issue any following update until the delete has reached all the nodes and all of them have been fully com...
Remove a counter at the specified location. Note that counters have limited support for deletes: if you remove a counter, you must wait to issue any following update until the delete has reached all the nodes and all of them have been fully compacted. Parameters: - key - path - consistency_l...
entailment
def batch_mutate(self, mutation_map, consistency_level): """ Mutate many columns or super columns for many row keys. See also: Mutation. mutation_map maps key to column family to a list of Mutation objects to take place at that scope. * Parameters: - mutation_map - consistency_level ...
Mutate many columns or super columns for many row keys. See also: Mutation. mutation_map maps key to column family to a list of Mutation objects to take place at that scope. * Parameters: - mutation_map - consistency_level
entailment
def atomic_batch_mutate(self, mutation_map, consistency_level): """ Atomically mutate many columns or super columns for many row keys. See also: Mutation. mutation_map maps key to column family to a list of Mutation objects to take place at that scope. * Parameters: - mutation_map - ...
Atomically mutate many columns or super columns for many row keys. See also: Mutation. mutation_map maps key to column family to a list of Mutation objects to take place at that scope. * Parameters: - mutation_map - consistency_level
entailment
def truncate(self, cfname): """ Truncate will mark and entire column family as deleted. From the user's perspective a successful call to truncate will result complete data deletion from cfname. Internally, however, disk space will not be immediatily released, as with all deletes in cassandra, this one ...
Truncate will mark and entire column family as deleted. From the user's perspective a successful call to truncate will result complete data deletion from cfname. Internally, however, disk space will not be immediatily released, as with all deletes in cassandra, this one only marks the data as deleted. T...
entailment
def describe_schema_versions(self, ): """ for each schema version present in the cluster, returns a list of nodes at that version. hosts that do not respond will be under the key DatabaseDescriptor.INITIAL_VERSION. the cluster is all on the same version if the size of the map is 1. """ self._seq...
for each schema version present in the cluster, returns a list of nodes at that version. hosts that do not respond will be under the key DatabaseDescriptor.INITIAL_VERSION. the cluster is all on the same version if the size of the map is 1.
entailment
def describe_keyspaces(self, ): """ list the defined keyspaces in this cluster """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_keyspaces() return d
list the defined keyspaces in this cluster
entailment
def describe_cluster_name(self, ): """ get the cluster name """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_cluster_name() return d
get the cluster name
entailment
def describe_version(self, ): """ get the thrift api version """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_version() return d
get the thrift api version
entailment
def describe_ring(self, keyspace): """ get the token ring: a map of ranges to host addresses, represented as a set of TokenRange instead of a map from range to list of endpoints, because you can't use Thrift structs as map keys: https://issues.apache.org/jira/browse/THRIFT-162 for the same ...
get the token ring: a map of ranges to host addresses, represented as a set of TokenRange instead of a map from range to list of endpoints, because you can't use Thrift structs as map keys: https://issues.apache.org/jira/browse/THRIFT-162 for the same reason, we can't return a set here, even though...
entailment
def describe_token_map(self, ): """ get the mapping between token->node ip without taking replication into consideration https://issues.apache.org/jira/browse/CASSANDRA-4092 """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_token_map() return d
get the mapping between token->node ip without taking replication into consideration https://issues.apache.org/jira/browse/CASSANDRA-4092
entailment
def describe_partitioner(self, ): """ returns the partitioner used by this cluster """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_partitioner() return d
returns the partitioner used by this cluster
entailment
def describe_snitch(self, ): """ returns the snitch used by this cluster """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_snitch() return d
returns the snitch used by this cluster
entailment
def describe_keyspace(self, keyspace): """ describe specified keyspace Parameters: - keyspace """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_keyspace(keyspace) return d
describe specified keyspace Parameters: - keyspace
entailment
def describe_splits(self, cfName, start_token, end_token, keys_per_split): """ experimental API for hadoop/parallel query support. may change violently and without warning. returns list of token strings such that first subrange is (list[0], list[1]], next is (list[1], list[2]], etc. Parameters...
experimental API for hadoop/parallel query support. may change violently and without warning. returns list of token strings such that first subrange is (list[0], list[1]], next is (list[1], list[2]], etc. Parameters: - cfName - start_token - end_token - keys_per_split
entailment
def trace_next_query(self, ): """ Enables tracing for the next query in this connection and returns the UUID for that trace session The next query will be traced idependently of trace probability and the returned UUID can be used to query the trace keyspace """ self._seqid += 1 d = self._reqs[se...
Enables tracing for the next query in this connection and returns the UUID for that trace session The next query will be traced idependently of trace probability and the returned UUID can be used to query the trace keyspace
entailment
def describe_splits_ex(self, cfName, start_token, end_token, keys_per_split): """ Parameters: - cfName - start_token - end_token - keys_per_split """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_splits_ex(cfName, start_token, end_token, k...
Parameters: - cfName - start_token - end_token - keys_per_split
entailment
def system_add_column_family(self, cf_def): """ adds a column family. returns the new schema id. Parameters: - cf_def """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_add_column_family(cf_def) return d
adds a column family. returns the new schema id. Parameters: - cf_def
entailment
def system_drop_column_family(self, column_family): """ drops a column family. returns the new schema id. Parameters: - column_family """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_drop_column_family(column_family) return d
drops a column family. returns the new schema id. Parameters: - column_family
entailment
def system_add_keyspace(self, ks_def): """ adds a keyspace and any column families that are part of it. returns the new schema id. Parameters: - ks_def """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_add_keyspace(ks_def) return d
adds a keyspace and any column families that are part of it. returns the new schema id. Parameters: - ks_def
entailment
def system_drop_keyspace(self, keyspace): """ drops a keyspace and any column families that are part of it. returns the new schema id. Parameters: - keyspace """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_drop_keyspace(keyspace) return d
drops a keyspace and any column families that are part of it. returns the new schema id. Parameters: - keyspace
entailment
def system_update_keyspace(self, ks_def): """ updates properties of a keyspace. returns the new schema id. Parameters: - ks_def """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_update_keyspace(ks_def) return d
updates properties of a keyspace. returns the new schema id. Parameters: - ks_def
entailment
def system_update_column_family(self, cf_def): """ updates properties of a column family. returns the new schema id. Parameters: - cf_def """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_system_update_column_family(cf_def) return d
updates properties of a column family. returns the new schema id. Parameters: - cf_def
entailment
def execute_cql_query(self, query, compression): """ Executes a CQL (Cassandra Query Language) statement and returns a CqlResult containing the results. Parameters: - query - compression """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_execute_cql_...
Executes a CQL (Cassandra Query Language) statement and returns a CqlResult containing the results. Parameters: - query - compression
entailment
def execute_cql3_query(self, query, compression, consistency): """ Parameters: - query - compression - consistency """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_execute_cql3_query(query, compression, consistency) return d
Parameters: - query - compression - consistency
entailment
def prepare_cql_query(self, query, compression): """ Prepare a CQL (Cassandra Query Language) statement by compiling and returning - the type of CQL statement - an id token of the compiled CQL stored on the server side. - a count of the discovered bound markers in the statement Parameters: ...
Prepare a CQL (Cassandra Query Language) statement by compiling and returning - the type of CQL statement - an id token of the compiled CQL stored on the server side. - a count of the discovered bound markers in the statement Parameters: - query - compression
entailment
def prepare_cql3_query(self, query, compression): """ Parameters: - query - compression """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_prepare_cql3_query(query, compression) return d
Parameters: - query - compression
entailment
def execute_prepared_cql_query(self, itemId, values): """ Executes a prepared CQL (Cassandra Query Language) statement by passing an id token and a list of variables to bind and returns a CqlResult containing the results. Parameters: - itemId - values """ self._seqid += 1 d = sel...
Executes a prepared CQL (Cassandra Query Language) statement by passing an id token and a list of variables to bind and returns a CqlResult containing the results. Parameters: - itemId - values
entailment
def execute_prepared_cql3_query(self, itemId, values, consistency): """ Parameters: - itemId - values - consistency """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_execute_prepared_cql3_query(itemId, values, consistency) return d
Parameters: - itemId - values - consistency
entailment
def set_cql_version(self, version): """ @deprecated This is now a no-op. Please use the CQL3 specific methods instead. Parameters: - version """ self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_set_cql_version(version) return d
@deprecated This is now a no-op. Please use the CQL3 specific methods instead. Parameters: - version
entailment
def new_linsolver(name,prop): """ Creates a linear solver. Parameters ---------- name : string prop : string Returns ------- solver : :class:`LinSolver <optalg.lin_solver.LinSolver>` """ if name == 'mumps': return LinSolverMUMPS(prop) elif name == 'supe...
Creates a linear solver. Parameters ---------- name : string prop : string Returns ------- solver : :class:`LinSolver <optalg.lin_solver.LinSolver>`
entailment
def cast_problem(problem): """ Casts problem object with known interface as OptProblem. Parameters ---------- problem : Object """ # Optproblem if isinstance(problem,OptProblem): return problem # Other else: # Type Base if (not hasattr(...
Casts problem object with known interface as OptProblem. Parameters ---------- problem : Object
entailment
def create_problem_from_type_base(problem): """ Creates OptProblem from type-base problem. Parameters ---------- problem : Object """ p = OptProblem() # Init attributes p.phi = problem.phi p.gphi = problem.gphi p.Hphi = problem.Hphi p.A = problem.A p.b = problem....
Creates OptProblem from type-base problem. Parameters ---------- problem : Object
entailment
def create_problem_from_type_A(problem): """ Creates OptProblem from type-A problem. Parameters ---------- problem : Object """ p = OptProblem() nx = problem.get_num_primal_variables() nz = problem.G.shape[0] p.phi = problem.phi p.gphi = np.hstack((problem.gphi,np...
Creates OptProblem from type-A problem. Parameters ---------- problem : Object
entailment
def recover_dual_variables(self,lam,nu,mu,pi): """ Recovers dual variables for original problem. Parameters ---------- lam : ndarray nu : ndarray mu : ndarray pi : ndarray """ return lam,nu,mu,pi
Recovers dual variables for original problem. Parameters ---------- lam : ndarray nu : ndarray mu : ndarray pi : ndarray
entailment
def get_num_primal_variables(self): """ Gets number of primal variables. Returns ------- num : int """ if self.x is not None: return self.x.size if self.gphi is not None: return self.gphi.size if self.Hphi is not None: ...
Gets number of primal variables. Returns ------- num : int
entailment
def get_dual_variables(self): """ Gets dual variables. Returns ------- lam : vector nu : vector mu : vector pi : vector """ if self.problem: return self.problem.recover_dual_variables(self.lam*self.obj_sca, ...
Gets dual variables. Returns ------- lam : vector nu : vector mu : vector pi : vector
entailment
def get_results(self): """ Gets results. Returns ------- results : dictionary """ return {'status': self.status, 'error_msg': self.error_msg, 'k': self.k, 'x': self.x, 'lam': self.lam*self.obj_sca, ...
Gets results. Returns ------- results : dictionary
entailment
def line_search(self,x,p,F,GradF,func,smax=np.inf,maxiter=40): """ Finds steplength along search direction p that satisfies the strong Wolfe conditions. Parameters ---------- x : current point (ndarray) p : search direction (ndarray) F : function...
Finds steplength along search direction p that satisfies the strong Wolfe conditions. Parameters ---------- x : current point (ndarray) p : search direction (ndarray) F : function value at `x` (float) GradF : gradient of function at `x` (ndarray) ...
entailment
def reset(self): """ Resets solver data. """ self.k = 0. self.x = np.zeros(0) self.lam = np.zeros(0) self.nu = np.zeros(0) self.mu = np.zeros(0) self.pi = np.zeros(0) self.status = self.STATUS_UNKNOWN self.error_msg = '' ...
Resets solver data.
entailment
def set_parameters(self,parameters): """ Sets solver parameters. Parameters ---------- parameters : dict """ for key,value in list(parameters.items()): if key in self.parameters: self.parameters[key] = value
Sets solver parameters. Parameters ---------- parameters : dict
entailment
def factorize_and_solve(self, A, b): """ Factorizes A and solves Ax=b. Returns ------- x : vector """ self.factorize(A) return self.solve(b)
Factorizes A and solves Ax=b. Returns ------- x : vector
entailment
def solve(self,problem): """ Solves optimization problem. Parameters ---------- problem : Object """ # Local vars norm2 = self.norm2 norminf = self.norminf parameters = self.parameters # Parameters fea...
Solves optimization problem. Parameters ---------- problem : Object
entailment
def format_files(src: str, dest: str, **fmt_vars: str) -> None: """Copies all files inside src into dest while formatting the contents of the files into the output. For example, a file with the following contents: {foo} bar {baz} and the vars {'foo': 'herp', 'baz': 'derp'} will end up in the...
Copies all files inside src into dest while formatting the contents of the files into the output. For example, a file with the following contents: {foo} bar {baz} and the vars {'foo': 'herp', 'baz': 'derp'} will end up in the output as herp bar derp :param text src: Source directory. ...
entailment
def analyze(self,A): """ Analyzes structure of A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part. """ A = coo_matrix(A) self.mumps.set_shape(A.shape[0]) self.mumps.set...
Analyzes structure of A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part.
entailment
def factorize(self,A): """ Factorizes A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part. """ A = coo_matrix(A) self.mumps.set_centralized_assembled_values(A.data) self.mumps.run(job=2)
Factorizes A. Parameters ---------- A : matrix For symmetric systems, should contain only lower diagonal part.
entailment
def solve(self,b): """ Solves system Ax=b. Parameters ---------- b : ndarray Returns ------- x : ndarray """ x = b.copy() self.mumps.set_rhs(x) self.mumps.run(job=3) return x
Solves system Ax=b. Parameters ---------- b : ndarray Returns ------- x : ndarray
entailment
def factorize_and_solve(self,A,b): """ Factorizes A and sovles Ax=b. Parameters ---------- A : matrix b : ndarray Returns ------- x : ndarray """ A = coo_matrix(A) x = b.copy() self.mumps.set_centralized_assemble...
Factorizes A and sovles Ax=b. Parameters ---------- A : matrix b : ndarray Returns ------- x : ndarray
entailment
def spsolve(A, b, comm=None): """Sparse solve A\b.""" assert A.dtype == 'd' and b.dtype == 'd', "Only double precision supported." with DMumpsContext(par=1, sym=0, comm=comm) as ctx: if ctx.myid == 0: # Set the sparse matrix -- only necessary on ctx.set_centralized_sparse(A....
Sparse solve A\b.
entailment
def set_centralized_sparse(self, A): """Set assembled matrix on processor 0. Parameters ---------- A : `scipy.sparse.coo_matrix` Sparse matrices of other formats will be converted to COOrdinate form. """ if self.myid != 0: return ...
Set assembled matrix on processor 0. Parameters ---------- A : `scipy.sparse.coo_matrix` Sparse matrices of other formats will be converted to COOrdinate form.
entailment
def set_centralized_assembled(self, irn, jcn, a): """Set assembled matrix on processor 0. The row and column indices (irn & jcn) should be one based. """ self.set_centralized_assembled_rows_cols(irn, jcn) self.set_centralized_assembled_values(a)
Set assembled matrix on processor 0. The row and column indices (irn & jcn) should be one based.
entailment
def set_centralized_assembled_rows_cols(self, irn, jcn): """Set assembled matrix indices on processor 0. The row and column indices (irn & jcn) should be one based. """ if self.myid != 0: return assert irn.size == jcn.size self._refs.update(irn=irn, jcn=jcn) ...
Set assembled matrix indices on processor 0. The row and column indices (irn & jcn) should be one based.
entailment