output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def populate_observable(self, time, kind, dataset, **kwargs): """ TODO: add documentation """ if kind in ['mesh', 'orb']: return if time==self.time and dataset in self.populated_at_time and 'pblum' not in kind: # then we've already computed the needed co...
Write a Python 3 function that can populate the internal data structures for the specified dataset.
As a Python code composer, you craft elegant and concise scripts.
def from_bundle(cls, b, component, compute=None, mesh_init_phi=0.0, datasets=[], **kwargs): """ Build a star from the :class:`phoebe.frontend.bundle.Bundle` and its hierarchy. Usually it makes more sense to call :meth:`System.from_bundle` directly. :paramete...
Implement a Python 3 function for building a star from a bundle.
As a Python code translator, you convert algorithms and pseudocode into Python.
def polar_direction_xyz(self): """ get current polar direction in Roche (xyz) coordinates """ return mesh.spin_in_roche(self.polar_direction_uvw, self.true_anom, self.elongan, self.eincl).astype(float)
How would you code a function in Python 3 to get current polar direction in Roche ( xyz coordinates
You are a Python code analyst, evaluating scripts for potential improvements.
get the target volume of the object
Can you tell what is the following Python 3 function doing def get_target_volume(self, etheta=0.0, scaled=False): # TODO: make this a function of d instead of etheta? logger.debug("determining target volume at t={}, theta={}".format(self.time, etheta)) # TODO: eventually this could allow us to ...
You are a Python code architect, reviewing and designing scalable and efficient code
location of the north pole in the global system frame
Can you tell what is the following Python 3 function doing def north_pole_uvw(self): # TODO: is this rpole scaling true for all distortion_methods?? rpole = self.instantaneous_rpole*self.sma return self.polar_direction_uvw*rpole+self.mesh._pos
You are a Python code generator, capable of creating scripts from specifications.
Fill the loggs of the current instance with the loggs of the current instance.
Here you have a function in Python 3, explain what it does def _fill_loggs(self, mesh=None, ignore_effects=False): logger.debug("{}._fill_loggs".format(self.component)) if mesh is None: mesh = self.mesh loggs = np.log10(mesh.normgrads.for_computations * g_rel_to_abs(self.masses[sel...
As a Python code composer, you craft elegant and concise scripts.
def _fill_gravs(self, mesh=None, **kwargs): """ TODO: add documentation requires _fill_loggs to have been called """ logger.debug("{}._fill_gravs".format(self.component)) if mesh is None: mesh = self.mesh # TODO: rename 'gravs' to 'gdcs' (gravity da...
Implement a Python 3 function for filling the gravbs of the current object with the current gravbs of the current object.
You are a Python code analyst, evaluating scripts for potential improvements.
r Fills the local temperatures of the given mesh with the local temperatures of the given instance of the class.
Explain what the following Python 3 code does def _fill_teffs(self, mesh=None, ignore_effects=False, **kwargs): logger.debug("{}._fill_teffs".format(self.component)) if mesh is None: mesh = self.mesh # Now we can compute the local temperatures. # see PHOEBE Legacy scientifi...
You are a Python code architect, reviewing and designing scalable and efficient code
Fill in the internal columns of the internal mesh.
Make a summary of the following Python 3 code def _fill_abuns(self, mesh=None, abun=0.0): logger.debug("{}._fill_abuns".format(self.component)) if mesh is None: mesh = self.mesh # TODO: support from frontend mesh.update_columns(abuns=abun) if not self.needs_recomp...
As a python code expert, you are capable of creating scripts from specifications.
Fill in the albedos of the current instance of the class.
How would you explain what the following Python 3 function does def _fill_albedos(self, mesh=None, irrad_frac_refl=0.0): logger.debug("{}._fill_albedos".format(self.component)) if mesh is None: mesh = self.mesh mesh.update_columns(irrad_frac_refl=irrad_frac_refl) if not se...
As a Python code composer, you craft elegant and concise scripts.
Compute the pblum scale for all intensities in this dataset.
Can you tell what is the following Python 3 function doing 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) # We now want to r...
As a Python code composer, you craft elegant and concise scripts.
def _populate_lp(self, dataset, **kwargs): """ Populate columns necessary for an LP dataset This should not be called directly, but rather via :meth:`Body.populate_observable` or :meth:`System.populate_observables` """ logger.debug("{}._populate_lp(dataset={})".format(se...
Can you write a function in Python 3 where it populates columns necessary for an LP dataset
You are a Python code architect, reviewing and designing scalable and efficient code
def _populate_rv(self, dataset, **kwargs): """ Populate columns necessary for an RV dataset This should not be called directly, but rather via :meth:`Body.populate_observable` or :meth:`System.populate_observables` """ logger.debug("{}._populate_rv(dataset={})".format(se...
Implement a Python 3 function for populating the columns necessary for an RV dataset
As a Python code translator, you convert algorithms and pseudocode into Python.
def _populate_lc(self, dataset, **kwargs): """ Populate columns necessary for an LC dataset This should not be called directly, but rather via :meth:`Body.populate_observable` or :meth:`System.populate_observables` :raises NotImplementedError: if lc_method is not supported ...
Write a Python 3 script to populate the columns necessary for an LC dataset.
You are a Python code analyst, evaluating scripts for potential improvements.
Returns True if the star needs to be re - meshed.
Given the following Python 3 function, write the documentation def needs_remesh(self): # TODO: may be able to get away with removing the features check and just doing for pulsations, etc? # TODO: what about dpdt, deccdt, dincldt, etc? return len(self.features) > 0 or self.is_misaligned or self.e...
You are a Python code architect, reviewing and designing scalable and efficient code
This function builds the mesh for a specific class of class
Make a summary of the following Python 3 code def _build_mesh(self, mesh_method, **kwargs): # need the sma to scale between Roche and real units sma = kwargs.get('sma', self.sma) # Rsol (same units as coordinates) mesh_args = self.instantaneous_mesh_args if mesh_method == 'marching':...
As a Python code composer, you craft elegant and concise scripts.
Builds a mesh from the given parameters.
Can you generate a brief explanation for the following Python 3 code def _build_mesh(self, mesh_method, **kwargs): # if we don't provide instantaneous masses or smas, then assume they are # not time dependent - in which case they were already stored in the init sma = kwargs.get('sma', self.sma)...
As a Python code translator, you convert algorithms and pseudocode into Python.
def populate_observable(self, time, kind, dataset, **kwargs): """ TODO: add documentation """ for half in self._halves: half.populate_observable(time, kind, dataset, **kwargs)
Can you write a function in Python 3 where it populates the internal data structures of the observed data structures.
As a python code expert, you are capable of creating scripts from specifications.
def from_bundle(cls, b, feature): """ Initialize a Spot feature from the bundle. """ 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: ...
Implement a Python 3 function for initializing a Spot feature from the bundle.
As a Python code analyst, you investigate and solve complex coding mysteries
def pointing_vector(self, s, time): """ s is the spin vector in roche coordinates time is the current time """ t = time - self._t0 longitude = self._longitude + self._dlongdt * t # define the basis vectors in the spin (primed) coordinates in terms of # th...
Implement a function in Python 3 to return the basis vectors in roche coordinates
You are a Python code generator, capable of creating scripts from specifications.
This function takes a set of teffs and a set of coordinates and returns a set of teffs that are within the spot and applies the relteff factor to those teffs.
Make a summary of the following Python 3 code def process_teffs(self, teffs, coords, s=np.array([0., 0., 1.]), t=None): if t is None: # then assume at t0 t = self._t0 pointing_vector = self.pointing_vector(s,t) logger.debug("spot.process_teffs at t={} with pointing_vecto...
As a Python code analyst, you investigate and solve complex coding mysteries
def from_bundle(cls, b, feature): """ Initialize a Pulsation feature from the bundle. """ 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.g...
Create a Python 3 function for initializing a Pulsation feature from a bundle.
As a Python code composer, you craft elegant and concise scripts.
project a mesh onto a potential
Given the following Python 3 function, write the documentation def project_onto_potential(r, pot_name, *args): pot = globals()[pot_name] dpdx = globals()['d%sdx'%(pot_name)] dpdy = globals()['d%sdy'%(pot_name)] dpdz = globals()['d%sdz'%(pot_name)] dpdr = globals()['d%sdr'%(pot_name)] n_iter = ...
You are a Python code generator, capable of creating scripts from specifications.
Open a new bundle from a JSON - formatted PHOEBE 2 file. This is a constructor so should be called as : class:`Bundle` object.
Can you tell what is the following Python 3 function doing def open(cls, filename): filename = os.path.expanduser(filename) logger.debug("importing from {}".format(filename)) f = open(filename, 'r') data = json.load(f, object_pairs_hook=parse_json) f.close() b = cls(data)...
You are a Python code architect, reviewing and designing scalable and efficient code
def from_server(cls, bundleid, server='http://localhost:5555', as_client=True): """Load a new bundle from a server. [NOT IMPLEMENTED] Load a bundle from a phoebe server. This is a constructor so should be called as: >>> b = Bundle.from_server('asdf', as_cl...
Write a Python 3 script to load a new bundle from a phoebe server.
As a Python code translator, you convert algorithms and pseudocode into Python.
Load a bundle from a PHOEBE 1. 0 Legacy file.
Explain what the following Python 3 code does 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_l...
You are a Python code architect, reviewing and designing scalable and efficient code
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'): """Load a bundle with a default triple system. ...
How would you code a function in Python 3 to load a bundle with a default triple system.
As a python code expert, you are capable of creating scripts from specifications.
def save(self, filename, clear_history=True, incl_uniqueid=False, compact=False): """Save the bundle to a JSON-formatted ASCII file. :parameter str filename: relative or full path to the file :parameter bool clear_history: whether to clear history log items before savin...
Write a Python 3 script for saving the bundle to a JSON - formatted ASCII file.
As a python code expert, you are capable of creating scripts from specifications.
def export_legacy(self, filename): """ TODO: add docs """ logger.warning("exporting to legacy is experimental until official 1.0 release") filename = os.path.expanduser(filename) return io.pass_to_legacy(self, filename)
Create a Python 3 function for exporting the current object to a legacy file.
You are a Python code generator, capable of creating scripts from specifications.
Handle incoming socket push updates from server
How would you explain what the following Python 3 function does def _on_socket_push_updates(self, resp): # TODO: check to make sure resp['meta']['bundleid']==bundleid ? # TODO: handle added parameters # TODO: handle removed (isDeleted) parameters for item in resp['data']: if...
As a Python code translator, you convert algorithms and pseudocode into Python.
def _attach_param_from_server(self, item): """ [NOT IMPLEMENTED] """ if isinstance(item, list): for itemi in item: self._attach_param_from_server(itemi) else: # then we need to add a new parameter d = item['attributes'] ...
How would you code a function in Python 3 to attach a parameter to the bundle based on the item.
As a Python code composer, you craft elegant and concise scripts.
Subscribe to the server and set as_client flag.
Can you generate the documentation for the following Python 3 function def as_client(self, as_client=True, server='http://localhost:5555', bundleid=None): """ [NOT IMPLEMENTED] """ if as_client: if not _can_client: raise ImportError("dependen...
You are a Python code architect, reviewing and designing scalable and efficient code
def client_update(self): """ [NOT IMPLEMENTED] """ if not self.is_client: raise ValueError("Bundle is not in client mode, cannot update") logger.info("updating client...") # wait briefly to pickup any missed messages, which should then fire # the corr...
Implement a Python 3 function for updating the bundle with the latest entries from the client.
As a Python code composer, you craft elegant and concise scripts.
This function returns a default label given a base label and a context and keyword arguments
Can you generate the documentation for the following Python 3 function 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)
As a Python code analyst, you investigate and solve complex coding mysteries
Filter in the setting context
Explain what the following Python 3 code does def get_setting(self, twig=None, **kwargs): if twig is not None: kwargs['twig'] = twig kwargs['context'] = 'setting' return self.filter_or_get(**kwargs)
You are a Python code generator, capable of creating scripts from specifications.
def _add_history(self, redo_func, redo_kwargs, undo_func, undo_kwargs, **kwargs): """ Add a new log (undo/redoable) to this history context :parameter str redo_func: function to redo the action, must be a method of :class:`Bundle` :parameter dict redo_kw...
Create a Python 3 function for adding a new log to the history
As a python code expert, you are capable of creating scripts from specifications.
Get a history item by index.
Explain what the following Python 3 code does def get_history(self, i=None): ps = self.filter(context='history') # if not len(ps): # raise ValueError("no history recorded") if i is not None: return ps.to_list()[i] else: return ps
As a Python code analyst, you investigate and solve complex coding mysteries
Removes a history item from the bundle by index.
Make a summary of the following Python 3 code 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)
You are a Python code generator, capable of creating scripts from specifications.
Undo an item in the history logs
Given the following Python 3 function, write the documentation def undo(self, i=-1): _history_enabled = self.history_enabled param = self.get_history(i) self.disable_history() param.undo() # TODO: do we really want to remove this? then what's the point of redo? self.rem...
You are a Python code architect, reviewing and designing scalable and efficient code
def set_hierarchy(self, *args, **kwargs): """ Set the hierarchy of the system. See tutorial on building a system. TODO: provide documentation args can be - string representation (preferably passed through hierarchy already) - func and strings/PSs/params to pass ...
Write a Python 3 script to set the hierarchy of the current system.
As a Python code composer, you craft elegant and concise scripts.
def get_system(self, twig=None, **kwargs): """ Filter in the 'system' context :parameter str twig: twig to use for filtering :parameter **kwargs: any other tags to do the filter (except twig or context) :return: :class:`phoebe.parameters.parameters.Parameter` or ...
Implement a Python 3 function for returning a new ParameterSet with only the system tags in the current context
As a Python code translator, you convert algorithms and pseudocode into Python.
Checks to see if the system is expected to be computable.
How would you explain what the following Python 3 function does def run_checks(self, **kwargs): # make sure all constraints have been run changed_params = self.run_delayed_constraints() hier = self.hierarchy if hier is None: return True, '' for component in hier.get...
As a Python code translator, you convert algorithms and pseudocode into Python.
def add_feature(self, kind, component=None, **kwargs): """ Add a new feature (spot, etc) to a component in the system. If not provided, 'feature' (the name of the new feature) will be created for you and can be accessed by the 'feature' attribute of the returned ParameterSet ...
Create a Python 3 function for adding a new feature to a component in the system.
You are a Python code generator, capable of creating scripts from specifications.
Filter in the proerty context
Make a summary of the following Python 3 code def get_feature(self, feature=None, **kwargs): if feature is not None: kwargs['feature'] = feature kwargs['context'] = 'feature' return self.filter(**kwargs)
As a Python code composer, you craft elegant and concise scripts.
def remove_feature(self, feature=None, **kwargs): """ [NOT IMPLEMENTED] Remove a 'feature' from the bundle :raises NotImplementedError: because this isn't implemented yet """ self._kwargs_checks(kwargs) # Let's avoid deleting ALL features from the matching cont...
Can you create a Python 3 function that removes a feature from the bundle.
You are a Python code generator, capable of creating scripts from specifications.
Change the label of a feature attached to the Bundle .
Make a summary of the following Python 3 code def rename_feature(self, old_feature, new_feature): # TODO: raise error if old_feature not found? self._check_label(new_feature) self._rename_label('feature', old_feature, new_feature)
As a Python code analyst, you investigate and solve complex coding mysteries
Shortcut to add_feature but with kind = spot
How would you explain what the following Python 3 function does def add_spot(self, component=None, feature=None, **kwargs): if component is None: if len(self.hierarchy.get_stars())==1: component = self.hierarchy.get_stars()[0] else: raise ValueError("must ...
As a Python code composer, you craft elegant and concise scripts.
Shortcut to remove_feature but with kind = spot
Given the following Python 3 function, write the documentation def remove_spot(self, feature=None, **kwargs): kwargs.setdefault('kind', 'spot') return self.remove_feature(feature, **kwargs)
You are a Python code architect, reviewing and designing scalable and efficient code
Add a new component to the system.
Can you tell what is the following Python 3 function doing def add_component(self, kind, **kwargs): func = _get_add_func(component, kind) if kwargs.get('component', False) is None: # then we want to apply the default below, so let's pop for now _ = kwargs.pop('component') ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_component(self, component=None, **kwargs): """ Filter in the 'component' context :parameter str component: name of the component (optional) :parameter **kwargs: any other tags to do the filter (except component or context) :return: :class:`phoebe.parameters.p...
Write a Python 3 script for filtering in the component context
As a Python code translator, you convert algorithms and pseudocode into Python.
Removes a component from the bundle
Given the following Python 3 function, write the documentation def remove_component(self, component, **kwargs): # NOTE: run_checks will check if an entry is in the hierarchy but has no parameters kwargs['component'] = component # NOTE: we do not remove from 'model' by default kwargs['con...
You are a Python code generator, capable of creating scripts from specifications.
def rename_component(self, old_component, new_component): """ Change the label of a component attached to the Bundle :parameter str old_component: the current name of the component (must exist) :parameter str new_component: the desired new name of the component (...
Write a Python 3 script for changing the label of a component attached to the Bundle .
As a Python code composer, you craft elegant and concise scripts.
Shortcut to add_component but with kind = orbit
Here you have a function in Python 3, explain what it does def add_orbit(self, component=None, **kwargs): kwargs.setdefault('component', component) return self.add_component('orbit', **kwargs)
You are a Python code architect, reviewing and designing scalable and efficient code
Shortcut to remove_component but with kind = orbit
Can you tell what is the following Python 3 function doing def remove_orbit(self, component=None, **kwargs): kwargs.setdefault('kind', 'orbit') return self.remove_component(component, **kwargs)
As a python code expert, you are capable of creating scripts from specifications.
Shortcut to get_component but with kind = star
Can you generate a brief explanation for the following Python 3 code def get_star(self, component=None, **kwargs): kwargs.setdefault('kind', 'star') return self.get_component(component, **kwargs)
As a python code expert, you are capable of creating scripts from specifications.
Shortcut to add_envelope but with kind = envelope
Explain what the following Python 3 code does def add_envelope(self, component=None, **kwargs): kwargs.setdefault('component', component) return self.add_component('envelope', **kwargs)
You are a Python code analyst, evaluating scripts for potential improvements.
def get_ephemeris(self, component=None, t0='t0_supconj', **kwargs): """ Get the ephemeris of a component (star or orbit) :parameter str component: name of the component. If not given, component will default to the top-most level of the current hierarchy :paramet...
Create a Python 3 function to return the ephemeris of a given component.
You are a Python code generator, capable of creating scripts from specifications.
def to_phase(self, time, component=None, t0='t0_supconj', **kwargs): """ Get the phase(s) of a time(s) for a given ephemeris :parameter time: time to convert to phases (should be in same system as t0s) :type time: float, list, or array :parameter t0: qualifier of the...
Can you create a Python 3 function that converts a time to phases
As a Python code composer, you craft elegant and concise scripts.
def to_time(self, phase, component=None, t0='t0_supconj', **kwargs): """ Get the time(s) of a phase(s) for a given ephemeris :parameter phase: phase to convert to times (should be in same system as t0s) :type phase: float, list, or array ` :parameter str component: com...
Implement a Python 3 function for converting the ephemeris time to a given phase.
As a python code expert, you are capable of creating scripts from specifications.
Add a new dataset to the bundle.
Explain what the following Python 3 code does def add_dataset(self, kind, component=None, **kwargs): sing_plural = {} sing_plural['time'] = 'times' sing_plural['flux'] = 'fluxes' sing_plural['sigma'] = 'sigmas' sing_plural['rv'] = 'rvs' func = _get_add_func(_dataset, ki...
As a python code expert, you are capable of creating scripts from specifications.
def get_dataset(self, dataset=None, **kwargs): """ Filter in the 'dataset' context :parameter str dataset: name of the dataset (optional) :parameter **kwargs: any other tags to do the filter (except dataset or context) :return: :class:`phoebe.parameters.parameters.Pa...
How would you implement a function in Python 3 that filters in the dataset context
You are a Python code analyst, evaluating scripts for potential improvements.
def remove_dataset(self, dataset=None, **kwargs): """ Remove a dataset from the Bundle. This removes all matching Parameters from the dataset, model, and constraint contexts (by default if the context tag is not provided). You must provide some sort of filter or this will raise an Erro...
Implement a function in Python 3 to remove a dataset from the Bundle. This removes all matching Parameters from the dataset, model, and constraint contexts (by default if the context tag is not provided). You must provide some sort of filter or this will raise an Error (so that all Parameters are not accidentally remov...
As a Python code analyst, you investigate and solve complex coding mysteries
def rename_dataset(self, old_dataset, new_dataset): """ Change the label of a dataset attached to the Bundle :parameter str old_dataset: the current name of the dataset (must exist) :parameter str new_dataset: the desired new name of the dataset (must not exist) ...
Write a Python 3 script for changing the label of a dataset attached to the Bundle
As a Python code translator, you convert algorithms and pseudocode into Python.
Enable a 'dataset'. Datasets that are enabled will be computed during :meth:`run_compute` and included in the cost function during :meth:`run_fitting`. If compute is not provided, the dataset will be enabled across all compute options. :parameter str dataset: name of the datas...
Make a summary of the following Python 3 code def enable_dataset(self, dataset=None, **kwargs): kwargs['context'] = 'compute' kwargs['dataset'] = dataset kwargs['qualifier'] = 'enabled' self.set_value_all(value=True, **kwargs) self._add_history(redo_func='enable_dataset', ...
As a Python code composer, you craft elegant and concise scripts.
Disable a 'dataset'. Datasets that are enabled will be computed during :meth:`run_compute` and included in the cost function during :meth:`run_fitting`. If compute is not provided, the dataset will be disabled across all compute options. :parameter str dataset: name of the dat...
Make a summary of the following Python 3 code def disable_dataset(self, dataset=None, **kwargs): kwargs['context'] = 'compute' kwargs['dataset'] = dataset kwargs['qualifier'] = 'enabled' self.set_value_all(value=False, **kwargs) self._add_history(redo_func='disable_dataset', ...
You are a Python code architect, reviewing and designing scalable and efficient code
def add_constraint(self, *args, **kwargs): """ TODO: add documentation args can be string representation (length 1) func and strings to pass to function """ # TODO: be smart enough to take kwargs (especially for undoing a # remove_constraint) for kind, value (exp...
Write a Python 3 script for adding a constraint to the current object
As a Python code composer, you craft elegant and concise scripts.
def get_constraint(self, twig=None, **kwargs): """ Filter in the 'constraint' context :parameter str constraint: name of the constraint (optional) :parameter **kwargs: any other tags to do the filter (except constraint or context) :return: :class:`phoebe.parameters.p...
Write a Python 3 script for returning a ParameterSet object with the constraint name
As a Python code translator, you convert algorithms and pseudocode into Python.
def remove_constraint(self, twig=None, **kwargs): """ Remove a 'constraint' from the bundle :parameter str twig: twig to filter for the constraint :parameter **kwargs: any other tags to do the filter (except twig or context) """ # let's run delayed constraint...
How would you code a function in Python 3 to remove a constraint from the bundle
You are a Python code architect, reviewing and designing scalable and efficient code
def flip_constraint(self, twig=None, solve_for=None, **kwargs): """ Flip an existing constraint to solve for a different parameter :parameter str twig: twig to filter the constraint :parameter solve_for: twig or actual parameter object of the new parameter which this constra...
Can you create a Python 3 function that flips an existing constraint to solve for a different parameter
You are a Python code architect, reviewing and designing scalable and efficient code
Run a given constraint now and set the value of the constrained parameter.
Here you have a function in Python 3, explain what it does 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['qual...
You are a Python code generator, capable of creating scripts from specifications.
def compute_pblums(self, compute=None, **kwargs): """ Compute the passband luminosities that will be applied to the system, following all coupling, etc, as well as all relevant compute options (ntriangles, distortion_method, etc). The exposed passband luminosities (and any coupl...
How would you implement a function in Python 3 that computes the passband luminosities that will be applied to the system and then re - compute the pblums for the specified compute.
You are a Python code generator, capable of creating scripts from specifications.
Adds a set of compute options for a given backend to the bundle.
Can you generate the documentation for the following Python 3 function def add_compute(self, kind=compute.phoebe, **kwargs): func = _get_add_func(_compute, kind) kwargs.setdefault('compute', self._default_label(func.func_name, **{'...
As a Python code analyst, you investigate and solve complex coding mysteries
def get_compute(self, compute=None, **kwargs): """ Filter in the 'compute' context :parameter str compute: name of the compute options (optional) :parameter **kwargs: any other tags to do the filter (except compute or context) :return: :class:`phoebe.parameters.param...
Can you write a function in Python 3 where it filters in the compute context
As a Python code translator, you convert algorithms and pseudocode into Python.
Remove a compute from the bundle
Given the following Python 3 function, write the documentation def remove_compute(self, compute, **kwargs): kwargs['compute'] = compute kwargs['context'] = 'comute' self.remove_parameters_all(**kwargs)
You are a Python code generator, capable of creating scripts from specifications.
def rename_compute(self, old_compute, new_compute): """ Change the label of a compute attached to the Bundle :parameter str old_compute: the current name of the compute options (must exist) :parameter str new_compute: the desired new name of the compute options (...
How would you code a function in Python 3 to change the label of a compute attached to the Bundle
As a python code expert, you are capable of creating scripts from specifications.
def run_compute(self, compute=None, model=None, detach=False, times=None, **kwargs): """ Run a forward model of the system on the enabled dataset using a specified set of compute options. To attach and set custom values for compute options, including choosing ...
Write a Python 3 function for running a forward model of the system on the enabled dataset using a specified set of compute options. To attach and set custom values for compute options, including choosing which backend to use, see: * :meth:`add_compute` To define the dataset types and times at which the model should be...
As a Python code analyst, you investigate and solve complex coding mysteries
Filter in the model context
Can you tell what is the following Python 3 function doing def get_model(self, model=None, **kwargs): if model is not None: kwargs['model'] = model kwargs['context'] = 'model' return self.filter(**kwargs)
As a python code expert, you are capable of creating scripts from specifications.
Remove a model from the bundle
Explain what the following Python 3 code does def remove_model(self, model, **kwargs): kwargs['model'] = model kwargs['context'] = 'model' self.remove_parameters_all(**kwargs)
As a Python code translator, you convert algorithms and pseudocode into Python.
Change the label of a model attached to the Bundle .
How would you explain what the following Python 3 function does def rename_model(self, old_model, new_model): # TODO: raise error if old_feature not found? self._check_label(new_model) self._rename_label('model', old_model, new_model)
You are a Python code analyst, evaluating scripts for potential improvements.
def add_prior(self, twig=None, **kwargs): """ [NOT IMPLEMENTED] :raises NotImplementedError: because it isn't """ raise NotImplementedError param = self.get_parameter(twig=twig, **kwargs) # TODO: make sure param is a float parameter? func = _get_add_fu...
Can you write a function in Python 3 where it adds a prior parameter to the current object.
As a Python code analyst, you investigate and solve complex coding mysteries
Returns a copy of the current object with the prior context.
Explain what the following Python 3 code does def get_prior(self, twig=None, **kwargs): raise NotImplementedError kwargs['context'] = 'prior' return self.filter(twig=twig, **kwargs)
You are a Python code architect, reviewing and designing scalable and efficient code
def get_fitting(self, fitting=None, **kwargs): """ [NOT IMPLEMENTED] :raises NotImplementedError: because it isn't """ raise NotImplementedError if fitting is not None: kwargs['fitting'] = fitting kwargs['context'] = 'fitting' return self.filt...
Can you write a function in Python 3 where it returns a new object with the given fitting.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_posterior(self, twig=None, feedback=None, **kwargs): """ [NOT IMPLEMENTED] :raises NotImplementedError: because it isn't """ raise NotImplementedError kwargs['context'] = 'posterior' return self.filter(twig=twig, **kwargs)
Can you implement a function in Python 3 that returns a new QuerySet with the posterior entries.
You are a Python code architect, reviewing and designing scalable and efficient code
Returns a new EntryCollection with feedback entries.
Make a summary of the following Python 3 code def get_feedback(self, feedback=None, **kwargs): raise NotImplementedError if feedback is not None: kwargs['feedback'] = feedback kwargs['context'] = 'feedback' return self.filter(**kwargs)
As a Python code translator, you convert algorithms and pseudocode into Python.
def _twig_to_uniqueid(bundle, twig, **kwargs): """ kwargs are passed on to filter """ res = bundle.filter(twig=twig, force_ps=True, check_visible=False, check_default=False, **kwargs) # we force_ps instead of checking is_instance(res, ParameterSet) to avoid # having to import from parameters ...
Create a Python 3 function to convert a twig parameter to a unique ID.
As a Python code analyst, you investigate and solve complex coding mysteries
Updates the user_label attribute of the current locale based on the least unique_twig from the bundle
Make a summary of the following Python 3 code def update_user_label(self): self._user_label = _uniqueid_to_uniquetwig(self._bundle, self.unique_label) self._set_curly_label()
As a Python code composer, you craft elegant and concise scripts.
get the parameter object for this var
How would you explain what the following Python 3 function does def get_parameter(self): if not self.is_param: raise ValueError("this var does not point to a parameter") # this is quite expensive, so let's cache the parameter object so we only # have to filter on the first time this...
As a python code expert, you are capable of creating scripts from specifications.
def _process_dimension_kwargs(direction, kwargs): """ process kwargs for AxDimension instances by stripping off the prefix for the appropriate direction """ acceptable_keys = ['unit', 'pad', 'lim', 'label'] # if direction in ['s']: # acceptable_keys += ['mode'] processed_kwargs = {} ...
Write a Python 3 function for processing kwargs for AxDimension instances by stripping off the prefix of the prefix and removing off the appropriate direction
As a Python code analyst, you investigate and solve complex coding mysteries
Returns a list of all the calls in z sorted in z
Make a summary of the following Python 3 code 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 ...
As a python code expert, you are capable of creating scripts from specifications.
check to see if a new call would be consistent with this Axes instance
Explain what the following Python 3 code does def consistent_with_call(self, call): if len(self.calls) == 0: return True, '' msg = [] if not _consistent_allow_none(call._axorder, self._axorder): msg.append('inconsistent axorder, {} != {}'.format(call.axorder, self.axord...
You are a Python code architect, reviewing and designing scalable and efficient code
set the limit of the available log entries
Make a summary of the following Python 3 code def lim(self, lim): if lim is None: self._lim = lim return typeerror_msg = "lim must be of type tuple, float, None, or in ['fixed', 'symmetric', 'frame', 'sliding']" if isinstance(lim, str): if lim in ['fixed', '...
As a Python code composer, you craft elegant and concise scripts.
def get_value(self, i, indeps=None): """ access the interpolated value at a give value of i (independent-variable) if indeps is not passed, then the entire range of indeps over all calls is assumed """ if self.value is None: return None if i is None: ...
Write a Python 3 function for getting the value at a give value of i
As a Python code analyst, you investigate and solve complex coding mysteries
def system(**kwargs): """ Generally, this will automatically be added to a newly initialized :class:`phoebe.frontend.bundle.Bundle` :parameter **kwargs: defaults for the values of any of the parameters :return: a :class:`phoebe.parameters.parameters.ParameterSet` of all newly created :class...
Can you write a function in Python 3 where it generates a new system parameter set for all the parameters in the order they appear.
As a Python code composer, you craft elegant and concise scripts.
Create new teams associated with the object.
Can you generate the documentation for the following Python 3 function def create_teams(obj, user, access): for field_name, access_types in access.items(): id_field = "{}_id".format(field_name) # Check that the team is associated with the object via a FK... if hasattr(obj, id_field) and geta...
As a Python code translator, you convert algorithms and pseudocode into Python.
Convert an object to a string or ParameterSet or a nested hierarchy.
Given the following Python 3 function, write the documentation def _to_component(obj, allow_hierarchy=True): def _to_str(obj): return "{}:{}".format(obj.kind, obj.component) if isinstance(obj, str): # TODO: check to see if valid?, use allow_hierarchy # TODO: when passed labels this is ...
You are a Python code generator, capable of creating scripts from specifications.
Builds a string representation of a binary hierarchy containing a 2 components orbit.
Can you generate the documentation for the following Python 3 function 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 '{}({}, {...
As a Python code composer, you craft elegant and concise scripts.
Computes the position of the neck in an contact_binary star1
Can you generate the documentation for the following Python 3 function def nekmin(omega_in,q,x0=0.5,z0=0.5): '''Computes the position of the neck (minimal radius) in an contact_binary star1''' def Omega_xz(q,x,z): return 1./np.sqrt(x**2+z**2)+q/np.sqrt((1-x)**2+z**2)+(q+1)*x**2/2.-q*x def Omega_x...
As a Python code composer, you craft elegant and concise scripts.
Computes the fractional areas belonging to each triangle that are a result of the intersection with the neck plane and assigns them to each vertex per triangle.
Make a summary of the following Python 3 code def compute_frac_areas(new_mesh,xmin): '''Computes fractional areas belonging to each triangle vertex that are a result of the intersection with the neck plane and assigns them to each vertex per triangle.''' def intersection(point1,point2,xmin): ''' p...
As a Python code composer, you craft elegant and concise scripts.
Creates parameters for a new orbit.
Given the following Python 3 function, write the documentation def orbit(component, **kwargs): params = [] #~ params += [ObjrefParameter(value=component)] params += [FloatParameter(qualifier='period', timederiv='dpdt', value=kwargs.get('period', 1.0), default_unit=u.d, limits=(0.0,None), description='Orbit...
You are a Python code architect, reviewing and designing scalable and efficient code
Creates a parameter set for a new component in the order they appear in the order they appear.
Explain what the following Python 3 code does def star(component, **kwargs): params = [] #~ params += [ObjrefParameter(value=component)] params += [FloatParameter(qualifier='requiv', value=kwargs.get('requiv', 1.0), default_unit=u.solRad, limits=(0.0,None), description='Equivalent radius')] params += ...
As a Python code translator, you convert algorithms and pseudocode into Python.