output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Plant artificial sources into a list of images provided by the caller. | Here you have a function in Python 3, explain what it does
def plant(expnums, ccd, rmin, rmax, ang, width, number=10, mmin=21.0, mmax=25.5, version='s', dry_run=False):
# Construct a list of artificial KBOs with positions in the image
# and rates of motion within the bounds given by the caller.
filename = ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
fit_radec of BK passing in the observations. | Explain what the following Python 3 code does
def _fit_radec(self):
# call fitradec with mpcfile, abgfile, resfile
self.orbfit.fitradec.restype = ctypes.c_int
self.orbfit.fitradec.argtypes = [ ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p ]
mpc_file = tempfile.NamedTemporaryFile(su... | You are a Python code generator, capable of creating scripts from specifications. |
Use the bk predict method to compute the location of the source on the given date. | How would you explain what the following Python 3 function does
def predict(self, date, obs_code=568):
time = Time(date, scale='utc', precision=6)
jd = ctypes.c_double(time.jd)
# call predict with agbfile, jdate, obscode
self.orbfit.predict.restype = ctypes.POINTER(ctypes.c_double * 5)
... | You are a Python code generator, capable of creating scripts from specifications. |
Write a file in the crazy MOP format given an mop data hdu. | Given the following Python 3 function, write the documentation
def write(file,hdu,order=None,format=None):
if order or format:
warnings.warn('Use of <order> and <format> depricated',DeprecationWarning)
## if the order of the columns isn't constrained just use the keys in what ever order
data='dat... | You are a Python code analyst, evaluating scripts for potential improvements. |
Store the contents of a MOP data structure into a SQL table | Given the following Python 3 function, write the documentation
def store(hdu,dbase='cfeps',duser='cfhls',dtype='MYSQL',table='source'):
import MOPdbaccess
db=MOPdbaccess.connect(dbase,duser,dbSystem=dtype)
dbc=db.cursor()
### INSERT THE 'HEADER' in the meta-data table
file_id=hdu['header']['image'... | As a Python code analyst, you investigate and solve complex coding mysteries |
Read in a file and create a data strucuture that is a hash with the header keywords and data. | How would you explain what the following Python 3 function does
def read(file):
f = open(file,'r')
lines=f.readlines()
f.close()
import re, string
keywords=[]
values=[]
formats={}
header={}
cdata={}
for line in lines:
if ( re.match(r'^##',line)):
## hea... | You are a Python code analyst, evaluating scripts for potential improvements. |
Given a list of MOPfiles merge them based on x and y coordinates matching. | How would you explain what the following Python 3 function does
def xymatch(outfile, filenames, tol=2):
import math
import sys
output={}
files=[]
for filename in filenames:
this_file=read(filename)
## match files based on the 'X' and 'Y' column.
## if those don't exist then s... | You are a Python code generator, capable of creating scripts from specifications. |
Prepare logging dict suitable with logging. config. dictConfig. | Can you generate the documentation for the following Python 3 function
def default_logging_dict(*loggers: str, **kwargs: Any) -> DictStrAny:
kwargs.setdefault('level', 'INFO')
return {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'ignore_errors': {
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
r Update Sentry logging dictionary. | Here you have a function in Python 3, explain what it does
def update_sentry_logging(logging_dict: DictStrAny,
sentry_dsn: Optional[str],
*loggers: str,
level: Union[str, int] = None,
**kwargs: Any) -> None:
r"""... | As a python code expert, you are capable of creating scripts from specifications. |
TRIM a CFHT MEGAPRIME frame using the DATASEC keyword | How would you explain what the following Python 3 function does
def trim(hdu, datasec='DATASEC'):
datasec = re.findall(r'(\d+)',
hdu.header.get(datasec))
l = int(datasec[0]) - 1
r = int(datasec[1])
b = int(datasec[2]) - 1
t = int(datasec[3])
logger.info("Trimming [%d:%d,... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def ossos_release_parser(table=False, data_release=parameters.RELEASE_VERSION):
"""
extra fun as this is space-separated so using CSV parsers is not an option
"""
names = ['cl', 'p', 'j', 'k', 'sh', 'object', 'mag', 'e_mag', 'Filt', 'Hsur', 'dist', 'e_dist', 'Nobs',
'time', 'av_xres', 'av_y... | Implement a function in Python 3 to
parse the OSSOS release file into a list of objects. | As a python code expert, you are capable of creating scripts from specifications. |
Returns a list of orbfit. Orbfit objects with the observations in the Orbfit. observations field. | Can you generate a brief explanation for the following Python 3 code
def ossos_discoveries(directory=parameters.REAL_KBO_AST_DIR,
suffix='ast',
no_nt_and_u=False,
single_object=None,
all_objects=True,
data_rele... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Wrap the objects from the Version Releases together with the objects instantiated from fitting their mpc lines | Given the following Python 3 function, write the documentation
def ossos_release_with_metadata():
# discoveries = ossos_release_parser()
discoveries = []
observations = ossos_discoveries()
for obj in observations:
discov = [n for n in obj[0].mpc_observations if n.discovery.is_discovery][0]
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _kbos_from_survey_sym_model_input_file(model_file):
"""
Load a Survey Simulator model file as an array of ephem EllipticalBody objects.
@param model_file:
@return:
"""
lines = storage.open_vos_or_local(model_file).read().split('\n')
kbos = []
for line in lines:
if len(line) =... | Can you write a function in Python 3 where it
loads a Survey Simulator model file as an array of ephem EllipticalBody objects. | As a Python code analyst, you investigate and solve complex coding mysteries |
def round_sig_error(num, uncert, pm=False):
"""
Return a string of the number and its uncertainty to the right sig figs via uncertainty's print methods.
The uncertainty determines the sig fig rounding of the number.
https://pythonhosted.org/uncertainties/user_guide.html
"""
u = ufloat(num, uncer... | How would you code a function in Python 3 to
round a number to the right sig figs. | As a python code expert, you are capable of creating scripts from specifications. |
parse eLCM response body as json | Given the following Python 3 function, write the documentation
def _parse_elcm_response_body_as_json(response):
try:
body = response.text
body_parts = body.split('\r\n')
if len(body_parts) > 0:
return jsonutils.loads(body_parts[-1])
else:
return None
excep... | You are a Python code generator, capable of creating scripts from specifications. |
send an eLCM request to the server | Can you generate a brief explanation for the following Python 3 code
def elcm_request(irmc_info, method, path, **kwargs):
host = irmc_info['irmc_address']
port = irmc_info.get('irmc_port', 443)
auth_method = irmc_info.get('irmc_auth_method', 'basic')
userid = irmc_info['irmc_username']
password = ir... | As a Python code composer, you craft elegant and concise scripts. |
def elcm_profile_get_versions(irmc_info):
"""send an eLCM request to get profile versions
:param irmc_info: node info
:returns: dict object of profiles if succeed
{
"Server":{
"@Version": "1.01",
"AdapterConfigIrmc":{
"@Version": "1.00... | Write a Python 3 script to
send an eLCM request to get profile versions of the current node | As a python code expert, you are capable of creating scripts from specifications. |
send an eLCM request to get a profile data | How would you explain what the following Python 3 function does
def elcm_profile_get(irmc_info, profile_name):
# Send GET request to the server
resp = elcm_request(irmc_info,
method='GET',
path=URL_PATH_PROFILE_MGMT + profile_name)
if resp.status_code == 200:... | You are a Python code analyst, evaluating scripts for potential improvements. |
Send an eLCM request to create a profile | Given the following Python 3 function, write the documentation
def elcm_profile_create(irmc_info, param_path):
# Send POST request to the server
# NOTE: This task may take time, so set a timeout
_irmc_info = dict(irmc_info)
_irmc_info['irmc_client_timeout'] = PROFILE_CREATE_TIMEOUT
resp = elcm_requ... | As a Python code analyst, you investigate and solve complex coding mysteries |
send an eLCM request to set param values to the node | Can you generate a brief explanation for the following Python 3 code
def elcm_profile_set(irmc_info, input_data):
# Prepare the data to apply
if isinstance(input_data, dict):
data = jsonutils.dumps(input_data)
else:
data = input_data
# Send POST request to the server
# NOTE: This ta... | As a Python code translator, you convert algorithms and pseudocode into Python. |
send an eLCM request to delete a profile | How would you explain what the following Python 3 function does
def elcm_profile_delete(irmc_info, profile_name):
# Send DELETE request to the server
resp = elcm_request(irmc_info,
method='DELETE',
path=URL_PATH_PROFILE_MGMT + profile_name)
if resp.status_cod... | As a Python code analyst, you investigate and solve complex coding mysteries |
send an eLCM request to list all sessions in the node | Here you have a function in Python 3, explain what it does
def elcm_session_list(irmc_info):
# Send GET request to the server
resp = elcm_request(irmc_info,
method='GET',
path='/sessionInformation/')
if resp.status_code == 200:
return _parse_elcm_resp... | As a Python code translator, you convert algorithms and pseudocode into Python. |
send an eLCM request to get the status of the specified session | Explain what the following Python 3 code does
def elcm_session_get_status(irmc_info, session_id):
# Send GET request to the server
resp = elcm_request(irmc_info,
method='GET',
path='/sessionInformation/%s/status' % session_id)
if resp.status_code == 200:
... | As a python code expert, you are capable of creating scripts from specifications. |
send an eLCM request to terminate a session | Can you generate the documentation for the following Python 3 function
def elcm_session_terminate(irmc_info, session_id):
# Send DELETE request to the server
resp = elcm_request(irmc_info,
method='DELETE',
path='/sessionInformation/%s/terminate' % session_id)
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def elcm_session_delete(irmc_info, session_id, terminate=False):
"""send an eLCM request to remove a session from the session list
:param irmc_info: node info
:param session_id: session id
:param terminate: a running session must be terminated before removing
:raises: ELCMSessionNotFound if the ses... | Create a Python 3 function for
sending an eLCM request to remove a session from the session list | You are a Python code generator, capable of creating scripts from specifications. |
Process the data from the session for BIOS config backup or restore or RAID config. | Given the following Python 3 function, write the documentation
def _process_session_data(irmc_info, operation, session_id,
session_timeout=BIOS_CONFIG_SESSION_TIMEOUT):
"""process session for Bios config backup/restore or RAID config operation
:param irmc_info: node info
:param op... | You are a Python code generator, capable of creating scripts from specifications. |
Restores the bios configuration to the server. | Here you have a function in Python 3, explain what it does
def restore_bios_config(irmc_info, bios_config):
def _process_bios_config():
try:
if isinstance(bios_config, dict):
input_data = bios_config
else:
input_data = jsonutils.loads(bios_config)
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_secure_boot_mode(irmc_info):
"""Get the status if secure boot is enabled or not.
:param irmc_info: node info.
:raises: SecureBootConfigNotFound, if there is no configuration for secure
boot mode in the bios.
:return: True if secure boot mode is enabled on the node, False otherwise.... | How would you code a function in Python 3 to
get the status of secure boot mode on the node. | You are a Python code generator, capable of creating scripts from specifications. |
def set_secure_boot_mode(irmc_info, enable):
"""Enable/Disable secure boot on the server.
:param irmc_info: node info
:param enable: True, if secure boot needs to be
enabled for next boot, else False.
"""
bios_config_data = {
'Server': {
'@Version': '1.01',
... | Create a Python 3 function to
enable or disable secure boot on the server. | You are a Python code architect, reviewing and designing scalable and efficient code |
def _update_raid_input_data(target_raid_config, raid_input):
"""Process raid input data.
:param target_raid_config: node raid info
:param raid_input: raid information for creating via eLCM
:raises ELCMValueError: raise msg if wrong input
:return: raid_input: raid input data which create raid config... | Write a Python 3 script for
updating the RAID input data with the new data. | You are a Python code generator, capable of creating scripts from specifications. |
Collect existing logical drives on the server. | Explain what the following Python 3 code does
def _get_existing_logical_drives(raid_adapter):
existing_logical_drives = []
logical_drives = raid_adapter['Server']['HWConfigurationIrmc'][
'Adapters']['RAIDAdapter'][0].get('LogicalDrives')
if logical_drives is not None:
for drive in logical_dr... | You are a Python code analyst, evaluating scripts for potential improvements. |
Create raid adapter profile on the server. | Can you generate the documentation for the following Python 3 function
def _create_raid_adapter_profile(irmc_info):
try:
# Attempt erase exist adapter on BM Server
elcm_profile_delete(irmc_info, PROFILE_RAID_CONFIG)
except ELCMProfileNotFound:
# Ignore this error as it's not an error in... | As a Python code composer, you craft elegant and concise scripts. |
Create a RAID config based on target_raid_config. | Can you generate a brief explanation for the following Python 3 code
def create_raid_configuration(irmc_info, target_raid_config):
if len(target_raid_config['logical_disks']) < 1:
raise ELCMValueError(message="logical_disks must not be empty")
# Check RAID config in the new RAID adapter. Must be erase... | You are a Python code architect, reviewing and designing scalable and efficient code |
def delete_raid_configuration(irmc_info):
"""Delete whole raid configuration or one of logical drive on the server.
:param irmc_info: node info
"""
# Attempt to get raid configuration on BM Server
raid_adapter = get_raid_adapter(irmc_info)
existing_logical_drives = _get_existing_logical_drives(... | Create a Python 3 function to
delete whole raid configuration or one of logical drive on the server. | You are a Python code analyst, evaluating scripts for potential improvements. |
Set the BIOS configurations on the server. | Here you have a function in Python 3, explain what it does
def set_bios_configuration(irmc_info, settings):
bios_config_data = {
'Server': {
'SystemConfig': {
'BiosConfig': {}
}
}
}
versions = elcm_profile_get_versions(irmc_info)
server_version =... | You are a Python code generator, capable of creating scripts from specifications. |
Get the current BIOS settings on the server | Can you generate a brief explanation for the following Python 3 code
def get_bios_settings(irmc_info):
bios_config = backup_bios_config(irmc_info)['bios_config']
bios_config_data = bios_config['Server']['SystemConfig']['BiosConfig']
settings = []
# TODO(trungnv): Allow working with multi levels of BIO... | As a python code expert, you are capable of creating scripts from specifications. |
A context manager for adding resources to a given router. | Given the following Python 3 function, write the documentation
def add_resource_context(router: web.AbstractRouter,
url_prefix: str = None,
name_prefix: str = None) -> Iterator[Any]:
"""Context manager for adding resources for given router.
Main goal of context... | You are a Python code generator, capable of creating scripts from specifications. |
def parse_aioredis_url(url: str) -> DictStrAny:
"""
Convert Redis URL string to dict suitable to pass to
``aioredis.create_redis(...)`` call.
**Usage**::
async def connect_redis(url=None):
url = url or 'redis://localhost:6379/0'
return await create_redis(**get_aioredis_... | How would you implement a function in Python 3 that
parses an AIoredis URL into a dict suitable to pass to aioredis. create_redis. | You are a Python code generator, capable of creating scripts from specifications. |
Generator that yields a dict of values corresponding to the internal JD values. | Explain what the following Python 3 code does
def str_kwargs(self):
iys, ims, ids, ihmsfs = sofa_time.jd_dtf(self.scale.upper()
.encode('utf8'),
6,
self.jd1, self.jd... | As a Python code analyst, you investigate and solve complex coding mysteries |
This function is taken from the ogg vorbis spec to get the total length of the window in samples | Can you generate the documentation for the following Python 3 function
def oggvorbis(s):
try:
s = np.arange(s)
except TypeError:
s = np.arange(s[0])
i = np.sin((s + .5) / len(s) * np.pi) ** 2
f = np.sin(.5 * np.pi * i)
return f * (1. / f.max()) | As a Python code composer, you craft elegant and concise scripts. |
def convert_source_location(self, source_reading, reference_reading):
"""
Converts the source (x, y) location from reading into the coordinate
system of reference_reading.
"""
offset_x, offset_y = reference_reading.get_coordinate_offset(source_reading)
focus = source_read... | Create a Python 3 function for
converting the source location from reading into the coordinate system of reference_reading. | You are a Python code analyst, evaluating scripts for potential improvements. |
def calculate_focus(self, reading):
"""
Determines what the focal point of the downloaded image should be.
Returns:
focal_point: (x, y)
The location of the source in the middle observation, in the
coordinate system of the current source reading.
"""
... | Create a Python 3 function for
calculating what the focal point of the downloaded image should be. | You are a Python code generator, capable of creating scripts from specifications. |
Plots the top - down Solar System on a given set of discoveries. | Explain what the following Python 3 code does
def top_down_SolarSystem(discoveries,
inner_limit=6, # truncate at 8 AU to show that we don't have sensitivity in close
extent=83, # extend to 83 AU as indicative only, sensitivity is to ~300 AU
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def plot_ossos_discoveries(ax, discoveries, plot_discoveries,
plot_colossos=False, split_plutinos=False):
"""
plotted at their discovery locations, provided by the Version Releases in decimal degrees.
"""
fc = ['b', '#E47833', 'k']
alpha = [0.85, 0.6, 1.]
marker = ['o'... | Write a Python 3 function that can
plot the discovered objects in the OSSOS format. | You are a Python code architect, reviewing and designing scalable and efficient code |
Brett is the actual orbit fit residuals
for orbits with d ( a ) < 1%. | Given the following Python 3 function, write the documentation
def orbit_fit_residuals(discoveries, blockID='O13AE'):
ra_residuals = []
dec_residuals = []
ressum = []
for i, orbit in enumerate(discoveries):
if (orbit.da / orbit.a) < 0.01:
print i, len(discoveries), orbit.observations... | As a python code expert, you are capable of creating scripts from specifications. |
Get the irmc firmware version of the node. | Given the following Python 3 function, write the documentation
def get_irmc_firmware_version(snmp_client):
try:
bmc_name = snmp_client.get(BMC_NAME_OID)
irmc_firm_ver = snmp_client.get(IRMC_FW_VERSION_OID)
return ('%(bmc)s%(sep)s%(firm_ver)s' %
{'bmc': bmc_name if bmc_name e... | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_bios_firmware_version(snmp_client):
"""Get bios firmware version of the node.
:param snmp_client: an SNMP client object.
:raises: SNMPFailure if SNMP operation failed.
:returns: a string of bios firmware version.
"""
try:
bios_firmware_version = snmp_client.get(BIOS_FW_VERSION_... | How would you implement a function in Python 3 that
gets the bios firmware version of the node. | You are a Python code generator, capable of creating scripts from specifications. |
def get_server_model(snmp_client):
"""Get server model of the node.
:param snmp_client: an SNMP client object.
:raises: SNMPFailure if SNMP operation failed.
:returns: a string of server model.
"""
try:
server_model = snmp_client.get(SERVER_MODEL_OID)
return six.text_type(serve... | Write a Python 3 function that can
get the server model of the node. | As a python code expert, you are capable of creating scripts from specifications. |
def _get_auth(self):
"""Return the authorization data for an SNMP request.
:returns: A
:class:`pysnmp.entity.rfc3413.oneliner.cmdgen.CommunityData`
object.
"""
if self.version == SNMP_V3:
# Handling auth/encryption credentials is not (yet) supported.
... | Can you implement a function in Python 3 that
returns the authorization data for an SNMP request. | You are a Python code generator, capable of creating scripts from specifications. |
def get(self, oid):
"""Use PySNMP to perform an SNMP GET operation on a single object.
:param oid: The OID of the object to get.
:raises: SNMPFailure if an SNMP request fails.
:returns: The value of the requested object.
"""
try:
results = self.cmd_gen.getCmd... | Write a Python 3 function for
using PySNMP to perform an SNMP GET operation on a single object. | As a Python code analyst, you investigate and solve complex coding mysteries |
Use PySNMP to perform an SNMP GET NEXT operation on a table object. | How would you explain what the following Python 3 function does
def get_next(self, oid):
try:
results = self.cmd_gen.nextCmd(self._get_auth(),
self._get_transport(),
oid)
except snmp_error.PySnmpError as e:... | As a Python code composer, you craft elegant and concise scripts. |
Use PySNMP to perform an SNMP SET operation on a single object. | Can you generate the documentation for the following Python 3 function
def set(self, oid, value):
try:
results = self.cmd_gen.setCmd(self._get_auth(),
self._get_transport(),
(oid, value))
except snmp_error.Py... | You are a Python code generator, capable of creating scripts from specifications. |
def filename(self):
"""
Name if the MOP formatted file to parse.
@rtype: basestring
@return: filename
"""
if self._filename is None:
self._filename = storage.get_file(self.basename,
self.ccd,
... | Write a Python 3 function that can
return the name of the MOP formatted file to parse. | You are a Python code analyst, evaluating scripts for potential improvements. |
read in a file and return a MOPFile object. | How would you explain what the following Python 3 function does
def _parse(self):
with open(self.filename, 'r') as fobj:
lines = fobj.read().split('\n')
# Create a header object with content at start of file
self.header = MOPHeader(self.subfmt).parser(lines)
# Create a data... | You are a Python code generator, capable of creating scripts from specifications. |
Returns the astropy. table. Table object that will contain the data result
| Can you tell what is the following Python 3 function doing
def table(self):
if self._table is None:
column_names = []
for fileid in self.header.file_ids:
for column_name in self.header.column_names:
column_names.append("{}_{}".format(column_name, filei... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def parser(self, lines):
"""Given a set of lines parse the into a MOP Header"""
while len(lines) > 0:
if lines[0].startswith('##') and lines[1].startswith('# '):
# A two-line keyword/value line starts here.
self._header_append(lines.pop(0), lines.pop(0))
... | Create a Python 3 function to
give a set of lines parse the into a MOP Header | You are a Python code analyst, evaluating scripts for potential improvements. |
def _compute_mjd(self, kw, val):
"""
Sometimes that MJD-OBS-CENTER keyword maps to a three component string, instead of a single value.
@param kw: a list of keywords
@param val: a list of matching values
@return: the MJD-OBS-CENTER as a julian date.
"""
try:
... | Can you write a function in Python 3 where it
computes the MJD from the MJD - OBS - CENTER keyword and the given list of values. | As a Python code analyst, you investigate and solve complex coding mysteries |
def getExpInfo(expnum):
"""Return a dictionary of information about a particular exposure"""
col_names=['object',
'e.expnum',
'mjdate',
'uttime',
'filter',
'elongation',
'obs_iq_refccd',
'triple', 'qso_stat... | Write a Python 3 script for
returning a dictionary of information about a particular exposure | You are a Python code generator, capable of creating scripts from specifications. |
Return a dictionary of information about a particular triple | Can you generate the documentation for the following Python 3 function
def getTripInfo(triple):
col_names=['mjdate', 'filter', 'elongation', 'discovery','checkup', 'recovery', 'iq','block' ]
sql="SELECT mjdate md,"
sql=sql+" filter, avg(elongation), d.id, checkup.checkup, recovery.recovery , avg(obs_iq_ref... | As a python code expert, you are capable of creating scripts from specifications. |
def getExpnums(pointing,night=None):
"""Get all exposures of specified pointing ID.
Default is to return a list of all exposure numbers"""
if night:
night=" floor(e.mjdate-0.0833)=%d " % ( night )
else:
night=''
sql="SELECT e.expnum "
sql=sql+"FROM bucket.exposure e "
... | Can you write a function in Python 3 where it
gets all exposures of specified pointing ID. | You are a Python code architect, reviewing and designing scalable and efficient code |
Get all triples of a specified pointing ID. | Make a summary of the following Python 3 code
def getTriples(pointing):
sql="SELECT id FROM triples t join triple_members m ON t.id=m.triple"
sql+=" join bucket.exposure e on e.expnum=m.expnum "
sql+=" WHERE pointing=%s group by id order by e.expnum "
cfeps.execute(sql, ( pointing, ) )
return(cf... | As a python code expert, you are capable of creating scripts from specifications. |
def createNewTriples(Win):
"""Add entries to the triples tables based on new images in the db"""
win.help("Building list of exposures to look for triples")
cols=('e.expnum', 'object',
'mjdate',
'uttime',
'elongation',
'filter',
'obs_iq_refccd','qso_status' )
header='%6s %... | Implement a Python 3 function for
creating a new list of triples based on new images in the db. | You are a Python code analyst, evaluating scripts for potential improvements. |
def setDiscoveryTriples(win,table="discovery"):
"""Provide user with a list of triples that could be discovery triples"""
win.help("Getting a list of pointings with triples from the CFEPS db")
pointings=getPointingsWithTriples()
win.help("Select the "+table+" triple form the list...")
import time
... | How would you code a function in Python 3 to
provide user with a list of triples that could be discovery triples | You are a Python code analyst, evaluating scripts for potential improvements. |
def run(expnum,
ccd,
prefix='',
version='p',
sex_thresh=_SEX_THRESHOLD,
wave_thresh=_WAVE_THRESHOLD,
maxcount=_MAX_COUNT,
dry_run=False,
force=True):
"""run the actual step1jmp/matt codes.
expnum: the CFHT expousre to process
ccd: which ccd i... | Can you create a Python 3 function that
runs the actual step1jmp code for a given CFHT entry. | You are a Python code generator, capable of creating scripts from specifications. |
def query(ra ,dec, rad=0.1, query=None):
"""Query the CADC TAP service to determine the list of images for the
NewHorizons Search. Things to determine:
a- Images to have the reference subtracted from.
b- Image to use as the 'REFERENCE' image.
c- Images to be used for input into the reference image
L... | How would you code a function in Python 3 to
query the CADC TAP service to determine the list of images that overlap with the given reference image. | You are a Python code architect, reviewing and designing scalable and efficient code |
Ingests the source table of the object. | Make a summary of the following Python 3 code
def objIngest(obj_file):
import sys,os,math,re
import pyfits
import MOPfiles
obj=MOPfiles.read(obj_file)
"""
The SQL description of the source table
+-------------+---------+------+-----+---------+----------------+
| Field |... | You are a Python code analyst, evaluating scripts for potential improvements. |
def load_edbfile(file=None):
"""Load the targets from a file"""
import ephem,string,math
if file is None:
import tkFileDialog
try:
file=tkFileDialog.askopenfilename()
except:
return
if file is None or file == '':
return
f=open(file)
lines=f.readl... | Write a Python 3 script for
loading the targets from an EDB file | As a Python code composer, you craft elegant and concise scripts. |
Load the targets from a file | Can you generate a brief explanation for the following Python 3 code
def load_abgfiles(dir=None):
import ephem,string
if dir is None:
import tkFileDialog
try:
dir=tkFileDialog.askdirectory()
except:
return
if dir is None:
return None
from glob import glo... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Get a list of files matching filter in directory root | Make a summary of the following Python 3 code
def fits_list(filter,root,fnames):
import re, pyfits, wcsutil
for file in fnames:
if re.match(filter,file):
fh=pyfits.open(file)
for ext in fh:
obj=ext.header.get('OBJECT',file)
dx=ext.header.get('NAXIS... | As a Python code composer, you craft elegant and concise scripts. |
def load_fis(dir=None):
"""Load fits images in a directory"""
if dir is None:
import tkFileDialog
try:
dir=tkFileDialog.askdirectory()
except:
return
if dir is None:
return None
from os.path import walk
walk(dir,fits_list,"*.fits") | Can you create a Python 3 function that
loads fits images in a directory | As a python code expert, you are capable of creating scripts from specifications. |
def do_objs(kbos):
"""Draw the actual plot"""
import orbfit, ephem, math
import re
re_string=w.FilterVar.get()
vlist=[]
for name in kbos:
if not re.search(re_string,name):
continue
vlist.append(name)
if type(kbos[name])==type(ephem.EllipticalBody()):
kbo... | Write a Python 3 function that can
draw the actual plot of the objects in the kbos. | You are a Python code generator, capable of creating scripts from specifications. |
def eps(self):
"""Print the canvas to a postscript file"""
import tkFileDialog,tkMessageBox
filename=tkFileDialog.asksaveasfilename(message="save postscript to file",filetypes=['eps','ps'])
if filename is None:
return
self.postscript(file=filename) | Can you create a Python 3 function that
prints the canvas to a postscript file | You are a Python code analyst, evaluating scripts for potential improvements. |
def c2s(self,p=[0,0]):
"""Convert from canvas to screen coordinates"""
return((p[0]-self.canvasx(self.cx1),p[1]-self.canvasy(self.cy1))) | Implement a Python 3 function for
converting from canvas to screen coordinates | As a Python code composer, you craft elegant and concise scripts. |
Draw a grid of RA and DEC on Canvas. | Given the following Python 3 function, write the documentation
def coord_grid(self):
import math,ephem
ra2=math.pi*2
ra1=0
dec1=-1*math.pi/2.0
dec2=math.pi/2.0
## grid space choices
## ra space in hours
ra_grids=["06:00:00",
"0... | You are a Python code analyst, evaluating scripts for potential improvements. |
Write label at plot coordinates x y | Explain what the following Python 3 code does
def label(self,x,y,label,offset=[0,0]):
(xc,yc)=self.p2c([x,y])
return self.create_text(xc-offset[0],yc-offset[1],text=label) | You are a Python code analyst, evaluating scripts for potential improvements. |
Set the coordinate boundaries of the plot | Here you have a function in Python 3, explain what it does
def limits(self,x1,x2,y1,y2):
import math
self.x1=x1
self.x2=x2
self.y1=y1
self.y2=y2
self.xscale=(self.cx2-self.cx1)/(self.x2-self.x1)
self.yscale=(self.cy2-self.cy1)/(self.y2-self.y1)
ra1=self.x1
ra2=... | As a Python code analyst, you investigate and solve complex coding mysteries |
def reset(self):
"""Expand to the full scale"""
import ephem, MOPcoord
sun=ephem.Sun()
sun.compute(self.date.get())
self.sun=MOPcoord.coord((sun.ra,sun.dec))
doplot(kbos)
self.plot_pointings() | How would you code a function in Python 3 to
expand to the full scale | You are a Python code analyst, evaluating scripts for potential improvements. |
Update the object in the search box | Explain what the following Python 3 code does
def updateObj(self,event):
name=w.objList.get("active")
w.SearchVar.set(name)
w.ObjInfo.set(objInfoDict[name])
return | You are a Python code architect, reviewing and designing scalable and efficient code |
def relocate(self):
"""Move to the postion of self.SearchVar"""
name=self.SearchVar.get()
if kbos.has_key(name):
import orbfit,ephem,math
jdate=ephem.julian_date(w.date.get())
try:
(ra,dec,a,b,ang)=orbfit.predict(kbos[name],jdate,568)
except:
return
ra=math... | Implement a function in Python 3 to
move to the postion of self. SearchVar | As a Python code composer, you craft elegant and concise scripts. |
def __zoom(self,event,scale=2.0):
"""Zoom in"""
import Tkinter,math
## compute the x,y of the center of the screen
sx1=self.cx1+(self.cx2-self.cx1+1.0)/2.0
sy1=self.cy1+(self.cy2-self.cy1+1.0)/2.0
#print sx1,sy1
if not event is None:
sx1=event.x
sy1=event.y
#print sx1,sy1... | Implement a function in Python 3 to
zoom in the event to the screen. | As a python code expert, you are capable of creating scripts from specifications. |
Create an ellipse at x y with size a b and orientation ang | Given the following Python 3 function, write the documentation
def create_ellipse(self,xcen,ycen,a,b,ang,resolution=40.0):
import math
e1=[]
e2=[]
ang=ang-math.radians(90)
for i in range(0,int(resolution)+1):
x=(-1*a+2*a*float(i)/resolution)
y=1-(x/a)**2
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_pointings(self):
"""Query for some pointings, given a block name"""
import MOPdbaccess,ephem,math
import tkSimpleDialog
result = tkSimpleDialog.askstring("Block Load", "Which Block do you want to plot?")
db = MOPdbaccess.connect('bucket','cfhls',dbSystem='MYSQL')
SQL = "... | Write a Python 3 function for
querying for some pointings given a block name | As a Python code translator, you convert algorithms and pseudocode into Python. |
Load some pointings from a file. | Make a summary of the following Python 3 code
def load_pointings(self):
import os,re,ephem
import tkFileDialog,tkMessageBox
filename=tkFileDialog.askopenfilename()
if filename is None:
return
f=open(filename)
lines=f.readlines()
f.close()
points=[]
if lines[0][0:5]=="<?... | As a Python code composer, you craft elegant and concise scripts. |
Create the sky coverage of pointing at event. x event. y on the canavas. | Explain what the following Python 3 code does
def create_pointing(self,event):
import math
(ra,dec)=self.c2p((self.canvasx(event.x),
self.canvasy(event.y)))
this_camera=camera(camera=self.camera.get())
ccds=this_camera.getGeometry(ra,dec)
items=[]
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Plot pointings on canavs | Make a summary of the following Python 3 code
def plot_pointings(self,pointings=None):
if pointings is None:
pointings=self.pointings
i=0
for pointing in pointings:
items=[]
i=i+1
label={}
label['text']=pointing['label']['text']
for ccd in pointing["... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
self.pointings[self.current]['label']['text']=w.plabel.get()
self.reset() | Can you write a function in Python 3 where it
lets the label of the current pointing to the value in the plabel box | As a Python code composer, you craft elegant and concise scripts. |
Print the currently defined POINTINGS. | Can you generate a brief explanation for the following Python 3 code
def save_pointings(self):
import tkFileDialog
f=tkFileDialog.asksaveasfile()
i=0
if self.pointing_format.get()=='CFHT PH':
f.write("""<?xml version = "1.0"?>
<!DOCTYPE ASTRO SYSTEM "http://vizier.u-strasbg.fr/xml/... | As a python code expert, you are capable of creating scripts from specifications. |
Return an array of rectangles that represent the ra dec corners of the FOV | Can you tell what is the following Python 3 function doing
def getGeometry(self,ra=None,dec=None):
import math,ephem
ccds=[]
if ra is None:
ra=self.ra
if dec is None:
dec=self.dec
self.ra=ephem.hours(ra)
self.dec=ephem.degrees(dec)
for ge... | You are a Python code architect, reviewing and designing scalable and efficient code |
def separation(self,ra,dec):
"""Compute the separation between self and (ra,dec)"""
import ephem
return ephem.separation((self.ra,self.dec),(ra,dec)) | Can you create a Python 3 function that
computes the separation between self and ( ra dec ) | You are a Python code architect, reviewing and designing scalable and efficient code |
def produce_fake_hash(x):
"""
Produce random, binary features, totally irrespective of the content of
x, but in the same shape as x.
"""
h = np.random.binomial(1, 0.5, (x.shape[0], 1024))
packed = np.packbits(h, axis=-1).view(np.uint64)
return zounds.ArrayWithUnits(
packed, [x.dimens... | Write a Python 3 script for
producing random binary features totally irrespective of the content of x but in the same shape as x. | You are a Python code analyst, evaluating scripts for potential improvements. |
def _parse_raw_bytes(raw_bytes):
"""Convert a string of hexadecimal values to decimal values parameters
Example: '0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00' is converted to:
46, 241, [128, 40, 0, 26, 1, 0]
:param raw_bytes: string of hexadecimal values
:returns: 3 decimal values
"""
... | Write a Python 3 function that can
convert a string of hexadecimal values to decimal values parameters | As a Python code analyst, you investigate and solve complex coding mysteries |
def _send_raw_command(ipmicmd, raw_bytes):
"""Use IPMI command object to send raw ipmi command to BMC
:param ipmicmd: IPMI command object
:param raw_bytes: string of hexadecimal values. This is commonly used
for certain vendor specific commands.
:returns: dict -- The response from IPMI device
... | Create a Python 3 function to
send raw IPMI command to BMC using raw command object. | You are a Python code analyst, evaluating scripts for potential improvements. |
Get the TPM support status of the node. | Can you generate a brief explanation for the following Python 3 code
def get_tpm_status(d_info):
# note:
# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'
#
# $ ipmitool raw 0x2E 0xF5 0x80 0x28 0x00 0x81 0xC0
#
# Raw response:
# 80 28 00 C0 C0: True
# 80 28 00 -- --: False ... | As a Python code analyst, you investigate and solve complex coding mysteries |
def _pci_seq(ipmicmd):
"""Get output of ipmiraw command and the ordinal numbers.
:param ipmicmd: IPMI command object.
:returns: List of tuple contain ordinal number and output of ipmiraw
command.
"""
for i in range(1, 0xff + 1):
try:
res = _send_raw_command(ipmicmd, GET_PCI ... | Create a Python 3 function for
getting output of ipmiraw command and the ordinal numbers. | You are a Python code generator, capable of creating scripts from specifications. |
Get quantity of PCI devices of the node. | Given the following Python 3 function, write the documentation
def get_pci_device(d_info, pci_device_ids):
# note:
# Get quantity of PCI devices:
# ipmi cmd '0xF1'
#
# $ ipmitool raw 0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00
#
# Raw response:
# 80 28 00 00 00 05 data1 data2 34 17 76 11 00... | As a Python code composer, you craft elegant and concise scripts. |
Override current dict with defaults values. | Can you generate a brief explanation for the following Python 3 code
def defaults(current: dict, *args: AnyMapping) -> dict:
for data in args:
for key, value in data.items():
current.setdefault(key, value)
return current | As a Python code analyst, you investigate and solve complex coding mysteries |
def validate_func_factory(validator_class: Any) -> ValidateFunc:
"""Provide default function for Schema validation.
:param validator_class: JSONSchema suitable validator class.
"""
def validate_func(schema: AnyMapping, pure_data: AnyMapping) -> AnyMapping:
"""Validate schema with given data.
... | Write a Python 3 function that can
provide default function for Schema validation. | You are a Python code analyst, evaluating scripts for potential improvements. |
Search the CFHT archive for more images of this location | Can you generate the documentation for the following Python 3 function
def moreData(ra,dec,box):
import cfhtCutout
cdata={'ra_deg': ra, 'dec_deg': dec, 'radius_deg': 0.2}
inter=cfhtCutout.find_images(cdata,0.2) | You are a Python code analyst, evaluating scripts for potential improvements. |
def xpacheck():
"""Check if xpa is running"""
import os
f=os.popen('xpaaccess ds9')
l=f.readline()
f.close()
if l.strip()!='yes':
logger.debug("\t Can't get ds9 access, xpaccess said: %s" % ( l.strip()))
return (False)
return(True) | Can you write a function in Python 3 where it
checks if xpa is running | As a Python code analyst, you investigate and solve complex coding mysteries |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.