output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def files_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro dns.log) ''' for row in list(stream): # dataframes['files_log'][['md5','mime_type','missing_bytes','rx_hosts','source','tx_hosts']] # If the mime-type is interesting add the uri and ...
Create a Python 3 function to build a graph of the files in the files log file.
As a Python code translator, you convert algorithms and pseudocode into Python.
Register callbacks for file creation modification and deletion.
How would you explain what the following Python 3 function does def register_callbacks(self, on_create, on_modify, on_delete): self.on_create = on_create self.on_modify = on_modify self.on_delete = on_delete
As a Python code analyst, you investigate and solve complex coding mysteries
Internal method that monitors the directory for changes
Explain what the following Python 3 code does def _start_monitoring(self): # Grab all the timestamp info before = self._file_timestamp_info(self.path) while True: gevent.sleep(1) after = self._file_timestamp_info(self.path) added = [fname for fname ...
You are a Python code generator, capable of creating scripts from specifications.
def _file_timestamp_info(self, path): """ Grab all the timestamps for the files in the directory """ files = [os.path.join(path, fname) for fname in os.listdir(path) if '.py' in fname] return dict ([(fname, os.path.getmtime(fname)) for fname in files])
Implement a function in Python 3 to grab all the timestamps for the files in the directory
You are a Python code analyst, evaluating scripts for potential improvements.
Recursively load the rules from the yara rules directory and save them to Workbench
Explain what the following Python 3 code does def get_rules_from_disk(self): ''' Recursively traverse the yara/rules directory for rules ''' # Try to find the yara rules directory relative to the worker my_dir = os.path.dirname(os.path.realpath(__file__)) yara_rule_path = os.path.join(m...
You are a Python code architect, reviewing and designing scalable and efficient code
def execute(self, input_data): ''' yara worker execute method ''' raw_bytes = input_data['sample']['raw_bytes'] matches = self.rules.match_data(raw_bytes) # The matches data is organized in the following way # {'filename1': [match_list], 'filename2': [match_list]} # matc...
Can you create a Python 3 function that executes the yara match data worker
As a Python code analyst, you investigate and solve complex coding mysteries
def chunks(data, chunk_size): """ Yield chunk_size chunks from data.""" for i in xrange(0, len(data), chunk_size): yield data[i:i+chunk_size]
Create a Python 3 function to yield chunk_size chunks from data.
You are a Python code analyst, evaluating scripts for potential improvements.
Recursively traverse the yara rules directory for rules
Here you have a function in Python 3, explain what it does def get_rules_from_disk(): ''' Recursively traverse the yara/rules directory for rules ''' # Try to find the yara rules directory relative to the worker my_dir = os.path.dirname(os.path.realpath(__file__)) yara_rule_path = os.path.join(my_dir, ...
You are a Python code analyst, evaluating scripts for potential improvements.
Setup the PCAPs for Bro to process and return the pcap filenames
How would you explain what the following Python 3 function does def setup_pcap_inputs(self, input_data): ''' Write the PCAPs to disk for Bro to process and return the pcap filenames ''' # Setup the pcap in the input data for processing by Bro. The input # may be either an individual sample or a...
You are a Python code analyst, evaluating scripts for potential improvements.
Execute the command line and return the result of the command line.
Can you generate a brief explanation for the following Python 3 code def execute(self, input_data): ''' Execute ''' # Get the bro script path (workers/bro/__load__.bro) script_path = self.bro_script_dir # Create a temporary directory with self.goto_temp_directory() as temp_dir:...
You are a Python code architect, reviewing and designing scalable and efficient code
def getConsole(rh): """ Get the virtual machine's console output. Input: Request Handle with the following properties: function - 'CMDVM' subfunction - 'CMD' userid - userid of the virtual machine Output: Request Handle updated with the results. ...
Write a Python 3 script for getting the console output of a virtual machine.
You are a Python code generator, capable of creating scripts from specifications.
Returns the virtual machine s directory statements.
How would you explain what the following Python 3 function does def getDirectory(rh): rh.printSysLog("Enter getVM.getDirectory") parms = ["-T", rh.userid] results = invokeSMCLI(rh, "Image_Query_DM", parms) if results['overallRC'] == 0: results['response'] = re.sub('\*DVHOPT.*', '', results['res...
You are a Python code analyst, evaluating scripts for potential improvements.
Get the basic status of a virtual machine.
Can you generate a brief explanation for the following Python 3 code def getStatus(rh): rh.printSysLog("Enter getVM.getStatus, userid: " + rh.userid) results = isLoggedOn(rh, rh.userid) if results['rc'] != 0: # Uhoh, can't determine if guest is logged on or not rh.updateResults(results) ...
As a python code expert, you are capable of creating scripts from specifications.
def extract_fcp_data(raw_data, status): """ extract data from smcli System_WWPN_Query output. Input: raw data returned from smcli Output: data extracted would be like: 'status:Free \n fcp_dev_no:1D2F\n physical_wwpn:C05076E9928051D1\n channel_path_id:8B\n npiv_wwp...
Write a Python 3 function that can extract data from smcli System_WWPN_Query output.
You are a Python code analyst, evaluating scripts for potential improvements.
def fcpinfo(rh): """ Get fcp info and filter by the status. Input: Request Handle with the following properties: function - 'GETVM' subfunction - 'FCPINFO' userid - userid of the virtual machine parms['status'] - The status for filter results. ...
Create a Python 3 function to get fcp info and filter by the status. Input: Request Handle with the following properties: function - 'GETVM' subfunction - 'FCPINFO' userid - userid of the virtual machine parms['status'] - The status for filter results. Output: Request Handle updated with the results. Return code - 0: o...
As a Python code translator, you convert algorithms and pseudocode into Python.
A method to get the value of _no_auto_update
Here you have a function in Python 3, explain what it does def _no_auto_update_getter(self): if getattr(self, '_no_auto_update', None) is not None: return self._no_auto_update else: self._no_auto_update = utils._TempBool() return self._no_auto_update
You are a Python code generator, capable of creating scripts from specifications.
Infer interval breaks from a coordinate.
Can you generate the documentation for the following Python 3 function def _infer_interval_breaks(coord): coord = np.asarray(coord) deltas = 0.5 * (coord[1:] - coord[:-1]) first = coord[0] - deltas[0] last = coord[-1] + deltas[-1] return np.r_[[first], coord[:-1] + deltas, [last]]
You are a Python code generator, capable of creating scripts from specifications.
Return the variable names of an array
Make a summary of the following Python 3 code def _get_variable_names(arr): if VARIABLELABEL in arr.dims: return arr.coords[VARIABLELABEL].tolist() else: return arr.name
You are a Python code analyst, evaluating scripts for potential improvements.
Test whether arr can be replaced by a slice
How would you explain what the following Python 3 function does def to_slice(arr): if isinstance(arr, slice): return arr if len(arr) == 1: return slice(arr[0], arr[0] + 1) step = np.unique(arr[1:] - arr[:-1]) if len(step) == 1: return slice(arr[0], arr[-1] + step[0], step[0])
As a Python code analyst, you investigate and solve complex coding mysteries
def get_index_from_coord(coord, base_index): """Function to return the coordinate as integer, integer array or slice If `coord` is zero-dimensional, the corresponding integer in `base_index` will be supplied. Otherwise it is first tried to return a slice, if that does not work an integer array with the...
Write a Python 3 script for functioning to return the coordinate as integer array or slice of integers or slice of integers
You are a Python code architect, reviewing and designing scalable and efficient code
def get_tdata(t_format, files): """ Get the time information from file names Parameters ---------- t_format: str The string that can be used to get the time information in the files. Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but not non-numeric string...
Write a Python 3 script for getting the time information from file names
You are a Python code analyst, evaluating scripts for potential improvements.
This function will store the given dataset as a netCDF file and return the netCDF file.
Can you generate a brief explanation for the following Python 3 code def to_netcdf(ds, *args, **kwargs): to_update = {} for v, obj in six.iteritems(ds.variables): units = obj.attrs.get('units', obj.encoding.get('units', None)) if units == 'day as %Y%m%d.%f' and np.issubdtype( obj...
As a Python code composer, you craft elegant and concise scripts.
def _get_fname_nio(store): """Try to get the file name from the NioDataStore store""" try: f = store.ds.file except AttributeError: return None try: return f.path except AttributeError: return None
How would you code a function in Python 3 to try to get the file name from the NioDataStore store
You are a Python code analyst, evaluating scripts for potential improvements.
Returns the path to the dataset that corresponds to a single file.
Can you generate a brief explanation for the following Python 3 code def get_filename_ds(ds, dump=True, paths=None, **kwargs): from tempfile import NamedTemporaryFile # if already specified, return that filename if ds.psy._filename is not None: return tuple([ds.psy._filename] + list(ds.psy.data_sto...
You are a Python code architect, reviewing and designing scalable and efficient code
def open_dataset(filename_or_obj, decode_cf=True, decode_times=True, decode_coords=True, engine=None, gridfile=None, **kwargs): """ Open an instance of :class:`xarray.Dataset`. This method has the same functionality as the :func:`xarray.open_dataset` method except that is supports an a...
Write a Python 3 function that can open an instance of xarray. Dataset.
You are a Python code generator, capable of creating scripts from specifications.
def open_mfdataset(paths, decode_cf=True, decode_times=True, decode_coords=True, engine=None, gridfile=None, t_format=None, **kwargs): """ Open multiple files as a single dataset. This function is essentially the same as the :func:`xarray.open_mfdataset` function b...
Can you implement a function in Python 3 that opens multiple files as a single dataset.
As a Python code translator, you convert algorithms and pseudocode into Python.
def _open_ds_from_store(fname, store_mod=None, store_cls=None, **kwargs): """Open a dataset and return it""" if isinstance(fname, xr.Dataset): return fname if not isstring(fname): try: # test iterable fname[0] except TypeError: pass else: ...
Implement a Python 3 function for opening a dataset and return it
As a Python code translator, you convert algorithms and pseudocode into Python.
def disconnect(self, func=None): """Disconnect a function call to the signal. If None, all connections are disconnected""" if func is None: self._connections = [] else: self._connections.remove(func)
Implement a function in Python 3 to disconnect a function call to the signal.
You are a Python code generator, capable of creating scripts from specifications.
Returns the logger of this instance.
Can you generate the documentation for the following Python 3 function def logger(self): try: return self._logger except AttributeError: name = '%s.%s' % (self.__module__, self.__class__.__name__) self._logger = logging.getLogger(name) self.logger.debug('I...
You are a Python code analyst, evaluating scripts for potential improvements.
def get_decoder(cls, ds, var): """ Class method to get the right decoder class that can decode the given dataset and variable Parameters ---------- %(CFDecoder.can_decode.parameters)s Returns ------- CFDecoder The decoder for the give...
Can you implement a function in Python 3 that returns the right decoder class that can decode the given dataset and variable.
As a Python code analyst, you investigate and solve complex coding mysteries
def decode_coords(ds, gridfile=None): """ Sets the coordinates and bounds in a dataset This static method sets those coordinates and bounds that are marked marked in the netCDF attributes as coordinates in :attr:`ds` (without deleting them from the variable attributes because th...
Create a Python 3 function for setting the coordinates and bounds in a dataset This static method sets those coordinates and bounds that are marked marked in the netCDF attributes as coordinates in :attr:`ds` (without deleting them from the variable attributes because this information is necessary for visualizing the d...
You are a Python code architect, reviewing and designing scalable and efficient code
def is_triangular(self, var): """ Test if a variable is on a triangular grid This method first checks the `grid_type` attribute of the variable (if existent) whether it is equal to ``"unstructered"``, then it checks whether the bounds are not two-dimensional. Parameters...
Write a Python 3 script for testing if a variable is on a triangular grid.
As a Python code composer, you craft elegant and concise scripts.
Returns the coordinates of the cell node in the variable attribute.
Can you generate a brief explanation for the following Python 3 code def get_cell_node_coord(self, var, coords=None, axis='x', nans=None): if coords is None: coords = self.ds.coords axis = axis.lower() get_coord = self.get_x if axis == 'x' else self.get_y coord = get_coord(va...
As a Python code analyst, you investigate and solve complex coding mysteries
def _get_coord_cell_node_coord(self, coord, coords=None, nans=None, var=None): """ Get the boundaries of an unstructed coordinate Parameters ---------- coord: xr.Variable The coordinate whose bounds should be returned %(CFDe...
How would you code a function in Python 3 to get the boundaries of an unstructed coordinate
As a Python code translator, you convert algorithms and pseudocode into Python.
def _check_triangular_bounds(self, var, coords=None, axis='x', nans=None): """ Checks whether the bounds in the variable attribute are triangular Parameters ---------- %(CFDecoder.get_cell_node_coord.parameters)s Returns ------- bool or None ...
Implement a Python 3 function for checking whether the bounds in the variable attribute are triangular.
You are a Python code generator, capable of creating scripts from specifications.
def is_unstructured(self, var): """ Test if a variable is on an unstructered grid Parameters ---------- %(CFDecoder.is_triangular.parameters)s Returns ------- %(CFDecoder.is_triangular.returns)s Notes ----- Currently this is the ...
Implement a Python 3 function for testing if a variable is on an unstructered grid.
You are a Python code architect, reviewing and designing scalable and efficient code
def is_circumpolar(self, var): """ Test if a variable is on a circumpolar grid Parameters ---------- %(CFDecoder.is_triangular.parameters)s Returns ------- %(CFDecoder.is_triangular.returns)s""" xcoord = self.get_x(var) return xcoord is n...
Can you write a function in Python 3 where it tests if a variable is on a circumpolar grid
You are a Python code generator, capable of creating scripts from specifications.
This method returns the coordinate matching the specified axis for the given variable.
Can you generate the documentation for the following Python 3 function def get_variable_by_axis(self, var, axis, coords=None): axis = axis.lower() if axis not in list('xyzt'): raise ValueError("Axis must be one of X, Y, Z, T, not {0}".format( axis)) # we first check f...
As a Python code composer, you craft elegant and concise scripts.
def get_x(self, var, coords=None): """ Get the x-coordinate of a variable This method searches for the x-coordinate in the :attr:`ds`. It first checks whether there is one dimension that holds an ``'axis'`` attribute with 'X', otherwise it looks whether there is an intersection ...
Can you create a Python 3 function that returns the x - coordinate of a variable in the x - dimension of the dataset.
As a Python code composer, you craft elegant and concise scripts.
def get_xname(self, var, coords=None): """Get the name of the x-dimension This method gives the name of the x-dimension (which is not necessarily the name of the coordinate if the variable has a coordinate attribute) Parameters ---------- var: xarray.Variables ...
Can you create a Python 3 function that gets the name of the x - dimension of the variable.
You are a Python code architect, reviewing and designing scalable and efficient code
def get_y(self, var, coords=None): """ Get the y-coordinate of a variable This method searches for the y-coordinate in the :attr:`ds`. It first checks whether there is one dimension that holds an ``'axis'`` attribute with 'Y', otherwise it looks whether there is an intersection ...
Create a Python 3 function to return the y - coordinate of a variable in the dict.
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_yname(self, var, coords=None): """Get the name of the y-dimension This method gives the name of the y-dimension (which is not necessarily the name of the coordinate if the variable has a coordinate attribute) Parameters ---------- var: xarray.Variables ...
Create a Python 3 function to get the name of the y - dimension for a variable.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_z(self, var, coords=None): """ Get the vertical (z-) coordinate of a variable This method searches for the z-coordinate in the :attr:`ds`. It first checks whether there is one dimension that holds an ``'axis'`` attribute with 'Z', otherwise it looks whether there is an i...
Can you implement a function in Python 3 that returns the z - coordinate of a variable in the dataset.
You are a Python code generator, capable of creating scripts from specifications.
def get_zname(self, var, coords=None): """Get the name of the z-dimension This method gives the name of the z-dimension (which is not necessarily the name of the coordinate if the variable has a coordinate attribute) Parameters ---------- var: xarray.Variables ...
Implement a function in Python 3 to get the name of the z-dimension This method gives the name of the z-dimension (which is not necessarily the name of the coordinate if the variable has a coordinate attribute) Parameters ---------- var: xarray.Variables The variable to get the dimension for coords: dict The coordinate...
As a python code expert, you are capable of creating scripts from specifications.
This method returns the time coordinate of a variable in the dataset.
Can you generate the documentation for the following Python 3 function def get_t(self, var, coords=None): coords = coords or self.ds.coords coord = self.get_variable_by_axis(var, 't', coords) if coord is not None: return coord dimlist = list(self.t.intersection(var.dims).inte...
You are a Python code generator, capable of creating scripts from specifications.
Get the name of the t - dimension for the variable
Can you generate the documentation for the following Python 3 function def get_tname(self, var, coords=None): if coords is not None: coord = self.get_variable_by_axis(var, 't', coords) if coord is not None and coord.name in var.dims: return coord.name dimlist = li...
As a python code expert, you are capable of creating scripts from specifications.
Get the coordinates in the dataset as int or slice or list of integer that represent the the coordinates in the given array.
How would you explain what the following Python 3 function does def get_idims(self, arr, coords=None): if coords is None: coords = arr.coords else: coords = { label: coord for label, coord in six.iteritems(arr.coords) if label in coords} re...
You are a Python code analyst, evaluating scripts for potential improvements.
Get the slicers for the given coordinates from the base dataset.
Make a summary of the following Python 3 code def get_coord_idims(self, coords): ret = dict( (label, get_index_from_coord(coord, self.ds.indexes[label])) for label, coord in six.iteritems(coords) if label in self.ds.indexes) return ret
You are a Python code generator, capable of creating scripts from specifications.
Returns the plotbounds for a given coordinate.
How would you explain what the following Python 3 function does def get_plotbounds(self, coord, kind=None, ignore_shape=False): if 'bounds' in coord.attrs: bounds = self.ds.coords[coord.attrs['bounds']] if ignore_shape: return bounds.values.ravel() if not boun...
As a Python code composer, you craft elegant and concise scripts.
Get the plot bounds for a given coordinate and bounds.
Can you generate a brief explanation for the following Python 3 code def _get_plotbounds_from_cf(coord, bounds): if bounds.shape[:-1] != coord.shape or bounds.shape[-1] != 2: raise ValueError( "Cannot interprete bounds with shape {0} for {1} " "coordinate with shape ...
As a python code expert, you are capable of creating scripts from specifications.
def get_triangles(self, var, coords=None, convert_radian=True, copy=False, src_crs=None, target_crs=None, nans=None, stacklevel=1): """ Get the triangles for the variable Parameters ---------- var: xarray.Variable or xarray.DataArray ...
Can you write a function in Python 3 where it returns the set of triangles for the variable in the current object.
As a python code expert, you are capable of creating scripts from specifications.
Infer interval breaks from the data in coord.
Can you generate the documentation for the following Python 3 function def _infer_interval_breaks(coord, kind=None): if coord.ndim == 1: return _infer_interval_breaks(coord) elif coord.ndim == 2: from scipy.interpolate import interp2d kind = kind or rcParams['decoder....
As a python code expert, you are capable of creating scripts from specifications.
Expands the dimensions to match the dims in the variable
Given the following Python 3 function, write the documentation def correct_dims(self, var, dims={}, remove=True): method_mapping = {'x': self.get_xname, 'z': self.get_zname, 't': self.get_tname} dims = dict(dims) if self.is_unstructured(var): # we assume a one-dimensio...
You are a Python code architect, reviewing and designing scalable and efficient code
def standardize_dims(self, var, dims={}): """Replace the coordinate names through x, y, z and t Parameters ---------- var: xarray.Variable The variable to use the dimensions of dims: dict The dictionary to use for replacing the original dimensions ...
Write a Python 3 script to replace the coordinate names through x y z and t with the original dimensions of the original dimensions of the current object.
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_mesh(self, var, coords=None): """Get the mesh variable for the given `var` Parameters ---------- var: xarray.Variable The data source whith the ``'mesh'`` attribute coords: dict The coordinates to use. If None, the coordinates of the dataset of ...
Implement a Python 3 function for getting the mesh variable for the given variable
As a Python code analyst, you investigate and solve complex coding mysteries
Get the triangles of a given variable.
Here you have a function in Python 3, explain what it does def get_triangles(self, var, coords=None, convert_radian=True, copy=False, src_crs=None, target_crs=None, nans=None, stacklevel=1): """ Get the of the given coordinate. Parameters ---------- %(CFDec...
You are a Python code analyst, evaluating scripts for potential improvements.
Returns the node coordinates for a variable in the specified axis.
Can you generate the documentation for the following Python 3 function def get_cell_node_coord(self, var, coords=None, axis='x', nans=None): if coords is None: coords = self.ds.coords idims = self.get_coord_idims(coords) def get_coord(coord): coord = coords.get(coord, s...
You are a Python code generator, capable of creating scripts from specifications.
Reimplemented to set the variables as coordinates
Can you generate a brief explanation for the following Python 3 code def decode_coords(ds, gridfile=None): extra_coords = set(ds.coords) for var in six.itervalues(ds.variables): if 'mesh' in var.attrs: mesh = var.attrs['mesh'] if mesh not in extra_coords: ...
You are a Python code generator, capable of creating scripts from specifications.
def get_nodes(self, coord, coords): """Get the variables containing the definition of the nodes Parameters ---------- coord: xarray.Coordinate The mesh variable coords: dict The coordinates to use to get node coordinates""" def get_coord(coord): ...
Can you write a function in Python 3 where it gets the variables containing the definition of the nodes
As a Python code translator, you convert algorithms and pseudocode into Python.
Get the centers of the triangles in the x - dimension.
Explain what the following Python 3 code does def get_x(self, var, coords=None): if coords is None: coords = self.ds.coords # first we try the super class ret = super(UGridDecoder, self).get_x(var, coords) # but if that doesn't work because we get the variable name in the ...
As a python code expert, you are capable of creating scripts from specifications.
Start an update of the current state of the a .
Explain what the following Python 3 code does def start_update(self, draw=None, queues=None): if self.plotter is not None: return self.plotter.start_update(draw=draw, queues=queues)
As a python code expert, you are capable of creating scripts from specifications.
Update the coordinates and the plot in this list.
Can you tell what is the following Python 3 function doing def update(self, fmt={}, replot=False, draw=None, auto_update=False, force=False, todefault=False, **kwargs): """ Update the coordinates and the plot This method updates all arrays in this list with the given coordinate ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Returns a set of the variable names in this list
Make a summary of the following Python 3 code def names(self): ret = set() for arr in self: if isinstance(arr, InteractiveList): ret.update(arr.names) else: ret.add(arr.name) return ret
As a Python code translator, you convert algorithms and pseudocode into Python.
The dimensions for each of the arrays in this list.
Make a summary of the following Python 3 code def all_dims(self): return [ _get_dims(arr) if not isinstance(arr, ArrayList) else arr.all_dims for arr in self]
You are a Python code analyst, evaluating scripts for potential improvements.
A boolean for each array whether it is unstructured or not
Here you have a function in Python 3, explain what it does def is_unstructured(self): return [ arr.psy.decoder.is_unstructured(arr) if not isinstance(arr, ArrayList) else arr.is_unstructured for arr in self]
You are a Python code analyst, evaluating scripts for potential improvements.
Coordinates of the arrays in this list that are used in all arrays
Explain what the following Python 3 code does def coords_intersect(self): return set.intersection(*map( set, (getattr(arr, 'coords_intersect', arr.coords) for arr in self) ))
As a python code expert, you are capable of creating scripts from specifications.
def with_plotter(self): """The arrays in this instance that are visualized with a plotter""" return self.__class__( (arr for arr in self if arr.psy.plotter is not None), auto_update=bool(self.auto_update))
Write a Python 3 function for returning a new instance with only the arrays that are visualized with a plotter.
You are a Python code architect, reviewing and designing scalable and efficient code
A list of all the data arrays in this list.
Given the following Python 3 function, write the documentation def arrays(self): return list(chain.from_iterable( ([arr] if not isinstance(arr, InteractiveList) else arr.arrays for arr in self)))
You are a Python code architect, reviewing and designing scalable and efficient code
Rename an array to find a name that isn t already in the list.
Explain what the following Python 3 code does def rename(self, arr, new_name=True): name_in_me = arr.psy.arr_name in self.arr_names if not name_in_me: return arr, False elif name_in_me and not self._contains_array(arr): if new_name is False: raise ValueErr...
As a python code expert, you are capable of creating scripts from specifications.
def copy(self, deep=False): """Returns a copy of the list Parameters ---------- deep: bool If False (default), only the list is copied and not the contained arrays, otherwise the contained arrays are deep copied""" if not deep: return self.__c...
Create a Python 3 function for returning a copy of the list containing the same attributes and attributes.
You are a Python code architect, reviewing and designing scalable and efficient code
def from_dataset(cls, base, method='isel', default_slice=None, decoder=None, auto_update=None, prefer_list=False, squeeze=True, attrs=None, load=False, **kwargs): """ Construct an ArrayList instance from an existing base dataset Parameters -----...
Create a Python 3 function for constructing an ArrayList instance from an existing base dataset.
As a python code expert, you are capable of creating scripts from specifications.
Recursive method to get all the file names or datasets out of a dictionary data
Here you have a function in Python 3, explain what it does def _get_ds_descriptions_unsorted( cls, data, ignore_keys=['attrs', 'plotter'], nums=None): """Recursive method to get all the file names or datasets out of a dictionary `data` created with the :meth`array_info` method""" ds_...
You are a Python code analyst, evaluating scripts for potential improvements.
Create a list from a dictionary containing filename dimension infos and array names.
Given the following Python 3 function, write the documentation def from_dict(cls, d, alternative_paths={}, datasets=None, pwd=None, ignore_keys=['attrs', 'plotter', 'ds'], only=None, chname={}, **kwargs): """ Create a list from the dictionary returned by :meth:`array_...
As a Python code analyst, you investigate and solve complex coding mysteries
def array_info(self, dump=None, paths=None, attrs=True, standardize_dims=True, pwd=None, use_rel_paths=True, alternative_paths={}, ds_description={'fname', 'store'}, full_ds=True, copy=False, **kwargs): """ Get dimension informations on you arrays...
How would you code a function in Python 3 to get dimension informations on you arrays This method returns a dictionary containing informations on the array in this instance Parameters ---------- dump: bool If True and the dataset has not been dumped so far, it is dumped to a temporary file or the one generated by `path...
You are a Python code analyst, evaluating scripts for potential improvements.
def _get_tnames(self): """Get the name of the time coordinate of the objects in this list""" tnames = set() for arr in self: if isinstance(arr, InteractiveList): tnames.update(arr.get_tnames()) else: tnames.add(arr.psy.decoder.get_tname( ...
Write a Python 3 script for getting the name of the time coordinate of the objects in this list
You are a Python code generator, capable of creating scripts from specifications.
def _register_update(self, method='isel', replot=False, dims={}, fmt={}, force=False, todefault=False): """ Register new dimensions and formatoptions for updating. The keywords are the same as for each single array Parameters ---------- %(Interac...
How would you implement a function in Python 3 that registers new dimensions and formatoptions for updating.
As a python code expert, you are capable of creating scripts from specifications.
Start the update of the items in the list.
Can you generate a brief explanation for the following Python 3 code def start_update(self, draw=None): def worker(arr): results[arr.psy.arr_name] = arr.psy.start_update( draw=False, queues=queues) if len(self) == 0: return results = {} threads = ...
As a Python code composer, you craft elegant and concise scripts.
Update the coordinates and formatoptions of the current object.
Make a summary of the following Python 3 code def update(self, method='isel', dims={}, fmt={}, replot=False, auto_update=False, draw=None, force=False, todefault=False, enable_post=None, **kwargs): """ Update the coordinates and the plot This method updates all arr...
You are a Python code analyst, evaluating scripts for potential improvements.
Draws all the figures in this instance
Explain what the following Python 3 code does def draw(self): for fig in set(chain(*map( lambda arr: arr.psy.plotter.figs2draw, self.with_plotter))): self.logger.debug("Drawing figure %s", fig.number) fig.canvas.draw() for arr in self: if arr.psy.plott...
As a python code expert, you are capable of creating scripts from specifications.
def _contains_array(self, val): """Checks whether exactly this array is in the list""" arr = self(arr_name=val.psy.arr_name)[0] is_not_list = any( map(lambda a: not isinstance(a, InteractiveList), [arr, val])) is_list = any(map(lambda a: isinstance(a, Interact...
Create a Python 3 function to check whether exactly this array is in the list
You are a Python code analyst, evaluating scripts for potential improvements.
def next_available_name(self, fmt_str='arr{0}', counter=None): """Create a new array out of the given format string Parameters ---------- format_str: str The base string to use. ``'{0}'`` will be replaced by a counter counter: iterable An iterable where t...
Can you write a function in Python 3 where it creates a new array out of the given format string and return the next available name.
As a python code expert, you are capable of creating scripts from specifications.
def append(self, value, new_name=False): """ Append a new array to the list Parameters ---------- value: InteractiveBase The data object to append to this list %(ArrayList.rename.parameters.new_name)s Raises ------ %(ArrayList.rename....
Implement a function in Python 3 to append a new array to the list.
As a Python code translator, you convert algorithms and pseudocode into Python.
Extend the list with the elements from an iterable.
Given the following Python 3 function, write the documentation def extend(self, iterable, new_name=False): # extend those arrays that aren't alredy in the list super(ArrayList, self).extend(t[0] for t in filter( lambda t: t[1] is not None, ( self.rename(arr, new_name) for arr...
You are a Python code generator, capable of creating scripts from specifications.
Removes an array from the list.
Here you have a function in Python 3, explain what it does def remove(self, arr): name = arr if isinstance(arr, six.string_types) else arr.psy.arr_name if arr not in self: raise ValueError( "Array {0} not in the list".format(name)) for i, arr in enumerate(self): ...
You are a Python code analyst, evaluating scripts for potential improvements.
def _njobs(self): """%(InteractiveBase._njobs)s""" ret = super(self.__class__, self)._njobs or [0] ret[0] += 1 return ret
Can you write a function in Python 3 where it returns the number of jobs in the current thread.
You are a Python code generator, capable of creating scripts from specifications.
Register new dimensions and formatoptions for updating
Can you generate a brief explanation for the following Python 3 code def _register_update(self, method='isel', replot=False, dims={}, fmt={}, force=False, todefault=False): """ Register new dimensions and formatoptions for updating Parameters ---------- ...
You are a Python code analyst, evaluating scripts for potential improvements.
def start_update(self, draw=None, queues=None): """ Conduct the formerly registered updates This method conducts the updates that have been registered via the :meth:`update` method. You can call this method if the :attr:`auto_update` attribute of this instance is True and the ...
Can you implement a function in Python 3 that starts updating the formerly registered updates with the current state of the entry.
As a Python code composer, you craft elegant and concise scripts.
Create an InteractiveList instance from the given base dataset.
Can you generate a brief explanation for the following Python 3 code def from_dataset(cls, *args, **kwargs): plotter = kwargs.pop('plotter', None) make_plot = kwargs.pop('make_plot', True) instance = super(InteractiveList, cls).from_dataset(*args, **kwargs) if plotter is not None: ...
As a python code expert, you are capable of creating scripts from specifications.
def createVM(rh): """ Create a virtual machine in z/VM. Input: Request Handle with the following properties: function - 'CMDVM' subfunction - 'CMD' userid - userid of the virtual machine Output: Request Handle updated with the results. Return ...
Can you create a Python 3 function that creates a virtual machine in z/VM. Input: Request Handle with the following properties: function - 'CMDVM' subfunction - 'CMD' userid - userid of the virtual machine Output: Request Handle updated with the results. Return code - 0: ok, non-zero: error
As a Python code translator, you convert algorithms and pseudocode into Python.
Prints the output related to operands.
How would you explain what the following Python 3 function does def showOperandLines(rh): if rh.function == 'HELP': rh.printLn("N", " For the MakeVM function:") else: rh.printLn("N", "Sub-Functions(s):") rh.printLn("N", " directory - " + "Create a virtual machine in the z/...
As a Python code analyst, you investigate and solve complex coding mysteries
Capture a virtual machine image.
Here you have a function in Python 3, explain what it does def capture_guest(userid): # check power state, if down, start it ret = sdk_client.send_request('guest_get_power_state', userid) power_status = ret['output'] if power_status == 'off': sdk_client.send_request('guest_start', userid) ...
As a python code expert, you are capable of creating scripts from specifications.
def import_image(image_path, os_version): """Import image. Input parameters: :image_path: Image file path :os_version: Operating system version. e.g. rhel7.2 """ image_name = os.path.basename(image_path) print("Checking if image %s exists or not, import it if not exists" % ...
Write a Python 3 script to import image. Input parameters: :image_path: Image file path :os_version: Operating system version. e.g. rhel7.2
You are a Python code analyst, evaluating scripts for potential improvements.
Create a new virtual machine and provision it.
Can you generate the documentation for the following Python 3 function def _run_guest(userid, image_path, os_version, profile, cpu, memory, network_info, disks_list): """Deploy and provision a virtual machine. Input parameters: :userid: USERID of the guest, no more than 8. :...
You are a Python code architect, reviewing and designing scalable and efficient code
def _remove_unexpected_query_parameters(schema, req): """Remove unexpected properties from the req.GET.""" additional_properties = schema.get('addtionalProperties', True) if additional_properties: pattern_regexes = [] patterns = schema.get('patternProperties', None) if patterns: ...
Create a Python 3 function to remove unexpected properties from the req. GET.
As a Python code translator, you convert algorithms and pseudocode into Python.
Register a schema to validate request query parameters.
Make a summary of the following Python 3 code def query_schema(query_params_schema, min_version=None, max_version=None): """Register a schema to validate request query parameters.""" def add_validator(func): @functools.wraps(func) def wrapper(*args, **kwargs): if 'r...
You are a Python code analyst, evaluating scripts for potential improvements.
def _close_after_stream(self, response, chunk_size): """Iterate over the content and ensure the response is closed after.""" # Yield each chunk in the response body for chunk in response.iter_content(chunk_size=chunk_size): yield chunk # Once we're done streaming the body, en...
How would you implement a function in Python 3 that iterates over the content and ensure the response is closed after.
You are a Python code architect, reviewing and designing scalable and efficient code
def _save_file(self, data, path): """Save an file to the specified path. :param data: binary data of the file :param path: path to save the file to """ with open(path, 'wb') as tfile: for chunk in data: tfile.write(chunk)
How would you implement a function in Python 3 that saves an file to the specified path.
You are a Python code analyst, evaluating scripts for potential improvements.
def process_docstring(app, what, name, obj, options, lines): """Process the docstring for a given python object. Called when autodoc has read and processed a docstring. `lines` is a list of docstring lines that `_process_docstring` modifies in place to change what Sphinx outputs. The following set...
Can you write a function in Python 3 where it processes the docstring for a given python object.
As a python code expert, you are capable of creating scripts from specifications.
Sphinx extension setup function
Can you generate a brief explanation for the following Python 3 code def setup(app): from sphinx.application import Sphinx if not isinstance(app, Sphinx): return # probably called by tests app.connect('autodoc-process-docstring', process_docstring) return napoleon_setup(app)
You are a Python code generator, capable of creating scripts from specifications.
def format_time(x): """Formats date values This function formats :class:`datetime.datetime` and :class:`datetime.timedelta` objects (and the corresponding numpy objects) using the :func:`xarray.core.formatting.format_timestamp` and the :func:`xarray.core.formatting.format_timedelta` functions. ...
Can you create a Python 3 function that formats date values in the .
As a Python code analyst, you investigate and solve complex coding mysteries