output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
Return a HPEAccountService object
How would you explain what the following Python 3 function does def get_account_service(self): account_service_url = utils.get_subresource_path_by(self, 'AccountService') return (account_service. HPEAccountService(self._conn, a...
As a Python code composer, you craft elegant and concise scripts.
def _execute_sum(sum_file_path, mount_point, components=None): """Executes the SUM based firmware update command. This method executes the SUM based firmware update command to update the components specified, if not, it performs update on all the firmware components on th server. :param sum_file_p...
Write a Python 3 function for executing the SUM based firmware update command.
You are a Python code architect, reviewing and designing scalable and efficient code
This method gets the log files created by SUM based firmware update and tar zip the files and BytesIO buffers.
Can you generate the documentation for the following Python 3 function def _get_log_file_data_as_encoded_content(): with io.BytesIO() as fp: with tarfile.open(fileobj=fp, mode='w:gz') as tar: for f in OUTPUT_FILES: if os.path.isfile(f): tar.add(f) fp....
You are a Python code analyst, evaluating scripts for potential improvements.
def _parse_sum_ouput(exit_code): """Parse the SUM output log file. This method parses through the SUM log file in the default location to return the SUM update status. Sample return string: "Summary: The installation of the component failed. Status of updated components: Total: 5 Success: 4 F...
How would you code a function in Python 3 to parse the SUM output log file. This method parses through the SUM log file in the default location to return the SUM update status. Sample return string: "Summary: The installation of the component failed. Status of updated components: Total: 5 Success: 4 Failed: 1" :param e...
You are a Python code architect, reviewing and designing scalable and efficient code
This method updates the SPP image of the ISO and the label file of the SPP ISO.
Can you tell what is the following Python 3 function doing def update_firmware(node): sum_update_iso = node['clean_step']['args'].get('url') # Validates the http image reference for SUM update ISO. try: utils.validate_href(sum_update_iso) except exception.ImageRefValidationFailed as e: ...
As a Python code composer, you craft elegant and concise scripts.
def parse(self, text): '''Return a string with markup tags converted to ansi-escape sequences.''' tags, results = [], [] text = self.re_tag.sub(lambda m: self.sub_tag(m, tags, results), text) if self.strict and tags: markup = "%s%s%s" % (self.tag_sep[0], tags.pop(0), self.t...
How would you implement a function in Python 3 that returns a string with markup tags converted to ansi - escape sequences.
As a Python code composer, you craft elegant and concise scripts.
Wrapper around builtins. print that runs parse on all arguments first.
Can you tell what is the following Python 3 function doing def ansiprint(self, *args, **kwargs): '''Wrapper around builtins.print() that runs parse() on all arguments first.''' args = (self.parse(str(i)) for i in args) builtins.print(*args, **kwargs)
As a Python code analyst, you investigate and solve complex coding mysteries
def strip(self, text): '''Return string with markup tags removed.''' tags, results = [], [] return self.re_tag.sub(lambda m: self.clear_tag(m, tags, results), text)
Can you implement a function in Python 3 that returns string with markup tags removed.
You are a Python code architect, reviewing and designing scalable and efficient code
def list_shares(self, prefix=None, marker=None, num_results=None, include_metadata=False, timeout=None): ''' Returns a generator to list the shares under the specified account. The generator will lazily follow the continuation tokens returned by the service and stop ...
Implement a function in Python 3 to return a generator to list the shares under the specified account.
As a Python code translator, you convert algorithms and pseudocode into Python.
Returns a generator to list the directories and files under the specified share.
Explain what the following Python 3 code does def list_directories_and_files(self, share_name, directory_name=None, num_results=None, marker=None, timeout=None, prefix=None): ''' Returns a generator to list the directories and files ...
As a Python code analyst, you investigate and solve complex coding mysteries
def _get_file(self, share_name, directory_name, file_name, start_range=None, end_range=None, validate_content=False, timeout=None, _context=None): ''' Downloads a file's content, metadata, and properties. You can specify a range if you don't need to download th...
Can you create a Python 3 function that downloads a file from the specified share and directory.
You are a Python code generator, capable of creating scripts from specifications.
Downloads a file to a file path.
Here you have a function in Python 3, explain what it does def get_file_to_path(self, share_name, directory_name, file_name, file_path, open_mode='wb', start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connect...
You are a Python code generator, capable of creating scripts from specifications.
Downloads a file from the server and writes it to the given stream.
Given the following Python 3 function, write the documentation def get_file_to_stream( self, share_name, directory_name, file_name, stream, start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None): ''' Downloads a file to ...
As a Python code composer, you craft elegant and concise scripts.
def get_file_to_bytes(self, share_name, directory_name, file_name, start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None): ''' Downloads a file as an array of bytes, with automatic chunking a...
Write a Python 3 script for downloading a file from the given share and returns an array of bytes.
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_file_to_text( self, share_name, directory_name, file_name, encoding='utf-8', start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None): ''' Downloads a file as unicode text, with automatic chunking and progress ...
Create a Python 3 function for downloading a file from the given share and returns it as unicode text.
You are a Python code architect, reviewing and designing scalable and efficient code
Processes the firmware image from the compact format and returns the core firmware file.
Can you tell what is the following Python 3 function doing def process_firmware_image(compact_firmware_file, ilo_object): fw_img_extractor = firmware_controller.get_fw_extractor( compact_firmware_file) LOG.debug('Extracting firmware file: %s ...', compact_firmware_file) raw_fw_file_path, is_extracte...
As a Python code translator, you convert algorithms and pseudocode into Python.
Create a hash object based on the given hashing algorithm.
Explain what the following Python 3 code does def _get_hash_object(hash_algo_name): algorithms = (hashlib.algorithms_guaranteed if six.PY3 else hashlib.algorithms) if hash_algo_name not in algorithms: msg = ("Unsupported/Invalid hash name '%s' provided." % hash_algo_name...
You are a Python code analyst, evaluating scripts for potential improvements.
Generate a hash for the contents of a file.
Can you generate the documentation for the following Python 3 function def hash_file(file_like_object, hash_algo='md5'): checksum = _get_hash_object(hash_algo) for chunk in iter(lambda: file_like_object.read(32768), b''): checksum.update(chunk) return checksum.hexdigest()
As a Python code analyst, you investigate and solve complex coding mysteries
Verifies checksum of image file against expected checksum.
Explain what the following Python 3 code does def verify_image_checksum(image_location, expected_checksum): try: with open(image_location, 'rb') as fd: actual_checksum = hash_file(fd) except IOError as e: raise exception.ImageRefValidationFailed(image_href=image_location, ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def validate_href(image_href): """Validate HTTP image reference. :param image_href: Image reference. :raises: exception.ImageRefValidationFailed if HEAD request failed or returned response code not equal to 200. :returns: Response to HEAD request. """ try: ...
How would you implement a function in Python 3 that validates HTTP image reference.
As a Python code analyst, you investigate and solve complex coding mysteries
Applies the filter to return the dict of filtered BIOS properties.
Can you tell what is the following Python 3 function doing def apply_bios_properties_filter(settings, filter_to_be_applied): if not settings or not filter_to_be_applied: return settings return {k: settings[k] for k in filter_to_be_applied if k in settings}
You are a Python code architect, reviewing and designing scalable and efficient code
Constructs an insert or replace entity request.
Can you generate a brief explanation for the following Python 3 code def _insert_or_replace_entity(entity, require_encryption=False, key_encryption_key=None, encryption_resolver=None): ''' Constructs an insert or replace entity request. ''' _validate_entity(entity, key_encr...
You are a Python code architect, reviewing and designing scalable and efficient code
Property to provide instance of HPEAccountCollection
Can you generate a brief explanation for the following Python 3 code def accounts(self): return account.HPEAccountCollection( self._conn, utils.get_subresource_path_by(self, 'Accounts'), redfish_version=self.redfish_version)
You are a Python code generator, capable of creating scripts from specifications.
def update_credentials(self, password): """Update credentials of a redfish system :param password: password to be updated """ data = { 'Password': password, } self._conn.patch(self.path, data=data)
Can you write a function in Python 3 where it updates the credentials of a redfish system
You are a Python code generator, capable of creating scripts from specifications.
def get_member_details(self, username): """Returns the HPEAccount object :param username: username of account :returns: HPEAccount object if criterion matches, None otherwise """ members = self.get_members() for member in members: if member.username == userna...
Can you create a Python 3 function that returns the HPEAccount object if criterion matches username
As a Python code analyst, you investigate and solve complex coding mysteries
Helper method to map the media types.
Can you tell what is the following Python 3 function doing def _get_media(media_types): get_mapped_media = (lambda x: maps.VIRTUAL_MEDIA_TYPES_MAP[x] if x in maps.VIRTUAL_MEDIA_TYPES_MAP else None) return list(map(get_mapped_media, media_types))
As a Python code composer, you craft elegant and concise scripts.
Helper method to return the action object.
Explain what the following Python 3 code does def _get_action_element(self, action_type): action = eval("self._hpe_actions." + action_type + "_vmedia") if not action: if action_type == "insert": action_path = '#HpeiLOVirtualMedia.InsertVirtualMedia' else: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def insert_media(self, url): """Inserts Virtual Media to the device :param url: URL to image. :raises: SushyError, on an error from iLO. """ try: super(VirtualMedia, self).insert_media(url, write_protected=True) except sushy_exceptions.SushyError: ...
Write a Python 3 function for inserting Virtual Media to the device.
You are a Python code generator, capable of creating scripts from specifications.
Ejects Virtual Media. :raises: SushyError, on an error from iLO.
Can you generate the documentation for the following Python 3 function def eject_media(self): try: super(VirtualMedia, self).eject_media() except sushy_exceptions.SushyError: target_uri = self._get_action_element('eject').target_uri self._conn.post(target_uri, data={}...
As a Python code analyst, you investigate and solve complex coding mysteries
Set the Virtual Media drive status.
Given the following Python 3 function, write the documentation def set_vm_status(self, boot_on_next_reset): data = { "Oem": { "Hpe": { "BootOnNextServerReset": boot_on_next_reset } } } self._conn.patch(self.p...
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_member_device(self, device): """Returns the given virtual media device object. :param device: virtual media device to be queried :returns virtual media device object. """ for vmedia_device in self.get_members(): if device in vmedia_device.media_types: ...
Implement a function in Python 3 to return the given virtual media device object.
As a Python code analyst, you investigate and solve complex coding mysteries
Constructs a get entity request.
How would you explain what the following Python 3 function does def _get_entity(partition_key, row_key, select, accept): ''' Constructs a get entity request. ''' _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('accept', accept) req...
You are a Python code generator, capable of creating scripts from specifications.
Constructs an insert entity request.
Can you generate a brief explanation for the following Python 3 code def _insert_entity(entity): ''' Constructs an insert entity request. ''' _validate_entity(entity) request = HTTPRequest() request.method = 'POST' request.headers = [_DEFAULT_CONTENT_TYPE_HEADER, _DE...
You are a Python code analyst, evaluating scripts for potential improvements.
def _merge_entity(entity, if_match): ''' Constructs a merge entity request. ''' _validate_not_none('if_match', if_match) _validate_entity(entity) request = HTTPRequest() request.method = 'MERGE' request.headers = [_DEFAULT_CONTENT_TYPE_HEADER, _DEFAULT_ACCEPT_HEA...
How would you code a function in Python 3 to construct a merge entity request.
You are a Python code architect, reviewing and designing scalable and efficient code
def _delete_entity(partition_key, row_key, if_match): ''' Constructs a delete entity request. ''' _validate_not_none('if_match', if_match) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) request = HTTPRequest() request.method = 'DELETE' requ...
Write a Python 3 function that can construct a delete entity request.
As a Python code translator, you convert algorithms and pseudocode into Python.
def _insert_or_replace_entity(entity): ''' Constructs an insert or replace entity request. ''' _validate_entity(entity) request = HTTPRequest() request.method = 'PUT' request.headers = [_DEFAULT_CONTENT_TYPE_HEADER, _DEFAULT_ACCEPT_HEADER] request.body = _get_req...
Can you create a Python 3 function that constructs an insert or replace entity request.
As a Python code analyst, you investigate and solve complex coding mysteries
def find_executable(executable_name): """Tries to find executable in PATH environment It uses ``shutil.which`` method in Python3 and ``distutils.spawn.find_executable`` method in Python2.7 to find the absolute path to the 'name' executable. :param executable_name: name of the executable :return...
Create a Python 3 function for trying to find the executable in PATH environment
As a Python code analyst, you investigate and solve complex coding mysteries
Decorator to check the firmware update component.
Make a summary of the following Python 3 code def check_firmware_update_component(func): @six.wraps(func) def wrapper(self, filename, component_type): """Wrapper around ``update_firmware`` call. :param filename: location of the raw firmware file. :param component_type: Type of component...
As a python code expert, you are capable of creating scripts from specifications.
def get_fw_extractor(fw_file): """Gets the firmware extractor object fine-tuned for specified type :param fw_file: compact firmware file to be extracted from :raises: InvalidInputError, for unsupported file types :returns: FirmwareImageExtractor object """ fw_img_extractor = FirmwareImageExtrac...
Implement a Python 3 function for returning the FirmwareImageExtractor object fine - tuned for the specified type of compact firmware file.
As a Python code analyst, you investigate and solve complex coding mysteries
Extracts the scexe file from the target file.
Can you generate the documentation for the following Python 3 function def _extract_scexe_file(self, target_file, extract_path): # Command to extract the smart component file. unpack_cmd = '--unpack=' + extract_path # os.path.isfile(target_file) cmd = [target_file, unpack_cmd] out, err = utils.trycm...
As a python code expert, you are capable of creating scripts from specifications.
Extracts the rpm file from the specified path.
Make a summary of the following Python 3 code def _extract_rpm_file(self, target_file, extract_path): if not os.path.exists(extract_path): os.makedirs(extract_path) os.chdir(extract_path) if find_executable('rpm2cpio') is None: raise exception.ImageExtractionFailed( image_ref=ta...
As a Python code composer, you craft elegant and concise scripts.
Gets the raw firmware file from the extracted directory structure
Make a summary of the following Python 3 code def _get_firmware_file(path): for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: file_name, file_ext = os.path.splitext(os.path.basename(filename)) if file_ext in RAW_FIRMWARE_EXTNS: # return fil...
As a Python code analyst, you investigate and solve complex coding mysteries
def _get_firmware_file_in_new_path(searching_path): """Gets the raw firmware file in a new path Gets the raw firmware file from the extracted directory structure and creates a hard link to that in a file path and cleans up the lookup extract path. :param searching_path: the directory structure to s...
Write a Python 3 function that can get the raw firmware file from the extracted directory structure creates a hard link to that file and cleans up the lookup extract path.
As a python code expert, you are capable of creating scripts from specifications.
Uploads the raw firmware file to iLO and returns the cookie so sent back to iLO.
How would you explain what the following Python 3 function does def upload_file_to(self, addressinfo, timeout): self.hostname, self.port = addressinfo self.timeout = timeout filename = self.fw_file firmware = open(filename, 'rb').read() # generate boundary boundary = b('...
As a Python code composer, you craft elegant and concise scripts.
Returns a ssl wrapped socket object for the current connection and SSLv1 protocol version.
Make a summary of the following Python 3 code def _get_socket(self, sslversion=ssl.PROTOCOL_TLSv1): err = None sock = None try: for res in socket.getaddrinfo( self.hostname, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = re...
You are a Python code generator, capable of creating scripts from specifications.
def extract(self): """Extracts the raw firmware file from its compact format Extracts the raw firmware file from its compact file format (already set as attribute in FirmwareImageControllerBase constructor). :raises: InvalidInputError, if raw firmware file not found :raises: Ima...
Create a Python 3 function to extract the raw firmware file from its compact format and returns the full path to the raw firmware file.
As a Python code analyst, you investigate and solve complex coding mysteries
def _generic_format(self, raid_config, controller=None): """Convert redfish data of current raid config to generic format. :param raid_config: Raid configuration dictionary :param controller: Array controller model in post_create read else None :returns: curre...
Can you implement a function in Python 3 that converts redfish data of current raid config to generic format.
As a Python code analyst, you investigate and solve complex coding mysteries
def _check_smart_storage_message(self): """Check for smart storage message. :returns: result, raid_message """ ssc_mesg = self.smart_storage_config_message result = True raid_message = "" for element in ssc_mesg: if "Success" not in element['MessageId...
Implement a function in Python 3 to check for smart storage message.
You are a Python code architect, reviewing and designing scalable and efficient code
Get the current RAID configuration from the system.
Can you generate a brief explanation for the following Python 3 code def read_raid(self, controller=None): if controller: if not self.logical_drives: msg = ('No logical drives found on the controller') LOG.debug(msg) raise exception.IloLogicalDriveNotF...
You are a Python code architect, reviewing and designing scalable and efficient code
Clears the RAID configuration from the system.
Here you have a function in Python 3, explain what it does def delete_raid(self): if not self.logical_drives: msg = ('No logical drives found on the controller ' '%(controller)s' % {'controller': str(self.controller_id)}) LOG.debug(msg) raise exception.IloL...
As a Python code composer, you craft elegant and concise scripts.
def create_raid(self, raid_config): """Create the raid configuration on the hardware. :param raid_config: A dictionary containing target raid configuration data. This data stucture should be as follows: raid_config = {'logical_disks': [{'raid_leve...
Can you create a Python 3 function that creates the raid configuration on the hardware.
As a python code expert, you are capable of creating scripts from specifications.
Private method that reads in the data file and organizes it into a list of tuples.
Can you tell what is the following Python 3 function doing def _readFile(self, fname, sldir): ''' Private method that reads in the data file and organizes it within this object. ''' if sldir.endswith('/'): fname = str(sldir)+str(fname) else: fname...
You are a Python code generator, capable of creating scripts from specifications.
get one data column with the data
Can you generate a brief explanation for the following Python 3 code def get(self, col_str): ''' get one data column with the data Parameters ---------- col_str : string One of the column strings in self.cols. ''' data_column=zeros(self.ilines) ...
As a Python code composer, you craft elegant and concise scripts.
This function will plot two columns against each other.
Given the following Python 3 function, write the documentation def plot_xtime(self, y, x='time', label='default', labelx=None, labely=None ,title=None, shape='.', logx=False, logy=True, base=10): ''' make a simple plot of two columns against each other. An ...
You are a Python code analyst, evaluating scripts for potential improvements.
This method returns the column of data for the associated column.
How would you explain what the following Python 3 function does def getColData(self, attri, fname, numtype='cycNum'): fname=self.findFile(fname,numtype) f=open(fname,'r') for i in range(self.index+1): f.readline() lines=f.readlines() for i in range(len(lines)): ...
You are a Python code analyst, evaluating scripts for potential improvements.
This method gets the element name of a particular attribute from a file. This method will return a list of the four element attributes number Z and Arac.
Explain what the following Python 3 code does def getElement(self, attri, fname, numtype='cycNum'): ''' In this method instead of getting a particular column of data, the program gets a particular row of data for a particular element name. attri : string The name of ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Private method for getting a cycle.
Here you have a function in Python 3, explain what it does def _getcycle(self, cycle, decayed=False): ''' Private method for getting a cycle, called from get.''' yps=self.get('ABUNDANCE_MF', cycle) z=self.get('Z', cycle) #charge a=self.get('A', cycle) #mass isomers=self.get('ISOM...
As a Python code translator, you convert algorithms and pseudocode into Python.
Private method that reads in and organizes the. DAT file fname and returns a list of dictionaries where the keys are column names and the values are column names and the index is the index of the column.
Can you generate a brief explanation for the following Python 3 code def _readFile(self, fname, sldir): ''' private method that reads in and organizes the .DAT file Loads the data of the .DAT File into the variables cattrs and cols. In both these cases they are dictionaries, but in the c...
As a Python code translator, you convert algorithms and pseudocode into Python.
Function that finds the associated file for fname when Fname is not in the table.
Can you generate the documentation for the following Python 3 function def findFile(self, fname, numtype): numType=numtype.upper() if numType == 'FILE': #do nothing return fname elif numType == 'CYCNUM': try: fname = int(fname) ...
As a Python code analyst, you investigate and solve complex coding mysteries
def _retry(self, context, backoff): ''' A function which determines whether and how to retry. :param ~azure.storage.models.RetryContext context: The retry context. This contains the request, response, and other data which can be used to determine whether or not to retr...
Write a Python 3 script for attempting to retry the given data in the given context.
As a Python code composer, you craft elegant and concise scripts.
def _convert_xml_to_service_stats(response): ''' <?xml version="1.0" encoding="utf-8"?> <StorageServiceStats> <GeoReplication> <Status>live|bootstrap|unavailable</Status> <LastSyncTime>sync-time|<empty></LastSyncTime> </GeoReplication> </StorageServiceStats> '''...
Write a Python 3 function for converting the response body of a storage service to a ServiceStats object.
As a Python code composer, you craft elegant and concise scripts.
def _get_firmware_update_element(self): """Get the url for firmware update :returns: firmware update url :raises: Missing resource error on missing url """ fw_update_action = self._actions.update_firmware if not fw_update_action: raise (sushy.exceptions. ...
Implement a Python 3 function for getting the url for firmware update
As a python code expert, you are capable of creating scripts from specifications.
def flash_firmware(self, redfish_inst, file_url): """Perform firmware flashing on a redfish system :param file_url: url to firmware bits. :param redfish_inst: redfish instance :raises: IloError, on an error from iLO. """ action_data = { 'ImageURI': file_url,...
Can you write a function in Python 3 where it performs firmware flashing on a redfish system.
As a Python code translator, you convert algorithms and pseudocode into Python.
This function polls for iLO firmware update to complete.
Can you generate a brief explanation for the following Python 3 code def wait_for_redfish_firmware_update_to_complete(self, redfish_object): p_state = ['Idle'] c_state = ['Idle'] def has_firmware_flash_completed(): """Checks for completion status of firmware update operation ...
You are a Python code generator, capable of creating scripts from specifications.
Get the progress of the firmware update.
Can you generate a brief explanation for the following Python 3 code def get_firmware_update_progress(self): # perform refresh try: self.refresh() except sushy.exceptions.SushyError as e: msg = (('Progress of firmware update not known. ' 'Error %(error...
You are a Python code analyst, evaluating scripts for potential improvements.
Property to provide reference to bios boot instance
Here you have a function in Python 3, explain what it does def boot_settings(self): return BIOSBootSettings( self._conn, utils.get_subresource_path_by( self, ["Oem", "Hpe", "Links", "Boot"]), redfish_version=self.redfish_version)
You are a Python code architect, reviewing and designing scalable and efficient code
Property to provide reference to bios iscsi resource instance
How would you explain what the following Python 3 function does def iscsi_resource(self): return iscsi.ISCSIResource( self._conn, utils.get_subresource_path_by( self, ["Oem", "Hpe", "Links", "iScsi"]), redfish_version=self.redfish_version)
As a Python code translator, you convert algorithms and pseudocode into Python.
Property to provide reference to bios mappings instance
Here you have a function in Python 3, explain what it does def bios_mappings(self): return BIOSMappings( self._conn, utils.get_subresource_path_by( self, ["Oem", "Hpe", "Links", "Mappings"]), redfish_version=self.redfish_version)
As a Python code analyst, you investigate and solve complex coding mysteries
Method that returns object of bios base configs.
Can you tell what is the following Python 3 function doing def _get_base_configs(self): return BIOSBaseConfigs( self._conn, utils.get_subresource_path_by( self, ["Oem", "Hpe", "Links", "BaseConfigs"]), redfish_version=self.redfish_version)
As a Python code translator, you convert algorithms and pseudocode into Python.
Sets the boot mode of the system for next boot.
Given the following Python 3 function, write the documentation def set_pending_boot_mode(self, boot_mode): bios_properties = { 'BootMode': mappings.GET_BIOS_BOOT_MODE_MAP_REV.get(boot_mode) } if boot_mode == sys_cons.BIOS_BOOT_MODE_UEFI: bios_properties['UefiOptimizedBoo...
As a Python code translator, you convert algorithms and pseudocode into Python.
def update_bios_data_by_post(self, data): """Update bios data by post :param data: default bios config data """ bios_settings_data = { 'Attributes': data } self._conn.post(self.path, data=bios_settings_data)
Can you create a Python 3 function that updates bios data by post
As a Python code analyst, you investigate and solve complex coding mysteries
def update_bios_data_by_patch(self, data): """Update bios data by patch :param data: default bios config data """ bios_settings_data = { 'Attributes': data } self._conn.patch(self.path, data=bios_settings_data)
Can you implement a function in Python 3 that updates bios data by patch
You are a Python code generator, capable of creating scripts from specifications.
def get_persistent_boot_device(self): """Get current persistent boot device set for the host :returns: persistent boot device for the system :raises: IloError, on an error from iLO. """ boot_string = None if not self.persistent_boot_config_order or not self.boot_sources:...
Create a Python 3 function to get the persistent boot device for the host.
As a python code expert, you are capable of creating scripts from specifications.
Get uefi boot string for the host and system.
Make a summary of the following Python 3 code def get_uefi_boot_string(self, mac): boot_sources = self.boot_sources if not boot_sources: msg = ('Boot sources are not found') LOG.debug(msg) raise exception.IloError(msg) for boot_source in boot_sources: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def visc_mol_sol(T,rho,X): ''' Molecular plasma viscosity (Spitzer 1962) Parameters ---------- X : float H mass fraction T : float temperature in K rho : float density in cgs Returns ------- nu : float molecular diffusivity in [cm**2/s] Note...
Write a Python 3 function that can return the viscosity of a single Molecular plasma.
You are a Python code analyst, evaluating scripts for potential improvements.
Radiative viscosity for electron scattering opacity in Schatzman 1930
Explain what the following Python 3 code does def visc_rad_kap_sc(T,rho,X): ''' Radiative viscosity (Thomas, 1930) for e- scattering opacity Parameters ---------- X : float H mass fraction T : float temperature in K rho : float density in cgs Returns ------- ...
As a Python code composer, you craft elegant and concise scripts.
Returns the Gamma1 for a mix of ideal gas and radiation.
Can you tell what is the following Python 3 function doing def Gamma1_gasrad(beta): ''' Gamma1 for a mix of ideal gas and radiation Hansen & Kawaler, page 177, Eqn. 3.110 Parameters ---------- beta : float Gas pressure fraction Pgas/(Pgas+Prad) ''' Gamma3minus1 = (old_div...
As a Python code composer, you craft elegant and concise scripts.
def Pgas(rho,T,mu): ''' P = R/mu * rho * T Parameters ---------- mu : float Mean molecular weight rho : float Density [cgs] T : float Temperature [K] ''' R = old_div(boltzmann_constant, atomic_mass_unit) return (old_div(R,mu)) * rho * T
Can you write a function in Python 3 where it returns the Pas of a base - class resource with the given mean molecular weight rho T and mu.
As a python code expert, you are capable of creating scripts from specifications.
Curvature MiMf from Ferrario etal. 2005MNRAS. 361. 1131.
Make a summary of the following Python 3 code def mimf_ferrario(mi): ''' Curvature MiMf from Ferrario etal. 2005MNRAS.361.1131.''' mf=-0.00012336*mi**6+0.003160*mi**5-0.02960*mi**4+\ 0.12350*mi**3-0.21550*mi**2+0.19022*mi+0.46575 return mf
As a Python code analyst, you investigate and solve complex coding mysteries
Returns N M according to Kroupa IMF
Can you generate the documentation for the following Python 3 function def imf(m): ''' Returns ------- N(M)dM for given mass according to Kroupa IMF, vectorization available via vimf() ''' m1 = 0.08; m2 = 0.50 a1 = 0.30; a2 = 1.30; a3 = 2.3 const2 = m1**-a1 -m1**-a2 ...
You are a Python code analyst, evaluating scripts for potential improvements.
Integrate IMF between m1 and m2.
Here you have a function in Python 3, explain what it does def int_imf_dm(m1,m2,m,imf,bywhat='bymass',integral='normal'): ''' Integrate IMF between m1 and m2. Parameters ---------- m1 : float Min mass m2 : float Max mass m : float Mass array imf : float ...
You are a Python code architect, reviewing and designing scalable and efficient code
def am_orb(m1,m2,a,e): ''' orbital angular momentum. e.g Ge etal2010 Parameters ---------- m1, m2 : float Masses of both stars in Msun. A : float Separation in Rsun. e : float Eccentricity ''' a_cm = a * rsun_cm m1_g = m1 * msun_g ...
Implement a function in Python 3 to calculate the orbital angular momentum for two sets of species A and A and e. g Ge etal2010
As a Python code composer, you craft elegant and concise scripts.
Returns the mass loss rate in Msun for a given log L and temperature.
How would you explain what the following Python 3 function does def mass_loss_loon05(L,Teff): ''' mass loss rate van Loon etal (2005). Parameters ---------- L : float L in L_sun. Teff : float Teff in K. Returns ------- Mdot Mdot in Msun/yr ...
You are a Python code analyst, evaluating scripts for potential improvements.
Calculates the Energ orbit of a set of species in the system.
How would you explain what the following Python 3 function does def energ_orb(m1,m2,r): ''' Parameters ---------- m1, m2 : float M in Msun. r : float Distance in Rsun. Returns ------- Epot Epot in erg. ''' epo = -grav_const * m1 * m2 * m...
As a Python code composer, you craft elegant and concise scripts.
def period(A,M1,M2): """ calculate binary period from separation. Parameters ---------- A : float separation A Rsun. M1, M2 : float M in Msun. Returns ------- p period in days. """ A *= rsun_cm print(A) velocity = np.sqrt(grav_const*msun_...
Can you create a Python 3 function that calculates the binary period from a separation A M1 and M2.
As a Python code composer, you craft elegant and concise scripts.
def escape_velocity(M,R): """ escape velocity. Parameters ---------- M : float Mass in solar masses. R : float Radius in solar radiu. Returns ------- v_escape in km/s. """ ve = np.sqrt(2.*grav_const*M*msun_g/(R*rsun_cm)) ve = ve*1....
Can you implement a function in Python 3 that returns the escape velocity of a single object in the solar masses and solar radiu.
You are a Python code generator, capable of creating scripts from specifications.
def Nasv(macs,T): ''' Returns ------- Na*<sigma v> for MACS [mb] at T [K]. ''' Na = avogadro_constant k = boltzmann_constant vtherm=(2.*k*T/mass_H_atom)**0.5 s = macs*1.e-27 Nasv = s*vtherm*Na return Nasv
Can you create a Python 3 function that returns the total number of masses in a single node
As a Python code analyst, you investigate and solve complex coding mysteries
def macs(nasv,T): ''' Returns ------- MACS [mb] at T [K] from Na*<sigma v>. ''' Na = avogadro_constant k = boltzmann_constant vtherm=(2.*k*T/mass_H_atom)**0.5 s = old_div(nasv,(vtherm*Na)) macs = s*1.e27 return macs
Can you implement a function in Python 3 that returns the MACS of a single site at a given mass at a given time.
You are a Python code analyst, evaluating scripts for potential improvements.
def mu_e(X): ''' mean molecular weight per free electron, assuming full ionisation, and approximating mu_i/Z_i ~ 2 for all elements heavier then Helium. (Kippenhahn & Weigert, Ch 13.1, Eq. 13.8) Parameters ---------- X : float Mass fraction of H. ''' try: ...
Write a Python 3 function for returning the mean molecular weight per free electron assuming full ionisation and mu_i approximating mu_i / Z_i ~ 2 for all elements heavier then Helium.
You are a Python code architect, reviewing and designing scalable and efficient code
returns the mean molecular weight assuming full ionisation.
Can you generate the documentation for the following Python 3 function def mu(X,Z,A): ''' mean molecular weight assuming full ionisation. (Kippenhahn & Weigert, Ch 13.1, Eq. 13.6) Parameters ---------- X : float Mass fraction vector. Z : float Charge number vector. ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Returns T that separates ideal gas and degenerate pressure dominated regions.
Can you tell what is the following Python 3 function doing def Trho_iddeg(rho,mu,mu_e): ''' T(rho) that separates ideal gas and degenerate pressure dominated regions. Kippenhahn & Weigert, Eq. 16.6 Parameters ---------- rho : float Density array [cgs]. mu : float Mean mole...
You are a Python code analyst, evaluating scripts for potential improvements.
This method finds the physical drives matching the criteria of the logical disk.
Can you generate a brief explanation for the following Python 3 code def _get_criteria_matching_disks(logical_disk, physical_drives): matching_physical_drives = [] criteria_to_consider = [x for x in FILTER_CRITERIA if x in logical_disk] for physical_drive_object in physical_driv...
As a Python code translator, you convert algorithms and pseudocode into Python.
Allocate physical disks to a logical disk.
Can you generate the documentation for the following Python 3 function def allocate_disks(logical_disk, server, raid_config): size_gb = logical_disk['size_gb'] raid_level = logical_disk['raid_level'] number_of_physical_disks = logical_disk.get( 'number_of_physical_disks', constants.RAID_LEVEL_MIN_DI...
You are a Python code generator, capable of creating scripts from specifications.
setup trajectories for constant radiation entropy.
Can you generate a brief explanation for the following Python 3 code def trajectory_SgConst(Sg=0.1, delta_logt_dex=-0.01): ''' setup trajectories for constant radiation entropy. S_gamma/R where the radiation constant R = N_A*k (Dave Arnett, Supernova book, p. 212) This relates rho and T but the tim...
As a Python code composer, you craft elegant and concise scripts.
def species_list(what_list): ''' provide default lists of elements to plot. what_list : string String name of species lists provided. If what_list is "CNONe", then C, N, O and some other light elements. If what_list is "s-process", then s-process indicators. ''' i...
Can you write a function in Python 3 where it returns a list of lists of elements to plot.
You are a Python code analyst, evaluating scripts for potential improvements.
This function returns a string and the number of lines that are plotted in a specific style.
Make a summary of the following Python 3 code def linestyle(i,a=5,b=3): ''' provide one out of 25 unique combinations of style, color and mark use in combination with markevery=a+mod(i,b) to add spaced points, here a would be the base spacing that would depend on the data density, modulated with th...
You are a Python code analyst, evaluating scripts for potential improvements.
colour blinding for a single item in the base image
Can you generate a brief explanation for the following Python 3 code def colourblind(i): ''' colour pallete from http://tableaufriction.blogspot.ro/ allegedly suitable for colour-blind folk SJ ''' rawRGBs = [(162,200,236), (255,128,14), (171,171,171), ...
As a Python code composer, you craft elegant and concise scripts.
def colourblind2(i): ''' another colour pallete from http://www.sron.nl/~pault/ allegedly suitable for colour-blind folk SJ ''' hexcols = ['#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#CC6677', '#882255', '#AA4499'] idx = sc.mod(i,len(hexcol...
Can you write a function in Python 3 where it gets another colour pallete from http://www. sron. nl/~pault / allegedly suitable for colour - blend folk SJ
As a Python code translator, you convert algorithms and pseudocode into Python.
version of linestyle function with colourblind colour scheme
Make a summary of the following Python 3 code def linestylecb(i,a=5,b=3): ''' version of linestyle function with colourblind colour scheme returns linetyle, marker, color (see example) Parameters ---------- i : integer Number of linestyle combination - there are man...
As a python code expert, you are capable of creating scripts from specifications.
def symbol_list(what_list): ''' provide default symbol lists Parameters ---------- what_list : string String name of symbol lists provided; "list1", "list2", "lines1" or "lines2". ''' if what_list is "list1": symbol=['ro','bo','ko','go','mo'\ ,'r-','...
Can you create a Python 3 function that returns a list of all possible symbol lists for the current language
You are a Python code analyst, evaluating scripts for potential improvements.