idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
40,000
def get_system ( self , twig = None , ** kwargs ) : if twig is not None : kwargs [ 'twig' ] = twig kwargs [ 'context' ] = 'system' return self . filter ( ** kwargs )
Filter in the system context
40,001
def get_feature ( self , feature = None , ** kwargs ) : if feature is not None : kwargs [ 'feature' ] = feature kwargs [ 'context' ] = 'feature' return self . filter ( ** kwargs )
Filter in the proerty context
40,002
def rename_feature ( self , old_feature , new_feature ) : self . _check_label ( new_feature ) self . _rename_label ( 'feature' , old_feature , new_feature )
Change the label of a feature attached to the Bundle
40,003
def get_component ( self , component = None , ** kwargs ) : if component is not None : kwargs [ 'component' ] = component kwargs [ 'context' ] = 'component' return self . filter ( ** kwargs )
Filter in the component context
40,004
def rename_component ( self , old_component , new_component ) : self . _check_label ( new_component ) if len ( [ c for c in self . components if new_component in c ] ) : logger . warning ( "hierarchy may not update correctly with new component" ) self . hierarchy . rename_component ( old_component , new_component ) sel...
Change the label of a component attached to the Bundle
40,005
def get_dataset ( self , dataset = None , ** kwargs ) : if dataset is not None : kwargs [ 'dataset' ] = dataset kwargs [ 'context' ] = 'dataset' if 'kind' in kwargs . keys ( ) : kwargs [ 'kind' ] = kwargs [ 'kind' ] . lower ( ) return self . filter ( ** kwargs )
Filter in the dataset context
40,006
def remove_dataset ( self , dataset = None , ** kwargs ) : self . _kwargs_checks ( kwargs ) if dataset is None and not len ( kwargs . items ( ) ) : raise ValueError ( "must provide some value to filter for datasets" ) kind = kwargs . get ( 'kind' , None ) if kind is not None : if isinstance ( kind , str ) : kind = [ ki...
Remove a dataset from the Bundle .
40,007
def rename_dataset ( self , old_dataset , new_dataset ) : self . _check_label ( new_dataset ) self . _rename_label ( 'dataset' , old_dataset , new_dataset ) self . _handle_dataset_selectparams ( )
Change the label of a dataset attached to the Bundle
40,008
def get_constraint ( self , twig = None , ** kwargs ) : if twig is not None : kwargs [ 'twig' ] = twig kwargs [ 'context' ] = 'constraint' return self . get ( ** kwargs )
Filter in the constraint context
40,009
def remove_constraint ( self , twig = None , ** kwargs ) : changed_params = self . run_delayed_constraints ( ) kwargs [ 'twig' ] = twig redo_kwargs = deepcopy ( kwargs ) kwargs [ 'context' ] = 'constraint' constraint = self . get_parameter ( ** kwargs ) constraint . _remove_bookkeeping ( ) self . remove_parameter ( ** ...
Remove a constraint from the bundle
40,010
def flip_constraint ( self , twig = None , solve_for = None , ** kwargs ) : self . _kwargs_checks ( kwargs , additional_allowed_keys = [ 'check_nan' ] ) kwargs [ 'twig' ] = twig redo_kwargs = deepcopy ( kwargs ) undo_kwargs = deepcopy ( kwargs ) changed_params = self . run_delayed_constraints ( ) param = self . get_con...
Flip an existing constraint to solve for a different parameter
40,011
def run_constraint ( self , twig = None , return_parameter = False , ** kwargs ) : if not kwargs . get ( 'skip_kwargs_checks' , False ) : self . _kwargs_checks ( kwargs ) kwargs [ 'twig' ] = twig kwargs [ 'context' ] = 'constraint' kwargs [ 'check_visible' ] = False kwargs [ 'check_default' ] = False expression_param =...
Run a given constraint now and set the value of the constrained parameter . In general there shouldn t be any need to manually call this - constraints should automatically be run whenever a dependent parameter s value is change .
40,012
def get_compute ( self , compute = None , ** kwargs ) : if compute is not None : kwargs [ 'compute' ] = compute kwargs [ 'context' ] = 'compute' return self . filter ( ** kwargs )
Filter in the compute context
40,013
def remove_compute ( self , compute , ** kwargs ) : kwargs [ 'compute' ] = compute kwargs [ 'context' ] = 'comute' self . remove_parameters_all ( ** kwargs )
Remove a compute from the bundle
40,014
def rename_compute ( self , old_compute , new_compute ) : self . _check_label ( new_compute ) self . _rename_label ( 'compute' , old_compute , new_compute )
Change the label of a compute attached to the Bundle
40,015
def get_model ( self , model = None , ** kwargs ) : if model is not None : kwargs [ 'model' ] = model kwargs [ 'context' ] = 'model' return self . filter ( ** kwargs )
Filter in the model context
40,016
def remove_model ( self , model , ** kwargs ) : kwargs [ 'model' ] = model kwargs [ 'context' ] = 'model' self . remove_parameters_all ( ** kwargs )
Remove a model from the bundle
40,017
def rename_model ( self , old_model , new_model ) : self . _check_label ( new_model ) self . _rename_label ( 'model' , old_model , new_model )
Change the label of a model attached to the Bundle
40,018
def _twig_to_uniqueid ( bundle , twig , ** kwargs ) : res = bundle . filter ( twig = twig , force_ps = True , check_visible = False , check_default = False , ** kwargs ) if len ( res ) == 1 : return res . to_list ( ) [ 0 ] . uniqueid else : raise ValueError ( "did not return a single unique match to a parameter for '{}...
kwargs are passed on to filter
40,019
def update_user_label ( self ) : self . _user_label = _uniqueid_to_uniquetwig ( self . _bundle , self . unique_label ) self . _set_curly_label ( )
finds this parameter and gets the least_unique_twig from the bundle
40,020
def get_parameter ( self ) : if not self . is_param : raise ValueError ( "this var does not point to a parameter" ) if self . _parameter is None : self . _parameter = self . _bundle . get_parameter ( uniqueid = self . unique_label , check_visible = False , check_default = False ) return self . _parameter
get the parameter object from the system for this var
40,021
def _process_dimension_kwargs ( direction , kwargs ) : acceptable_keys = [ 'unit' , 'pad' , 'lim' , 'label' ] processed_kwargs = { } for k , v in kwargs . items ( ) : if k . startswith ( direction ) : processed_key = k . lstrip ( direction ) else : processed_key = k if processed_key in acceptable_keys : processed_kwarg...
process kwargs for AxDimension instances by stripping off the prefix for the appropriate direction
40,022
def calls_sorted ( self ) : def _z ( call ) : if isinstance ( call . z . value , np . ndarray ) : return np . mean ( call . z . value . flatten ( ) ) elif isinstance ( call . z . value , float ) or isinstance ( call . z . value , int ) : return call . z . value else : return - np . inf calls = self . _calls zs = np . a...
calls sorted in z
40,023
def create_teams ( obj , user , access ) : for field_name , access_types in access . items ( ) : id_field = "{}_id" . format ( field_name ) if hasattr ( obj , id_field ) and getattr ( obj , id_field ) is None : next_pk = next ( iter ( instance . pk for instance in obj . __class__ . objects . order_by ( "-pk" ) ) , 0 ) ...
Will create new teams associated with the referenced obj and set the resulting relation to the correct attribute .
40,024
def binaryorbit ( orbit , comp1 , comp2 , envelope = None ) : if envelope : return '{}({}, {}, {})' . format ( _to_component ( orbit , False ) , _to_component ( comp1 ) , _to_component ( comp2 ) , _to_component ( envelope , False ) ) else : return '{}({}, {})' . format ( _to_component ( orbit , False ) , _to_component ...
Build the string representation of a hierarchy containing a binary orbit with 2 components .
40,025
def direction ( self , direction ) : if not isinstance ( direction , str ) : raise TypeError ( "direction must be of type str" ) accepted_values = [ 'i' , 'x' , 'y' , 'z' , 's' , 'c' ] if direction not in accepted_values : raise ValueError ( "must be one of: {}" . format ( accepted_values ) ) self . _direction = direct...
set the direction
40,026
def error ( self , error ) : if self . direction not in [ 'x' , 'y' , 'z' ] and error is not None : raise ValueError ( "error only accepted for x, y, z dimensions" ) if isinstance ( error , u . Quantity ) : error = error . to ( self . unit ) . value self . _error = error
set the error
40,027
def label ( self , label ) : if self . direction in [ 'i' ] and label is not None : raise ValueError ( "label not accepted for indep dimension" ) if label is None : self . _label = label return if not isinstance ( label , str ) : try : label = str ( label ) except : raise TypeError ( "label must be of type str" ) self ...
set the label
40,028
def value ( self ) : if isinstance ( self . _value , str ) : dimension = self . _value return getattr ( self . call , dimension ) . value return super ( CallDimensionI , self ) . _get_value ( )
access the value
40,029
def _ensure_tuple ( item ) : if isinstance ( item , tuple ) : return item elif isinstance ( item , list ) : return tuple ( item ) elif isinstance ( item , np . ndarray ) : return tuple ( item . tolist ( ) ) else : raise NotImplementedError
Simply ensure that the passed item is a tuple . If it is not then convert it if possible or raise a NotImplementedError
40,030
def asini ( b , orbit , solve_for = None ) : orbit_ps = _get_system_ps ( b , orbit ) metawargs = orbit_ps . meta metawargs . pop ( 'qualifier' ) sma_def = FloatParameter ( qualifier = 'sma' , value = 8.0 , default_unit = u . solRad , description = 'Semi major axis' ) incl_def = FloatParameter ( qualifier = 'incl' , val...
Create a constraint for asini in an orbit .
40,031
def esinw ( b , orbit , solve_for = None , ** kwargs ) : orbit_ps = _get_system_ps ( b , orbit ) metawargs = orbit_ps . meta metawargs . pop ( 'qualifier' ) esinw_def = FloatParameter ( qualifier = 'esinw' , value = 0.0 , default_unit = u . dimensionless_unscaled , limits = ( - 1.0 , 1.0 ) , description = 'Eccentricity...
Create a constraint for esinw in an orbit .
40,032
def ecosw ( b , orbit , solve_for = None , ** kwargs ) : orbit_ps = _get_system_ps ( b , orbit ) metawargs = orbit_ps . meta metawargs . pop ( 'qualifier' ) ecosw_def = FloatParameter ( qualifier = 'ecosw' , value = 0.0 , default_unit = u . dimensionless_unscaled , limits = ( - 1.0 , 1.0 ) , description = 'Eccentricity...
Create a constraint for ecosw in an orbit .
40,033
def t0_perpass_supconj ( b , orbit , solve_for = None , ** kwargs ) : orbit_ps = _get_system_ps ( b , orbit ) metawargs = orbit_ps . meta metawargs . pop ( 'qualifier' ) t0_perpass = b . get_parameter ( qualifier = 't0_perpass' , ** metawargs ) t0_supconj = b . get_parameter ( qualifier = 't0_supconj' , ** metawargs ) ...
Create a constraint for t0_perpass in an orbit - allowing translating between t0_perpass and t0_supconj .
40,034
def t0_ref_supconj ( b , orbit , solve_for = None , ** kwargs ) : orbit_ps = _get_system_ps ( b , orbit ) metawargs = orbit_ps . meta metawargs . pop ( 'qualifier' ) t0_ref = b . get_parameter ( qualifier = 't0_ref' , ** metawargs ) t0_supconj = b . get_parameter ( qualifier = 't0_supconj' , ** metawargs ) period = b ....
Create a constraint for t0_ref in an orbit - allowing translating between t0_ref and t0_supconj .
40,035
def irrad_frac ( b , component , solve_for = None , ** kwargs ) : comp_ps = b . get_component ( component = component ) irrad_frac_refl_bol = comp_ps . get_parameter ( qualifier = 'irrad_frac_refl_bol' ) irrad_frac_lost_bol = comp_ps . get_parameter ( qualifier = 'irrad_frac_lost_bol' ) if solve_for in [ irrad_frac_los...
Create a constraint to ensure that energy is conserved and all incident light is accounted for .
40,036
def semidetached ( b , component , solve_for = None , ** kwargs ) : comp_ps = b . get_component ( component = component ) requiv = comp_ps . get_parameter ( qualifier = 'requiv' ) requiv_critical = comp_ps . get_parameter ( qualifier = 'requiv_max' ) if solve_for in [ requiv , None ] : lhs = requiv rhs = 1.0 * requiv_c...
Create a constraint to force requiv to be semidetached
40,037
def mass ( b , component , solve_for = None , ** kwargs ) : hier = b . get_hierarchy ( ) if not len ( hier . get_value ( ) ) : raise NotImplementedError ( "constraint for mass requires hierarchy" ) component_ps = _get_system_ps ( b , component ) parentorbit = hier . get_parent_of ( component ) parentorbit_ps = _get_sys...
Create a constraint for the mass of a star based on Kepler s third law from its parent orbit .
40,038
def comp_sma ( b , component , solve_for = None , ** kwargs ) : hier = b . get_hierarchy ( ) if not len ( hier . get_value ( ) ) : raise NotImplementedError ( "constraint for comp_sma requires hierarchy" ) component_ps = _get_system_ps ( b , component ) parentorbit = hier . get_parent_of ( component ) parentorbit_ps = ...
Create a constraint for the star s semi - major axes WITHIN its parent orbit . This is NOT the same as the semi - major axes OF the parent orbit
40,039
def fillout_factor ( b , component , solve_for = None , ** kwargs ) : hier = b . get_hierarchy ( ) if not len ( hier . get_value ( ) ) : raise NotImplementedError ( "constraint for requiv_contact_max requires hierarchy" ) component_ps = _get_system_ps ( b , component ) parentorbit = hier . get_parent_of ( component ) p...
Create a constraint to determine the fillout factor of a contact envelope .
40,040
def rotation_period ( b , component , solve_for = None , ** kwargs ) : hier = b . get_hierarchy ( ) if not len ( hier . get_value ( ) ) : raise NotImplementedError ( "constraint for comp_sma requires hierarchy" ) component_ps = _get_system_ps ( b , component ) parentorbit = hier . get_parent_of ( component ) parentorbi...
Create a constraint for the rotation period of a star given its orbital period and synchronicity parameters .
40,041
def is_unit ( value ) : if not _has_astropy : raise ImportError ( "astropy must be installed for unit support" ) if ( isinstance ( value , units . Unit ) or isinstance ( value , units . IrreducibleUnit ) or isinstance ( value , units . CompositeUnit ) ) : return True , value else : return False , value
must be an astropy unit
40,042
def is_unit_or_unitstring ( value ) : if is_unit ( value ) [ 0 ] : return True , value try : unit = units . Unit ( value ) except : return False , value else : return True , unit
must be an astropy . unit
40,043
def is_float ( value ) : return isinstance ( value , float ) or isinstance ( value , int ) or isinstance ( value , np . float64 ) , float ( value )
must be a float
40,044
def to ( self , unit ) : if not _has_astropy : raise ImportError ( "astropy must be installed for unit/quantity support" ) if self . unit is None : raise ValueError ( "no units currently set" ) if not is_unit_or_unitstring ( unit ) [ 0 ] : raise ValueError ( "unit not recognized" ) mult_factor = self . unit . to ( unit...
convert between units . Returns a new nparray object with the new units
40,045
def to_dict ( self ) : def _json_safe ( v ) : if isinstance ( v , np . ndarray ) : return v . tolist ( ) elif is_unit ( v ) [ 0 ] : return v . to_string ( ) else : return v d = { k : _json_safe ( v ) for k , v in self . _descriptors . items ( ) } d [ 'nparray' ] = self . __class__ . __name__ . lower ( ) return d
dump a representation of the nparray object to a dictionary . The nparray object should then be able to be fully restored via nparray . from_dict
40,046
def to_file ( self , filename , ** kwargs ) : f = open ( filename , 'w' ) f . write ( self . to_json ( ** kwargs ) ) f . close ( ) return filename
dump a representation of the nparray object to a json - formatted file . The nparray object should then be able to be fully restored via nparray . from_file
40,047
def to_linspace ( self ) : num = int ( ( self . stop - self . start ) / ( self . step ) ) return Linspace ( self . start , self . stop - self . step , num )
convert from arange to linspace
40,048
def to_arange ( self ) : arr , step = np . linspace ( self . start , self . stop , self . num , self . endpoint , retstep = True ) return Arange ( self . start , self . stop + step , step )
convert from linspace to arange
40,049
def to_linspace ( self ) : if hasattr ( self . shape , '__len__' ) : raise NotImplementedError ( "can only convert flat Full arrays to linspace" ) return Linspace ( self . fill_value , self . fill_value , self . shape )
convert from full to linspace
40,050
def crossing ( b , component , time , dynamics_method = 'keplerian' , ltte = True , tol = 1e-4 , maxiter = 1000 ) : def projected_separation_sq ( time , b , dynamics_method , cind1 , cind2 , ltte = True ) : times = np . array ( [ time ] ) if dynamics_method in [ 'nbody' , 'rebound' ] : ts , xs , ys , zs , vxs , vys , v...
tol in days
40,051
def _delta_t_supconj_perpass ( period , ecc , per0 ) : ups_sc = np . pi / 2 - per0 E_sc = 2 * np . arctan ( np . sqrt ( ( 1 - ecc ) / ( 1 + ecc ) ) * np . tan ( ups_sc / 2 ) ) M_sc = E_sc - ecc * np . sin ( E_sc ) return period * ( M_sc / 2. / np . pi )
time shift between superior conjuction and periastron passage
40,052
def from_dict ( d ) : if isinstance ( d , str ) : return from_json ( d ) if not isinstance ( d , dict ) : raise TypeError ( "argument must be of type dict" ) if 'nparray' not in d . keys ( ) : raise ValueError ( "input dictionary missing 'nparray' entry" ) classname = d . pop ( 'nparray' ) . title ( ) return getattr ( ...
load an nparray object from a dictionary
40,053
def from_json ( j ) : if isinstance ( j , dict ) : return from_dict ( j ) if not ( isinstance ( j , str ) or isinstance ( j , unicode ) ) : raise TypeError ( "argument must be of type str" ) return from_dict ( json . loads ( j ) )
load an nparray object from a json - formatted string
40,054
def from_file ( filename ) : f = open ( filename , 'r' ) j = json . load ( f ) f . close ( ) return from_dict ( j )
load an nparray object from a json filename
40,055
def monkeypatch ( ) : 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 . zeros_like = zeros_like np . ones = ones np . ones_like = ones_like np . eye = eye
monkeypath built - in numpy functions to call those provided by nparray instead .
40,056
def install_passband ( fname , local = True ) : pbdir = _pbdir_local if local else _pbdir_global shutil . copy ( fname , pbdir ) init_passband ( os . path . join ( pbdir , fname ) )
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
40,057
def download_passband ( passband , local = True ) : if passband not in list_online_passbands ( ) : raise ValueError ( "passband '{}' not available" . format ( passband ) ) pbdir = _pbdir_local if local else _pbdir_global passband_fname = _online_passbands [ passband ] [ 'fname' ] passband_fname_local = os . path . join...
Download and install a given passband from the repository .
40,058
def _planck_deriv ( self , lam , Teff ) : expterm = np . exp ( self . h * self . c / lam / self . k / Teff ) return 2 * self . h * self . c * self . c / self . k / Teff / lam ** 7 * ( expterm - 1 ) ** - 2 * ( self . h * self . c * expterm - 5 * lam * self . k * Teff * ( expterm - 1 ) )
Computes the derivative of the monochromatic blackbody intensity using the Planck function .
40,059
def interpolate_ck2004_ldcoeffs ( self , Teff = 5772. , logg = 4.43 , abun = 0.0 , atm = 'ck2004' , ld_func = 'power' , photon_weighted = False ) : if 'ck2004_ld' not in self . content : print ( 'Castelli & Kurucz (2004) limb darkening coefficients are not computed yet. Please compute those first.' ) return None if pho...
Interpolate the passband - stored table of LD model coefficients .
40,060
def import_wd_atmcof ( self , plfile , atmfile , wdidx , Nabun = 19 , Nlogg = 11 , Npb = 25 , Nints = 4 ) : self . wd_data = libphoebe . wd_readdata ( plfile , atmfile ) self . extern_wd_idx = wdidx atmtab = np . reshape ( self . wd_data [ 'atm_table' ] , ( Nabun , Npb , Nlogg , Nints , - 1 ) ) atmtab = atmtab [ : , wd...
Parses WD s atmcof and reads in all Legendre polynomials for the given passband .
40,061
def _log10_Inorm_extern_planckint ( self , Teff ) : log10_Inorm = libphoebe . wd_planckint ( Teff , self . extern_wd_idx , self . wd_data [ "planck_table" ] ) return log10_Inorm
Internal function to compute normal passband intensities using the external WD machinery that employs blackbody approximation .
40,062
def _log10_Inorm_extern_atmx ( self , Teff , logg , abun ) : log10_Inorm = libphoebe . wd_atmint ( Teff , logg , abun , self . extern_wd_idx , self . wd_data [ "planck_table" ] , self . wd_data [ "atm_table" ] ) return log10_Inorm
Internal function to compute normal passband intensities using the external WD machinery that employs model atmospheres and ramps .
40,063
def set_keyspace ( self , keyspace ) : self . keyspace = keyspace dfrds = [ ] for p in self . _protos : dfrds . append ( p . submitRequest ( ManagedThriftRequest ( 'set_keyspace' , keyspace ) ) ) return defer . gatherResults ( dfrds )
switch all connections to another keyspace
40,064
def login ( self , credentials ) : dfrds = [ ] for p in self . _protos : dfrds . append ( p . submitRequest ( ManagedThriftRequest ( 'login' , ttypes . AuthenticationRequest ( credentials = credentials ) ) ) ) return defer . gatherResults ( dfrds )
authenticate all connections
40,065
def retry ( self ) : if self . connector is None : raise ValueError ( "No connector to retry" ) if self . service is None : return self . connector . connect ( )
Retry this factory s connection . It is assumed that a previous connection was attempted and failed - either before or after a successful connection .
40,066
def prep_connection ( self , creds = None , keyspace = None , node_auto_discovery = True ) : d = defer . succeed ( None ) if creds is not None : d . addCallback ( lambda _ : self . my_login ( creds ) ) if keyspace is not None : d . addCallback ( lambda _ : self . my_set_keyspace ( keyspace ) ) if node_auto_discovery : ...
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 .
40,067
def my_pick_non_system_keyspace ( self ) : d = self . my_describe_keyspaces ( ) def pick_non_system ( klist ) : for k in klist : if k . name not in SYSTEM_KEYSPACES : return k . name err = NoKeyspacesAvailable ( "Can't gather information about the " "Cassandra ring; no non-system " "keyspaces available" ) warn ( err ) ...
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 .
40,068
def finish_and_die ( self ) : self . logstate ( 'finish_and_die' ) self . stop_working_on_queue ( ) if self . jobphase != 'pending_request' : self . stopFactory ( )
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 .
40,069
def add_connection_score ( self , node ) : conntime = node . seconds_until_connect_ok ( ) if conntime > 0 : self . log ( "not considering %r for new connection; has %r left on " "connect blackout" % ( node , conntime ) ) return - conntime numconns = self . num_connectors_to ( node ) if numconns >= self . max_connection...
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 future .
40,070
def resubmit ( self , req , keyspace , req_d , retries ) : self . log ( 'resubmitting %s request' % ( req . method , ) ) self . pushRequest_really ( req , keyspace , req_d , retries ) try : self . request_queue . pending . remove ( ( req , keyspace , req_d , retries ) ) except ValueError : pass else : self . request_qu...
Push this request to the front of the line just to be a jerk .
40,071
def set_keyspace ( self , keyspace ) : d = self . pushRequest ( ManagedThriftRequest ( 'set_keyspace' , keyspace ) ) def store_keyspace ( _ ) : self . keyspace = keyspace d . addCallback ( store_keyspace ) return d
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 .
40,072
def keyspaceConnection ( self , keyspace , consistency = ConsistencyLevel . ONE ) : conn = CassandraKeyspaceConnection ( self , keyspace ) return CassandraClient ( conn , consistency = consistency )
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 .
40,073
def split_by_commas ( maybe_s : str ) -> Tuple [ str , ... ] : if not maybe_s : return ( ) parts : List [ str ] = [ ] split_by_backslash = maybe_s . split ( r'\,' ) for split_by_backslash_part in split_by_backslash : splitby_comma = split_by_backslash_part . split ( ',' ) if parts : parts [ - 1 ] += ',' + splitby_comma...
Split a string by commas but allow escaped commas . - If maybe_s is falsey returns an empty tuple - Ignore backslashed commas
40,074
def multiget_slice ( self , keys , column_parent , predicate , consistency_level ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_multiget_slice ( keys , column_parent , predicate , consistency_level ) return d
Performs a get_slice for column_parent and predicate for the given keys in parallel .
40,075
def get_range_slices ( self , column_parent , predicate , range , consistency_level ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_get_range_slices ( column_parent , predicate , range , consistency_level ) return d
returns a subset of columns for a contiguous range of keys .
40,076
def get_paged_slice ( self , column_family , range , start_column , consistency_level ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_get_paged_slice ( column_family , range , start_column , consistency_level ) return d
returns a range of columns wrapping to the next rows if necessary to collect max_results .
40,077
def insert ( self , key , column_parent , column , consistency_level ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_insert ( key , column_parent , column , consistency_level ) return d
Insert a Column at the given column_parent . column_family and optional column_parent . super_column .
40,078
def add ( self , key , column_parent , column , consistency_level ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_add ( key , column_parent , column , consistency_level ) return d
Increment or decrement a counter .
40,079
def truncate ( self , cfname ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_truncate ( cfname ) return d
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 . The operation succ...
40,080
def describe_schema_versions ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_schema_versions ( ) return d
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 .
40,081
def describe_keyspaces ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_keyspaces ( ) return d
list the defined keyspaces in this cluster
40,082
def describe_cluster_name ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_cluster_name ( ) return d
get the cluster name
40,083
def describe_version ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_version ( ) return d
get the thrift api version
40,084
def describe_partitioner ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_partitioner ( ) return d
returns the partitioner used by this cluster
40,085
def describe_snitch ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_snitch ( ) return d
returns the snitch used by this cluster
40,086
def describe_keyspace ( self , keyspace ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_describe_keyspace ( keyspace ) return d
describe specified keyspace
40,087
def trace_next_query ( self , ) : self . _seqid += 1 d = self . _reqs [ self . _seqid ] = defer . Deferred ( ) self . send_trace_next_query ( ) return d
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
40,088
def system_add_column_family ( self , 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 .
40,089
def system_drop_column_family ( self , 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 .
40,090
def system_add_keyspace ( self , 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 .
40,091
def system_drop_keyspace ( self , 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 .
40,092
def system_update_keyspace ( self , 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 .
40,093
def system_update_column_family ( self , 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 .
40,094
def new_linsolver ( name , prop ) : if name == 'mumps' : return LinSolverMUMPS ( prop ) elif name == 'superlu' : return LinSolverSUPERLU ( prop ) elif name == 'umfpack' : return LinSolverUMFPACK ( prop ) elif name == 'default' : try : return new_linsolver ( 'mumps' , prop ) except ImportError : return new_linsolver ( '...
Creates a linear solver .
40,095
def cast_problem ( problem ) : if isinstance ( problem , OptProblem ) : return problem else : if ( not hasattr ( problem , 'G' ) or ( problem . G . shape [ 0 ] == problem . G . shape [ 1 ] and problem . G . shape [ 0 ] == problem . G . nnz and np . all ( problem . G . row == problem . G . col ) and np . all ( problem ....
Casts problem object with known interface as OptProblem .
40,096
def create_problem_from_type_base ( problem ) : p = OptProblem ( ) p . phi = problem . phi p . gphi = problem . gphi p . Hphi = problem . Hphi p . A = problem . A p . b = problem . b p . f = problem . f p . J = problem . J p . H_combined = problem . H_combined p . u = problem . u p . l = problem . l p . x = problem . x...
Creates OptProblem from type - base problem .
40,097
def recover_dual_variables ( self , lam , nu , mu , pi ) : return lam , nu , mu , pi
Recovers dual variables for original problem .
40,098
def get_num_primal_variables ( self ) : 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 : return self . Hphi . shape [ 0 ] if self . A is not None : return self . A . shape [ 1 ] if self . J is not None : return self . J . shape [ 1 ] if...
Gets number of primal variables .
40,099
def get_results ( self ) : return { 'status' : self . status , 'error_msg' : self . error_msg , 'k' : self . k , 'x' : self . x , 'lam' : self . lam * self . obj_sca , 'nu' : self . nu * self . obj_sca , 'mu' : self . mu * self . obj_sca , 'pi' : self . pi * self . obj_sca }
Gets results .