output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def load_axes(d): """Create an axes or subplot from what is returned by :meth:`inspect_axes`""" import matplotlib.pyplot as plt fig = plt.figure(d.pop('fig', None)) proj = d.pop('projection', None) spines = d.pop('spines', None) invert_yaxis = d.pop('yaxis_inverte...
Write a Python 3 script for creating an axes or subplot from what is returned by inspect_axes
As a Python code translator, you convert algorithms and pseudocode into Python.
def show_plot_methods(self): """Print the plotmethods of this instance""" print_func = PlotterInterface._print_func if print_func is None: print_func = six.print_ s = "\n".join( "%s\n %s" % t for t in six.iteritems(self._plot_methods)) return print_func...
Write a Python 3 script for printing the plotmethods of this instance
As a Python code translator, you convert algorithms and pseudocode into Python.
def _register_plotter(cls, identifier, module, plotter_name, plotter_cls=None, summary='', prefer_list=False, default_slice=None, default_dims={}, show_examples=True, example_call="filename, name=['my_variable'], ......
Write a Python 3 script to register a plotter for making plots for the given object.
You are a Python code generator, capable of creating scripts from specifications.
def _gen_doc(cls, summary, full_name, identifier, example_call, doc_str, show_examples): """Generate the documentation docstring for a PlotMethod""" ret = docstrings.dedents(""" %s This plotting method adds data arrays and plots them via :class:`%s` ...
Write a Python 3 script for generating the documentation docstring for a PlotMethod
As a python code expert, you are capable of creating scripts from specifications.
A validation method for the data shape of the object.
Explain what the following Python 3 code does def check_data(self, ds, name, dims): if isinstance(name, six.string_types): name = [name] dims = [dims] else: dims = list(dims) variables = [ds[safe_list(n)[0]] for n in name] decoders = [CFDecoder.get_dec...
You are a Python code analyst, evaluating scripts for potential improvements.
def _add_data(self, plotter_cls, *args, **kwargs): """ Add new plots to the project Parameters ---------- %(ProjectPlotter._add_data.parameters.no_filename_or_obj)s Other Parameters ---------------- %(ProjectPlotter._add_data.other_parameters)s ...
Implement a function in Python 3 to add new plots to the project holding the current data and the current time_of_work_on_data_set.
As a python code expert, you are capable of creating scripts from specifications.
Generate the documentation docstring for a PlotMethod
Explain what the following Python 3 code does def _gen_doc(cls, summary, full_name, identifier, example_call, doc_str, show_examples): """Generate the documentation docstring for a PlotMethod""" # leave out the first argument example_call = ', '.join(map(str.strip, example_call....
As a Python code composer, you craft elegant and concise scripts.
Check whether the plotter of this plot method can visualize the data.
How would you explain what the following Python 3 function does def check_data(self, *args, **kwargs): plotter_cls = self.plotter_cls da_list = self._project_plotter._da.psy.to_interactive_list() return plotter_cls.check_data( da_list.all_names, da_list.all_dims, da_list.is_unstructu...
You are a Python code generator, capable of creating scripts from specifications.
Add the data array to the plotter.
Make a summary of the following Python 3 code def _add_data(self, plotter_cls, *args, **kwargs): # this method is just a shortcut to the :meth:`Project._add_data` # method but is reimplemented by subclasses as the # :class:`DatasetPlotter` or the :class:`DataArrayPlotter` return plotter_...
As a Python code composer, you craft elegant and concise scripts.
Collect Parameter stanzas from inline + file.
Can you tell what is the following Python 3 function doing def yaml_from_file(self, fpath): lookup = self._load_param_file(fpath) if not lookup: return content = "\n".join(self.content) parsed = yaml.safe_load(content) # self.app.info("Params loaded is %s" % parsed)...
As a Python code composer, you craft elegant and concise scripts.
def get_libsodium(): '''Locate the libsodium C library''' __SONAMES = (13, 10, 5, 4) # Import libsodium from system sys_sodium = ctypes.util.find_library('sodium') if sys_sodium is None: sys_sodium = ctypes.util.find_library('libsodium') if sys_sodium: try: return c...
Create a Python 3 function to locate the libsodium C library
You are a Python code architect, reviewing and designing scalable and efficient code
def make_plot(fnames=[], name=[], dims=None, plot_method=None, output=None, project=None, engine=None, formatoptions=None, tight=False, rc_file=None, encoding=None, enable_post=False, seaborn_style=None, output_project=None, concat_dim=get_default_value(xr.open_mf...
Can you implement a function in Python 3 that creates a new plot of the specified data.
As a Python code composer, you craft elegant and concise scripts.
def get_parser(create=True): """Return a parser to make that can be used to make plots or open files from the command line Returns ------- psyplot.parser.FuncArgParser The :class:`argparse.ArgumentParser` instance""" #: The parse that is used to parse arguments from the command line ...
Write a Python 3 script to return a parser to make that can be used to make plots or open files from the command line.
As a Python code composer, you craft elegant and concise scripts.
This function returns a key derived using the scrypt key - derivarion function.
Can you generate a brief explanation for the following Python 3 code def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64): check_args(password, salt, N, r, p, olen) if _scrypt_ll: out = ctypes.create_string_buffer(olen) if _scrypt_ll(password, len(password), salt, len(salt), ...
As a Python code composer, you craft elegant and concise scripts.
Derives a Modular Crypt Format hash using the scrypt algorithm.
Here you have a function in Python 3, explain what it does def scrypt_mcf(password, salt=None, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, prefix=SCRYPT_MCF_PREFIX_DEFAULT): """Derives a Modular Crypt Format hash using the scrypt KDF Parameter space is smaller than for scrypt(): N must be a power of...
You are a Python code analyst, evaluating scripts for potential improvements.
def scrypt_mcf_check(mcf, password): """Returns True if the password matches the given MCF hash""" if isinstance(password, unicode): password = password.encode('utf8') elif not isinstance(password, bytes): raise TypeError('password must be a unicode or byte string') if not isinstance(mcf...
How would you implement a function in Python 3 that returns True if the password matches the given MCF hash
As a Python code analyst, you investigate and solve complex coding mysteries
def _temp_bool_prop(propname, doc="", default=False): """Creates a property that uses the :class:`_TempBool` class Parameters ---------- propname: str The attribute name to use. The _TempBool instance will be stored in the ``'_' + propname`` attribute of the corresponding instance d...
Write a Python 3 script for creating a property that uses the _TempBool class.
You are a Python code generator, capable of creating scripts from specifications.
def check_key(key, possible_keys, raise_error=True, name='formatoption keyword', msg=("See show_fmtkeys function for possible formatopion " "keywords"), *args, **kwargs): """ Checks whether the key is in a list of possible keys This function chec...
Can you implement a function in Python 3 that checks whether a key is in a list of possible formatoptions and returns a list of similar sounding keys.
As a Python code analyst, you investigate and solve complex coding mysteries
def sort_kwargs(kwargs, *param_lists): """Function to sort keyword arguments and sort them into dictionaries This function returns dictionaries that contain the keyword arguments from `kwargs` corresponding given iterables in ``*params`` Parameters ---------- kwargs: dict Original dict...
How would you code a function in Python 3 to function to sort keyword arguments and sort them into dictionaries
You are a Python code analyst, evaluating scripts for potential improvements.
Test if val is hashable and if not get it s string representation
Can you generate a brief explanation for the following Python 3 code def hashable(val): if val is None: return val try: hash(val) except TypeError: return repr(val) else: return val
As a Python code composer, you craft elegant and concise scripts.
Join multiple dictionaries into one node - level dictionary.
Can you generate the documentation for the following Python 3 function def join_dicts(dicts, delimiter=None, keep_all=False): if not dicts: return {} if keep_all: all_keys = set(chain(*(d.keys() for d in dicts))) else: all_keys = set(dicts[0]) for d in dicts[1:]: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Decorator to check guest exist in database.
Can you tell what is the following Python 3 function doing def check_guest_exist(check_index=0): def outer(f): @six.wraps(f) def inner(self, *args, **kw): userids = args[check_index] if isinstance(userids, list): # convert all userids to upper case ...
You are a Python code generator, capable of creating scripts from specifications.
Power on a virtual machine.
Here you have a function in Python 3, explain what it does def guest_start(self, userid): action = "start guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_start(userid)
You are a Python code generator, capable of creating scripts from specifications.
Power off a virtual machine.
How would you explain what the following Python 3 function does def guest_stop(self, userid, **kwargs): action = "stop guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_stop(userid, **kwargs)
As a Python code analyst, you investigate and solve complex coding mysteries
Issue a soft stop command to shutdown the OS in a virtual machine and then log the guest off z/VM..
Here you have a function in Python 3, explain what it does def guest_softstop(self, userid, **kwargs): action = "soft stop guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_softstop(userid, **kwargs)
You are a Python code architect, reviewing and designing scalable and efficient code
reset a virtual machine
Can you tell what is the following Python 3 function doing def guest_reset(self, userid): action = "reset guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_reset(userid)
You are a Python code architect, reviewing and designing scalable and efficient code
def guest_pause(self, userid): """Pause a virtual machine. :param str userid: the id of the virtual machine to be paused :returns: None """ action = "pause guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_pause(useri...
How would you code a function in Python 3 to pause a virtual machine.
You are a Python code analyst, evaluating scripts for potential improvements.
Unpause a virtual machine.
Can you generate the documentation for the following Python 3 function def guest_unpause(self, userid): action = "unpause guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.guest_unpause(userid)
You are a Python code generator, capable of creating scripts from specifications.
def guest_get_power_state(self, userid): """Returns power state.""" action = "get power state of guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): return self._vmops.get_power_state(userid)
Write a Python 3 script to return the power state of the guest.
You are a Python code analyst, evaluating scripts for potential improvements.
Get the status of a virtual machine.
How would you explain what the following Python 3 function does def guest_get_info(self, userid): action = "get info of guest '%s'" % userid with zvmutils.log_and_reraise_sdkbase_error(action): return self._vmops.get_info(userid)
You are a Python code architect, reviewing and designing scalable and efficient code
def host_diskpool_get_info(self, disk_pool=None): """ Retrieve diskpool information. :param str disk_pool: the disk pool info. It use ':' to separate disk pool type and pool name, eg "ECKD:eckdpool" or "FBA:fbapool" :returns: Dictionary describing disk pool usage info """ ...
Write a Python 3 script for retrieving disk pool usage information.
As a Python code analyst, you investigate and solve complex coding mysteries
Delete image from image repository
Given the following Python 3 function, write the documentation def image_delete(self, image_name): try: self._imageops.image_delete(image_name) except exception.SDKBaseException: LOG.error("Failed to delete image '%s'" % image_name) raise
You are a Python code analyst, evaluating scripts for potential improvements.
def image_get_root_disk_size(self, image_name): """Get the root disk size of the image :param image_name: the image name in image Repository :returns: the disk size in units CYL or BLK """ try: return self._imageops.image_get_root_disk_size(image_name) except...
How would you implement a function in Python 3 that gets the root disk size of the image
You are a Python code generator, capable of creating scripts from specifications.
Import image to zvmsdk image repository - set the local_host to be used to identify the image
Explain what the following Python 3 code does def image_import(self, image_name, url, image_meta, remote_host=None): try: self._imageops.image_import(image_name, url, image_meta, remote_host=remote_host) except exception.SDKBaseException: L...
You are a Python code generator, capable of creating scripts from specifications.
Query the list of image info in image repository
Explain what the following Python 3 code does def image_query(self, imagename=None): try: return self._imageops.image_query(imagename) except exception.SDKBaseException: LOG.error("Failed to query image") raise
As a python code expert, you are capable of creating scripts from specifications.
Export the image to the specified location
Can you generate a brief explanation for the following Python 3 code def image_export(self, image_name, dest_url, remote_host=None): try: return self._imageops.image_export(image_name, dest_url, remote_host) except exception.SDKBaseException: ...
As a python code expert, you are capable of creating scripts from specifications.
Deploy the image to vm.
Here you have a function in Python 3, explain what it does def guest_deploy(self, userid, image_name, transportfiles=None, remotehost=None, vdev=None, hostname=None): """ Deploy the image to vm. :param userid: (str) the user id of the vm :param image_name: (str) the name of...
As a Python code analyst, you investigate and solve complex coding mysteries
Capture the guest to generate a image
Can you tell what is the following Python 3 function doing def guest_capture(self, userid, image_name, capture_type='rootonly', compress_level=6): """ Capture the guest to generate a image :param userid: (str) the user id of the vm :param image_name: (str) the unique image...
As a Python code composer, you craft elegant and concise scripts.
Create the nic for the guest.
Given the following Python 3 function, write the documentation def guest_create_nic(self, userid, vdev=None, nic_id=None, mac_addr=None, active=False): """ Create the nic for the vm, add NICDEF record into the user direct. :param str userid: the user id of the vm :param...
As a Python code translator, you convert algorithms and pseudocode into Python.
delete the nic for the guest
How would you explain what the following Python 3 function does def guest_delete_nic(self, userid, vdev, active=False): self._networkops.delete_nic(userid, vdev, active=active)
You are a Python code analyst, evaluating scripts for potential improvements.
def guest_get_definition_info(self, userid, **kwargs): """Get definition info for the specified guest vm, also could be used to check specific info. :param str userid: the user id of the guest vm :param dict kwargs: Dictionary used to check specific info in user ...
How would you code a function in Python 3 to get the definition info for the specified guest vm.
As a Python code composer, you craft elegant and concise scripts.
def guest_live_migrate(self, userid, dest_zcc_userid, destination, parms, lgr_action): """Move an eligible, running z/VM(R) virtual machine transparently from one z/VM system to another within an SSI cluster. :param userid: (str) the userid of the vm to be relocated o...
Write a Python 3 script to move an eligible running z/VM to another z/VM system and test for vm.
As a Python code translator, you convert algorithms and pseudocode into Python.
def guest_create(self, userid, vcpus, memory, disk_list=None, user_profile=CONF.zvm.user_profile, max_cpu=CONF.zvm.user_default_max_cpu, max_mem=CONF.zvm.user_default_max_memory, ipl_from='', ipl_param='', ipl_loadparam=''): """...
Write a Python 3 function that can create a new virtual machine in zvm.
You are a Python code generator, capable of creating scripts from specifications.
Live resize virtual cpus of guests.
Given the following Python 3 function, write the documentation def guest_live_resize_cpus(self, userid, cpu_cnt): action = "live resize guest '%s' to have '%i' virtual cpus" % (userid, cpu_cnt) LOG.info("Begin to %s" % action) ...
You are a Python code analyst, evaluating scripts for potential improvements.
def guest_live_resize_mem(self, userid, size): """Live resize memory of guests. :param userid: (str) the userid of the guest to be live resized :param size: (str) The memory size that the guest should have in available status after live resize. The value should be ...
How would you code a function in Python 3 to live resize memory of guests.
You are a Python code generator, capable of creating scripts from specifications.
Resize memory of guests.
Here you have a function in Python 3, explain what it does def guest_resize_mem(self, userid, size): action = "resize guest '%s' to have '%s' memory" % (userid, size) LOG.info("Begin to %s" % action) with zvmutils.log_and_reraise_sdkbase_error(action): self._vmops.resize_memory(useri...
You are a Python code architect, reviewing and designing scalable and efficient code
This function creates a list of root disks for a guest vm.
Make a summary of the following Python 3 code def guest_create_disks(self, userid, disk_list): if disk_list == [] or disk_list is None: # nothing to do LOG.debug("No disk specified when calling guest_create_disks, " "nothing happened") return ac...
As a python code expert, you are capable of creating scripts from specifications.
def guest_delete_disks(self, userid, disk_vdev_list): """Delete disks from an existing guest vm. :param userid: (str) the userid of the vm to be deleted :param disk_vdev_list: (list) the vdev list of disks to be deleted, for example: ['0101', '0102'] """ action = "de...
Write a Python 3 script to delete disks from an existing guest vm.
As a Python code analyst, you investigate and solve complex coding mysteries
Couple nic device to specified vswitch.
Explain what the following Python 3 code does def guest_nic_couple_to_vswitch(self, userid, nic_vdev, vswitch_name, active=False): """ Couple nic device to specified vswitch. :param str userid: the user's name who owns the nic :param str nic_vdev: nic device ...
As a Python code composer, you craft elegant and concise scripts.
Unlink nic device from vswitch
Can you tell what is the following Python 3 function doing def guest_nic_uncouple_from_vswitch(self, userid, nic_vdev, active=False): """ Disonnect nic device with network. :param str userid: the user's name who owns the nic :param str nic_vdev: nic devic...
As a Python code translator, you convert algorithms and pseudocode into Python.
def vswitch_create(self, name, rdev=None, controller='*', connection='CONNECT', network_type='ETHERNET', router="NONROUTER", vid='UNAWARE', port_type='ACCESS', gvrp='GVRP', queue_mem=8, native_vid=1, persist=True): """ C...
Can you write a function in Python 3 where it creates a new virtual switch.
You are a Python code generator, capable of creating scripts from specifications.
def guest_get_console_output(self, userid): """Get the console output of the guest virtual machine. :param str userid: the user id of the vm :returns: console log string :rtype: str """ action = "get the console output of guest '%s'" % userid with zvmutils.log_an...
Write a Python 3 function that can get the console output of the guest virtual machine.
You are a Python code analyst, evaluating scripts for potential improvements.
def guest_delete(self, userid): """Delete guest. :param userid: the user id of the vm """ # check guest exist in database or not userid = userid.upper() if not self._vmops.check_guests_exist_in_db(userid, raise_exc=False): if zvmutils.check_userid_exist(user...
Implement a function in Python 3 to delete guest. :param userid: the user id of the vm
As a Python code translator, you convert algorithms and pseudocode into Python.
def guest_inspect_stats(self, userid_list): """Get the statistics including cpu and mem of the guests :param userid_list: a single userid string or a list of guest userids :returns: dictionary describing the cpu statistics of the vm in the form {'UID1': { ...
Can you create a Python 3 function that gets the cpu and mem of the guests
As a Python code composer, you craft elegant and concise scripts.
Get the vnics statistics of the guest virtual machines
Can you generate the documentation for the following Python 3 function def guest_inspect_vnics(self, userid_list): if not isinstance(userid_list, list): userid_list = [userid_list] action = "get the vnics statistics of guest '%s'" % str(userid_list) with zvmutils.log_and_reraise_sdkb...
You are a Python code analyst, evaluating scripts for potential improvements.
Set vlan id for user when connecting to the vswitch
Make a summary of the following Python 3 code def vswitch_set_vlan_id_for_user(self, vswitch_name, userid, vlan_id): self._networkops.set_vswitch_port_vlan_id(vswitch_name, userid, vlan_id)
You are a Python code generator, capable of creating scripts from specifications.
def guest_config_minidisks(self, userid, disk_info): """Punch the script that used to process additional disks to vm :param str userid: the user id of the vm :param disk_info: a list contains disks info for the guest. It contains dictionaries that describes disk info for each dis...
Write a Python 3 script to punch the script that used to process additional disks for a guest.
As a Python code composer, you craft elegant and concise scripts.
def vswitch_set(self, vswitch_name, **kwargs): """Change the configuration of an existing virtual switch :param str vswitch_name: the name of the virtual switch :param dict kwargs: - grant_userid=<value>: A userid to be added to the access list - user_vla...
Can you create a Python 3 function that changes the configuration of an existing virtual switch.
As a Python code composer, you craft elegant and concise scripts.
Delete the vswitch from the system
Make a summary of the following Python 3 code def vswitch_delete(self, vswitch_name, persist=True): self._networkops.delete_vswitch(vswitch_name, persist)
As a Python code analyst, you investigate and solve complex coding mysteries
Retrieve nic information in the network database according to the requirements of the guests.
Given the following Python 3 function, write the documentation def guests_get_nic_info(self, userid=None, nic_id=None, vswitch=None): action = "get nic information" with zvmutils.log_and_reraise_sdkbase_error(action): return self._networkops.get_nic_info(userid=userid, nic_id=nic_id, ...
As a Python code composer, you craft elegant and concise scripts.
def vswitch_query(self, vswitch_name): """Check the virtual switch status :param str vswitch_name: the name of the virtual switch :returns: Dictionary describing virtual switch info :rtype: dict """ action = "get virtual switch information" with zvmutils.log_and_...
Create a Python 3 function to query the virtual switch status
You are a Python code analyst, evaluating scripts for potential improvements.
def guest_delete_network_interface(self, userid, os_version, vdev, active=False): """ delete the nic and network configuration for the vm :param str userid: the user id of the guest :param str os_version: operating system version of the guest :para...
Can you implement a function in Python 3 that deletes the nic and network configuration for the guest
You are a Python code analyst, evaluating scripts for potential improvements.
Context Manager that mockes the requests session with the given path to any files found within a static path.
How would you explain what the following Python 3 function does def mock_session_with_fixtures(session, path, url): _orig_adapters = session.adapters mock_adapter = adapter.Adapter() session.adapters = OrderedDict() if isinstance(url, (list, tuple)): for u in url: session.mount(u, mo...
As a Python code composer, you craft elegant and concise scripts.
def mock_session_with_class(session, cls, url): """ Context Manager Mock the responses with a particular session to any private methods for the URLs :param session: The requests session object :type session: :class:`requests.Session` :param cls: The class instance with private methods fo...
Write a Python 3 function that can mock the requests session with a particular class instance with any private methods for the URLs.
As a Python code translator, you convert algorithms and pseudocode into Python.
def _fixpath(self, p): """Apply tilde expansion and absolutization to a path.""" return os.path.abspath(os.path.expanduser(p))
Can you create a Python 3 function that applies tilde expansion and absolutization to a path.
You are a Python code architect, reviewing and designing scalable and efficient code
Return a list of directories where config files may be located.
Can you generate the documentation for the following Python 3 function def _get_config_dirs(self): _cwd = os.path.split(os.path.abspath(__file__))[0] _pdir = os.path.split(_cwd)[0] _etcdir = ''.join((_pdir, '/', 'etc/')) cfg_dirs = [ self._fixpath(_cwd), sel...
As a Python code composer, you craft elegant and concise scripts.
Search a list of directories for a given filename or directory name. Returns the first file with the supplied name and extension.
Can you generate the documentation for the following Python 3 function def _search_dirs(self, dirs, basename, extension=""): for d in dirs: path = os.path.join(d, '%s%s' % (basename, extension)) if os.path.exists(path): return path return None
You are a Python code analyst, evaluating scripts for potential improvements.
def find_config_file(self, project=None, extension='.conf'): """Return the config file. :param project: "zvmsdk" :param extension: the type of the config file """ cfg_dirs = self._get_config_dirs() config_files = self._search_dirs(cfg_dirs, project, extension) ...
Implement a function in Python 3 to return the config file.
You are a Python code analyst, evaluating scripts for potential improvements.
Derives a Modular Crypt Format hash using the scrypt KDF given a password and a salt.
Can you generate a brief explanation for the following Python 3 code def scrypt_mcf(scrypt, password, salt=None, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, prefix=SCRYPT_MCF_PREFIX_DEFAULT): """Derives a Modular Crypt Format hash using the scrypt KDF given Expects the signature: scrypt(password, sa...
As a Python code analyst, you investigate and solve complex coding mysteries
Checks if the given password matches the given MCF hash.
How would you explain what the following Python 3 function does def scrypt_mcf_check(scrypt, mcf, password): if not isinstance(mcf, bytes): raise TypeError('MCF must be a byte string') if isinstance(password, unicode): password = password.encode('utf8') elif not isinstance(password, bytes): ...
You are a Python code generator, capable of creating scripts from specifications.
def new_plugin(odir, py_name=None, version='0.0.1.dev0', description='New plugin'): """ Create a new plugin for the psyplot package Parameters ---------- odir: str The name of the directory where the data will be copied to. The directory must not exist! The name of th...
Write a Python 3 function that can create a new plugin for the psyplot package.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_versions(requirements=True, key=None): """ Get the version information for psyplot, the plugins and its requirements Parameters ---------- requirements: bool If True, the requirements of the plugins and psyplot are investigated key: func A function that determines whethe...
Write a Python 3 script for getting the version information for psyplot and the plugins and its requirements.
As a Python code analyst, you investigate and solve complex coding mysteries
def switch_delete_record_for_userid(self, userid): """Remove userid switch record from switch table.""" with get_network_conn() as conn: conn.execute("DELETE FROM switch WHERE userid=?", (userid,)) LOG.debug("Switch record for user %s is removed from " ...
Can you implement a function in Python 3 that removes userid switch record from switch table.
You are a Python code analyst, evaluating scripts for potential improvements.
Remove userid switch record for nic.
Can you generate the documentation for the following Python 3 function def switch_delete_record_for_nic(self, userid, interface): with get_network_conn() as conn: conn.execute("DELETE FROM switch WHERE userid=? and interface=?", (userid, interface)) LOG.debug("Sw...
As a python code expert, you are capable of creating scripts from specifications.
def switch_add_record(self, userid, interface, port=None, switch=None, comments=None): """Add userid and nic name address into switch table.""" with get_network_conn() as conn: conn.execute("INSERT INTO switch VALUES (?, ?, ?, ?, ?)", (useri...
Write a Python 3 function for adding userid nic name address into switch table.
You are a Python code generator, capable of creating scripts from specifications.
def switch_update_record_with_switch(self, userid, interface, switch=None): """Update information in switch table.""" if not self._get_switch_by_user_interface(userid, interface): msg = "User %s with nic %s does not exist in DB" % (userid, ...
Create a Python 3 function for updating user record with switch.
You are a Python code generator, capable of creating scripts from specifications.
Query the image record from database.
Can you generate the documentation for the following Python 3 function def image_query_record(self, imagename=None): if imagename: with get_image_conn() as conn: result = conn.execute("SELECT * FROM image WHERE " "imagename=?", (imagename,)) ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Get comments record by userid.
Here you have a function in Python 3, explain what it does def get_comments_by_userid(self, userid): userid = userid with get_guest_conn() as conn: res = conn.execute("SELECT comments FROM guests " "WHERE userid=?", (userid,)) result = res.fetchall() ...
As a Python code composer, you craft elegant and concise scripts.
get metadata record by userid
Given the following Python 3 function, write the documentation def get_metadata_by_userid(self, userid): userid = userid with get_guest_conn() as conn: res = conn.execute("SELECT * FROM guests " "WHERE userid=?", (userid,)) guest = res.fetchall() ...
As a python code expert, you are capable of creating scripts from specifications.
def transfer_metadata_to_dict(self, meta): """transfer str to dict. output should be like: {'a':1, 'b':2, 'c':3} """ dic = {} arr = meta.strip(' ,').split(',') for i in arr: temp = i.split('=') key = temp[0].strip() value = temp[1].stri...
Implement a function in Python 3 to transfer str to dict. output should be like : 1 b 2 c 3
You are a Python code analyst, evaluating scripts for potential improvements.
def face_index(vertices): """Takes an MxNx3 array and returns a 2D vertices and MxN face_indices arrays""" new_verts = [] face_indices = [] for wall in vertices: face_wall = [] for vert in wall: if new_verts: if not np.isclose(vert, new_verts).all(axis=1).any(...
How would you code a function in Python 3 to take an array and returns a 2D vertices and a MxN face_indices arrays
As a Python code composer, you craft elegant and concise scripts.
def fan_triangulate(indices): """Return an array of vertices in triangular order using a fan triangulation algorithm.""" if len(indices[0]) != 4: raise ValueError("Assumes working with a sequence of quad indices") new_indices = [] for face in indices: new_indices.extend([face[:-1], face[...
Write a Python 3 script to return an array of vertices in triangular order using a fan triangulation algorithm.
As a Python code translator, you convert algorithms and pseudocode into Python.
def from_dicts(cls, mesh_name, vert_dict, normal_dict): """Returns a wavefront .obj string using pre-triangulated vertex dict and normal dict as reference.""" # Put header in string wavefront_str = "o {name}\n".format(name=mesh_name) # Write Vertex data from vert_dict for wall ...
Can you write a function in Python 3 where it returns a wavefront. obj string using pre - triangulated vertex dict and normal dict as reference.
You are a Python code analyst, evaluating scripts for potential improvements.
Returns a wavefront. obj string using pre - triangulated vertex dict and normal dict as reference.
Can you tell what is the following Python 3 function doing def from_arrays(cls, name, verts, normals, n_verts=3): """Returns a wavefront .obj string using pre-triangulated vertex dict and normal dict as reference.""" # Put header in string wavefront_str = "o {name}\n".format(name=name) ...
You are a Python code analyst, evaluating scripts for potential improvements.
def from_indexed_arrays(cls, name, verts, normals): """Takes MxNx3 verts, Mx3 normals to build obj file""" # Put header in string wavefront_str = "o {name}\n".format(name=name) new_verts, face_indices = face_index(verts) assert new_verts.shape[1] == 3, "verts should be Nx3 arr...
Can you implement a function in Python 3 that takes Nx3 array vertices and normals and creates a new object from it.
You are a Python code analyst, evaluating scripts for potential improvements.
Write Wavefront data to file. Takes File object or filename.
How would you explain what the following Python 3 function does def dump(self, f): try: f.write(self._data) except AttributeError: with open(f, 'w') as wf: wf.write(self._data)
You are a Python code architect, reviewing and designing scalable and efficient code
Returns a key derived using the scrypt key - derivarion function
Can you generate the documentation for the following Python 3 function def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64): check_args(password, salt, N, r, p, olen) try: return _scrypt(password=password, salt=salt, N=N, r=r, p=p, buflen=olen) except: raise ValueError
As a python code expert, you are capable of creating scripts from specifications.
This function is called by the daemon to perform the requested function by invoking the subfunction handler.
Here you have a function in Python 3, explain what it does def doIt(rh): rh.printSysLog("Enter cmdVM.doIt") # Show the invocation parameters, if requested. if 'showParms' in rh.parms and rh.parms['showParms'] is True: rh.printLn("N", "Invocation parameters: ") rh.printLn("N", " Routine: c...
You are a Python code generator, capable of creating scripts from specifications.
Invoke the command in the virtual machine s operating system.
Explain what the following Python 3 code does def invokeCmd(rh): rh.printSysLog("Enter cmdVM.invokeCmd, userid: " + rh.userid) results = execCmdThruIUCV(rh, rh.userid, rh.parms['cmd']) if results['overallRC'] == 0: rh.printLn("N", results['response']) else: rh.printLn("ES", results['r...
You are a Python code architect, reviewing and designing scalable and efficient code
def parseCmdline(rh): """ Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error """ rh.printSysLog("Enter cmdVM.parseCmdline") if rh.totalParms >= 2: rh.userid = rh.reques...
Implement a Python 3 function for parsing the command line and return the handle of the next element.
You are a Python code analyst, evaluating scripts for potential improvements.
Generate virtual device number based on base and offset.
How would you explain what the following Python 3 function does def _generate_vdev(self, base, offset): vdev = hex(int(base, 16) + offset)[2:] return vdev.rjust(4, '0')
As a python code expert, you are capable of creating scripts from specifications.
def generate_disk_vdev(self, start_vdev=None, offset=0): """Generate virtual device number for disks :param offset: offset of user_root_vdev. :return: virtual device number, string of 4 bit hex. """ if not start_vdev: start_vdev = CONF.zvm.user_root_vdev vdev ...
Can you write a function in Python 3 where it generates virtual device number for disks :param offset: offset of user_root_vdev. :return: virtual device number, string of 4 bit hex.
As a python code expert, you are capable of creating scripts from specifications.
def add_mdisks(self, userid, disk_list, start_vdev=None): """Add disks for the userid :disks: A list dictionary to describe disk info, for example: disk: [{'size': '1g', 'format': 'ext3', 'disk_pool': 'ECKD:eckdpool1'}] """ ...
Can you write a function in Python 3 where it adds disks for the userid to the list of disks.
As a Python code analyst, you investigate and solve complex coding mysteries
dedicate a virtual device to the directory entry
Given the following Python 3 function, write the documentation def dedicate_device(self, userid, vaddr, raddr, mode): # dedicate device to directory entry self._dedicate_device(userid, vaddr, raddr, mode)
As a Python code analyst, you investigate and solve complex coding mysteries
def get_fcp_info_by_status(self, userid, status): """get fcp information by the status. :userid: The name of the image to query fcp info :status: The status of target fcps. eg:'active', 'free' or 'offline'. """ results = self._get_fcp_info_by_status(userid, status) retu...
Implement a function in Python 3 to get fcp information by the status
As a python code expert, you are capable of creating scripts from specifications.
undedicate a device from a virtual machine.
Make a summary of the following Python 3 code def _undedicate_device(self, userid, vaddr): action = 'undedicate' rd = ('changevm %(uid)s %(act)s %(va)s' % {'uid': userid, 'act': action, 'va': vaddr}) action = "undedicate device from userid '%s'" % userid with...
You are a Python code architect, reviewing and designing scalable and efficient code
Get CPU and memory usage information for the zvm userid.
Make a summary of the following Python 3 code def get_image_performance_info(self, userid): pi_dict = self.image_performance_query([userid]) return pi_dict.get(userid, None)
As a Python code translator, you convert algorithms and pseudocode into Python.
def _parse_vswitch_inspect_data(self, rd_list): """ Parse the Virtual_Network_Vswitch_Query_Byte_Stats data to get inspect data. """ def _parse_value(data_list, idx, keyword, offset): return idx + offset, data_list[idx].rpartition(keyword)[2].strip() vsw_dict = {} ...
Create a Python 3 function for parsing the Virtual_Network_Vswitch_Query_Byte_Stats data to get inspect data.
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_power_state(self, userid): """Get power status of a z/VM instance.""" LOG.debug('Querying power stat of %s' % userid) requestData = "PowerVM " + userid + " status" action = "query power state of '%s'" % userid with zvmutils.log_and_reraise_smt_request_failed(action): ...
How would you code a function in Python 3 to get power state of a z/VM instance.
As a Python code composer, you craft elegant and concise scripts.
def guest_stop(self, userid, **kwargs): """Power off VM.""" requestData = "PowerVM " + userid + " off" if 'timeout' in kwargs.keys() and kwargs['timeout']: requestData += ' --maxwait ' + str(kwargs['timeout']) if 'poll_interval' in kwargs.keys() and kwargs['poll_interval']: ...
Can you implement a function in Python 3 that powers off a VM.
As a Python code analyst, you investigate and solve complex coding mysteries