output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
This function creates a list of symbols that the user choose to use according for the list of species and arrays to plot. | Can you tell what is the following Python 3 function doing
def make_list(default_symbol_list, len_list_to_print):
'''
provide the list of symbols to use according for the list of
species/arrays to plot.
Parameters
----------
default_symbol_list : list
Symbols that the user choose to use... | You are a Python code analyst, evaluating scripts for potential improvements. |
This method returns a sorted list of indices that are strictly monotonic. | Can you tell what is the following Python 3 function doing
def strictly_monotonic(bb):
'''
bb is an index array which may have numerous double or triple
occurrences of indices, such as for example the decay_index_pointer.
This method removes all entries <= -, then all dublicates and
finally returns ... | As a python code expert, you are capable of creating scripts from specifications. |
Reads the solar abundances from filename_solar and creates a hashed array of solar abundances. | How would you explain what the following Python 3 function does
def solar(filename_solar, solar_factor):
'''
read solar abundances from filename_solar.
Parameters
----------
filename_solar : string
The file name.
solar_factor : float
The correction factor to apply, in case filen... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Convert the specie names from h5 files to ppn. | Can you generate the documentation for the following Python 3 function
def convert_specie_naming_from_h5_to_ppn(isotope_names):
'''
read isotopes names from h5 files, and convert them
according to standard scheme used inside ppn and mppnp. Also
Z and A are recalculated, for these species. Isomers are
... | You are a Python code generator, capable of creating scripts from specifications. |
def element_abund_marco(i_decay, stable_isotope_list,
stable_isotope_identifier,
mass_fractions_array_not_decayed,
mass_fractions_array_decayed):
'''
Given an array of isotopic abundances not decayed and a similar
array of isotopic abun... | Write a Python 3 function for
giving an array of isotopic abundances not decayed and a similar array of isotopic abundances not decayed, here elements abundances, and production factors for elements are calculated | As a Python code composer, you craft elegant and concise scripts. |
def stable_specie():
''' provide the list of stable species, and decay path feeding stables '''
#import numpy as np
stable_raw=[]
stable_raw = ['H 1', 'H 2',\
'HE 3', 'HE 4',\
'LI 6', 'LI 7',\
'BE 9',\
'B 10', 'B 11',\
'C 12', 'C 13',\
'N 14', 'N 15',\
'O ... | Create a Python 3 function for
providing the list of stable species and decay path feeding stables | You are a Python code architect, reviewing and designing scalable and efficient code |
def give_zip_element_z_and_names(element_name):
''' create 2 indexes that, given the name of the element/specie, give the atomic number.'''
#import numpy as np
global z_bismuth
z_bismuth = 83
global z_for_elem
z_for_elem = []
global index_stable
index_stable = []
i_for_stable = 1
... | Implement a Python 3 function for
creating 2 indexes that given the name of the element and give the atomic number. | You are a Python code architect, reviewing and designing scalable and efficient code |
This function returns the atomic number as a string when given the element symbol. | Explain what the following Python 3 code does
def get_el_from_z(z):
'''
Very simple Vfunction that gives the atomic number AS A STRING when given the element symbol.
Uses predefined a dictionnary.
Parameter :
z : string or number
For the other way, see get_z_from_el
'''
if(type(z)==float... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Fits the fit function with the specified data arrays x and y. | Given the following Python 3 function, write the documentation
def fit(self, x, y, dcoef='none'):
'''
performs the fit
x, y : list
Matching data arrays that define a numerical function y(x),
this is the data to be fitted.
dcoef : list or string
You ca... | As a Python code analyst, you investigate and solve complex coding mysteries |
Plot the data and the fitted function. | Can you tell what is the following Python 3 function doing
def plot(self, ifig=1, data_label='data', fit_label='fit',
data_shape='o', fit_shape='-'):
'''
plot the data and the fitted function.
Parameters
----------
ifig : integer
Figure window number. T... | As a python code expert, you are capable of creating scripts from specifications. |
Private method to extract the element names from the stable_el attribute. | Here you have a function in Python 3, explain what it does
def _stable_names(self):
'''
This private method extracts the element names from stable_el.
Note that stable_names is a misnomer as stable_el also contains
unstable element names with a number 999 for the *stable* mass
nu... | As a python code expert, you are capable of creating scripts from specifications. |
This private method processes one vector definition and returns the processed input variables and isomers and z. | How would you explain what the following Python 3 function does
def _process_abundance_vector(self, a, z, isomers, yps):
'''
This private method takes as input one vector definition and
processes it, including sorting by charge number and
mass number. It returns the processed input varia... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Writes an initial abundance file for a PPN run. | Here you have a function in Python 3, explain what it does
def write(self, outfile='initial_abundance.dat',
header_string='initial abundances for a PPN run'):
'''
Write initial abundance file (intended for use with ppn)
Parameters
----------
outfile : string
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def write_mesa(self, mesa_isos_file='isos.txt',
add_excess_iso='fe56', outfile='xa_iniabu.dat',
header_string='initial abundances for a MESA run',
header_char='!'):
'''
Write initial abundance file, returns written abundances and
mesa name... | Implement a function in Python 3 to
write initial abundance file, returns written abundances and mesa names. Parameters ---------- mesa_isos_file : string, optional List with isos copied from mesa network definition file in mesa/data/net_data/nets. The default is 'isos.txt'. add_excess_iso : string, optional Add 1.-sum... | You are a Python code architect, reviewing and designing scalable and efficient code |
This method sets the internal state of the object to the values of the abundances of the species names in the object. | Explain what the following Python 3 code does
def set_and_normalize(self,species_hash):
'''
species_hash is a hash array in which you provide abundances
referenced by species names that you want to set to some
particular value; all other species are then normalised so that
the to... | You are a Python code architect, reviewing and designing scalable and efficient code |
This routine returns the abundance of a specific isotope. | Given the following Python 3 function, write the documentation
def iso_abundance(self,isos):
'''
This routine returns the abundance of a specific isotope.
Isotope given as, e.g., 'Si-28' or as list
['Si-28','Si-29','Si-30']
'''
if type(isos) == list:
dumb = [... | You are a Python code analyst, evaluating scripts for potential improvements. |
Gets the set of rotational speed of the HDD drives | Can you generate the documentation for the following Python 3 function
def drive_rotational_speed_rpm(self):
drv_rot_speed_rpm = set()
for member in self.get_members():
if member.rotational_speed_rpm is not None:
drv_rot_speed_rpm.add(member.rotational_speed_rpm)
retu... | You are a Python code analyst, evaluating scripts for potential improvements. |
def iso_name_converter(iso):
'''
Converts the name of the given isotope (input), e.g., 'N-14' to
14N as used later to compare w/ grain database.
'''
sp = iso.split('-')
output = sp[1] + sp[0]
return output.lower() | Can you implement a function in Python 3 that
converts the name of the isotope input e. g. N - 14 to 14N as used later to compare w / grain database. | You are a Python code analyst, evaluating scripts for potential improvements. |
Resets the filter and goes back to initialized value. This routine resets the style and the data and header dictionaries. | Can you generate a brief explanation for the following Python 3 code
def reset_filter(self):
'''
Resets the filter and goes back to initialized value. This
routine also resets the style if you have changed it.
'''
self.header_desc = self._header_desc
self.header_data = s... | As a python code expert, you are capable of creating scripts from specifications. |
This method filters isotopic values according to the limit. | How would you explain what the following Python 3 function does
def filter_data(self, isos, limit, delta=True):
'''
This subroutine filters isotopic values according to the limit
you give. You can filter in ratio or in delta space.
Parameters
----------
isos : list
... | As a Python code analyst, you investigate and solve complex coding mysteries |
This routine changes the plotting style of the current object based on the label of the grains you want to change. | Can you generate the documentation for the following Python 3 function
def style_chg_label(self,type,symb=None,edc=None,fac=None,smbsz=None,edw=None,lab=None):
'''
This routine changes the plotting style that is set by default.
The style is changed according the the label that you choose.
... | You are a Python code analyst, evaluating scripts for potential improvements. |
This routine returns data isotopic data from the current state of the object. | Can you tell what is the following Python 3 function doing
def plot_ratio_return(self, isox, isoy, deltax=True, deltay=True):
'''
This routine returns data isotopic data to plot from the
filtered list of data.
Parameters
----------
isox : list
Isotopes for x ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def ratio_to_delta(self, isos_ss, ratio, oneover=False):
'''
Transforms an isotope ratio into a delta value
Parameters
----------
isos_ss: list or float
list w/ isotopes, e.g., ['N-14','N-15'] OR the solar
system ratio.
ratio : float
r... | Create a Python 3 function to
transform an isotope ratio into a delta value Parameters ---------- isos_ss: list or float list w/ isotopes, e.g., ['N-14','N-15'] OR the solar system ratio. ratio : float ratio of the isotopes to transform. oneover : boolean take the inverse of the ratio before transforming (never inverse... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a new service which will process requests with the specified filter. | Given the following Python 3 function, write the documentation
def with_filter(self, filter):
'''
Returns a new service which will process requests with the specified
filter. Filtering operations can include logging, automatic retrying,
etc... The filter is a lambda which receives the HT... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _perform_request(self, request, encoding='utf-8'):
'''
Sends the request and return response. Catches HTTPError and hands it
to error handler
'''
try:
resp = self._filter(request)
if sys.version_info >= (3,) and isinstance(resp, bytes) and \
... | Write a Python 3 script to
send the request and returns the response. Catches HTTPError and hands itto error handler. | As a Python code composer, you craft elegant and concise scripts. |
Validates SNMP credentials.
:raises exception.IloInvalidInputError | Here you have a function in Python 3, explain what it does
def _validate_snmp(self):
cred = self.snmp_credentials
if cred is not None:
if cred.get('snmp_inspection') is True:
if not all([cred.get('auth_user'),
cred.get('auth_prot_pp'),
... | As a Python code composer, you craft elegant and concise scripts. |
Call the corresponding method using RIBCL RIS or REDFISH way. | Given the following Python 3 function, write the documentation
def _call_method(self, method_name, *args, **kwargs):
if self.use_redfish_only:
if method_name in SUPPORTED_REDFISH_METHODS:
the_operation_object = self.redfish
else:
raise NotImplementedError(... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Set the iscsi details of the initiator system in uefi boot mode. | Can you generate the documentation for the following Python 3 function
def set_iscsi_info(self, target_name, lun, ip_address,
port='3260', auth_method=None, username=None,
password=None):
"""Set iscsi details of the system in uefi boot mode.
The initiator s... | You are a Python code analyst, evaluating scripts for potential improvements. |
def set_iscsi_boot_info(self, mac, target_name, lun, ip_address,
port='3260', auth_method=None, username=None,
password=None):
"""Set iscsi details of the system in uefi boot mode.
The initiator system is set with the target details like
I... | Create a Python 3 function for
setting the iSCSI boot information of the initiator system in uefi boot mode. | As a python code expert, you are capable of creating scripts from specifications. |
def set_vm_status(self, device='FLOPPY',
boot_option='BOOT_ONCE', write_protect='YES'):
"""Sets the Virtual Media drive status and allows the
boot options for booting from the virtual media.
"""
return self._call_method('set_vm_status', device, boot_option,
... | Create a Python 3 function for
setting the Virtual Media drive status and allows the virtual media to boot from the virtual media. | You are a Python code analyst, evaluating scripts for potential improvements. |
Get the essential scheduling properties of the current node. | Make a summary of the following Python 3 code
def get_essential_properties(self):
data = self._call_method('get_essential_properties')
if (data['properties']['local_gb'] == 0):
cred = self.snmp_credentials
if cred and cred.get('snmp_inspection'):
disksize = snmp.g... | You are a Python code generator, capable of creating scripts from specifications. |
def get_server_capabilities(self):
"""Get hardware properties which can be used for scheduling
:return: a dictionary of server capabilities.
:raises: IloError, on an error from iLO.
:raises: IloCommandNotSupportedError, if the command is not supported
on the server.
... | Write a Python 3 function for
getting the server capabilities for the specified iLO entry. | As a Python code analyst, you investigate and solve complex coding mysteries |
def _cleanstarlog(file_in):
"""
cleaning history.data or star.log file, e.g. to take care of
repetitive restarts.
private, should not be called by user directly
Parameters
----------
file_in : string
Typically the filename of the mesa output history.data or
star.log file, c... | Create a Python 3 function for
cleaning history.data or star.log file, e.g. to take care of repetitive restarts. private, should not be called by user directly Parameters ---------- file_in : string Typically the filename of the mesa output history.data or star.log file, creates a clean file called history.datasa or st... | You are a Python code generator, capable of creating scripts from specifications. |
def abu_profiles(p,ifig=1,xlm=xlm,ylm=(-8,0),show=False,abunds='All',xaxis=xaxis_type, figsize1=(8,8)):
'''Four panels of abundance plots
Parameters
----------
p : instance
mesa_profile instance
xlm : tuple
xlimits: mass_min, mass_max
abus : 'All' plots many 'commonly used'... | Implement a function in Python 3 to
plot the Mesa profile and returns a list of lists of the desired abundance plots. | As a Python code composer, you craft elegant and concise scripts. |
Plots the other profiles of a Msun object. | Can you tell what is the following Python 3 function doing
def other_profiles(p,ifig=1,xlm=xlm,show=False,xaxis=xaxis_type, figsize2=(10,8)):
'''Four panels of other profile plots
Parameters
----------
p : instance
mesa_profile instance
xll : tuple
xlimits: mass_min, mass_max
... | As a python code expert, you are capable of creating scripts from specifications. |
def _profiles_index(self):
"""
read profiles.index and make hash array
Notes
-----
sets the attributes.
log_ind : hash array that returns profile.data or log.data
file number from model number.
model : the models for which profile.data or log.data is
... | Can you write a function in Python 3 where it
reads the profiles. index file and make hash array | You are a Python code generator, capable of creating scripts from specifications. |
Returns the number of profile. data files that are available for the specified inum. | Can you generate a brief explanation for the following Python 3 code
def _log_file_ind(self,inum):
self._profiles_index()
if inum <= 0:
print("Smallest argument is 1")
return
inum_max = len(self.log_ind)
inum -= 1
if inum > inum_max:
print('... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get(self,str_name):
"""
return a column of data with the name str_name.
Parameters
----------
str_name : string
Is the name of the column as printed in the
profilennn.data or lognnn.data file; get the available
columns from self.cols (wher... | How would you implement a function in Python 3 that
gets a column of data with the name str_name | As a Python code composer, you craft elegant and concise scripts. |
def write_PROM_HOTB_progenitor(self,name,description):
"""
Write a progenitor file for the PROMETHEUS/HBOT supernova code.
Parameters
----------
name : string
File name for the progenitor file
description : string
Information to be written into th... | Can you create a Python 3 function that
writes a PROMETHEUS HBOT supernova file for the specified class. | As a python code expert, you are capable of creating scripts from specifications. |
def write_STELLA_model(self,name):
"""
Write an initial model in a format that may easily be read by the
radiation hydrodynamics code STELLA.
Parameters
----------
name : string
an identifier for the model. There are two output files from
this met... | Write a Python 3 function that can
write an initial model in a format that may easily be read by the radiation hydrodynamics code STELLA. Parameters ---------- name : string an identifier for the model. There are two output files from this method, which will be <name>.hyd and <name>.abn, which contain the profiles for ... | You are a Python code architect, reviewing and designing scalable and efficient code |
def energy_profile(self,ixaxis):
"""
Plot radial profile of key energy generations eps_nuc,
eps_neu etc.
Parameters
----------
ixaxis : 'mass' or 'radius'
"""
mass = self.get('mass')
radius = self.get('radius') * ast.rsun_cm
... | Can you write a function in Python 3 where it
plots radial profile of key energy generations | You are a Python code generator, capable of creating scripts from specifications. |
def _read_starlog(self):
""" read history.data or star.log file again"""
sldir = self.sldir
slname = self.slname
slaname = slname+'sa'
if not os.path.exists(sldir+'/'+slaname):
print('No '+self.slname+'sa file found, create new one from '+self.slname)
... | Can you create a Python 3 function that
reads history. data or star. log file again | As a Python code composer, you craft elegant and concise scripts. |
def CO_ratio(self,ifig,ixaxis):
"""
plot surface C/O ratio in Figure ifig with x-axis quantity ixaxis
Parameters
----------
ifig : integer
Figure number in which to plot
ixaxis : string
what quantity is to be on the x-axis, either 'time' or 'model... | Write a Python 3 script to
plot the surface C / O ratio in the specified x - axis. | As a Python code analyst, you investigate and solve complex coding mysteries |
def hrd(self,ifig=None,label=None,colour=None,s2ms=False,
dashes=None,**kwargs):
"""
Plot an HR diagram
Parameters
----------
ifig : integer or string
Figure label, if None the current figure is used
The default value is None.
lims : l... | Can you create a Python 3 function that
plots an HR diagram of the current state of the object. | As a Python code translator, you convert algorithms and pseudocode into Python. |
This function plots an HR diagram of the related class. | Explain what the following Python 3 code does
def hrd_key(self, key_str):
pyl.plot(self.data[:,self.cols['log_Teff']-1],\
self.data[:,self.cols['log_L']-1],label = key_str)
pyl.legend()
pyl.xlabel('log Teff')
pyl.ylabel('log L')
x1,x2=pl.xlim()
if x2 > x... | As a Python code analyst, you investigate and solve complex coding mysteries |
Plot an HR diagram with options to skip the first N lines and add a label string | Can you tell what is the following Python 3 function doing
def hrd_new(self, input_label="", skip=0):
xl_old=pyl.gca().get_xlim()
if input_label == "":
my_label="M="+str(self.header_attr['initial_mass'])+", Z="+str(self.header_attr['initial_z'])
else:
my_label="M="+str(se... | You are a Python code analyst, evaluating scripts for potential improvements. |
Plots effective temperature against central helium abundance. | Explain what the following Python 3 code does
def xche4_teff(self,ifig=None,lims=[1.,0.,3.4,4.7],label=None,colour=None,
s2ms=True,dashes=None):
"""
Plot effective temperature against central helium abundance.
Parameters
----------
ifig : integer or string
... | As a Python code composer, you craft elegant and concise scripts. |
Function to plot the current state of the object. | Explain what the following Python 3 code does
def tcrhoc(self,ifig=None,lims=[3.,10.,8.,10.],label=None,colour=None,
dashes=None):
"""
Central temperature again central density plot
Parameters
----------
ifig : integer or string
Figure label, if None t... | As a python code expert, you are capable of creating scripts from specifications. |
def mdot_t(self,ifig=None,lims=[7.4,2.6,-8.5,-4.5],label=None,colour=None,s2ms=False,
dashes=None):
"""
Plot mass loss history as a function of log-time-left
Parameters
----------
ifig : integer or string
Figure label, if None the current figure is use... | Can you write a function in Python 3 where it
plots mass loss history as a function of log - time - left. | You are a Python code analyst, evaluating scripts for potential improvements. |
def mcc_t(self,ifig=None,lims=[0,15,0,25],label=None,colour=None,
mask=False,s2ms=False,dashes=None):
"""
Plot mass of [oclark01@scandium 15M_led_f_print_nets]$ cp ../15M_led_f_ppcno/ective core as a function of time.
Parameters
----------
ifig : integer or string
... | Can you implement a function in Python 3 that
plots mass of [ oclark01@scandium 15M_led_f_print_nets ]$ cp.. / 15M_led_f_ppcno. | As a python code expert, you are capable of creating scripts from specifications. |
def kippenhahn_CO(self, num_frame, xax, t0_model=0,
title='Kippenhahn diagram', tp_agb=0.,
ylim_CO=[0,0]):
"""
Kippenhahn plot as a function of time or model with CO ratio
Parameters
----------
num_frame : integer
Number of... | Implement a function in Python 3 to
function to plot a Kippenhahn diagram. | You are a Python code analyst, evaluating scripts for potential improvements. |
Function to plot a new Kippenhahn plot. | Can you tell what is the following Python 3 function doing
def kippenhahn(self, num_frame, xax, t0_model=0,
title='Kippenhahn diagram', tp_agb=0., t_eps=5.e2,
plot_star_mass=True, symbol_size=8, c12_bm=False,
print_legend=True):
"""Kippenhahn plot as a fu... | You are a Python code generator, capable of creating scripts from specifications. |
def t_lumi(self,num_frame,xax):
"""
Luminosity evolution as a function of time or model.
Parameters
----------
num_frame : integer
Number of frame to plot this plot into.
xax : string
Either model or time to indicate what is to be used on the
... | Implement a Python 3 function for
plotting the luminosity evolution of the current state of the entry. | As a Python code composer, you craft elegant and concise scripts. |
This function plots the surfaces of the current state of the state of the state of the surfaces of the current state of the surfaces. | Can you tell what is the following Python 3 function doing
def t_surf_parameter(self, num_frame, xax):
pyl.figure(num_frame)
if xax == 'time':
xaxisarray = self.get('star_age')
elif xax == 'model':
xaxisarray = self.get('model_number')
else:
print('k... | As a Python code analyst, you investigate and solve complex coding mysteries |
This function creates a Kippenhahn plot with energy flux using the specified contour parameters. | Explain what the following Python 3 code does
def kip_cont(self, ifig=110, modstart=0, modstop=-1,t0_model=0,
outfile='out.png', xlims=None, ylims=None,
xres=1000, yres=1000, ixaxis='model_number',
mix_zones=20, burn_zones=20, plot_radius=False,
engenP... | As a python code expert, you are capable of creating scripts from specifications. |
def find_first_TP(self):
"""
Find first TP of the TPAGB phase and returns the model
number at its LHe maximum.
Parameters
----------
"""
star_mass = self.get('star_mass')
he_lumi = self.get('log_LHe')
h_lumi = self.... | Can you write a function in Python 3 where it
finds the first TP of the TPAGB phase and returns the model that is at its LHe maximum. | You are a Python code analyst, evaluating scripts for potential improvements. |
def find_TPs_and_DUPs(self, percent=5., makefig=False):
"""
Function which finds TPs and uses the calc_DUP_parameter
function. To calculate DUP parameter evolution dependent of
the star or core mass.
Parameters
----------
fig : integer
Figure number ... | Write a Python 3 function for
functioning which finds TPs and uses the calc_DUP_parameter function. To calculate DUP parameter evolution dependent of the star or core mass. Parameters ---------- fig : integer Figure number to plot. t0_model : integer First he-shell lum peak. percent : float dredge-up is defined as when... | You are a Python code architect, reviewing and designing scalable and efficient code |
def TPAGB_properties(self):
"""
Temporary, use for now same function in nugrid_set.py!
Returns many TPAGB parameters which are
TPstart,TPmods,TP_max_env,TPend,min_m_TP,max_m_TP,DUPmods,DUPm_min_h
Same function in nugrid_set.py.
Parameters
----------
"""... | Write a Python 3 script to
return a list of all properties which are TPAGB parameters which are defined in the nugrid_set. py file. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Method to calculate the DUP parameter evolution for different types of a single duplicate TPs. | Can you generate the documentation for the following Python 3 function
def calc_DUP_parameter(self, modeln, label, fig=10, color='r', marker_type='*',
h_core_mass=False):
"""
Method to calculate the DUP parameter evolution for different
TPs specified specified by their... | As a Python code composer, you craft elegant and concise scripts. |
def _create_usm_user_obj(snmp_cred):
"""Creates the UsmUserData obj for the given credentials.
This method creates an instance for the method hlapi.UsmUserData.
The UsmUserData() allows the 'auth_protocol' and 'priv_protocol'
to be undefined by user if their pass phrases are provided.
:param snmp_... | Create a Python 3 function for
creating the UsmUserData object for the given credentials. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Parses the MIBs from the given iLOIP and returns a dictionary of the parsed MIBs. | Make a summary of the following Python 3 code
def _parse_mibs(iLOIP, snmp_credentials):
result = {}
usm_user_obj = _create_usm_user_obj(snmp_credentials)
try:
for(errorIndication,
errorStatus,
errorIndex,
varBinds) in hlapi.nextCmd(
hlapi.SnmpEngin... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _get_disksize_MiB(iLOIP, cred):
"""Reads the dictionary of parsed MIBs and gets the disk size.
:param iLOIP: IP address of the server on which SNMP discovery
has to be executed.
:param snmp_credentials in a dictionary having following mandatory
keys.
auth_user: S... | Create a Python 3 function to
read the dictionary of parsed MIBs and gets the disk size. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Gets the maximum disk size among all disks. | Make a summary of the following Python 3 code
def get_local_gb(iLOIP, snmp_credentials):
disk_sizes = _get_disksize_MiB(iLOIP, snmp_credentials)
max_size = 0
for uuid in disk_sizes:
for key in disk_sizes[uuid]:
if int(disk_sizes[uuid][key]) > max_size:
max_size = int(disk... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Simple error handler for azure. | Make a summary of the following Python 3 code
def _http_error_handler(http_error):
''' Simple error handler for azure.'''
message = str(http_error)
if http_error.respbody is not None:
message += '\n' + http_error.respbody.decode('utf-8-sig')
raise AzureHttpError(message, http_error.status) | You are a Python code generator, capable of creating scripts from specifications. |
property to return the summary MAC addresses and state | Here you have a function in Python 3, explain what it does
def summary(self):
mac_dict = {}
for eth in self.get_members():
if eth.mac_address is not None:
if (eth.status is not None and
eth.status.health == sys_cons.HEALTH_OK
an... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _update_physical_disk_details(raid_config, server):
"""Adds the physical disk details to the RAID configuration passed."""
raid_config['physical_disks'] = []
physical_drives = server.get_physical_drives()
for physical_drive in physical_drives:
physical_drive_dict = physical_drive.get_physica... | Implement a Python 3 function for
updating the RAID configuration with the details of the physical disks. | You are a Python code analyst, evaluating scripts for potential improvements. |
Validates the RAID configuration provided against the RAID specification. | Here you have a function in Python 3, explain what it does
def validate(raid_config):
raid_schema_fobj = open(RAID_CONFIG_SCHEMA, 'r')
raid_config_schema = json.load(raid_schema_fobj)
try:
jsonschema.validate(raid_config, raid_config_schema)
except json_schema_exc.ValidationError as e:
r... | You are a Python code architect, reviewing and designing scalable and efficient code |
def _select_controllers_by(server, select_condition, msg):
"""Filters out the hpssa controllers based on the condition.
This method updates the server with only the controller which satisfies
the condition. The controllers which doesn't satisfies the selection
condition will be removed from the list.
... | Write a Python 3 function that can
filter out the controllers which satisfy the condition. | As a python code expert, you are capable of creating scripts from specifications. |
def create_configuration(raid_config):
"""Create a RAID configuration on this server.
This method creates the given RAID configuration on the
server based on the input passed.
:param raid_config: The dictionary containing the requested
RAID configuration. This data structure should be as follow... | Create a Python 3 function for
creating a RAID configuration on this server based on the input passed. | You are a Python code architect, reviewing and designing scalable and efficient code |
Sort the logical disks based on the conditions that are set in the RAID1 and RAID2. | Make a summary of the following Python 3 code
def _sort_shared_logical_disks(logical_disks):
is_shared = (lambda x: True if ('share_physical_disks' in x and
x['share_physical_disks']) else False)
num_of_disks = (lambda x: x['number_of_physical_disks']
if '... | As a python code expert, you are capable of creating scripts from specifications. |
Delete a RAID configuration on this server. | Can you tell what is the following Python 3 function doing
def delete_configuration():
server = objects.Server()
select_controllers = lambda x: not x.properties.get('HBA Mode Enabled',
False)
_select_controllers_by(server, select_controllers, 'RAID en... | You are a Python code generator, capable of creating scripts from specifications. |
Get the current RAID configuration. | Can you generate a brief explanation for the following Python 3 code
def get_configuration():
server = objects.Server()
logical_drives = server.get_logical_drives()
raid_config = {}
raid_config['logical_disks'] = []
for logical_drive in logical_drives:
logical_drive_dict = logical_drive.get... | As a Python code composer, you craft elegant and concise scripts. |
Erase all the drives on this server. | Here you have a function in Python 3, explain what it does
def erase_devices():
server = objects.Server()
for controller in server.controllers:
drives = [x for x in controller.unassigned_physical_drives
if (x.get_physical_drive_dict().get('erase_status', '')
== '... | As a python code expert, you are capable of creating scripts from specifications. |
Extracts approximate messages count header. | Can you generate the documentation for the following Python 3 function
def _parse_metadata_and_message_count(response):
'''
Extracts approximate messages count header.
'''
metadata = _parse_metadata(response)
headers = _parse_response_for_dict(response)
metadata.approximate_message_count = _int... | As a Python code composer, you craft elegant and concise scripts. |
def _parse_queue_message_from_headers(response):
'''
Extracts pop receipt and time next visible from headers.
'''
headers = _parse_response_for_dict(response)
message = QueueMessage()
message.pop_receipt = headers.get('x-ms-popreceipt')
message.time_next_visible = parser.parse(headers.get('... | Create a Python 3 function for
extracting pop receipt and time next visible from headers. | As a python code expert, you are capable of creating scripts from specifications. |
def _convert_xml_to_queue_messages(response, decode_function):
'''
<?xml version="1.0" encoding="utf-8"?>
<QueueMessagesList>
<QueueMessage>
<MessageId>string-message-id</MessageId>
<InsertionTime>insertion-time</InsertionTime>
<ExpirationTime>expiration-time</Expiratio... | Write a Python 3 script to
convert XML response to QueueMessagesList | You are a Python code analyst, evaluating scripts for potential improvements. |
def _drives_list(self):
"""Gets the list of drives
:return a list of drives.
"""
drives_list = []
for member in self.drives:
drives_list.append(sys_drives.Drive(
self._conn, member.get('@odata.id'), self.redfish_version))
return drives_list | Implement a function in Python 3 to
get the list of drives. | As a Python code composer, you craft elegant and concise scripts. |
def has_ssd(self):
"""Return true if any of the drive is ssd"""
for member in self._drives_list():
if member.media_type == constants.MEDIA_TYPE_SSD:
return True
return False | Create a Python 3 function to
return true if any of the drives is ssd | You are a Python code analyst, evaluating scripts for potential improvements. |
Return True if any of the drives is HDD. | Here you have a function in Python 3, explain what it does
def has_rotational(self):
for member in self._drives_list():
if member.media_type == constants.MEDIA_TYPE_HDD:
return True
return False | As a Python code composer, you craft elegant and concise scripts. |
def has_nvme_ssd(self):
"""Return True if the drive is SSD and protocol is NVMe"""
for member in self._drives_list():
if (member.media_type == constants.MEDIA_TYPE_SSD and
member.protocol == constants.PROTOCOL_NVMe):
return True
return False | Can you implement a function in Python 3 that
returns True if the drive is SSD and protocol is NVMe | As a Python code composer, you craft elegant and concise scripts. |
Gets the set of rotational speed of the disks | How would you explain what the following Python 3 function does
def drive_rotational_speed_rpm(self):
drv_rot_speed_rpm = set()
for member in self._drives_list():
if member.rotation_speed_rpm is not None:
drv_rot_speed_rpm.add(member.rotation_speed_rpm)
return drv_ro... | As a python code expert, you are capable of creating scripts from specifications. |
Gets the biggest logical drive node s maximum size in MiB. | Make a summary of the following Python 3 code
def volumes_maximum_size_bytes(self):
return utils.max_safe([member.volumes.maximum_size_bytes
for member in self.get_members()]) | You are a Python code analyst, evaluating scripts for potential improvements. |
Gets the set of rotational speed of the disks | Can you generate the documentation for the following Python 3 function
def drive_rotational_speed_rpm(self):
drv_rot_speed_rpm = set()
for member in self.get_members():
drv_rot_speed_rpm.update(member.drive_rotational_speed_rpm)
return drv_rot_speed_rpm | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates a TableService object with the settings specified in the
CloudStorageAccount. | Here you have a function in Python 3, explain what it does
def create_table_service(self):
'''
Creates a TableService object with the settings specified in the
CloudStorageAccount.
:return: A service object.
:rtype: :class:`~azure.storage.table.tableservice.TableService`
... | You are a Python code generator, capable of creating scripts from specifications. |
def get_queue_service_properties(self, timeout=None):
'''
Gets the properties of a storage account's Queue service, including
logging, analytics and CORS rules.
:param int timeout:
The server timeout, expressed in seconds.
:return: The queue service properties.
... | Create a Python 3 function to
retrieve the properties of a storage account s Queue service including Azure Storage Account s Queue service logging analytics and CORS rules. | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns a generator to list the queues in the specified prefix. | Given the following Python 3 function, write the documentation
def list_queues(self, prefix=None, num_results=None, include_metadata=False,
marker=None, timeout=None):
'''
Returns a generator to list the queues. The generator will lazily follow
the continuation tokens retur... | You are a Python code architect, reviewing and designing scalable and efficient code |
Returns a list of queues under the specified account. | Can you tell what is the following Python 3 function doing
def _list_queues(self, prefix=None, marker=None, max_results=None,
include=None, timeout=None):
'''
Returns a list of queues under the specified account. Makes a single list
request to the service. Used internally by... | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a queue under the given account. | Here you have a function in Python 3, explain what it does
def create_queue(self, queue_name, metadata=None, fail_on_exist=False, timeout=None):
'''
Creates a queue under the given account.
:param str queue_name:
The name of the queue to create. A queue name must be from 3 through
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Retrieves user - defined metadata and queue properties on the specified queue. | Can you generate a brief explanation for the following Python 3 code
def get_queue_metadata(self, queue_name, timeout=None):
'''
Retrieves user-defined metadata and queue properties on the specified
queue. Metadata is associated with the queue as name-value pairs.
:param str queue_name:... | As a python code expert, you are capable of creating scripts from specifications. |
Sets user - defined metadata on the specified queue. | Make a summary of the following Python 3 code
def set_queue_metadata(self, queue_name, metadata=None, timeout=None):
'''
Sets user-defined metadata on the specified queue. Metadata is
associated with the queue as name-value pairs.
:param str queue_name:
The name of an existi... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_queue_acl(self, queue_name, timeout=None):
'''
Returns details about any stored access policies specified on the
queue that may be used with Shared Access Signatures.
:param str queue_name:
The name of an existing queue.
:param int timeout:
The se... | Write a Python 3 script to
return details about any stored access policies associated with the specified queue. | As a Python code analyst, you investigate and solve complex coding mysteries |
Sets the permissions for a queue. | Can you tell what is the following Python 3 function doing
def set_queue_acl(self, queue_name, signed_identifiers=None, timeout=None):
'''
Sets stored access policies for the queue that may be used with Shared
Access Signatures.
When you set permissions for a queue, the existi... | As a python code expert, you are capable of creating scripts from specifications. |
Adds a new message into the back of the message queue. | How would you explain what the following Python 3 function does
def put_message(self, queue_name, content, visibility_timeout=None,
time_to_live=None, timeout=None):
'''
Adds a new message to the back of the message queue.
The visibility timeout specifies the time that the ... | As a Python code composer, you craft elegant and concise scripts. |
def get_messages(self, queue_name, num_messages=None,
visibility_timeout=None, timeout=None):
'''
Retrieves one or more messages from the front of the queue.
When a message is retrieved from the queue, the response includes the message
content and a pop_receipt val... | Can you create a Python 3 function that
retrieves one or more messages from the front of a queue. | You are a Python code architect, reviewing and designing scalable and efficient code |
Deletes all messages from the specified queue. | Can you tell what is the following Python 3 function doing
def clear_messages(self, queue_name, timeout=None):
'''
Deletes all messages from the specified queue.
:param str queue_name:
The name of the queue whose messages to clear.
:param int timeout:
The server ... | You are a Python code generator, capable of creating scripts from specifications. |
Updates the visibility timeout of a message. | Can you generate a brief explanation for the following Python 3 code
def update_message(self, queue_name, message_id, pop_receipt, visibility_timeout,
content=None, timeout=None):
'''
Updates the visibility timeout of a message. You can also use this
operation to update t... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def enable_secure_boot(self, secure_boot_enable):
"""Enable/Disable secure boot on the server.
Caller needs to reset the server after issuing this command
to bring this into effect.
:param secure_boot_enable: True, if secure boot needs to be
enabled for next boot, else Fa... | Implement a Python 3 function for
enabling or disable secure boot on the server. | As a python code expert, you are capable of creating scripts from specifications. |
Get the allowed values for resetting the system. | Can you generate a brief explanation for the following Python 3 code
def get_allowed_reset_keys_values(self):
reset_keys_action = self._get_reset_keys_action_element()
if not reset_keys_action.allowed_values:
LOG.warning('Could not figure out the allowed values for the '
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Resets the secure boot keys. | Here you have a function in Python 3, explain what it does
def reset_keys(self, target_value):
valid_keys_resets = self.get_allowed_reset_keys_values()
if target_value not in valid_keys_resets:
msg = ('The parameter "%(parameter)s" value "%(target_value)s" is '
'invalid. V... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _parse_properties(response, result_class):
'''
Extracts out resource properties and metadata information.
Ignores the standard http headers.
'''
if response is None or response.headers is None:
return None
props = result_class()
for key, value in response.headers:
info ... | Create a Python 3 function to
extract out resource properties and metadata information. | You are a Python code architect, reviewing and designing scalable and efficient code |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.