_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q3600
Network.clip
train
def clip(self, lower=None, upper=None): ''' Trim values at input thresholds using pandas function ''' df = self.export_df() df = df.clip(lower=lower, upper=upper) self.load_df(df)
python
{ "resource": "" }
q3601
Network.random_sample
train
def random_sample(self, num_samples, df=None, replace=False, weights=None, random_state=100, axis='row'): ''' Return random sample of matrix. ''' if df is None: df = self.dat_to_df() if axis == 'row': axis = 0 if axis == 'col': axis = 1 df = self.export_df() df = df....
python
{ "resource": "" }
q3602
Network.load_gene_exp_to_df
train
def load_gene_exp_to_df(inst_path): ''' Loads gene expression data from 10x in sparse matrix format and returns a Pandas dataframe ''' import pandas as pd from scipy import io from scipy import sparse from ast import literal_eval as make_tuple # matrix Matrix = io.mmread( inst_...
python
{ "resource": "" }
q3603
Network.sim_same_and_diff_category_samples
train
def sim_same_and_diff_category_samples(self, df, cat_index=1, dist_type='cosine', equal_var=False, plot_roc=True, precalc_dist=False, calc_roc=True): ''' Calculate the similarity of samples from the same and different categori...
python
{ "resource": "" }
q3604
Network.generate_signatures
train
def generate_signatures(self, df_ini, category_level, pval_cutoff=0.05, num_top_dims=False, verbose=True, equal_var=False): ''' Generate signatures for column categories ''' df_t = df_ini.transpose() # remove columns with constant values df_t = df_t.loc[:, (df_t != d...
python
{ "resource": "" }
q3605
Network.predict_cats_from_sigs
train
def predict_cats_from_sigs(self, df_data_ini, df_sig_ini, dist_type='cosine', predict_level='Predict Category', truth_level=1, unknown_thresh=-1): ''' Predict category using signature ''' keep_rows = df_sig_ini.index.tolist() data_rows = df_data_ini.index.tolist() ...
python
{ "resource": "" }
q3606
Network.confusion_matrix_and_correct_series
train
def confusion_matrix_and_correct_series(self, y_info): ''' Generate confusion matrix from y_info ''' a = deepcopy(y_info['true']) true_count = dict((i, a.count(i)) for i in set(a)) a = deepcopy(y_info['pred']) pred_count = dict((i, a.count(i)) for i in set(a)) sorted_cats = sorte...
python
{ "resource": "" }
q3607
load_data_to_net
train
def load_data_to_net(net, inst_net): ''' load data into nodes and mat, also convert mat to numpy array''' net.dat['nodes'] = inst_net['nodes'] net.dat['mat'] = inst_net['mat'] data_formats.mat_to_numpy_arr(net)
python
{ "resource": "" }
q3608
export_net_json
train
def export_net_json(net, net_type, indent='no-indent'): ''' export json string of dat ''' import json from copy import deepcopy if net_type == 'dat': exp_dict = deepcopy(net.dat) if type(exp_dict['mat']) is not list: exp_dict['mat'] = exp_dict['mat'].tolist() if 'mat_orig' in exp_dict: ...
python
{ "resource": "" }
q3609
install_npm
train
def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None): """Return a Command for managing an npm installation. Note: The command is skipped if the `--skip-npm` flag is used. Parameters ---------- path: str, optional The base path of the node pa...
python
{ "resource": "" }
q3610
_glob_pjoin
train
def _glob_pjoin(*parts): """Join paths for glob processing""" if parts[0] in ('.', ''): parts = parts[1:] return pjoin(*parts).replace(os.sep, '/')
python
{ "resource": "" }
q3611
_get_data_files
train
def _get_data_files(data_specs, existing, top=HERE): """Expand data file specs into valid data files metadata. Parameters ---------- data_specs: list of tuples See [create_cmdclass] for description. existing: list of tuples The existing distrubution data_files metadata. Returns...
python
{ "resource": "" }
q3612
_get_files
train
def _get_files(file_patterns, top=HERE): """Expand file patterns to a list of paths. Parameters ----------- file_patterns: list or str A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`. They should be relative paths from the t...
python
{ "resource": "" }
q3613
_get_package_data
train
def _get_package_data(root, file_patterns=None): """Expand file patterns to a list of `package_data` paths. Parameters ----------- root: str The relative path to the package root from `HERE`. file_patterns: list or str, optional A list of glob patterns for the data file locations. ...
python
{ "resource": "" }
q3614
df_filter_row_sum
train
def df_filter_row_sum(df, threshold, take_abs=True): ''' filter rows in matrix at some threshold and remove columns that have a sum below this threshold ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_c...
python
{ "resource": "" }
q3615
df_filter_col_sum
train
def df_filter_col_sum(df, threshold, take_abs=True): ''' filter columns in matrix at some threshold and remove rows that have all zero values ''' from copy import deepcopy from .__init__ import Network net = Network() if take_abs is True: df_copy = deepcopy(df['mat'].abs()) else: df_copy = deepc...
python
{ "resource": "" }
q3616
infer_flags
train
def infer_flags(bytecode, is_async=False): """Infer the proper flags for a bytecode based on the instructions. """ flags = CompilerFlags(0) if not isinstance(bytecode, (_bytecode.Bytecode, _bytecode.ConcreteBytecode, _bytecode.ControlFlo...
python
{ "resource": "" }
q3617
ControlFlowGraph.to_bytecode
train
def to_bytecode(self): """Convert to Bytecode.""" used_blocks = set() for block in self: target_block = block.get_jump() if target_block is not None: used_blocks.add(id(target_block)) labels = {} jumps = [] instructions = [] ...
python
{ "resource": "" }
q3618
ControlFlowGraph.to_code
train
def to_code(self, stacksize=None): """Convert to code.""" if stacksize is None: stacksize = self.compute_stacksize() bc = self.to_bytecode() return bc.to_code(stacksize=stacksize)
python
{ "resource": "" }
q3619
Instr.set
train
def set(self, name, arg=UNSET): """Modify the instruction in-place. Replace name and arg attributes. Don't modify lineno. """ self._set(name, arg, self._lineno)
python
{ "resource": "" }
q3620
LinSpace
train
def LinSpace(start, stop, num): """ Linspace op. """ return np.linspace(start, stop, num=num, dtype=np.float32),
python
{ "resource": "" }
q3621
Range
train
def Range(start, limit, delta): """ Range op. """ return np.arange(start, limit, delta, dtype=np.int32),
python
{ "resource": "" }
q3622
RandomUniformInt
train
def RandomUniformInt(shape, minval, maxval, seed): """ Random uniform int op. """ if seed: np.random.seed(seed) return np.random.randint(minval, maxval, size=shape),
python
{ "resource": "" }
q3623
Rank
train
def Rank(a): """ Rank op. """ return np.array([len(a.shape)], dtype=np.int32),
python
{ "resource": "" }
q3624
Squeeze
train
def Squeeze(a, squeeze_dims): """ Squeeze op, i.e. removes singular axes. """ if not squeeze_dims: squeeze_dims = list(range(len(a.shape))) slices = [(0 if (dim == 1 and i in squeeze_dims) else slice(None)) \ for i, dim in enumerate(a.shape)] return np.copy(a)[slices],
python
{ "resource": "" }
q3625
ExpandDims
train
def ExpandDims(a, dim): """ Expand dim op, i.e. add singular axis at dim. """ shape = list(a.shape) if dim >= 0: shape.insert(dim, 1) else: shape.insert(len(shape) + dim + 1, 1) return np.copy(a).reshape(*shape),
python
{ "resource": "" }
q3626
Slice
train
def Slice(a, begin, size): """ Slicing op. """ return np.copy(a)[[slice(*tpl) for tpl in zip(begin, begin+size)]],
python
{ "resource": "" }
q3627
Split
train
def Split(axis, a, n): """ Split op with n splits. """ return tuple(np.split(np.copy(a), n, axis=axis))
python
{ "resource": "" }
q3628
SplitV
train
def SplitV(a, splits, axis): """ Split op with multiple split sizes. """ return tuple(np.split(np.copy(a), np.cumsum(splits), axis=axis))
python
{ "resource": "" }
q3629
ConcatV2
train
def ConcatV2(inputs): """ Concat op. """ axis = inputs.pop() return np.concatenate(inputs, axis=axis),
python
{ "resource": "" }
q3630
Unpack
train
def Unpack(a, num, axis): """ Unpack op. """ return tuple(np.squeeze(b, axis=axis) for b in np.split(a, num, axis=axis))
python
{ "resource": "" }
q3631
ReverseSequence
train
def ReverseSequence(a, seq_lengths, seq_dim, batch_dim): """ Sequential reverse op. """ r = np.copy(a) invidxs = (len(r.shape) - 1) * [slice(None)] if seq_dim < batch_dim: invidxs[seq_dim] = slice(None, None, -1) else: invidxs[seq_dim - 1] = slice(None, None, -1) _invidxs...
python
{ "resource": "" }
q3632
ReverseV2
train
def ReverseV2(a, axes): """ Reverse op. """ idxs = tuple(slice(None, None, 2 * int(i not in axes) - 1) for i in range(len(a.shape))) return np.copy(a[idxs]),
python
{ "resource": "" }
q3633
Betainc
train
def Betainc(a, b, x): """ Complemented, incomplete gamma op. """ return sp.special.betainc(a, b, x),
python
{ "resource": "" }
q3634
Diag
train
def Diag(a): """ Diag op. """ r = np.zeros(2 * a.shape, dtype=a.dtype) for idx, v in np.ndenumerate(a): r[2 * idx] = v return r,
python
{ "resource": "" }
q3635
MatrixDiagPart
train
def MatrixDiagPart(a): """ Batched diag op that returns only the diagonal elements. """ r = np.zeros(a.shape[:-2] + (min(a.shape[-2:]),)) for coord in np.ndindex(a.shape[:-2]): pos = coord + (Ellipsis,) r[pos] = np.diagonal(a[pos]) return r,
python
{ "resource": "" }
q3636
MatMul
train
def MatMul(a, b, transpose_a, transpose_b): """ Matrix multiplication op. """ return np.dot(a if not transpose_a else np.transpose(a), b if not transpose_b else np.transpose(b)),
python
{ "resource": "" }
q3637
MatrixInverse
train
def MatrixInverse(a, adj): """ Matrix inversion op. """ return np.linalg.inv(a if not adj else _adjoint(a)),
python
{ "resource": "" }
q3638
MatrixSolve
train
def MatrixSolve(a, rhs, adj): """ Matrix solve op. """ return np.linalg.solve(a if not adj else _adjoint(a), rhs),
python
{ "resource": "" }
q3639
MatrixTriangularSolve
train
def MatrixTriangularSolve(a, rhs, lower, adj): """ Matrix triangular solve op. """ trans = 0 if not adj else 2 r = np.empty(rhs.shape).astype(a.dtype) for coord in np.ndindex(a.shape[:-2]): pos = coord + (Ellipsis,) r[pos] = sp.linalg.solve_triangular(a[pos] if not adj else np.c...
python
{ "resource": "" }
q3640
MatrixSolveLs
train
def MatrixSolveLs(a, rhs, l2_reg): """ Matrix least-squares solve op. """ r = np.empty(rhs.shape).astype(a.dtype) for coord in np.ndindex(a.shape[:-2]): pos = coord + (Ellipsis,) r[pos] = np.linalg.lstsq(a[pos], rhs[pos])[0] return r,
python
{ "resource": "" }
q3641
SelfAdjointEig
train
def SelfAdjointEig(a): """ Eigen decomp op. """ shape = list(a.shape) shape[-2] += 1 return np.append(*np.linalg.eig(a)).reshape(*shape),
python
{ "resource": "" }
q3642
Svd
train
def Svd(a, uv, full): """ Single value decomp op. """ u, s, v = np.linalg.svd(a, full_matrices=full, compute_uv=uv) return s, u, v
python
{ "resource": "" }
q3643
Sum
train
def Sum(a, axis, keep_dims): """ Sum reduction op. """ return np.sum(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3644
Prod
train
def Prod(a, axis, keep_dims): """ Prod reduction op. """ return np.prod(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3645
Min
train
def Min(a, axis, keep_dims): """ Min reduction op. """ return np.amin(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3646
Max
train
def Max(a, axis, keep_dims): """ Max reduction op. """ return np.amax(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3647
Mean
train
def Mean(a, axis, keep_dims): """ Mean reduction op. """ return np.mean(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3648
All
train
def All(a, axis, keep_dims): """ All reduction op. """ return np.all(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3649
Any
train
def Any(a, axis, keep_dims): """ Any reduction op. """ return np.any(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
python
{ "resource": "" }
q3650
SegmentSum
train
def SegmentSum(a, ids, *args): """ Segmented sum op. """ func = lambda idxs: reduce(np.add, a[idxs]) return seg_map(func, a, ids),
python
{ "resource": "" }
q3651
SegmentProd
train
def SegmentProd(a, ids): """ Segmented prod op. """ func = lambda idxs: reduce(np.multiply, a[idxs]) return seg_map(func, a, ids),
python
{ "resource": "" }
q3652
SegmentMin
train
def SegmentMin(a, ids): """ Segmented min op. """ func = lambda idxs: np.amin(a[idxs], axis=0) return seg_map(func, a, ids),
python
{ "resource": "" }
q3653
SegmentMax
train
def SegmentMax(a, ids): """ Segmented max op. """ func = lambda idxs: np.amax(a[idxs], axis=0) return seg_map(func, a, ids),
python
{ "resource": "" }
q3654
SegmentMean
train
def SegmentMean(a, ids): """ Segmented mean op. """ func = lambda idxs: np.mean(a[idxs], axis=0) return seg_map(func, a, ids),
python
{ "resource": "" }
q3655
ListDiff
train
def ListDiff(a, b): """ List diff op. """ d = np.setdiff1d(a, b) return d, np.searchsorted(a, d).astype(np.int32)
python
{ "resource": "" }
q3656
Unique
train
def Unique(a, t): """ Unique op. """ _, idxs, inv = np.unique(a, return_index=True, return_inverse=True) return np.copy(a)[np.sort(idxs)], idxs[inv].astype(dtype_map[t])
python
{ "resource": "" }
q3657
Elu
train
def Elu(a): """ Elu op. """ return np.where(a < 0, np.subtract(np.exp(a), 1), a),
python
{ "resource": "" }
q3658
Softsign
train
def Softsign(a): """ Softsign op. """ return np.divide(a, np.add(np.abs(a), 1)),
python
{ "resource": "" }
q3659
Softmax
train
def Softmax(a): """ Softmax op. """ e = np.exp(a) return np.divide(e, np.sum(e, axis=-1, keepdims=True)),
python
{ "resource": "" }
q3660
Conv1D
train
def Conv1D(a, f, strides, padding, data_format): """ 1D conv op. """ if data_format.decode("ascii") == "NCHW": a = np.rollaxis(a, 1, -1), patches = _conv_patches(a, f, 3 * [strides], padding.decode("ascii")) conv = np.sum(patches, axis=tuple(range(-f.ndim, -1))) if data_format.deco...
python
{ "resource": "" }
q3661
Conv3D
train
def Conv3D(a, f, strides, padding): """ 3D conv op. """ patches = _conv_patches(a, f, strides, padding.decode("ascii")) return np.sum(patches, axis=tuple(range(-f.ndim, -1))),
python
{ "resource": "" }
q3662
AvgPool
train
def AvgPool(a, k, strides, padding, data_format): """ Average pooling op. """ if data_format.decode("ascii") == "NCHW": a = np.rollaxis(a, 1, -1), patches = _pool_patches(a, k, strides, padding.decode("ascii")) pool = np.average(patches, axis=tuple(range(-len(k), 0))) if data_forma...
python
{ "resource": "" }
q3663
MaxPool
train
def MaxPool(a, k, strides, padding, data_format): """ Maximum pooling op. """ if data_format.decode("ascii") == "NCHW": a = np.rollaxis(a, 1, -1), patches = _pool_patches(a, k, strides, padding.decode("ascii")) pool = np.amax(patches, axis=tuple(range(-len(k), 0))) if data_format.d...
python
{ "resource": "" }
q3664
AvgPool3D
train
def AvgPool3D(a, k, strides, padding): """ Average 3D pooling op. """ patches = _pool_patches(a, k, strides, padding.decode("ascii")) return np.average(patches, axis=tuple(range(-len(k), 0))),
python
{ "resource": "" }
q3665
MaxPool3D
train
def MaxPool3D(a, k, strides, padding): """ Maximum 3D pooling op. """ patches = _pool_patches(a, k, strides, padding.decode("ascii")) return np.amax(patches, axis=tuple(range(-len(k), 0))),
python
{ "resource": "" }
q3666
Matrix_Keypad.pressed_keys
train
def pressed_keys(self): """An array containing all detected keys that are pressed from the initalized list-of-lists passed in during creation""" # make a list of all the keys that are detected pressed = [] # set all pins pins to be inputs w/pullups for pin in self.row_pi...
python
{ "resource": "" }
q3667
MultiHarParser.get_load_times
train
def get_load_times(self, asset_type): """ Just a ``list`` of the load times of a certain asset type for each page :param asset_type: ``str`` of the asset type to return load times for """ load_times = [] search_str = '{0}_load_time'.format(asset_type) for har_pag...
python
{ "resource": "" }
q3668
MultiHarParser.get_stdev
train
def get_stdev(self, asset_type): """ Returns the standard deviation for a set of a certain asset type. :param asset_type: ``str`` of the asset type to calculate standard deviation for. :returns: A ``int`` or ``float`` of standard deviation, depending on the self.decimal_...
python
{ "resource": "" }
q3669
MultiHarParser.pages
train
def pages(self): """ The aggregate pages of all the parser objects. """ pages = [] for har_dict in self.har_data: har_parser = HarParser(har_data=har_dict) if self.page_id: for page in har_parser.pages: if page.page_id =...
python
{ "resource": "" }
q3670
MultiHarParser.time_to_first_byte
train
def time_to_first_byte(self): """ The aggregate time to first byte for all pages. """ ttfb = [] for page in self.pages: if page.time_to_first_byte is not None: ttfb.append(page.time_to_first_byte) return round(mean(ttfb), self.decimal_precision...
python
{ "resource": "" }
q3671
MultiHarParser.js_load_time
train
def js_load_time(self): """ Returns aggregate javascript load time. """ load_times = self.get_load_times('js') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3672
MultiHarParser.css_load_time
train
def css_load_time(self): """ Returns aggregate css load time for all pages. """ load_times = self.get_load_times('css') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3673
MultiHarParser.image_load_time
train
def image_load_time(self): """ Returns aggregate image load time for all pages. """ load_times = self.get_load_times('image') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3674
MultiHarParser.html_load_time
train
def html_load_time(self): """ Returns aggregate html load time for all pages. """ load_times = self.get_load_times('html') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3675
MultiHarParser.audio_load_time
train
def audio_load_time(self): """ Returns aggregate audio load time for all pages. """ load_times = self.get_load_times('audio') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3676
MultiHarParser.video_load_time
train
def video_load_time(self): """ Returns aggregate video load time for all pages. """ load_times = self.get_load_times('video') return round(mean(load_times), self.decimal_precision)
python
{ "resource": "" }
q3677
HarParser.match_headers
train
def match_headers(self, entry, header_type, header, value, regex=True): """ Function to match headers. Since the output of headers might use different case, like: 'content-type' vs 'Content-Type' This function is case-insensitive :param entry: entry object ...
python
{ "resource": "" }
q3678
HarParser.match_content_type
train
def match_content_type(entry, content_type, regex=True): """ Matches the content type of a request using the mimeType metadata. :param entry: ``dict`` of a single entry from a HarPage :param content_type: ``str`` of regex to use for finding content type :param regex: ``bool`` in...
python
{ "resource": "" }
q3679
HarParser.match_status_code
train
def match_status_code(self, entry, status_code, regex=True): """ Helper function that returns entries with a status code matching then given `status_code` argument. NOTE: This is doing a STRING comparison NOT NUMERICAL :param entry: entry object to analyze :param status...
python
{ "resource": "" }
q3680
HarParser.pages
train
def pages(self): """ This is a list of HarPage objects, each of which represents a page from the HAR file. """ # Start with a page object for unknown entries if the HAR data has # any entries with no page ID pages = [] if any('pageref' not in entry for ent...
python
{ "resource": "" }
q3681
HarPage.filter_entries
train
def filter_entries(self, request_type=None, content_type=None, status_code=None, http_version=None, regex=True): """ Returns a ``list`` of entry objects based on the filter criteria. :param request_type: ``str`` of request type (i.e. - GET or POST) :param content_...
python
{ "resource": "" }
q3682
HarPage.get_load_time
train
def get_load_time(self, request_type=None, content_type=None, status_code=None, asynchronous=True, **kwargs): """ This method can return the TOTAL load time for the assets or the ACTUAL load time, the difference being that the actual load time takes asynchronous tra...
python
{ "resource": "" }
q3683
HarPage.get_total_size
train
def get_total_size(self, entries): """ Returns the total size of a collection of entries. :param entries: ``list`` of entries to calculate the total size of. """ size = 0 for entry in entries: if entry['response']['bodySize'] > 0: size += entr...
python
{ "resource": "" }
q3684
HarPage.get_total_size_trans
train
def get_total_size_trans(self, entries): """ Returns the total size of a collection of entries - transferred. NOTE: use with har file generated with chrome-har-capturer :param entries: ``list`` of entries to calculate the total size of. """ size = 0 for entry in...
python
{ "resource": "" }
q3685
HarPage.time_to_first_byte
train
def time_to_first_byte(self): """ Time to first byte of the page request in ms """ # The unknown page is just a placeholder for entries with no page ID. # As such, it would not have a TTFB if self.page_id == 'unknown': return None ttfb = 0 for ...
python
{ "resource": "" }
q3686
AggregatedGroup._data
train
def _data(self): """ Cached data built from instance raw _values as a dictionary. """ d = {} # Iterate all keys and values for k, v in self._row_values.items(): # Split related model fields attrs = k.rsplit('__', 1) # Set value depend...
python
{ "resource": "" }
q3687
AggregatedGroup._set_values
train
def _set_values(self): """ Populate instance with given. """ # Iterate all keys and values in data for k, v in self._data.items(): # If it's a dict, process it (it's probably instance data) if isinstance(v, dict): try: #...
python
{ "resource": "" }
q3688
GroupByMixin._expand_group_by_fields
train
def _expand_group_by_fields(cls, model, fields): """ Expand FK fields into all related object's fields to avoid future lookups. :param fields: fields to "group by" :return: expanded fields """ # Containers for resulting fields and related model fields res...
python
{ "resource": "" }
q3689
Dummy.write
train
def write(self, addr, data): '''Write to dummy memory Parameters ---------- addr : int The register address. data : list, tuple Data (byte array) to be written. Returns ------- nothing ''' logger.debug( ...
python
{ "resource": "" }
q3690
BitLogic._swap_slice_indices
train
def _swap_slice_indices(self, slc, make_slice=False): '''Swap slice indices Change slice indices from Verilog slicing (e.g. IEEE 1800-2012) to Python slicing. ''' try: start = slc.start stop = slc.stop slc_step = slc.step except AttributeError...
python
{ "resource": "" }
q3691
Pixel._clear_strobes
train
def _clear_strobes(self): """ Resets the "enable" and "load" output streams to all 0. """ #reset some stuff self['SEQ']['GLOBAL_SHIFT_EN'].setall(False) self['SEQ']['GLOBAL_CTR_LD'].setall(False) self['SEQ']['GLOBAL_DAC_LD'].setall(False) self['SEQ']['PIX...
python
{ "resource": "" }
q3692
spi.set_data
train
def set_data(self, data, addr=0): ''' Sets data for outgoing stream ''' if self._mem_bytes < len(data): raise ValueError('Size of data (%d bytes) is too big for memory (%d bytes)' % (len(data), self._mem_bytes)) self._intf.write(self._conf['base_addr'] + self._spi_mem...
python
{ "resource": "" }
q3693
spi.get_data
train
def get_data(self, size=None, addr=None): ''' Gets data for incoming stream ''' # readback memory offset if addr is None: addr = self._mem_bytes if size and self._mem_bytes < size: raise ValueError('Size is too big') if size is None: ...
python
{ "resource": "" }
q3694
GPAC.read_eeprom_calibration
train
def read_eeprom_calibration(self): # use default values for temperature, EEPROM values are usually not calibrated and random '''Reading EEPROM calibration for sources and regulators ''' header = self.get_format() if header == self.HEADER_GPAC: data = self._read_eeprom(self.C...
python
{ "resource": "" }
q3695
GPAC.get_over_current
train
def get_over_current(self, channel): '''Reading over current status of power channel ''' try: bit = self._ch_map[channel]['GPIOOC']['bit'] except KeyError: raise ValueError('get_over_current() not supported for channel %s' % channel) return not self._get_p...
python
{ "resource": "" }
q3696
GPAC.set_current
train
def set_current(self, channel, value, unit='A'): '''Setting current of current source ''' dac_offset = self._ch_cal[channel]['DAC']['offset'] dac_gain = self._ch_cal[channel]['DAC']['gain'] if unit == 'raw': value = value elif unit == 'A': value = ...
python
{ "resource": "" }
q3697
bram_fifo.get_data
train
def get_data(self): ''' Reading data in BRAM. Returns ------- array : numpy.ndarray Array of unsigned integers (32 bit). ''' fifo_int_size_1 = self.FIFO_INT_SIZE fifo_int_size_2 = self.FIFO_INT_SIZE if fifo_int_size_1 > fifo_int_size_2: ...
python
{ "resource": "" }
q3698
Fei4Dcs.set_default
train
def set_default(self, channels=None): '''Setting default voltage ''' if not channels: channels = self._ch_cal.keys() for channel in channels: self.set_voltage(channel, self._ch_cal[channel]['default'], unit='V')
python
{ "resource": "" }
q3699
PickleInterface.send
train
def send(self, obj): """Prepend a 4-byte length to the string""" assert isinstance(obj, ProtocolBase) string = pickle.dumps(obj) length = len(string) self.sock.sendall(struct.pack("<I", length) + string)
python
{ "resource": "" }