_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q267700
ABweb._login
test
def _login(self, username, password): '''login and update cached cookies''' self.logger.debug('login ...') res = self.session.http.get(self.login_url) input_list = self._input_re.findall(res.text) if not input_list: raise PluginError('Missing input data on login webs...
python
{ "resource": "" }
q267701
StreamMapper.map
test
def map(self, key, func, *args, **kwargs): """Creates a key-function mapping. The return value from the function should be either - A tuple containing a name and stream - A iterator of tuples containing a name and stream Any extra arguments will be passed to the function. ...
python
{ "resource": "" }
q267702
CrunchyrollAPI._api_call
test
def _api_call(self, entrypoint, params=None, schema=None): """Makes a call against the api. :param entrypoint: API method to call. :param params: parameters to include in the request data. :param schema: schema to use to validate the data """ url = self._api_url.format(e...
python
{ "resource": "" }
q267703
CrunchyrollAPI.start_session
test
def start_session(self): """ Starts a session against Crunchyroll's server. Is recommended that you call this method before making any other calls to make sure you have a valid session against the server. """ params = {} if self.auth: param...
python
{ "resource": "" }
q267704
CrunchyrollAPI.get_info
test
def get_info(self, media_id, fields=None, schema=None): """ Returns the data for a certain media item. :param media_id: id that identifies the media item to be accessed. :param fields: list of the media"s field to be returned. By default the API returns some fiel...
python
{ "resource": "" }
q267705
Crunchyroll._create_api
test
def _create_api(self): """Creates a new CrunchyrollAPI object, initiates it's session and tries to authenticate it either by using saved credentials or the user's username and password. """ if self.options.get("purge_credentials"): self.cache.set("session_id", None, 0...
python
{ "resource": "" }
q267706
compress
test
def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0): """Compress a byte string. Args: string (bytes): The input data. mode (int, optional): The compression mode can be MODE_GENERIC (default), MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0). qua...
python
{ "resource": "" }
q267707
outputCharFormatter
test
def outputCharFormatter(c): """Show character in readable format """ #TODO 2: allow hex only output if 32<c<127: return chr(c) elif c==10: return '\\n' elif c==13: return '\\r' elif c==32: return '" "' else: return '\\x{:02x}'.format(c)
python
{ "resource": "" }
q267708
outputFormatter
test
def outputFormatter(s): """Show string or char. """ result = '' def formatSubString(s): for c in s: if c==32: yield ' ' else: yield outputCharFormatter(c) if len(result)<200: return ''.join(formatSubString(s)) else: return ''.join(formatSubString(s[:100]))...
python
{ "resource": "" }
q267709
BitStream.readBytes
test
def readBytes(self, n): """Read n bytes from the stream on a byte boundary. """ if self.pos&7: raise ValueError('readBytes: need byte boundary') result = self.data[self.pos>>3:(self.pos>>3)+n] self.pos += 8*n return result
python
{ "resource": "" }
q267710
Symbol.value
test
def value(self, extra=None): """The value used for processing. Can be a tuple. with optional extra bits """ if isinstance(self.code, WithExtra): if not 0<=extra<1<<self.extraBits(): raise ValueError("value: extra value doesn't fit in extraBits") re...
python
{ "resource": "" }
q267711
Symbol.explanation
test
def explanation(self, extra=None): """Long explanation of the value from the numeric value with optional extra bits Used by Layout.verboseRead when printing the value """ if isinstance(self.code, WithExtra): return self.code.callback(self, extra) return self.c...
python
{ "resource": "" }
q267712
PrefixDecoder.setDecode
test
def setDecode(self, decodeTable): """Store decodeTable, and compute lengthTable, minLength, maxLength from encodings. """ self.decodeTable = decodeTable #set of symbols with unknown length todo = set(decodeTable) #bit size under investigation maskLength = ...
python
{ "resource": "" }
q267713
PrefixDecoder.setLength
test
def setLength(self, lengthTable): """Given the bit pattern lengths for symbols given in lengthTable, set decodeTable, minLength, maxLength """ self.lengthTable = lengthTable self.minLength = min(lengthTable.values()) self.maxLength = max(lengthTable.values()) #com...
python
{ "resource": "" }
q267714
Code.showCode
test
def showCode(self, width=80): """Show all words of the code in a nice format. """ #make table of all symbols with binary strings symbolStrings = [ (self.bitPattern(s.index), self.mnemonic(s.index)) for s in self ] #determine column widths the w...
python
{ "resource": "" }
q267715
Code.readTuple
test
def readTuple(self, stream): """Read symbol from stream. Returns symbol, length. """ length, symbol = self.decodePeek(stream.peek(self.maxLength)) stream.pos += length return length, symbol
python
{ "resource": "" }
q267716
WithExtra.explanation
test
def explanation(self, index, extra=None): """Expanded version of Code.explanation supporting extra bits. If you don't supply extra, it is not mentioned. """ extraBits = 0 if extra is None else self.extraBits(index) if not hasattr(self, 'extraTable'): formatString = '{...
python
{ "resource": "" }
q267717
Enumerator.value
test
def value(self, index, extra): """Override if you don't define value0 and extraTable """ lower, upper = self.span(index) value = lower+(extra or 0) if value>upper: raise ValueError('value: extra out of range') return value
python
{ "resource": "" }
q267718
Enumerator.span
test
def span(self, index): """Give the range of possible values in a tuple Useful for mnemonic and explanation """ lower = self.value0+sum(1<<x for x in self.extraTable[:index]) upper = lower+(1<<self.extraTable[index]) return lower, upper-1
python
{ "resource": "" }
q267719
TreeAlphabet.value
test
def value(self, index, extra): """Give count and value.""" index = index if index==0: return 1, 0 if index<=self.RLEMAX: return (1<<index)+extra, 0 return 1, index-self.RLEMAX
python
{ "resource": "" }
q267720
InsertAndCopyAlphabet.mnemonic
test
def mnemonic(self, index): """Make a nice mnemonic """ i,c,d0 = self.splitSymbol(index) iLower, _ = i.code.span(i.index) iExtra = i.extraBits() cLower, _ = c.code.span(c.index) cExtra = c.extraBits() return 'I{}{}{}C{}{}{}{}'.format( iLower, ...
python
{ "resource": "" }
q267721
DistanceAlphabet.mnemonic
test
def mnemonic(self, index, verbose=False): """Give mnemonic representation of meaning. verbose compresses strings of x's """ if index<16: return ['last', '2last', '3last', '4last', 'last-1', 'last+1', 'last-2', 'last+2', 'last-3', 'last+3', '2la...
python
{ "resource": "" }
q267722
WordList.compileActions
test
def compileActions(self): """Build the action table from the text above """ import re self.actionList = actions = [None]*121 #Action 73, which is too long, looks like this when expanded: actions[73] = "b' the '+w+b' of the '" #find out what the columns are ...
python
{ "resource": "" }
q267723
WordList.doAction
test
def doAction(self, w, action): """Perform the proper action """ #set environment for the UpperCaseFirst U = self.upperCase1 return eval(self.actionList[action], locals())
python
{ "resource": "" }
q267724
Layout.makeHexData
test
def makeHexData(self, pos): """Produce hex dump of all data containing the bits from pos to stream.pos """ firstAddress = pos+7>>3 lastAddress = self.stream.pos+7>>3 return ''.join(map('{:02x} '.format, self.stream.data[firstAddress:lastAddress]))
python
{ "resource": "" }
q267725
Layout.processStream
test
def processStream(self): """Process a brotli stream. """ print('addr hex{:{}s}binary context explanation'.format( '', self.width-10)) print('Stream header'.center(60, '-')) self.windowSize = self.verboseRead(WindowSizeAlphabet()) print('Metablock header'.cent...
python
{ "resource": "" }
q267726
Layout.metablockLength
test
def metablockLength(self): """Read MNIBBLES and meta block length; if empty block, skip block and return true. """ self.MLEN = self.verboseRead(MetablockLengthAlphabet()) if self.MLEN: return False #empty block; skip and return False self.verboseRead(R...
python
{ "resource": "" }
q267727
Layout.uncompressed
test
def uncompressed(self): """If true, handle uncompressed data """ ISUNCOMPRESSED = self.verboseRead( BoolCode('UNCMPR', description='Is uncompressed?')) if ISUNCOMPRESSED: self.verboseRead(FillerAlphabet(streamPos=self.stream.pos)) print('Uncompressed d...
python
{ "resource": "" }
q267728
Layout.blockType
test
def blockType(self, kind): """Read block type switch descriptor for given kind of blockType.""" NBLTYPES = self.verboseRead(TypeCountAlphabet( 'BT#'+kind[0].upper(), description='{} block types'.format(kind), )) self.numberOfBlockTypes[kind] = NBLTYPES ...
python
{ "resource": "" }
q267729
Layout.IMTF
test
def IMTF(v): """In place inverse move to front transform. """ #mtf is initialized virtually with range(infinity) mtf = [] for i, vi in enumerate(v): #get old value from mtf. If never seen, take virtual value try: value = mtf.pop(vi) except Inde...
python
{ "resource": "" }
q267730
Layout.readPrefixArray
test
def readPrefixArray(self, kind, numberOfTrees): """Read prefix code array""" prefixes = [] for i in range(numberOfTrees): if kind==L: alphabet = LiteralAlphabet(i) elif kind==I: alphabet = InsertAndCopyAlphabet(i) elif kind==D: alphabet = DistanceAlphabet( ...
python
{ "resource": "" }
q267731
monochrome
test
def monochrome(I, color, vmin=None, vmax=None): """Turns a intensity array to a monochrome 'image' by replacing each intensity by a scaled 'color' Values in I between vmin and vmax get scaled between 0 and 1, and values outside this range are clipped to this. Example >>> I = np.arange(16.).reshape(4,...
python
{ "resource": "" }
q267732
polychrome
test
def polychrome(I, colors, vmin=None, vmax=None, axis=-1): """Similar to monochrome, but now do it for multiple colors Example >>> I = np.arange(32.).reshape(4,4,2) >>> colors = [(0, 0, 1), (0, 1, 0)] # red and green >>> rgb = vx.image.polychrome(I, colors) # shape is (4,4,3) :param I: ndarray ...
python
{ "resource": "" }
q267733
arrow_table_from_vaex_df
test
def arrow_table_from_vaex_df(ds, column_names=None, selection=None, strings=True, virtual=False): """Implementation of Dataset.to_arrow_table""" names = [] arrays = [] for name, array in ds.to_items(column_names=column_names, selection=selection, strings=strings, virtual=virtual): names.append(n...
python
{ "resource": "" }
q267734
patch
test
def patch(f): '''Adds method f to the Dataset class''' name = f.__name__ Dataset.__hidden__[name] = f return f
python
{ "resource": "" }
q267735
add_virtual_columns_cartesian_velocities_to_pmvr
test
def add_virtual_columns_cartesian_velocities_to_pmvr(self, x="x", y="y", z="z", vx="vx", vy="vy", vz="vz", vr="vr", pm_long="pm_long", pm_lat="pm_lat", distance=None): """Concert velocities from a cartesian system to proper motions and radial velocities TODO: errors :param x: name of x column (input) ...
python
{ "resource": "" }
q267736
add_virtual_columns_proper_motion2vperpendicular
test
def add_virtual_columns_proper_motion2vperpendicular(self, distance="distance", pm_long="pm_l", pm_lat="pm_b", vl="vl", vb="vb", propagate_uncertainties=False, r...
python
{ "resource": "" }
q267737
Expression._graphviz
test
def _graphviz(self, dot=None): """Return a graphviz.Digraph object with a graph of the expression""" from graphviz import Graph, Digraph node = self._graph() dot = dot or Digraph(comment=self.expression) def walk(node): if isinstance(node, six.string_types): ...
python
{ "resource": "" }
q267738
Expression.value_counts
test
def value_counts(self, dropna=False, dropnull=True, ascending=False, progress=False): """Computes counts of unique values. WARNING: * If the expression/column is not categorical, it will be converted on the fly * dropna is False by default, it is True by default in pandas ...
python
{ "resource": "" }
q267739
Expression.map
test
def map(self, mapper, nan_mapping=None, null_mapping=None): """Map values of an expression or in memory column accoring to an input dictionary or a custom callable function. Example: >>> import vaex >>> df = vaex.from_arrays(color=['red', 'red', 'blue', 'red', 'green']) ...
python
{ "resource": "" }
q267740
app
test
def app(*args, **kwargs): """Create a vaex app, the QApplication mainloop must be started. In ipython notebook/jupyter do the following: >>> import vaex.ui.main # this causes the qt api level to be set properly >>> import vaex Next cell: >>> %gui qt Next cell: >>> app = vaex.app() ...
python
{ "resource": "" }
q267741
open_many
test
def open_many(filenames): """Open a list of filenames, and return a DataFrame with all DataFrames cocatenated. :param list[str] filenames: list of filenames/paths :rtype: DataFrame """ dfs = [] for filename in filenames: filename = filename.strip() if filename and filename[0] !=...
python
{ "resource": "" }
q267742
from_samp
test
def from_samp(username=None, password=None): """Connect to a SAMP Hub and wait for a single table load event, disconnect, download the table and return the DataFrame. Useful if you want to send a single table from say TOPCAT to vaex in a python console or notebook. """ print("Waiting for SAMP message.....
python
{ "resource": "" }
q267743
from_astropy_table
test
def from_astropy_table(table): """Create a vaex DataFrame from an Astropy Table.""" import vaex.file.other return vaex.file.other.DatasetAstropyTable(table=table)
python
{ "resource": "" }
q267744
from_arrays
test
def from_arrays(**arrays): """Create an in memory DataFrame from numpy arrays. Example >>> import vaex, numpy as np >>> x = np.arange(5) >>> y = x ** 2 >>> vaex.from_arrays(x=x, y=y) # x y 0 0 0 1 1 1 2 2 4 3 3 9 4 4 16 ...
python
{ "resource": "" }
q267745
from_scalars
test
def from_scalars(**kwargs): """Similar to from_arrays, but convenient for a DataFrame of length 1. Example: >>> import vaex >>> df = vaex.from_scalars(x=1, y=2) :rtype: DataFrame """ import numpy as np return from_arrays(**{k: np.array([v]) for k, v in kwargs.items()})
python
{ "resource": "" }
q267746
from_pandas
test
def from_pandas(df, name="pandas", copy_index=True, index_name="index"): """Create an in memory DataFrame from a pandas DataFrame. :param: pandas.DataFrame df: Pandas DataFrame :param: name: unique for the DataFrame >>> import vaex, pandas as pd >>> df_pandas = pd.from_csv('test.csv') >>> df =...
python
{ "resource": "" }
q267747
from_csv
test
def from_csv(filename_or_buffer, copy_index=True, **kwargs): """Shortcut to read a csv file using pandas and convert to a DataFrame directly. :rtype: DataFrame """ import pandas as pd return from_pandas(pd.read_csv(filename_or_buffer, **kwargs), copy_index=copy_index)
python
{ "resource": "" }
q267748
server
test
def server(url, **kwargs): """Connect to hostname supporting the vaex web api. :param str hostname: hostname or ip address of server :return vaex.dataframe.ServerRest: returns a server object, note that it does not connect to the server yet, so this will always succeed :rtype: ServerRest """ fr...
python
{ "resource": "" }
q267749
zeldovich
test
def zeldovich(dim=2, N=256, n=-2.5, t=None, scale=1, seed=None): """Creates a zeldovich DataFrame. """ import vaex.file return vaex.file.other.Zeldovich(dim=dim, N=N, n=n, t=t, scale=scale)
python
{ "resource": "" }
q267750
concat
test
def concat(dfs): '''Concatenate a list of DataFrames. :rtype: DataFrame ''' ds = reduce((lambda x, y: x.concat(y)), dfs) return ds
python
{ "resource": "" }
q267751
vrange
test
def vrange(start, stop, step=1, dtype='f8'): """Creates a virtual column which is the equivalent of numpy.arange, but uses 0 memory""" from .column import ColumnVirtualRange return ColumnVirtualRange(start, stop, step, dtype)
python
{ "resource": "" }
q267752
VaexApp.open
test
def open(self, path): """Add a dataset and add it to the UI""" logger.debug("open dataset: %r", path) if path.startswith("http") or path.startswith("ws"): dataset = vaex.open(path, thread_mover=self.call_in_main_thread) else: dataset = vaex.open(path) self...
python
{ "resource": "" }
q267753
DatasetRest.evaluate
test
def evaluate(self, expression, i1=None, i2=None, out=None, selection=None, delay=False): expression = _ensure_strings_from_expressions(expression) """basic support for evaluate at server, at least to run some unittest, do not expect this to work from strings""" result = self.server._call_dataset...
python
{ "resource": "" }
q267754
delayed
test
def delayed(f): '''Decorator to transparantly accept delayed computation. Example: >>> delayed_sum = ds.sum(ds.E, binby=ds.x, limits=limits, >>> shape=4, delay=True) >>> @vaex.delayed >>> def total_sum(sums): >>> return sums.sum() >>> sum_of_sums = total_sum(delay...
python
{ "resource": "" }
q267755
Selection._depending_columns
test
def _depending_columns(self, ds): '''Find all columns that this selection depends on for df ds''' depending = set() for expression in self.expressions: expression = ds._expr(expression) # make sure it is an expression depending |= expression.variables() if self.p...
python
{ "resource": "" }
q267756
SubspaceLocal._task
test
def _task(self, task, progressbar=False): """Helper function for returning tasks results, result when immediate is True, otherwise the task itself, which is a promise""" if self.delay: # should return a task or a promise nesting it return self.executor.schedule(task) else...
python
{ "resource": "" }
q267757
____RankingTableModel.sort
test
def sort(self, Ncol, order): """Sort table by given column number. """ self.emit(QtCore.SIGNAL("layoutAboutToBeChanged()")) if Ncol == 0: print("by name") # get indices, sorted by pair name sortlist = list(zip(self.pairs, list(range(len(self.pairs)))))...
python
{ "resource": "" }
q267758
getinfo
test
def getinfo(filename, seek=None): """Read header data from Gadget data file 'filename' with Gadget file type 'gtype'. Returns offsets of positions and velocities.""" DESC = '=I4sII' # struct formatting string HEAD = '=I6I6dddii6iiiddddii6ii60xI' # struct formatting string keys...
python
{ "resource": "" }
q267759
Slicer.clear
test
def clear(self, event): """clear the cursor""" if self.useblit: self.background = ( self.canvas.copy_from_bbox(self.canvas.figure.bbox)) for line in self.vlines + self.hlines: line.set_visible(False) self.ellipse.set_visible(False)
python
{ "resource": "" }
q267760
PlotDialog._wait
test
def _wait(self): """Used for unittesting to make sure the plots are all done""" logger.debug("will wait for last plot to finish") self._plot_event = threading.Event() self.queue_update._wait() self.queue_replot._wait() self.queue_redraw._wait() qt_app = QtCore.QCo...
python
{ "resource": "" }
q267761
os_open
test
def os_open(document): """Open document by the default handler of the OS, could be a url opened by a browser, a text file by an editor etc""" osname = platform.system().lower() if osname == "darwin": os.system("open \"" + document + "\"") if osname == "linux": cmd = "xdg-open \"" + docum...
python
{ "resource": "" }
q267762
write_to
test
def write_to(f, mode): """Flexible writing, where f can be a filename or f object, if filename, closed after writing""" if hasattr(f, 'write'): yield f else: f = open(f, mode) yield f f.close()
python
{ "resource": "" }
q267763
_split_and_combine_mask
test
def _split_and_combine_mask(arrays): '''Combines all masks from a list of arrays, and logically ors them into a single mask''' masks = [np.ma.getmaskarray(block) for block in arrays if np.ma.isMaskedArray(block)] arrays = [block.data if np.ma.isMaskedArray(block) else block for block in arrays] mask = None if mask...
python
{ "resource": "" }
q267764
DataFrame.nop
test
def nop(self, expression, progress=False, delay=False): """Evaluates expression, and drop the result, usefull for benchmarking, since vaex is usually lazy""" expression = _ensure_string_from_expression(expression) def map(ar): pass def reduce(a, b): pass r...
python
{ "resource": "" }
q267765
DataFrame.first
test
def first(self, expression, order_expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, edges=False, progress=None): """Return the first element of a binned `expression`, where the values each bin are sorted by `order_expression`. Example: >>> import vaex ...
python
{ "resource": "" }
q267766
DataFrame.mean
test
def mean(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None, edges=False): """Calculate the mean for expression, possibly on a grid defined by binby. Example: >>> df.mean("x") -0.067131491264005971 >>> df.mean("(x**2+y**2)*...
python
{ "resource": "" }
q267767
DataFrame.sum
test
def sum(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None, edges=False): """Calculate the sum for the given expression, possible on a grid defined by binby Example: >>> df.sum("L") 304054882.49378014 >>> df.sum("L", binby=...
python
{ "resource": "" }
q267768
DataFrame.std
test
def std(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None): """Calculate the standard deviation for the given expression, possible on a grid defined by binby >>> df.std("vz") 110.31773397535071 >>> df.std("vz", binby=["(x**2+y**2)...
python
{ "resource": "" }
q267769
DataFrame.cov
test
def cov(self, x, y=None, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None): """Calculate the covariance matrix for x and y or more expressions, possibly on a grid defined by binby. Either x and y are expressions, e.g: >>> df.cov("x", "y") Or only...
python
{ "resource": "" }
q267770
DataFrame.minmax
test
def minmax(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None): """Calculate the minimum and maximum for expressions, possibly on a grid defined by binby. Example: >>> df.minmax("x") array([-128.293991, 271.365997]) >>> d...
python
{ "resource": "" }
q267771
DataFrame.min
test
def min(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None, edges=False): """Calculate the minimum for given expressions, possibly on a grid defined by binby. Example: >>> df.min("x") array(-128.293991) >>> df.min(["x", "y...
python
{ "resource": "" }
q267772
DataFrame.median_approx
test
def median_approx(self, expression, percentage=50., binby=[], limits=None, shape=default_shape, percentile_shape=256, percentile_limits="minmax", selection=False, delay=False): """Calculate the median , possibly on a grid defined by binby. NOTE: this value is approximated by calculating the cumulative ...
python
{ "resource": "" }
q267773
DataFrame.plot_widget
test
def plot_widget(self, x, y, z=None, grid=None, shape=256, limits=None, what="count(*)", figsize=None, f="identity", figure_key=None, fig=None, axes=None, xlabel=None, ylabel=None, title=None, show=True, selection=[None, True], colormap="afmhot", grid_limits=None, normalize="norma...
python
{ "resource": "" }
q267774
DataFrame.healpix_count
test
def healpix_count(self, expression=None, healpix_expression=None, healpix_max_level=12, healpix_level=8, binby=None, limits=None, shape=default_shape, delay=False, progress=None, selection=None): """Count non missing value for expression on an array which represents healpix data. :param expression: Exp...
python
{ "resource": "" }
q267775
DataFrame.healpix_plot
test
def healpix_plot(self, healpix_expression="source_id/34359738368", healpix_max_level=12, healpix_level=8, what="count(*)", selection=None, grid=None, healpix_input="equatorial", healpix_output="galactic", f=None, colormap="afmhot", grid_limits=None, image_s...
python
{ "resource": "" }
q267776
DataFrame.plot3d
test
def plot3d(self, x, y, z, vx=None, vy=None, vz=None, vwhat=None, limits=None, grid=None, what="count(*)", shape=128, selection=[None, True], f=None, vcount_limits=None, smooth_pre=None, smooth_post=None, grid_limits=None, normalize="normalize", colormap="afmhot", figure_key=...
python
{ "resource": "" }
q267777
DataFrame.dtype
test
def dtype(self, expression, internal=False): """Return the numpy dtype for the given expression, if not a column, the first row will be evaluated to get the dtype.""" expression = _ensure_string_from_expression(expression) if expression in self.variables: return np.float64(1).dtype ...
python
{ "resource": "" }
q267778
DataFrame.get_private_dir
test
def get_private_dir(self, create=False): """Each DataFrame has a directory where files are stored for metadata etc. Example >>> import vaex >>> ds = vaex.example() >>> vaex.get_private_dir() '/Users/users/breddels/.vaex/dfs/_Users_users_breddels_vaex-testing_data_helmi-...
python
{ "resource": "" }
q267779
DataFrame.state_get
test
def state_get(self): """Return the internal state of the DataFrame in a dictionary Example: >>> import vaex >>> df = vaex.from_scalars(x=1, y=2) >>> df['r'] = (df.x**2 + df.y**2)**0.5 >>> df.state_get() {'active_range': [0, 1], 'column_names': ['x', 'y',...
python
{ "resource": "" }
q267780
DataFrame.state_set
test
def state_set(self, state, use_active_range=False): """Sets the internal state of the df Example: >>> import vaex >>> df = vaex.from_scalars(x=1, y=2) >>> df # x y r 0 1 2 2.23607 >>> df['r'] = (df.x**2 + df.y**2)**0.5 >>>...
python
{ "resource": "" }
q267781
DataFrame.remove_virtual_meta
test
def remove_virtual_meta(self): """Removes the file with the virtual column etc, it does not change the current virtual columns etc.""" dir = self.get_private_dir(create=True) path = os.path.join(dir, "virtual_meta.yaml") try: if os.path.exists(path): os.remove...
python
{ "resource": "" }
q267782
DataFrame.write_virtual_meta
test
def write_virtual_meta(self): """Writes virtual columns, variables and their ucd,description and units. The default implementation is to write this to a file called virtual_meta.yaml in the directory defined by :func:`DataFrame.get_private_dir`. Other implementation may store this in the DataFr...
python
{ "resource": "" }
q267783
DataFrame.write_meta
test
def write_meta(self): """Writes all meta data, ucd,description and units The default implementation is to write this to a file called meta.yaml in the directory defined by :func:`DataFrame.get_private_dir`. Other implementation may store this in the DataFrame file itself. (For instance ...
python
{ "resource": "" }
q267784
DataFrame.subspaces
test
def subspaces(self, expressions_list=None, dimensions=None, exclude=None, **kwargs): """Generate a Subspaces object, based on a custom list of expressions or all possible combinations based on dimension :param expressions_list: list of list of expressions, where the inner list defines the subsp...
python
{ "resource": "" }
q267785
DataFrame.set_variable
test
def set_variable(self, name, expression_or_value, write=True): """Set the variable to an expression or value defined by expression_or_value. Example >>> df.set_variable("a", 2.) >>> df.set_variable("b", "a**2") >>> df.get_variable("b") 'a**2' >>> df.evaluate_var...
python
{ "resource": "" }
q267786
DataFrame.evaluate_variable
test
def evaluate_variable(self, name): """Evaluates the variable given by name.""" if isinstance(self.variables[name], six.string_types): # TODO: this does not allow more than one level deep variable, like a depends on b, b on c, c is a const value = eval(self.variables[name], expres...
python
{ "resource": "" }
q267787
DataFrame._evaluate_selection_mask
test
def _evaluate_selection_mask(self, name="default", i1=None, i2=None, selection=None, cache=False): """Internal use, ignores the filter""" i1 = i1 or 0 i2 = i2 or len(self) scope = scopes._BlockScopeSelection(self, i1, i2, selection, cache=cache) return scope.evaluate(name)
python
{ "resource": "" }
q267788
DataFrame.to_dict
test
def to_dict(self, column_names=None, selection=None, strings=True, virtual=False): """Return a dict containing the ndarray corresponding to the evaluated data :param column_names: list of column names, to export, when None DataFrame.get_column_names(strings=strings, virtual=virtual) is used :pa...
python
{ "resource": "" }
q267789
DataFrame.to_copy
test
def to_copy(self, column_names=None, selection=None, strings=True, virtual=False, selections=True): """Return a copy of the DataFrame, if selection is None, it does not copy the data, it just has a reference :param column_names: list of column names, to copy, when None DataFrame.get_column_names(string...
python
{ "resource": "" }
q267790
DataFrame.to_pandas_df
test
def to_pandas_df(self, column_names=None, selection=None, strings=True, virtual=False, index_name=None): """Return a pandas DataFrame containing the ndarray corresponding to the evaluated data If index is given, that column is used for the index of the dataframe. Example >>> df_pan...
python
{ "resource": "" }
q267791
DataFrame.to_arrow_table
test
def to_arrow_table(self, column_names=None, selection=None, strings=True, virtual=False): """Returns an arrow Table object containing the arrays corresponding to the evaluated data :param column_names: list of column names, to export, when None DataFrame.get_column_names(strings=strings, virtual=virtua...
python
{ "resource": "" }
q267792
DataFrame.to_astropy_table
test
def to_astropy_table(self, column_names=None, selection=None, strings=True, virtual=False, index=None): """Returns a astropy table object containing the ndarrays corresponding to the evaluated data :param column_names: list of column names, to export, when None DataFrame.get_column_names(strings=string...
python
{ "resource": "" }
q267793
DataFrame.add_column
test
def add_column(self, name, f_or_array): """Add an in memory array as a column.""" if isinstance(f_or_array, (np.ndarray, Column)): data = ar = f_or_array # it can be None when we have an 'empty' DataFrameArrays if self._length_original is None: self._l...
python
{ "resource": "" }
q267794
DataFrame.rename_column
test
def rename_column(self, name, new_name, unique=False, store_in_state=True): """Renames a column, not this is only the in memory name, this will not be reflected on disk""" new_name = vaex.utils.find_valid_name(new_name, used=[] if not unique else list(self)) data = self.columns.get(name) ...
python
{ "resource": "" }
q267795
DataFrame.add_virtual_columns_cartesian_to_polar
test
def add_virtual_columns_cartesian_to_polar(self, x="x", y="y", radius_out="r_polar", azimuth_out="phi_polar", propagate_uncertainties=False, radians=False): """Convert cartesian to polar coordinates :param x: ...
python
{ "resource": "" }
q267796
DataFrame.add_virtual_columns_cartesian_velocities_to_spherical
test
def add_virtual_columns_cartesian_velocities_to_spherical(self, x="x", y="y", z="z", vx="vx", vy="vy", vz="vz", vr="vr", vlong="vlong", vlat="vlat", distance=None): """Concert velocities from a cartesian to a spherical coordinate system TODO: errors :param x: name of x column (input) :...
python
{ "resource": "" }
q267797
DataFrame.add_virtual_columns_cartesian_velocities_to_polar
test
def add_virtual_columns_cartesian_velocities_to_polar(self, x="x", y="y", vx="vx", radius_polar=None, vy="vy", vr_out="vr_polar", vazimuth_out="vphi_polar", propagate_uncertainties=False,): """Convert cartesian to polar velocities. :param x: ...
python
{ "resource": "" }
q267798
DataFrame.add_virtual_columns_polar_velocities_to_cartesian
test
def add_virtual_columns_polar_velocities_to_cartesian(self, x='x', y='y', azimuth=None, vr='vr_polar', vazimuth='vphi_polar', vx_out='vx', vy_out='vy', propagate_uncertainties=False): """ Convert cylindrical polar velocities to Cartesian. :param x: :param y: :param azimuth: Optional exp...
python
{ "resource": "" }
q267799
DataFrame.add_virtual_columns_rotation
test
def add_virtual_columns_rotation(self, x, y, xnew, ynew, angle_degrees, propagate_uncertainties=False): """Rotation in 2d. :param str x: Name/expression of x column :param str y: idem for y :param str xnew: name of transformed x column :param str ynew: :param float angle...
python
{ "resource": "" }