output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Updates the values of the cadence and exposure objects for the current instance of the base class. | Explain what the following Python 3 code does
def update(self, *args):
g = get_root(self).globals
expTime, deadTime, cycleTime, dutyCycle, frameRate = g.ipars.timing()
total, peak, peakSat, peakWarn, ston, ston3 = \
self.counts(expTime, cycleTime)
if cycleTime < 0.01:
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Compute the counts per pixel total counts sky counts and signal to noise per exposure and aperture radius. | Given the following Python 3 function, write the documentation
def counts(self, expTime, cycleTime, ap_scale=1.6, ndiv=5):
# code directly translated from Java equivalent.
g = get_root(self).globals
# Set the readout speed
readSpeed = g.ipars.readSpeed()
if readSpeed == 'Fast':... | As a Python code analyst, you investigate and solve complex coding mysteries |
def disable(self):
"""
Disable the button, if in non-expert mode.
"""
w.ActButton.disable(self)
g = get_root(self).globals
if self._expert:
self.config(bg=g.COL['start'])
else:
self.config(bg=g.COL['startD']) | Write a Python 3 script to
disable the button if in non - expert mode. | As a python code expert, you are capable of creating scripts from specifications. |
Turn on expert status whereby the button is always enabled regardless of its activity status. | How would you explain what the following Python 3 function does
def setExpert(self):
w.ActButton.setExpert(self)
g = get_root(self).globals
self.config(bg=g.COL['start']) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Actually asks if user has permission to start a new entry in the database. | Make a summary of the following Python 3 code
def act(self):
g = get_root(self).globals
# check binning against overscan
msg = """
HiperCAM has an o/scan of 50 pixels.
Your binning does not fit into this
region. Some columns will contain a
mix of o/scan and data.
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Carries out the action associated with the Load button. | Can you generate the documentation for the following Python 3 function
def act(self):
g = get_root(self).globals
fname = filedialog.askopenfilename(
defaultextension='.json',
filetypes=[('json files', '.json'), ('fits files', '.fits')],
initialdir=g.cpars['app_directo... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def act(self):
"""
Carries out the action associated with the Save button
"""
g = get_root(self).globals
g.clog.info('\nSaving current application to disk')
# check instrument parameters
if not g.ipars.check():
g.clog.warn('Invalid instrument paramete... | Write a Python 3 function that can
carry out the action associated with the Save button. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Carries out the action associated with the Unfreeze button | Can you generate the documentation for the following Python 3 function
def act(self):
g = get_root(self).globals
g.ipars.unfreeze()
g.rpars.unfreeze()
g.observe.load.enable()
self.disable() | You are a Python code generator, capable of creating scripts from specifications. |
def setExpertLevel(self):
"""
Set expert level
"""
g = get_root(self).globals
level = g.cpars['expert_level']
# now set whether buttons are permanently enabled or not
if level == 0 or level == 1:
self.load.setNonExpert()
self.save.setNonEx... | Create a Python 3 function for
setting the expert level of the user s current user. | You are a Python code generator, capable of creating scripts from specifications. |
This function operates on a class dictionary and base classes and returns the value of the attribute name. | Make a summary of the following Python 3 code
def deep_getattr(clsdict: Dict[str, Any],
bases: Tuple[Type[object], ...],
name: str,
default: Any = _missing) -> Any:
"""
Acts just like ``getattr`` would on a constructed class object, except this operates
on ... | As a Python code analyst, you investigate and solve complex coding mysteries |
Get the attribute of the base class. | Make a summary of the following Python 3 code
def getattr(self, name, default: Any = _missing):
return deep_getattr(self.clsdict, self.bases, name, default) | As a Python code composer, you craft elegant and concise scripts. |
def qualname(self) -> str:
"""
Returns the fully qualified name of the class-under-construction, if possible,
otherwise just the class name.
"""
if self.module:
return self.module + '.' + self.name
return self.name | Create a Python 3 function to
return the fully qualified name of the class. | You are a Python code analyst, evaluating scripts for potential improvements. |
Whether or not the class - under - construction was declared as abstract. | Explain what the following Python 3 code does
def is_abstract(self) -> bool:
meta_value = getattr(self.clsdict.get('Meta'), 'abstract', False)
return self.clsdict.get(ABSTRACT_ATTR, meta_value) is True | As a python code expert, you are capable of creating scripts from specifications. |
Returns the value for self. name given the class - under - construction s class
Meta and McsArgs. | How would you explain what the following Python 3 function does
def get_value(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs) -> Any:
value = self.default
if self.inherit and base_classes_meta is not None:
value = getattr(base_classes_meta, self.name, value)
if Meta i... | As a python code expert, you are capable of creating scripts from specifications. |
def _get_meta_options(self) -> List[MetaOption]:
"""
Returns a list of :class:`MetaOption` instances that this factory supports.
"""
return [option if isinstance(option, MetaOption) else option()
for option in self._options] | Create a Python 3 function to
return a list of MetaOption instances that this factory supports. | You are a Python code analyst, evaluating scripts for potential improvements. |
This method is called by _parse_and_contribute_to_class. | How would you explain what the following Python 3 function does
def _contribute_to_class(self, mcs_args: McsArgs):
self._mcs_args = mcs_args
Meta = mcs_args.clsdict.pop('Meta', None) # type: Type[object]
base_classes_meta = mcs_args.getattr('Meta', None) # type: MetaOptionsFactory
mc... | You are a Python code architect, reviewing and designing scalable and efficient code |
def _fill_from_meta(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs):
"""
Iterate over our supported meta options, and set attributes on the factory
instance (self) for each meta option's name/value. Raises ``TypeError`` if
we discover any unsupported meta options on the c... | Create a Python 3 function to
fill the instance with the values from the Meta object. | You are a Python code generator, capable of creating scripts from specifications. |
def get_object(self, binding_name, cls):
"""
Get a reference to a remote object using CORBA
"""
return self._state.get_object(self, binding_name, cls) | Write a Python 3 script to
get a reference to an object using CORBA | You are a Python code analyst, evaluating scripts for potential improvements. |
def get_object(conn, binding_name, object_cls):
"""
Get a reference to a remote object using CORBA
"""
try:
obj = conn.rootContext.resolve(binding_name)
narrowed = obj._narrow(object_cls)
except CORBA.TRANSIENT:
raise IOError('Attempt to retrie... | Create a Python 3 function for
getting a reference to a remote object using CORBA. | As a Python code composer, you craft elegant and concise scripts. |
Sets the current value equal to num
| Can you tell what is the following Python 3 function doing
def set(self, num):
self._value = str(int(num))
self._variable.set(self._value) | As a Python code analyst, you investigate and solve complex coding mysteries |
Avoid repeated trigger of callback.
| Explain what the following Python 3 code does
def on_key_release_repeat(self, *dummy):
self.has_prev_key_release = self.after_idle(self.on_key_release, dummy) | You are a Python code architect, reviewing and designing scalable and efficient code |
Polls at the mouse and adds a slight delay at the mouse end. | Given the following Python 3 function, write the documentation
def _pollMouse(self):
if self._mouseJustPressed:
delay = 300
self._mouseJustPressed = False
else:
delay = 100
if self._leftMousePressed:
self.add(1)
self.after_id = self.af... | As a python code expert, you are capable of creating scripts from specifications. |
Sets the key bindings for this entry | Given the following Python 3 function, write the documentation
def set_bind(self):
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(0)) | As a Python code composer, you craft elegant and concise scripts. |
Validate the value of the recordstore entry. | Make a summary of the following Python 3 code
def validate(self, value):
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
if v < 0:
return None
return value
except ValueError:
retu... | As a Python code analyst, you investigate and solve complex coding mysteries |
def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(max(0, val)) | Write a Python 3 script to
add num to the current value of the attribute. | As a python code expert, you are capable of creating scripts from specifications. |
Subtracts num from the current value | Here you have a function in Python 3, explain what it does
def sub(self, num):
try:
val = self.value() - num
except:
val = -num
self.set(max(0, val)) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns True if OK to use False otherwise | Given the following Python 3 function, write the documentation
def ok(self):
try:
v = int(self._value)
if v < 0:
return False
else:
return True
except:
return False | As a Python code composer, you craft elegant and concise scripts. |
def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(self.imin))
self.bind('<Prior>', lambda e: self.set(self.imax)) | Write a Python 3 script to
set the key bindings for this entry | As a python code expert, you are capable of creating scripts from specifications. |
def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
... | Write a Python 3 script for
validating the value of the recordset. | You are a Python code generator, capable of creating scripts from specifications. |
def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(min(self.imax, max(self.imin, val))) | Write a Python 3 script for
adding num to the current value | As a python code expert, you are capable of creating scripts from specifications. |
def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
if v < self.imin or v > self.imax:
return False
else:
return True
except:
return False | Create a Python 3 function for
returning True if OK to use False otherwise | As a Python code analyst, you investigate and solve complex coding mysteries |
def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
RangedInt.set_bind(self)
self.unbind('<Next>')
self.unbind('<Prior>')
self.bind('<Next>', lambda e: self.set(self._min()))
self.bind('<Prior>', lambda e: self.set(self._max())) | Implement a Python 3 function for
setting the key bindings for this instance. | As a Python code composer, you craft elegant and concise scripts. |
Adds num to the current value jumping up the next next | Make a summary of the following Python 3 code
def add(self, num):
try:
val = self.value() + num
except:
val = num
chunk = self.mfac.value()
if val % chunk > 0:
if num > 0:
val = chunk*(val // chunk + 1)
elif num < 0:
... | As a python code expert, you are capable of creating scripts from specifications. |
Returns True if OK to use False otherwise | Here you have a function in Python 3, explain what it does
def ok(self):
try:
v = int(self._value)
chunk = self.mfac.value()
if v < self.imin or v > self.imax or (v % chunk != 0):
return False
else:
return True
except:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.unbind('<Shift-Up>')
self.unbind('<Shift-Down>')
self.unbind('<Control-Up>')
self.unbind('<Control-Down>')
self.unbind('<Double-Button-1>'... | Write a Python 3 function that can
set key bindings for the current locale. | You are a Python code analyst, evaluating scripts for potential improvements. |
def set_unbind(self):
"""
Unsets key bindings -- we need this more than once
"""
IntegerEntry.set_unbind(self)
self.unbind('<Button-1>')
self.unbind('<Button-3>')
self.unbind('<Up>')
self.unbind('<Down>')
self.unbind('<Enter>')
self.unbind(... | Can you write a function in Python 3 where it
unbinds the key bindings for the current entry. | As a python code expert, you are capable of creating scripts from specifications. |
def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
v = int(value)
if v not in self.allowed:
return None
return value
... | Create a Python 3 function for
validating the value of the national product of the current user s log entry. | As a python code expert, you are capable of creating scripts from specifications. |
def set(self, num):
"""
Sets current value to num
"""
if self.validate(num) is not None:
self.index = self.allowed.index(num)
IntegerEntry.set(self, num) | Write a Python 3 script to
set the current value to num | You are a Python code architect, reviewing and designing scalable and efficient code |
def add(self, num):
"""
Adds num to the current value
"""
self.index = max(0, min(len(self.allowed)-1, self.index+num))
self.set(self.allowed[self.index]) | Create a Python 3 function for
adding num to the current value of the set. | You are a Python code generator, capable of creating scripts from specifications. |
def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
float(value)
... | Can you implement a function in Python 3 that
validates the value of the key. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def set(self, num):
"""
Sets the current value equal to num
"""
self._value = str(round(float(num), self.nplaces))
self._variable.set(self._value) | Write a Python 3 function for
setting the current value equal to num | You are a Python code architect, reviewing and designing scalable and efficient code |
def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
FloatEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(self.fmin))
self.bind('<Prior>', lambda e: self.set(self.fmax)) | Write a Python 3 script for
setting the bound methods for this object to the values of the current FloatEntry. | As a Python code analyst, you investigate and solve complex coding mysteries |
def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = float(value)
... | Can you create a Python 3 function that
validates the value of the record ID field. | As a python code expert, you are capable of creating scripts from specifications. |
def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(min(self.fmax, max(self.fmin, val))) | Can you implement a function in Python 3 that
adds num to the current value | You are a Python code generator, capable of creating scripts from specifications. |
def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = float(self._value)
if v < self.fmin or v > self.fmax:
return False
else:
return True
except:
return False | Create a Python 3 function for
returning True if OK to use False otherwise | You are a Python code architect, reviewing and designing scalable and efficient code |
def validate(self, value):
"""
This prevents setting any value more precise than 0.00001
"""
try:
# trap blank fields here
if value:
v = float(value)
if (v != 0 and v < self.fmin) or v > self.fmax:
return None
... | How would you code a function in Python 3 to
validate the value of the recordstore. | You are a Python code architect, reviewing and designing scalable and efficient code |
Updates minimum value of the log entry. | Make a summary of the following Python 3 code
def set_min(self, fmin):
if round(100000*fmin) != 100000*fmin:
raise DriverError('utils.widgets.Expose.set_min: ' +
'fmin must be a multiple of 0.00001')
self.fmin = fmin
self.set(self.fmin) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def disable(self):
"""
Disable the button, if in non-expert mode;
unset its activity flag come-what-may.
"""
if not self._expert:
self.config(state='disable')
self._active = False | Implement a Python 3 function for
disabling the button if in non - expert mode unset its activity flag come - what - may. | You are a Python code generator, capable of creating scripts from specifications. |
def setNonExpert(self):
"""
Turns off 'expert' status whereby to allow a button to be disabled
"""
self._expert = False
if self._active:
self.enable()
else:
self.disable() | Can you create a Python 3 function that
turns off expert status whereby to allow a button to be disabled | As a Python code translator, you convert algorithms and pseudocode into Python. |
def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
"""
try:
coord.Angle(value, unit=self.unit)
return value
except ValueError:
return None | Write a Python 3 script to
validate the value of the key as specified by the user. | You are a Python code generator, capable of creating scripts from specifications. |
Sets the current value equal to num
| Explain what the following Python 3 code does
def set(self, num):
self._value = coord.Angle(num, unit=u.deg)
self._variable.set(self.as_string()) | You are a Python code analyst, evaluating scripts for potential improvements. |
Adds an angle to the value
| Can you generate a brief explanation for the following Python 3 code
def add(self, quantity):
newvalue = self._value + quantity
self.set(newvalue.deg) | You are a Python code analyst, evaluating scripts for potential improvements. |
def sub(self, quantity):
"""
Subtracts an angle from the value
"""
newvalue = self._value - quantity
self.set(newvalue.deg) | Write a Python 3 function for
subtracting an angle from the value | You are a Python code generator, capable of creating scripts from specifications. |
Returns True if OK to use False otherwise | Make a summary of the following Python 3 code
def ok(self):
try:
coord.Angle(self._value, unit=u.deg)
return True
except ValueError:
return False | As a Python code analyst, you investigate and solve complex coding mysteries |
This is the callback function that is called when the value of the Entry is changed. | How would you explain what the following Python 3 function does
def _callback(self, *dummy):
# retrieve the value from the Entry
value = self._variable.get()
# run the validation. Returns None if no good
newvalue = self.validate(value)
if newvalue is None:
# Invalid: ... | As a Python code analyst, you investigate and solve complex coding mysteries |
def act(self):
"""
Carries out the action associated with Stop button
"""
g = get_root(self).globals
g.clog.debug('Stop pressed')
# Stop exposure meter
# do this first, so timer doesn't also try to enable idle mode
g.info.timer.stop()
def stop_in... | Write a Python 3 script for
carrying out the action associated with Stop button | You are a Python code analyst, evaluating scripts for potential improvements. |
def check(self):
"""
Checks the status of the stop exposure command
This is run in background and can take a few seconds
"""
g = get_root(self).globals
if self.stopped_ok:
# Exposure stopped OK; modify buttons
self.disable()
# try and ... | Can you create a Python 3 function that
checks the status of the stop exposure command | You are a Python code architect, reviewing and designing scalable and efficient code |
Change the status of the current user to the status of the current verify button. | Can you tell what is the following Python 3 function doing
def modver(self, *args):
g = get_root(self).globals
if self.ok():
tname = self.val.get()
if tname in self.successes:
# known to be in simbad
self.verify.config(bg=g.COL['start'])
... | You are a Python code generator, capable of creating scripts from specifications. |
def act(self):
"""
Carries out the action associated with Verify button
"""
tname = self.val.get()
g = get_root(self).globals
g.clog.info('Checking ' + tname + ' in simbad')
try:
ret = checkSimbad(g, tname)
if len(ret) == 0:
... | Write a Python 3 script to
carry out the action associated with Verify button | You are a Python code architect, reviewing and designing scalable and efficient code |
def setExpertLevel(self):
"""
Set expert level
"""
g = get_root(self).globals
level = g.cpars['expert_level']
# first define which buttons are visible
if level == 0:
# simple layout
for button in self.all_buttons:
button.gr... | How would you implement a function in Python 3 that
sets the expert level of the current object. | As a Python code analyst, you investigate and solve complex coding mysteries |
def setExpertLevel(self):
"""
Modifies widget according to expertise level, which in this
case is just matter of hiding or revealing the button to
set CCD temps
"""
g = get_root(self).globals
level = g.cpars['expert_level']
if level == 0:
if se... | Can you write a function in Python 3 where it
sets the expertise level of the current item | You are a Python code architect, reviewing and designing scalable and efficient code |
Starts the timer from zero
| Can you tell what is the following Python 3 function doing
def start(self):
self.startTime = time.time()
self.configure(text='{0:<d} s'.format(0))
self.update() | As a python code expert, you are capable of creating scripts from specifications. |
def update(self):
"""
Updates @ 10Hz to give smooth running clock, checks
run status @0.2Hz to reduce load on servers.
"""
g = get_root(self).globals
try:
self.count += 1
delta = int(round(time.time() - self.startTime))
self.configure(t... | Implement a function in Python 3 to
update the current state of the current object with the current state of the current object. | As a Python code composer, you craft elegant and concise scripts. |
def dumpJSON(self):
"""
Return dictionary of data for FITS headers.
"""
g = get_root(self).globals
return dict(
RA=self.ra['text'],
DEC=self.dec['text'],
tel=g.cpars['telins_name'],
alt=self._getVal(self.alt),
az=self._g... | Write a Python 3 function for
dumping the current object to a dictionary of data for FITS headers. | As a python code expert, you are capable of creating scripts from specifications. |
Periodically update TCS info. | Can you generate a brief explanation for the following Python 3 code
def update_tcs(self):
g = get_root(self).globals
if not g.cpars['tcs_on']:
self.after(20000, self.update_tcs)
return
if g.cpars['telins_name'] == 'WHT':
tcsfunc = tcs.getWhtTcs
elif... | You are a Python code analyst, evaluating scripts for potential improvements. |
Updates run & tel status window. Runs
once every 2 seconds. | Explain what the following Python 3 code does
def update(self):
g = get_root(self).globals
if g.astro is None or g.fpslide is None:
self.after(100, self.update)
return
try:
if g.cpars['tcs_on']:
try:
# Poll TCS for ra,dec... | You are a Python code generator, capable of creating scripts from specifications. |
Updates the internal state of the object with the current state of the object. | Make a summary of the following Python 3 code
def update(self):
try:
# update counter
self.counter += 1
g = get_root(self).globals
# current time
now = Time.now()
# configure times
self.utc.configure(text=now.datetime.strfti... | You are a Python code architect, reviewing and designing scalable and efficient code |
def check(self):
"""
Checks the values of the window pairs. If any problems are found, it
flags them by changing the background colour.
Returns (status, synced)
status : flag for whether parameters are viable at all
synced : flag for whether the windows are synchron... | Implement a function in Python 3 to
check the values of the window pairs. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def sync(self):
"""
Synchronise the settings. This means that the pixel start
values are shifted downwards so that they are synchronised
with a full-frame binned version. This does nothing if the
binning factors == 1.
"""
# needs some mods for ultracam ??
... | Write a Python 3 function that can
synchronise the settings. This means that the pixel start values are shifted downwards so that they are synchronised with a full-frame binned version. This does nothing if the binning factors == 1. | As a python code expert, you are capable of creating scripts from specifications. |
Freeze all settings so they can t be altered | Given the following Python 3 function, write the documentation
def freeze(self):
for xsl, xsr, ys, nx, ny in \
zip(self.xsl, self.xsr,
self.ys, self.nx, self.ny):
xsl.disable()
xsr.disable()
ys.disable()
nx.disable()
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Disable all but possibly not binning. | Can you generate the documentation for the following Python 3 function
def disable(self, everything=False):
self.freeze()
if not everything:
self.xbin.enable()
self.ybin.enable()
self.frozen = False | As a python code expert, you are capable of creating scripts from specifications. |
def enable(self):
"""
Enables WinPair settings
"""
npair = self.npair.value()
for label, xsl, xsr, ys, nx, ny in \
zip(self.label[:npair], self.xsl[:npair], self.xsr[:npair],
self.ys[:npair], self.nx[:npair], self.ny[:npair]):
label... | Write a Python 3 function that can
enable WinPair settings for the current instance of this class. | You are a Python code architect, reviewing and designing scalable and efficient code |
Checks the values of the window quads. If any problems are found it checks the values of the window quads. If any problems are found it checks the values of the offending window by changing the background colour. | Explain what the following Python 3 code does
def check(self):
status = synced = True
xbin = self.xbin.value()
ybin = self.ybin.value()
nquad = self.nquad.value()
g = get_root(self).globals
# individual window checks
for (xsllw, xsulw, xslrw, xsurw, ysw, nxw, ny... | You are a Python code generator, capable of creating scripts from specifications. |
def sync(self):
"""
Synchronise the settings.
This routine changes the window settings so that the pixel start
values are shifted downwards until they are synchronised with a
full-frame binned version. This does nothing if the binning factor
is 1.
"""
xbi... | Can you create a Python 3 function that
synchronises the settings. This routine changes the window settings so that the pixel start values are shifted downwards until they are synchronised with a full-frame binned version. This does nothing if the binning factor is 1. | You are a Python code generator, capable of creating scripts from specifications. |
Freeze all settings in this instance. | Given the following Python 3 function, write the documentation
def freeze(self):
for fields in zip(self.xsll, self.xsul, self.xslr, self.xsur,
self.ys, self.nx, self.ny):
for field in fields:
field.disable()
self.nquad.disable()
self.xbin.dis... | You are a Python code analyst, evaluating scripts for potential improvements. |
Checks the values of the active windows and returns status and flag for whether parameters are viable. | Can you generate a brief explanation for the following Python 3 code
def check(self):
status = True
synced = True
xbin = self.xbin.value()
ybin = self.ybin.value()
nwin = self.nwin.value()
# individual window checks
g = get_root(self).globals
for xsw, y... | You are a Python code analyst, evaluating scripts for potential improvements. |
def sync(self, *args):
"""
Synchronise the settings. This means that the pixel start
values are shifted downwards so that they are synchronised
with a full-frame binned version. This does nothing if the
binning factor == 1
"""
xbin = self.xbin.value()
ybin... | Implement a Python 3 function for
synchronising the settings. This is a no - op if the pixel start is not binned. | As a python code expert, you are capable of creating scripts from specifications. |
def freeze(self):
"""
Freeze all settings so they can't be altered
"""
for xs, ys, nx, ny in \
zip(self.xs, self.ys, self.nx, self.ny):
xs.disable()
ys.disable()
nx.disable()
ny.disable()
self.nwin.disable()
... | Can you implement a function in Python 3 that
freezes all settings so they can t be altered | As a Python code analyst, you investigate and solve complex coding mysteries |
def enable(self):
"""
Enables all settings
"""
nwin = self.nwin.value()
for label, xs, ys, nx, ny in \
zip(self.label[:nwin], self.xs[:nwin], self.ys[:nwin],
self.nx[:nwin], self.ny[:nwin]):
label.config(state='normal')
... | Create a Python 3 function for
enabling all settings for the current instance of the class. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def check_download(self, link_item_dict: Dict[str, LinkItem], folder: Path, log: bool = True) -> Tuple[
Dict[str, LinkItem], Dict[str, LinkItem]]:
"""
Check if the download of the given dict was successful. No proving if the content of the file is correct too.
:param link_item_dict: dic... | Write a Python 3 function for
checking if the download of the given dict was successful. | As a python code expert, you are capable of creating scripts from specifications. |
def delete_data(self):
"""
Delete everything which is related to the plugin. **Do not use if you do not know what you do!**
"""
self.clean_up()
tools.delete_dir_rec(self._download_path)
if self._save_state_file.exists():
self._save_state_file.unlink() | Write a Python 3 function that can
delete all data related to the plugin. | You are a Python code architect, reviewing and designing scalable and efficient code |
Download the given url to the given target folder. | Can you generate the documentation for the following Python 3 function
def download_as_file(self, url: str, folder: Path, name: str, delay: float = 0) -> str:
while folder.joinpath(name).exists(): # TODO: handle already existing files
self.log.warning('already exists: ' + name)
name = n... | As a Python code composer, you craft elegant and concise scripts. |
def download(self, link_item_dict: Dict[str, LinkItem], folder: Path, desc: str, unit: str, delay: float = 0) -> \
List[str]:
"""
.. warning::
The parameters may change in future versions. (e.g. change order and accept another host)
Download the given LinkItem dict from... | Can you create a Python 3 function that
downloads the given LinkItem dict to the given folder. | You are a Python code architect, reviewing and designing scalable and efficient code |
Create protobuf savestate of the module and the given data. | How would you explain what the following Python 3 function does
def _create_save_state(self, link_item_dict: Dict[str, LinkItem]) -> SaveState:
return SaveState(dynamic_data.SAVE_STATE_VERSION, self.info, self.last_update, link_item_dict) | You are a Python code architect, reviewing and designing scalable and efficient code |
def save_save_state(self, data_dict: Dict[str, LinkItem]): # TODO: add progressbar
"""
Save meta data about the downloaded things and the plugin to file.
:param data_dict: data
:type data_dict: Dict[link, ~unidown.plugin.link_item.LinkItem]
"""
json_data = json_format.M... | Implement a function in Python 3 to
save meta data about the downloaded things and the plugin to file. | You are a Python code architect, reviewing and designing scalable and efficient code |
Loads the savestate of the plugin. | Given the following Python 3 function, write the documentation
def load_save_state(self) -> SaveState:
if not self._save_state_file.exists():
self.log.info("No savestate file found.")
return SaveState(dynamic_data.SAVE_STATE_VERSION, self.info, datetime(1970, 1, 1), {})
savestat... | As a Python code composer, you craft elegant and concise scripts. |
def get_updated_data(self, old_data: Dict[str, LinkItem]) -> Dict[str, LinkItem]:
"""
Get links who needs to be downloaded by comparing old and the new data.
:param old_data: old data
:type old_data: Dict[str, ~unidown.plugin.link_item.LinkItem]
:return: data which is newer or d... | How would you code a function in Python 3 to
get links who need to be downloaded by comparing old and new data. | You are a Python code architect, reviewing and designing scalable and efficient code |
Update the base dict with the new dict. | Explain what the following Python 3 code does
def update_dict(self, base: Dict[str, LinkItem], new: Dict[str, LinkItem]):
if logging.INFO >= logging.getLevelName(dynamic_data.LOG_LEVEL): # TODO: logging here or outside
for link, item in new.items():
if link in base:
... | As a Python code composer, you craft elegant and concise scripts. |
Convert the option list to a dictionary where the key is the option and the value is the related option. | How would you explain what the following Python 3 function does
def _get_options_dic(self, options: List[str]) -> Dict[str, str]:
options_dic = {}
for option in options:
cur_option = option.split("=")
if len(cur_option) != 2:
self.log.warning(f"'{option}' is not v... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_plugins() -> Dict[str, pkg_resources.EntryPoint]:
"""
Get all available plugins for unidown.
:return: plugin name list
:rtype: Dict[str, ~pkg_resources.EntryPoint]
"""
return {entry.name: entry for entry in pkg_resources.iter_entry_points('unidown.plugin')} | Write a Python 3 function that can
get all available plugins for unidown. | You are a Python code architect, reviewing and designing scalable and efficient code |
Find the difference between apparent and mean solar time. | Can you tell what is the following Python 3 function doing
def _equation_of_time(t):
# Julian centuries since J2000.0
T = (t - Time("J2000")).to(u.year).value / 100
# obliquity of ecliptic (Meeus 1998, eq 22.2)
poly_pars = (84381.448, 46.8150, 0.00059, 0.001813)
eps = u.Quantity(polyval(T, poly_pa... | You are a Python code generator, capable of creating scripts from specifications. |
def _astropy_time_from_LST(t, LST, location, prev_next):
"""
Convert a Local Sidereal Time to an astropy Time object.
The local time is related to the LST through the RA of the Sun.
This routine uses this relationship to convert a LST to an astropy
time object.
Returns
-------
ret1 : `... | Write a Python 3 script to
convert a Local Sidereal Time to an astropy. time. Time object. | You are a Python code architect, reviewing and designing scalable and efficient code |
def calc_riseset(t, target_name, location, prev_next, rise_set, horizon):
"""
Time at next rise/set of ``target``.
Parameters
----------
t : `~astropy.time.Time` or other (see below)
Time of observation. This will be passed in as the first argument to
the `~astropy.time.Time` initia... | Create a Python 3 function to
calculate next rise set of target. | As a python code expert, you are capable of creating scripts from specifications. |
Calculate the time and altitude crossing of a base time and altitudes. | Given the following Python 3 function, write the documentation
def _horiz_cross(t, alt, rise_set, horizon=0*u.degree):
if rise_set == 'rising':
# Find index where altitude goes from below to above horizon
condition = (alt[:-1] < horizon) * (alt[1:] > horizon)
elif rise_set == 'setting':
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Do linear interpolation between two times and altitudes at
two times and horizon. | Can you tell what is the following Python 3 function doing
def _two_point_interp(times, altitudes, horizon=0*u.deg):
if not isinstance(times, Time):
return MAGIC_TIME
else:
slope = (altitudes[1] - altitudes[0])/(times[1].jd - times[0].jd)
return Time(times[1].jd - ((altitudes[1] - horizo... | As a Python code composer, you craft elegant and concise scripts. |
Initialize the main directories. | Can you generate a brief explanation for the following Python 3 code
def init_dirs(main_dir: Path, logfilepath: Path):
global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH
MAIN_DIR = main_dir
TEMP_DIR = MAIN_DIR.joinpath(Path('temp/'))
DOWNLOAD_DIR = MAIN_DIR.joinpath(Path('downloads/'))
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def reset():
"""
Reset all dynamic variables to the default values.
"""
global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH, USING_CORES, LOG_LEVEL, DISABLE_TQDM, \
SAVE_STATE_VERSION
MAIN_DIR = Path('./')
TEMP_DIR = MAIN_DIR.joinpath(Path('temp/'))
DOWNLOAD_DIR = MAI... | Create a Python 3 function for
resetting all dynamic variables to the default values. | As a Python code composer, you craft elegant and concise scripts. |
Checks the directories if they exist. | Can you generate a brief explanation for the following Python 3 code
def check_dirs():
dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR]
for directory in dirs:
if directory.exists() and not directory.is_dir():
raise FileExistsError(str(directory.resolve()) + " cannot be used as a direc... | You are a Python code analyst, evaluating scripts for potential improvements. |
Parse a single item from the telescope server into name value comment. | How would you explain what the following Python 3 function does
def parse_hstring(hs):
# split the string on = and /, also stripping whitespace and annoying quotes
name, value, comment = yield_three(
[val.strip().strip("'") for val in filter(None, re.split("[=/]+", hs))]
)
# if comment has a sl... | As a Python code analyst, you investigate and solve complex coding mysteries |
Create a list of fits header items from GTC telescope pars. | Here you have a function in Python 3, explain what it does
def create_header_from_telpars(telpars):
# pars is a list of strings describing tel info in FITS
# style, each entry in the list is a different class of
# thing (weather, telescope, instrument etc).
# first, we munge it into a single list of st... | 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.