idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
39,900
def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_charging_params ( self . _id ) if data : self . __battery_level = data [ 'battery_level' ] self . __charging_state = data [ 'charging_state' ]
Update the battery state .
39,901
def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_charging_params ( self . _id ) if data : self . __battery_range = data [ 'battery_range' ] self . __est_battery_range = data [ 'est_battery_range' ] self . __ideal_battery_range = data [ 'ideal_batt...
Update the battery range state .
39,902
def assumed_state ( self ) : return ( not self . _controller . car_online [ self . id ( ) ] and ( self . _controller . _last_update_time [ self . id ( ) ] - self . _controller . _last_wake_up_time [ self . id ( ) ] > self . _controller . update_interval ) )
Return whether the data is from an online vehicle .
39,903
def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_drive_params ( self . _id ) if data : self . __longitude = data [ 'longitude' ] self . __latitude = data [ 'latitude' ] self . __heading = data [ 'heading' ] if self . __longitude and self . __latit...
Update the current GPS location .
39,904
def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_state_params ( self . _id ) if data : self . __odometer = data [ 'odometer' ] data = self . _controller . get_gui_params ( self . _id ) if data : if data [ 'gui_distance_units' ] == "mi/hr" : self ....
Update the odometer and the unit of measurement based on GUI .
39,905
def lc ( ** kwargs ) : obs_params = [ ] syn_params , constraints = lc_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) return ParameterSet ( obs_params ) , constraints
Create parameters for a new light curve dataset .
39,906
def rv ( ** kwargs ) : obs_params = [ ] syn_params , constraints = rv_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) return ParameterSet ( obs_params ) , constraints
Create parameters for a new radial velocity dataset .
39,907
def lp ( ** kwargs ) : obs_params = [ ] syn_params , constraints = lp_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) return ParameterSet ( obs_params ) , constraints
Create parameters for a new line profile dataset .
39,908
def etv ( ** kwargs ) : if not conf . devel : raise NotImplementedError ( "'etv' dataset not officially supported for this release. Enable developer mode to test." ) obs_params = [ ] syn_params , constraints = etv_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) return ParameterSet ( obs_params )...
Create parameters for a new eclipse timing variations dataset .
39,909
def orb ( ** kwargs ) : obs_params = [ ] syn_params , constraints = orb_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) return ParameterSet ( obs_params ) , [ ]
Create parameters for a new orbit dataset .
39,910
def mesh ( ** kwargs ) : obs_params = [ ] syn_params , constraints = mesh_syn ( syn = False , ** kwargs ) obs_params += syn_params . to_list ( ) obs_params += [ SelectParameter ( qualifier = 'include_times' , value = kwargs . get ( 'include_times' , [ ] ) , description = 'append to times from the following datasets/tim...
Create parameters for a new mesh dataset .
39,911
def team_required ( func = None ) : def decorator ( view_func ) : @ functools . wraps ( view_func , assigned = available_attrs ( view_func ) ) def _wrapped_view ( request , * args , ** kwargs ) : slug = kwargs . pop ( "slug" , None ) if not getattr ( request , "team" , None ) : request . team = get_object_or_404 ( Team...
Decorator for views that require a team be supplied wither via a slug in the url pattern or already set on the request object from the TeamMiddleware
39,912
def manager_required ( func = None ) : def decorator ( view_func ) : @ team_required @ login_required @ functools . wraps ( view_func , assigned = available_attrs ( view_func ) ) def _wrapped_view ( request , * args , ** kwargs ) : role = request . team . role_for ( request . user ) if role not in [ Membership . ROLE_M...
Decorator for views that require not only a team but also that a user be logged in and be the manager or owner of that team .
39,913
def _create_syns ( b , needed_syns ) : params = [ ] for needed_syn in needed_syns : syn_kind = '{}' . format ( needed_syn [ 'kind' ] ) if 'times' in needed_syn . keys ( ) : needed_syn [ 'times' ] . sort ( ) needed_syn [ 'empty_arrays_len' ] = len ( needed_syn [ 'times' ] ) these_params , these_constraints = getattr ( _...
Create empty synthetics
39,914
def _make_packet ( qualifier , value , time , info , ** kwargs ) : packet = { 'dataset' : kwargs . get ( 'dataset' , info [ 'dataset' ] ) , 'component' : kwargs . get ( 'component' , info [ 'component' ] ) , 'kind' : kwargs . get ( 'kind' , info [ 'kind' ] ) , 'qualifier' : qualifier , 'value' : value , 'time' : time }...
where kwargs overrides info
39,915
def run_checks ( self , b , compute , times = [ ] , ** kwargs ) : raise NotImplementedError ( "run_checks is not implemented by the {} backend" . format ( self . __class__ . __name__ ) )
run any sanity checks to make sure the parameters and options are legal for this backend . If they are not raise an error here to avoid errors within the workers .
39,916
def _fill_syns ( self , new_syns , rpacketlists_per_worker ) : logger . debug ( "rank:{}/{} {}._fill_syns" . format ( mpi . myrank , mpi . nprocs , self . __class__ . __name__ ) ) for packetlists in rpacketlists_per_worker : for packetlist in packetlists : for packet in packetlist : new_syns . set_value ( ** packet ) r...
rpacket_per_worker is a list of packetlists as returned by _run_chunk
39,917
def run ( self , b , compute , times = [ ] , ** kwargs ) : self . run_checks ( b , compute , times , ** kwargs ) logger . debug ( "rank:{}/{} calling get_packet_and_syns" . format ( mpi . myrank , mpi . nprocs ) ) packet , new_syns = self . get_packet_and_syns ( b , compute , times , ** kwargs ) if mpi . enabled : mpi ...
if within mpirun workers should call _run_worker instead of run
39,918
def compute_volume ( sizes , centers , normals ) : normal_mags = np . linalg . norm ( normals , axis = 1 ) return np . sum ( sizes * ( ( centers * normals ) . sum ( axis = 1 ) / normal_mags ) / 3 )
Compute the numerical volume of a convex mesh
39,919
def spin_in_system ( incl , long_an ) : return np . dot ( Rz ( long_an ) , np . dot ( Rx ( - incl ) , np . array ( [ 0. , 0. , 1. ] ) ) )
Spin in the plane of sky of a star given its inclination and long_an
39,920
def spin_in_roche ( s , etheta , elongan , eincl ) : m = euler_trans_matrix ( etheta , elongan , eincl ) return np . dot ( m . T , s )
Transform the spin s of a star on Kerpler orbit with
39,921
def transform_position_array ( array , pos , euler , is_normal , reverse = False ) : trans_matrix = euler_trans_matrix ( * euler ) if not reverse : trans_matrix = trans_matrix . T if isinstance ( array , ComputedColumn ) : array = array . for_computations if is_normal : return np . dot ( np . asarray ( array ) , trans_...
Transform any Nx3 position array by translating to a center - of - mass pos and applying an euler transformation
39,922
def transform_velocity_array ( array , pos_array , vel , euler , rotation_vel = ( 0 , 0 , 0 ) ) : trans_matrix = euler_trans_matrix ( * euler ) rotation_component = np . cross ( rotation_vel , pos_array , axisb = 1 ) orbital_component = np . asarray ( vel ) if isinstance ( array , ComputedColumn ) : array = array . for...
Transform any Nx3 velocity vector array by adding the center - of - mass vel accounting for solid - body rotation and applying an euler transformation .
39,923
def wd_grid_to_mesh_dict ( the_grid , q , F , d ) : triangles_9N = the_grid [ : , 4 : 13 ] new_mesh = { } new_mesh [ 'compute_at_vertices' ] = False new_mesh [ 'vertices' ] = triangles_9N . reshape ( - 1 , 3 ) new_mesh [ 'triangles' ] = np . arange ( len ( triangles_9N ) * 3 ) . reshape ( - 1 , 3 ) new_mesh [ 'centers'...
Transform a wd - style mesh to the format used by PHOEBE . Namely this handles translating vertices from Nx9 to Nx3x3 and creating the array of indices for each triangle .
39,924
def weighted_averages ( self ) : if not self . mesh . _compute_at_vertices : return None vertices_per_triangle = self . vertices_per_triangle if vertices_per_triangle . ndim == 2 : return np . sum ( vertices_per_triangle * self . mesh . weights , axis = 1 ) elif vertices_per_triangle . ndim == 3 : return np . sum ( ver...
Access to the weighted averages of the values at the vertices for each triangle based on the weights provided by mesh . weights . This is most useful for partially visible triangles when using libphoebe s eclipse detection that returns weights for each vertex .
39,925
def from_proto ( cls , proto_mesh , scale , pos , vel , euler , euler_vel , rotation_vel = ( 0 , 0 , 0 ) , component_com_x = None ) : mesh = cls ( ** proto_mesh . items ( ) ) mesh . _copy_roche_values ( ) mesh . _scale_mesh ( scale = scale ) mesh . _place_in_orbit ( pos , vel , euler , euler_vel , rotation_vel , compon...
Turn a ProtoMesh into a Mesh scaled and placed in orbit .
39,926
def update_columns ( self , field , value_dict , inds = None , computed_type = None ) : if not isinstance ( value_dict , dict ) : value_dict = { comp_no : value_dict for comp_no in self . _dict . keys ( ) } for comp , value in value_dict . items ( ) : if computed_type is not None : self . _dict [ comp ] . _observables ...
update the columns of all meshes
39,927
def _true_anomaly ( M , ecc , itermax = 8 ) : r Fn = M + ecc * sin ( M ) + ecc ** 2 / 2. * sin ( 2 * M ) for i in range ( itermax ) : F = Fn Mn = F - ecc * sin ( F ) Fn = F + ( M - Mn ) / ( 1. - ecc * cos ( F ) ) keep = F != 0 if hasattr ( F , '__iter__' ) : if np . all ( abs ( ( Fn - F ) [ keep ] / F [ keep ] ) < 0.00...
r Calculation of true and eccentric anomaly in Kepler orbits .
39,928
def spot ( feature , ** kwargs ) : params = [ ] params += [ FloatParameter ( qualifier = "colat" , value = kwargs . get ( 'colat' , 0.0 ) , default_unit = u . deg , description = 'Colatitude of the center of the spot wrt spin axes' ) ] params += [ FloatParameter ( qualifier = "long" , value = kwargs . get ( 'long' , 0....
Create parameters for a spot
39,929
def pulsation ( feature , ** kwargs ) : if not conf . devel : raise NotImplementedError ( "'pulsation' feature not officially supported for this release. Enable developer mode to test." ) params = [ ] params += [ FloatParameter ( qualifier = 'radamp' , value = kwargs . get ( 'radamp' , 0.1 ) , default_unit = u . dimen...
Create parameters for a pulsation feature
39,930
def load_lc_data ( filename , indep , dep , indweight = None , mzero = None , dir = './' ) : if '/' in filename : path , filename = os . path . split ( filename ) else : path = dir load_file = os . path . join ( path , filename ) lcdata = np . loadtxt ( load_file ) ncol = len ( lcdata [ 0 ] ) if dep == 'Magnitude' : ma...
load dictionary with lc data
39,931
def load_rv_data ( filename , indep , dep , indweight = None , dir = './' ) : if '/' in filename : path , filename = os . path . split ( filename ) else : path = dir load_file = os . path . join ( path , filename ) rvdata = np . loadtxt ( load_file ) d = { } d [ 'phoebe_rv_time' ] = rvdata [ : , 0 ] d [ 'phoebe_rv_vel'...
load dictionary with rv data .
39,932
def det_dataset ( eb , passband , dataid , comp , time ) : rvs = eb . get_dataset ( kind = 'rv' ) . datasets if dataid == 'Undefined' : dataid = None try : eb . _check_label ( dataid ) rv_dataset = eb . add_dataset ( 'rv' , dataset = dataid , times = [ ] ) except ValueError : logger . warning ( "The name picked for the...
Since RV datasets can have values related to each component in phoebe2 but are component specific in phoebe1 it is important to determine which dataset to add parameters to . This function will do that . eb - bundle rvpt - relevant phoebe 1 parameters
39,933
def rpole_to_pot_aligned ( rpole , sma , q , F , d , component = 1 ) : q = q_for_component ( q , component = component ) rpole_ = np . array ( [ 0 , 0 , rpole / sma ] ) logger . debug ( "libphoebe.roche_Omega(q={}, F={}, d={}, rpole={})" . format ( q , F , d , rpole_ ) ) pot = libphoebe . roche_Omega ( q , F , d , rpol...
Transforms polar radius to surface potential
39,934
def pot_to_rpole_aligned ( pot , sma , q , F , d , component = 1 ) : q = q_for_component ( q , component = component ) Phi = pot_for_component ( pot , q , component = component ) logger . debug ( "libphobe.roche_pole(q={}, F={}, d={}, Omega={})" . format ( q , F , d , pot ) ) return libphoebe . roche_pole ( q , F , d ,...
Transforms surface potential to polar radius
39,935
def BinaryRoche ( r , D , q , F , Omega = 0.0 ) : r return 1.0 / sqrt ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) + q * ( 1.0 / sqrt ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) - r [ 0 ] / D / D ) + 0.5 * F * F * ( 1 + q ) * ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] ) -...
r Computes a value of the asynchronous eccentric Roche potential .
39,936
def dBinaryRochedx ( r , D , q , F ) : return - r [ 0 ] * ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5 - q * ( r [ 0 ] - D ) * ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5 - q / D / D + F * F * ( 1 + q ) * r [ 0 ]
Computes a derivative of the potential with respect to x .
39,937
def d2BinaryRochedx2 ( r , D , q , F ) : return ( 2 * r [ 0 ] * r [ 0 ] - r [ 1 ] * r [ 1 ] - r [ 2 ] * r [ 2 ] ) / ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** 2.5 + q * ( 2 * ( r [ 0 ] - D ) * ( r [ 0 ] - D ) - r [ 1 ] * r [ 1 ] - r [ 2 ] * r [ 2 ] ) / ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ]...
Computes second derivative of the potential with respect to x .
39,938
def dBinaryRochedy ( r , D , q , F ) : return - r [ 1 ] * ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5 - q * r [ 1 ] * ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5 + F * F * ( 1 + q ) * r [ 1 ]
Computes a derivative of the potential with respect to y .
39,939
def dBinaryRochedz ( r , D , q , F ) : return - r [ 2 ] * ( r [ 0 ] * r [ 0 ] + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5 - q * r [ 2 ] * ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** - 1.5
Computes a derivative of the potential with respect to z .
39,940
def dBinaryRochedr ( r , D , q , F ) : r2 = ( r * r ) . sum ( ) r1 = np . sqrt ( r2 ) return - 1. / r2 - q * ( r1 - r [ 0 ] / r1 * D ) / ( ( r [ 0 ] - D ) * ( r [ 0 ] - D ) + r [ 1 ] * r [ 1 ] + r [ 2 ] * r [ 2 ] ) ** 1.5 - q * r [ 0 ] / r1 / D / D + F * F * ( 1 + q ) * ( 1 - r [ 2 ] * r [ 2 ] / r2 ) * r1
Computes a derivative of the potential with respect to r .
39,941
def send_if_client ( fctn ) : @ functools . wraps ( fctn ) def _send_if_client ( self , * args , ** kwargs ) : fctn_map = { 'set_quantity' : 'set_value' } b = self . _bundle if b is not None and b . is_client : method = fctn_map . get ( fctn . __name__ , fctn . __name__ ) d = self . _filter if hasattr ( self , '_filter...
Intercept and send to the server if bundle is in client mode .
39,942
def update_if_client ( fctn ) : @ functools . wraps ( fctn ) def _update_if_client ( self , * args , ** kwargs ) : b = self . _bundle if b is None or not hasattr ( b , 'is_client' ) : return fctn ( self , * args , ** kwargs ) elif b . is_client and ( b . _last_client_update is None or ( datetime . now ( ) - b . _last_c...
Intercept and check updates from server if bundle is in client mode .
39,943
def _uniqueid ( n = 30 ) : return '' . join ( random . SystemRandom ( ) . choice ( string . ascii_uppercase + string . ascii_lowercase ) for _ in range ( n ) )
Return a unique string with length n .
39,944
def parameter_from_json ( dictionary , bundle = None ) : if isinstance ( dictionary , str ) : dictionary = json . loads ( dictionary , object_pairs_hook = parse_json ) classname = dictionary . pop ( 'Class' ) if classname not in _parameter_class_that_require_bundle : bundle = None cls = getattr ( sys . modules [ __name...
Load a single parameter from a JSON dictionary .
39,945
def get_meta ( self , ignore = [ 'uniqueid' ] ) : return OrderedDict ( [ ( k , getattr ( self , k ) ) for k in _meta_fields_twig if k not in ignore ] )
Dictionary of all meta - tags with option to ignore certain tags .
39,946
def set_meta ( self , ** kwargs ) : for param in self . to_list ( ) : for k , v in kwargs . items ( ) : if getattr ( param , '_{}' . format ( k ) ) is None : setattr ( param , '_{}' . format ( k ) , v )
Set the value of tags for all Parameters in this ParameterSet .
39,947
def tags ( self ) : ret = { } for typ in _meta_fields_twig : if typ in [ 'uniqueid' , 'plugin' , 'feedback' , 'fitting' , 'history' , 'twig' , 'uniquetwig' ] : continue k = '{}s' . format ( typ ) ret [ k ] = getattr ( self , k ) return ret
Returns a dictionary that lists all available tags that can be used for further filtering
39,948
def _set_meta ( self ) : for field in _meta_fields_twig : keys_for_this_field = set ( [ getattr ( p , field ) for p in self . to_list ( ) if getattr ( p , field ) is not None ] ) if len ( keys_for_this_field ) == 1 : setattr ( self , '_' + field , list ( keys_for_this_field ) [ 0 ] ) else : setattr ( self , '_' + field...
set the meta fields of the ParameterSet as those that are shared by ALL parameters in the ParameterSet . For any fields that are not
39,949
def _uniquetwig ( self , twig , force_levels = [ 'qualifier' ] ) : for_this_param = self . filter ( twig , check_visible = False ) metawargs = { } if 'context' not in force_levels : force_levels . append ( 'context' ) for k in force_levels : metawargs [ k ] = getattr ( for_this_param , k ) prev_count = len ( self ) ps_...
get the least unique twig for the parameter given by twig that will return this single result for THIS PS
39,950
def _check_copy_for ( self ) : if not self . _bundle : return for param in self . to_list ( ) : if param . copy_for : attrs = [ k for k , v in param . copy_for . items ( ) if '*' in v ] ps = self . _bundle . filter ( check_visible = False , check_default = False , force_ps = True , ** param . copy_for ) metawargs = { k...
Check the value of copy_for and make appropriate copies .
39,951
def _check_label ( self , label ) : if not isinstance ( label , str ) : label = str ( label ) if label . lower ( ) in _forbidden_labels : raise ValueError ( "'{}' is forbidden to be used as a label" . format ( label ) ) if not re . match ( "^[a-z,A-Z,0-9,_]*$" , label ) : raise ValueError ( "label '{}' is forbidden - o...
Check to see if the label is allowed .
39,952
def save ( self , filename , incl_uniqueid = False , compact = False ) : filename = os . path . expanduser ( filename ) f = open ( filename , 'w' ) if compact : if _can_ujson : ujson . dump ( self . to_json ( incl_uniqueid = incl_uniqueid ) , f , sort_keys = False , indent = 0 ) else : logger . warning ( "for faster co...
Save the ParameterSet to a JSON - formatted ASCII file
39,953
def set ( self , key , value , ** kwargs ) : twig = key method = None twigsplit = re . findall ( r"[\w']+" , twig ) if twigsplit [ 0 ] == 'value' : twig = '@' . join ( twigsplit [ 1 : ] ) method = 'set_value' elif twigsplit [ 0 ] == 'quantity' : twig = '@' . join ( twigsplit [ 1 : ] ) method = 'set_quantity' elif twigs...
Set the value of a Parameter in the ParameterSet .
39,954
def to_json ( self , incl_uniqueid = False ) : lst = [ ] for context in _contexts : lst += [ v . to_json ( incl_uniqueid = incl_uniqueid ) for v in self . filter ( context = context , check_visible = False , check_default = False ) . to_list ( ) ] return lst
Convert the ParameterSet to a json - compatible dictionary
39,955
def filter ( self , twig = None , check_visible = True , check_default = True , ** kwargs ) : kwargs [ 'check_visible' ] = check_visible kwargs [ 'check_default' ] = check_default kwargs [ 'force_ps' ] = True return self . filter_or_get ( twig = twig , ** kwargs )
Filter the ParameterSet based on the meta - tags of the Parameters and return another ParameterSet .
39,956
def get ( self , twig = None , check_visible = True , check_default = True , ** kwargs ) : kwargs [ 'check_visible' ] = check_visible kwargs [ 'check_default' ] = check_default ps = self . filter ( twig = twig , ** kwargs ) if not len ( ps ) : raise ValueError ( "0 results found" ) elif len ( ps ) != 1 : raise ValueErr...
Get a single parameter from this ParameterSet . This works exactly the same as filter except there must be only a single result and the Parameter itself is returned instead of a ParameterSet .
39,957
def exclude ( self , twig = None , check_visible = True , ** kwargs ) : return self - self . filter ( twig = twig , check_visible = check_visible , ** kwargs )
Exclude the results from this filter from the current ParameterSet .
39,958
def _remove_parameter ( self , param ) : self . _params = [ p for p in self . _params if p != param ]
Remove a Parameter from the ParameterSet
39,959
def show ( self , ** kwargs ) : kwargs . setdefault ( 'show' , True ) kwargs . setdefault ( 'save' , False ) kwargs . setdefault ( 'animate' , False ) return self . _show_or_save ( ** kwargs )
Draw and show the plot .
39,960
def savefig ( self , filename , ** kwargs ) : filename = os . path . expanduser ( filename ) kwargs . setdefault ( 'show' , False ) kwargs . setdefault ( 'save' , filename ) kwargs . setdefault ( 'animate' , False ) return self . _show_or_save ( ** kwargs )
Draw and save the plot .
39,961
def save ( self , filename , incl_uniqueid = False ) : filename = os . path . expanduser ( filename ) f = open ( filename , 'w' ) json . dump ( self . to_json ( incl_uniqueid = incl_uniqueid ) , f , sort_keys = True , indent = 0 , separators = ( ',' , ': ' ) ) f . close ( ) return filename
Save the Parameter to a JSON - formatted ASCII file
39,962
def get_meta ( self , ignore = [ 'uniqueid' ] ) : return OrderedDict ( [ ( k , getattr ( self , k ) ) for k in _meta_fields_all if k not in ignore ] )
See all the meta - tag properties for this Parameter
39,963
def expand_value ( self , ** kwargs ) : selection = [ ] for v in self . get_value ( ** kwargs ) : for choice in self . choices : if v == choice and choice not in selection : selection . append ( choice ) elif fnmatch ( choice , v ) and choice not in selection : selection . append ( choice ) return selection
expand the selection to account for wildcards
39,964
def is_constraint ( self ) : if self . _is_constraint is None : return None return self . _bundle . get_parameter ( context = 'constraint' , uniqueid = self . _is_constraint )
returns the expression of the constraint that constrains this parameter
39,965
def constrained_by ( self ) : if self . _is_constraint is None : return [ ] params = [ ] for var in self . is_constraint . _vars : param = var . get_parameter ( ) if param . uniqueid != self . uniqueid : params . append ( param ) return params
returns a list of parameters that constrain this parameter
39,966
def in_constraints ( self ) : expressions = [ ] for uniqueid in self . _in_constraints : expressions . append ( self . _bundle . get_parameter ( context = 'constraint' , uniqueid = uniqueid ) ) return expressions
returns a list of the expressions in which this parameter constrains another
39,967
def constrains ( self ) : params = [ ] for constraint in self . in_constraints : for var in constraint . _vars : param = var . get_parameter ( ) if param . component == constraint . component and param . qualifier == constraint . qualifier : if param not in params and param . uniqueid != self . uniqueid : params . appe...
returns a list of parameters that are constrained by this parameter
39,968
def related_to ( self ) : params = [ ] constraints = self . in_constraints if self . is_constraint is not None : constraints . append ( self . is_constraint ) for constraint in constraints : for var in constraint . _vars : param = var . get_parameter ( ) if param not in params and param . uniqueid != self . uniqueid : ...
returns a list of all parameters that are either constrained by or constrain this parameter
39,969
def set_property ( self , ** kwargs ) : if not isinstance ( self . _value , nparray . ndarray ) : raise ValueError ( "value is not a nparray object" ) for property , value in kwargs . items ( ) : setattr ( self . _value , property , value )
set any property of the underlying nparray object
39,970
def _recurse_find_trace ( self , structure , item , trace = [ ] ) : try : i = structure . index ( item ) except ValueError : for j , substructure in enumerate ( structure ) : if isinstance ( substructure , list ) : return self . _recurse_find_trace ( substructure , item , trace + [ j ] ) else : return trace + [ i ]
given a nested structure from _parse_repr and find the trace route to get to item
39,971
def get_stars ( self ) : l = re . findall ( r"[\w']+" , self . get_value ( ) ) return [ l [ i + 1 ] for i , s in enumerate ( l ) if s == 'star' ]
get component of all stars in order primary - > secondary
39,972
def get_orbits ( self ) : orbits = [ ] for star in self . get_stars ( ) : parent = self . get_parent_of ( star ) if parent not in orbits and parent != 'component' and parent is not None : orbits . append ( parent ) return orbits
get component of all orbits in order primary - > secondary
39,973
def get_stars_of_sibling_of ( self , component ) : sibling = self . get_sibling_of ( component ) if sibling in self . get_stars ( ) : return sibling stars = [ child for child in self . get_stars_of_children_of ( sibling ) ] return stars
same as get_sibling_of except if the sibling is an orbit this will recursively follow the tree to return a list of all stars under that orbit
39,974
def get_children_of ( self , component , kind = None ) : structure , trace , item = self . _get_structure_and_trace ( component ) item_kind , item_label = item . split ( ':' ) if isinstance ( kind , str ) : kind = [ kind ] if item_kind not in [ 'orbit' ] : return [ ] else : items = self . _get_by_trace ( structure , tr...
get to component labels of the children of a given component
39,975
def get_primary_or_secondary ( self , component , return_ind = False ) : parent = self . get_parent_of ( component ) if parent is None : return 'primary' children_of_parent = self . get_children_of ( parent ) ind = children_of_parent . index ( component ) if ind > 1 : return None if return_ind : return ind + 1 return [...
return whether a given component is the primary or secondary component in its parent orbit
39,976
def vars ( self ) : if self . _var_params is None : self . _var_params = ParameterSet ( [ var . get_parameter ( ) for var in self . _vars ] ) return self . _var_params
return all the variables in a PS
39,977
def get_parameter ( self , twig = None , ** kwargs ) : kwargs [ 'twig' ] = twig kwargs [ 'check_default' ] = False kwargs [ 'check_visible' ] = False ps = self . vars . filter ( ** kwargs ) if len ( ps ) == 1 : return ps . get ( check_visible = False , check_default = False ) elif len ( ps ) > 1 : return ps . to_list (...
get a parameter from those that are variables
39,978
def flip_for ( self , twig = None , expression = None , ** kwargs ) : _orig_expression = self . get_value ( ) kwargs [ 'twig' ] = twig newly_constrained_var = self . _get_var ( ** kwargs ) newly_constrained_param = self . get_parameter ( ** kwargs ) check_kwargs = { k : v for k , v in newly_constrained_param . meta . i...
flip the constraint to solve for for any of the parameters in the expression
39,979
def get_unbound_form ( self ) : form_kwargs = self . get_form_kwargs ( ) bound_fields = [ "data" , "files" ] for field in bound_fields : form_kwargs . pop ( field , None ) return self . get_form_class ( ) ( ** form_kwargs )
Overrides behavior of FormView . get_form_kwargs when method is POST or PUT
39,980
def get_form_success_data ( self , form ) : data = { "html" : render_to_string ( "pinax/teams/_invite_form.html" , { "invite_form" : self . get_unbound_form ( ) , "team" : self . team } , request = self . request ) } membership = self . membership if membership is not None : if membership . state == Membership . STATE_...
Allows customization of the JSON data returned when a valid form submission occurs .
39,981
def _value ( obj ) : if hasattr ( obj , 'value' ) : return obj . value elif isinstance ( obj , np . ndarray ) : return np . array ( [ o . value for o in obj ] ) elif hasattr ( obj , '__iter__' ) : return [ _value ( o ) for o in obj ] return obj
make sure to get a float
39,982
def _estimate_delta ( ntriangles , area ) : return np . sqrt ( 4. / np . sqrt ( 3 ) * float ( area ) / float ( ntriangles ) )
estimate the value for delta to send to marching based on the number of requested triangles and the expected surface area of mesh
39,983
def handle_eclipses ( self , expose_horizon = False , ** kwargs ) : eclipse_method = kwargs . get ( 'eclipse_method' , self . eclipse_method ) horizon_method = kwargs . get ( 'horizon_method' , self . horizon_method ) possible_eclipse = False if len ( self . bodies ) == 1 : if self . bodies [ 0 ] . __class__ . __name__...
Detect the triangles at the horizon and the eclipsed triangles handling any necessary subdivision .
39,984
def compute_pblum_scale ( self , dataset , pblum , ** kwargs ) : logger . debug ( "{}.compute_pblum_scale(dataset={}, pblum={})" . format ( self . component , dataset , pblum ) ) abs_luminosity = self . compute_luminosity ( dataset , ** kwargs ) pblum_scale = pblum / abs_luminosity self . set_pblum_scale ( dataset , pb...
intensities should already be computed for this dataset at the time for which pblum is being provided
39,985
def _populate_lp ( self , dataset , ** kwargs ) : logger . debug ( "{}._populate_lp(dataset={})" . format ( self . component , dataset ) ) profile_rest = kwargs . get ( 'profile_rest' , self . lp_profile_rest . get ( dataset ) ) rv_cols = self . _populate_rv ( dataset , ** kwargs ) cols = rv_cols return cols
Populate columns necessary for an LP dataset
39,986
def _populate_rv ( self , dataset , ** kwargs ) : logger . debug ( "{}._populate_rv(dataset={})" . format ( self . component , dataset ) ) lc_cols = self . _populate_lc ( dataset , ** kwargs ) rvs = - 1 * self . mesh . velocities . for_computations [ : , 2 ] if self . do_rv_grav : rv_grav = c . G * ( self . mass * u . ...
Populate columns necessary for an RV dataset
39,987
def from_bundle ( cls , b , feature ) : feature_ps = b . get_feature ( feature ) colat = feature_ps . get_value ( 'colat' , unit = u . rad ) longitude = feature_ps . get_value ( 'long' , unit = u . rad ) if len ( b . hierarchy . get_stars ( ) ) >= 2 : star_ps = b . get_component ( feature_ps . component ) orbit_ps = b ...
Initialize a Spot feature from the bundle .
39,988
def pointing_vector ( self , s , time ) : t = time - self . _t0 longitude = self . _longitude + self . _dlongdt * t ex = np . array ( [ 1. , 0. , 0. ] ) ezp = s exp = ( ex - s * np . dot ( s , ex ) ) eyp = np . cross ( s , exp ) return np . sin ( self . _colat ) * np . cos ( longitude ) * exp + np . sin ( self . _colat...
s is the spin vector in roche coordinates time is the current time
39,989
def process_teffs ( self , teffs , coords , s = np . array ( [ 0. , 0. , 1. ] ) , t = None ) : if t is None : t = self . _t0 pointing_vector = self . pointing_vector ( s , t ) logger . debug ( "spot.process_teffs at t={} with pointing_vector={} and radius={}" . format ( t , pointing_vector , self . _radius ) ) cos_alph...
Change the local effective temperatures for any values within the cone defined by the spot . Any teff within the spot will have its current value multiplied by the relteff factor
39,990
def from_bundle ( cls , b , feature ) : feature_ps = b . get_feature ( feature ) freq = feature_ps . get_value ( 'freq' , unit = u . d ** - 1 ) radamp = feature_ps . get_value ( 'radamp' , unit = u . dimensionless_unscaled ) l = feature_ps . get_value ( 'l' , unit = u . dimensionless_unscaled ) m = feature_ps . get_val...
Initialize a Pulsation feature from the bundle .
39,991
def from_server ( cls , bundleid , server = 'http://localhost:5555' , as_client = True ) : if not conf . devel : raise NotImplementedError ( "'from_server' not officially supported for this release. Enable developer mode to test." ) url = "{}/{}/json" . format ( server , bundleid ) logger . info ( "downloading bundle ...
Load a new bundle from a server .
39,992
def from_legacy ( cls , filename , add_compute_legacy = True , add_compute_phoebe = True ) : logger . warning ( "importing from legacy is experimental until official 1.0 release" ) filename = os . path . expanduser ( filename ) return io . load_legacy ( filename , add_compute_legacy , add_compute_phoebe )
Load a bundle from a PHOEBE 1 . 0 Legacy file .
39,993
def default_triple ( cls , inner_as_primary = True , inner_as_overcontact = False , starA = 'starA' , starB = 'starB' , starC = 'starC' , inner = 'inner' , outer = 'outer' , contact_envelope = 'contact_envelope' ) : if not conf . devel : raise NotImplementedError ( "'default_triple' not officially supported for this re...
Load a bundle with a default triple system .
39,994
def save ( self , filename , clear_history = True , incl_uniqueid = False , compact = False ) : if clear_history : self . remove_history ( ) return super ( Bundle , self ) . save ( filename , incl_uniqueid = incl_uniqueid , compact = compact )
Save the bundle to a JSON - formatted ASCII file .
39,995
def _default_label ( self , base , context , ** kwargs ) : kwargs [ 'context' ] = context params = len ( getattr ( self . filter ( check_visible = False , ** kwargs ) , '{}s' . format ( context ) ) ) return "{}{:02d}" . format ( base , params + 1 )
Determine a default label given a base label and the passed kwargs
39,996
def get_setting ( self , twig = None , ** kwargs ) : if twig is not None : kwargs [ 'twig' ] = twig kwargs [ 'context' ] = 'setting' return self . filter_or_get ( ** kwargs )
Filter in the setting context
39,997
def get_history ( self , i = None ) : ps = self . filter ( context = 'history' ) if i is not None : return ps . to_list ( ) [ i ] else : return ps
Get a history item by index .
39,998
def remove_history ( self , i = None ) : if i is None : self . remove_parameters_all ( context = 'history' ) else : param = self . get_history ( i = i ) self . remove_parameter ( uniqueid = param . uniqueid )
Remove a history item from the bundle by index .
39,999
def undo ( self , i = - 1 ) : _history_enabled = self . history_enabled param = self . get_history ( i ) self . disable_history ( ) param . undo ( ) self . remove_parameter ( uniqueid = param . uniqueid ) if _history_enabled : self . enable_history ( )
Undo an item in the history logs