body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def __init__(self, zvar, key):
'Create a Hyperslice\n\n @param zvar: zVariable that this slices\n @type zvar: :py:class:`pycdf.Var`\n @param key: Python multi-dimensional slice as passed to\n __getitem__\n @type key: tuple of slice and/or int\n @raise IndexError... | -3,304,340,210,359,956,500 | Create a Hyperslice
@param zvar: zVariable that this slices
@type zvar: :py:class:`pycdf.Var`
@param key: Python multi-dimensional slice as passed to
__getitem__
@type key: tuple of slice and/or int
@raise IndexError: if slice is out of range, mismatches dimensions, or
otherwise unparsab... | pycdf/__init__.py | __init__ | cpiker/condaCDF | python | def __init__(self, zvar, key):
'Create a Hyperslice\n\n @param zvar: zVariable that this slices\n @type zvar: :py:class:`pycdf.Var`\n @param key: Python multi-dimensional slice as passed to\n __getitem__\n @type key: tuple of slice and/or int\n @raise IndexError... |
def expected_dims(self, data=None):
'Calculate size of non-degenerate dimensions\n\n Figures out size, in each dimension, of expected input data\n\n @return: size of each dimension for this slice, excluding degenerate\n @rtype: list of int\n '
return [self.counts[i] for i in range(se... | -5,050,537,631,013,452,000 | Calculate size of non-degenerate dimensions
Figures out size, in each dimension, of expected input data
@return: size of each dimension for this slice, excluding degenerate
@rtype: list of int | pycdf/__init__.py | expected_dims | cpiker/condaCDF | python | def expected_dims(self, data=None):
'Calculate size of non-degenerate dimensions\n\n Figures out size, in each dimension, of expected input data\n\n @return: size of each dimension for this slice, excluding degenerate\n @rtype: list of int\n '
return [self.counts[i] for i in range(se... |
def expand(self, data):
"Expands the record dimension of this slice to hold a set of data\n\n If the length of data (outermost dimension) is larger than the record\n count (counts[0]) for this slice, expand the slice to hold all the data.\n This requires that the record dimension of the slice n... | 3,023,531,243,950,046,000 | Expands the record dimension of this slice to hold a set of data
If the length of data (outermost dimension) is larger than the record
count (counts[0]) for this slice, expand the slice to hold all the data.
This requires that the record dimension of the slice not be degenerate,
and also that it not have been complete... | pycdf/__init__.py | expand | cpiker/condaCDF | python | def expand(self, data):
"Expands the record dimension of this slice to hold a set of data\n\n If the length of data (outermost dimension) is larger than the record\n count (counts[0]) for this slice, expand the slice to hold all the data.\n This requires that the record dimension of the slice n... |
def create_array(self):
'Creates a numpy array to hold the data from this slice\n\n Returns\n =======\n out : numpy.array\n array sized, typed, and dimensioned to hold data from\n this slice\n '
counts = self.counts
degen = self.degen
if self.column:
... | -6,894,357,864,719,320,000 | Creates a numpy array to hold the data from this slice
Returns
=======
out : numpy.array
array sized, typed, and dimensioned to hold data from
this slice | pycdf/__init__.py | create_array | cpiker/condaCDF | python | def create_array(self):
'Creates a numpy array to hold the data from this slice\n\n Returns\n =======\n out : numpy.array\n array sized, typed, and dimensioned to hold data from\n this slice\n '
counts = self.counts
degen = self.degen
if self.column:
... |
def convert_input_array(self, buffer):
'Converts a buffer of raw data from this slice\n\n EPOCH(16) variables always need to be converted.\n CHAR need converted to Unicode if py3k\n\n Parameters\n ==========\n buffer : numpy.array\n data as read from the CDF file\n\n ... | 3,856,380,486,523,786,000 | Converts a buffer of raw data from this slice
EPOCH(16) variables always need to be converted.
CHAR need converted to Unicode if py3k
Parameters
==========
buffer : numpy.array
data as read from the CDF file
Returns
=======
out : numpy.array
converted data | pycdf/__init__.py | convert_input_array | cpiker/condaCDF | python | def convert_input_array(self, buffer):
'Converts a buffer of raw data from this slice\n\n EPOCH(16) variables always need to be converted.\n CHAR need converted to Unicode if py3k\n\n Parameters\n ==========\n buffer : numpy.array\n data as read from the CDF file\n\n ... |
def convert_output_array(self, buffer):
'Convert a buffer of data that will go into this slice\n \n Parameters\n ==========\n buffer : numpy.array\n data to go into the CDF file\n\n Returns\n =======\n out : numpy.array\n input with majority flipped an... | -1,402,077,456,776,283,000 | Convert a buffer of data that will go into this slice
Parameters
==========
buffer : numpy.array
data to go into the CDF file
Returns
=======
out : numpy.array
input with majority flipped and dimensions reversed to be
suitable to pass directly to CDF library. | pycdf/__init__.py | convert_output_array | cpiker/condaCDF | python | def convert_output_array(self, buffer):
'Convert a buffer of data that will go into this slice\n \n Parameters\n ==========\n buffer : numpy.array\n data to go into the CDF file\n\n Returns\n =======\n out : numpy.array\n input with majority flipped an... |
def _flip_array(self, data):
'\n Operations for majority, etc. common between convert_input and _output\n '
cdftype = self.zvar.type()
if (self.column and (not min(self.degen))):
if self.degen[0]:
if (cdftype == const.CDF_EPOCH16.value):
data = data.transpos... | 4,481,637,856,396,805,600 | Operations for majority, etc. common between convert_input and _output | pycdf/__init__.py | _flip_array | cpiker/condaCDF | python | def _flip_array(self, data):
'\n \n '
cdftype = self.zvar.type()
if (self.column and (not min(self.degen))):
if self.degen[0]:
if (cdftype == const.CDF_EPOCH16.value):
data = data.transpose((list(range((len(data.shape) - 2), 0, (- 1))) + [(len(data.shape) - ... |
def select(self):
'Selects this hyperslice in the CDF\n\n Calls the CDF library to select the CDF, variable, records, and\n array elements corresponding to this slice.\n '
args = (const.SELECT_, const.zVAR_RECNUMBER_, ctypes.c_long(self.starts[0]), const.SELECT_, const.zVAR_RECCOUNT_, ctype... | 4,518,925,746,976,599,000 | Selects this hyperslice in the CDF
Calls the CDF library to select the CDF, variable, records, and
array elements corresponding to this slice. | pycdf/__init__.py | select | cpiker/condaCDF | python | def select(self):
'Selects this hyperslice in the CDF\n\n Calls the CDF library to select the CDF, variable, records, and\n array elements corresponding to this slice.\n '
args = (const.SELECT_, const.zVAR_RECNUMBER_, ctypes.c_long(self.starts[0]), const.SELECT_, const.zVAR_RECCOUNT_, ctype... |
@staticmethod
def expand_ellipsis(slices, n_dims):
'Expands any ellipses into correct number of full-size slices\n\n @param slices: tuple of slices, integers, or ellipse objects\n @type slices: tuple\n @param n_dims: number of dimensions this slice is over\n @type n_dims: int\n @r... | 8,211,416,177,040,501,000 | Expands any ellipses into correct number of full-size slices
@param slices: tuple of slices, integers, or ellipse objects
@type slices: tuple
@param n_dims: number of dimensions this slice is over
@type n_dims: int
@return: L{slices} with ellipses replaced by appropriate number of
full-dimension slices
@rtype... | pycdf/__init__.py | expand_ellipsis | cpiker/condaCDF | python | @staticmethod
def expand_ellipsis(slices, n_dims):
'Expands any ellipses into correct number of full-size slices\n\n @param slices: tuple of slices, integers, or ellipse objects\n @type slices: tuple\n @param n_dims: number of dimensions this slice is over\n @type n_dims: int\n @r... |
@staticmethod
def check_well_formed(data):
'Checks if input data is well-formed, regular array'
d = numpy.asanyarray(data)
if (d.dtype == numpy.object):
try:
len(d.flat[0])
except TypeError:
pass
else:
raise ValueError('Data must be well-formed, re... | -5,000,262,813,788,040,000 | Checks if input data is well-formed, regular array | pycdf/__init__.py | check_well_formed | cpiker/condaCDF | python | @staticmethod
def check_well_formed(data):
d = numpy.asanyarray(data)
if (d.dtype == numpy.object):
try:
len(d.flat[0])
except TypeError:
pass
else:
raise ValueError('Data must be well-formed, regular array of number, string, or datetime') |
@staticmethod
def dimensions(data):
'Finds the dimensions of a nested list-of-lists\n\n @param data: data of which dimensions are desired\n @type data: list (of lists)\n @return: dimensions of L{data}, in order outside-in\n @rtype: list of int\n @raise ValueError: if L{data} has i... | 1,178,304,907,912,685,000 | Finds the dimensions of a nested list-of-lists
@param data: data of which dimensions are desired
@type data: list (of lists)
@return: dimensions of L{data}, in order outside-in
@rtype: list of int
@raise ValueError: if L{data} has irregular dimensions | pycdf/__init__.py | dimensions | cpiker/condaCDF | python | @staticmethod
def dimensions(data):
'Finds the dimensions of a nested list-of-lists\n\n @param data: data of which dimensions are desired\n @type data: list (of lists)\n @return: dimensions of L{data}, in order outside-in\n @rtype: list of int\n @raise ValueError: if L{data} has i... |
@staticmethod
def types(data, backward=False):
'Find dimensions and valid types of a nested list-of-lists\n\n Any given data may be representable by a range of CDF types; infer\n the CDF types which can represent this data. This breaks down to:\n 1. Proper kind (numerical, string, time)\n ... | 8,817,305,071,486,589,000 | Find dimensions and valid types of a nested list-of-lists
Any given data may be representable by a range of CDF types; infer
the CDF types which can represent this data. This breaks down to:
1. Proper kind (numerical, string, time)
2. Proper range (stores highest and lowest number)
3. Sufficient resolution (EPOC... | pycdf/__init__.py | types | cpiker/condaCDF | python | @staticmethod
def types(data, backward=False):
'Find dimensions and valid types of a nested list-of-lists\n\n Any given data may be representable by a range of CDF types; infer\n the CDF types which can represent this data. This breaks down to:\n 1. Proper kind (numerical, string, time)\n ... |
@staticmethod
def reorder(seq):
'Reorders seq to switch array majority\n\n Used to take an array of subscripts between row\n and column majority. First element is not touched,\n being the record number.\n\n @param seq: a sequence of *subscripts*\n @type seq: sequence of integers\n... | 8,341,042,401,191,011,000 | Reorders seq to switch array majority
Used to take an array of subscripts between row
and column majority. First element is not touched,
being the record number.
@param seq: a sequence of *subscripts*
@type seq: sequence of integers
@return: seq with all but element 0 reversed in order
@rtype: sequence of integers | pycdf/__init__.py | reorder | cpiker/condaCDF | python | @staticmethod
def reorder(seq):
'Reorders seq to switch array majority\n\n Used to take an array of subscripts between row\n and column majority. First element is not touched,\n being the record number.\n\n @param seq: a sequence of *subscripts*\n @type seq: sequence of integers\n... |
@staticmethod
def convert_range(start, stop, step, size):
'Converts a start/stop/step range to start/count/interval\n\n (i.e. changes from Python-style slice to CDF-style)\n @param start: index to start a slice at, may be none or negative\n @type start: int\n @param stop: index at end of... | 435,904,559,742,375,740 | Converts a start/stop/step range to start/count/interval
(i.e. changes from Python-style slice to CDF-style)
@param start: index to start a slice at, may be none or negative
@type start: int
@param stop: index at end of slice (one-past, standard Python),
may be none or negative
@type stop: int
@param step... | pycdf/__init__.py | convert_range | cpiker/condaCDF | python | @staticmethod
def convert_range(start, stop, step, size):
'Converts a start/stop/step range to start/count/interval\n\n (i.e. changes from Python-style slice to CDF-style)\n @param start: index to start a slice at, may be none or negative\n @type start: int\n @param stop: index at end of... |
def __init__(self, cdf_file, attr_name, create=False):
'Initialize this attribute\n\n @param cdf_file: CDF file containing this attribute\n @type cdf_file: :py:class:`pycdf.CDF`\n @param attr_name: Name of this attribute\n @type attr_name: str\n @param create: True to create attri... | -2,708,256,634,244,691,500 | Initialize this attribute
@param cdf_file: CDF file containing this attribute
@type cdf_file: :py:class:`pycdf.CDF`
@param attr_name: Name of this attribute
@type attr_name: str
@param create: True to create attribute, False to look up existing.
@type create: bool | pycdf/__init__.py | __init__ | cpiker/condaCDF | python | def __init__(self, cdf_file, attr_name, create=False):
'Initialize this attribute\n\n @param cdf_file: CDF file containing this attribute\n @type cdf_file: :py:class:`pycdf.CDF`\n @param attr_name: Name of this attribute\n @type attr_name: str\n @param create: True to create attri... |
def __getitem__(self, key):
'Return a slice of Entries.\n\n Because Attributes may be sparse, a multi-element slice will return\n None for those elements which do not have associated Entries.\n\n @param key: index or range of Entry number to return\n @type key: slice or int\n @ret... | 1,325,622,620,025,109,200 | Return a slice of Entries.
Because Attributes may be sparse, a multi-element slice will return
None for those elements which do not have associated Entries.
@param key: index or range of Entry number to return
@type key: slice or int
@return: a list of entries, appropriate type.
@raise IndexError: if L{key} is an int... | pycdf/__init__.py | __getitem__ | cpiker/condaCDF | python | def __getitem__(self, key):
'Return a slice of Entries.\n\n Because Attributes may be sparse, a multi-element slice will return\n None for those elements which do not have associated Entries.\n\n @param key: index or range of Entry number to return\n @type key: slice or int\n @ret... |
def _check_other_entries(self, types):
"Try to get the type of this entry from others in the Attribute\n\n For zAttrs, checks if all other Entries are the same type, and at\n least one doesn't match its zVar, i.e. Entry type dominates (otherwise\n assumption is the Var type dominates).\n\n ... | 2,458,194,628,741,711,400 | Try to get the type of this entry from others in the Attribute
For zAttrs, checks if all other Entries are the same type, and at
least one doesn't match its zVar, i.e. Entry type dominates (otherwise
assumption is the Var type dominates).
For gAttrs, checks all other Entries, and gives priority to the
one that's earl... | pycdf/__init__.py | _check_other_entries | cpiker/condaCDF | python | def _check_other_entries(self, types):
"Try to get the type of this entry from others in the Attribute\n\n For zAttrs, checks if all other Entries are the same type, and at\n least one doesn't match its zVar, i.e. Entry type dominates (otherwise\n assumption is the Var type dominates).\n\n ... |
def __setitem__(self, key, data):
"Set a slice of Entries.\n\n @param key: index or range of Entry numbers to set\n @type key: slice or int\n @param data: the data to set these entries to. Normally each entry should\n be a sequence; if a scalar is provided, it is treated\n as a si... | 7,629,561,312,053,855,000 | Set a slice of Entries.
@param key: index or range of Entry numbers to set
@type key: slice or int
@param data: the data to set these entries to. Normally each entry should
be a sequence; if a scalar is provided, it is treated
as a single-element list.
@type data: scalar or list
@raise ValueError: if size of {data} do... | pycdf/__init__.py | __setitem__ | cpiker/condaCDF | python | def __setitem__(self, key, data):
"Set a slice of Entries.\n\n @param key: index or range of Entry numbers to set\n @type key: slice or int\n @param data: the data to set these entries to. Normally each entry should\n be a sequence; if a scalar is provided, it is treated\n as a si... |
def __delitem__(self, key):
"Delete a slice of Entries.\n\n @param key: index or range of Entry numbers to delete\n @type key: slice or int\n @note: Attributes do not 'grow' or 'shrink' as entries are added\n or removed. Indexes of entries never change and there is no\n ... | -6,487,788,381,629,699,000 | Delete a slice of Entries.
@param key: index or range of Entry numbers to delete
@type key: slice or int
@note: Attributes do not 'grow' or 'shrink' as entries are added
or removed. Indexes of entries never change and there is no
way to 'insert'. | pycdf/__init__.py | __delitem__ | cpiker/condaCDF | python | def __delitem__(self, key):
"Delete a slice of Entries.\n\n @param key: index or range of Entry numbers to delete\n @type key: slice or int\n @note: Attributes do not 'grow' or 'shrink' as entries are added\n or removed. Indexes of entries never change and there is no\n ... |
def __iter__(self, current=0):
'Iterates over all entries in this Attribute\n\n Returns data from one entry at a time until reaches the end.\n @note: Returned in entry-number order.\n '
while (current <= self.max_idx()):
if self.has_entry(current):
value = (yield self._g... | 1,073,632,310,754,900,200 | Iterates over all entries in this Attribute
Returns data from one entry at a time until reaches the end.
@note: Returned in entry-number order. | pycdf/__init__.py | __iter__ | cpiker/condaCDF | python | def __iter__(self, current=0):
'Iterates over all entries in this Attribute\n\n Returns data from one entry at a time until reaches the end.\n @note: Returned in entry-number order.\n '
while (current <= self.max_idx()):
if self.has_entry(current):
value = (yield self._g... |
def __reversed__(self, current=None):
'Iterates over all entries in this Attribute\n\n Returns data from one entry at a time, starting at end and going\n to beginning.\n @note: Returned in entry-number order.\n '
if (current is None):
current = self.max_idx()
while (curre... | -2,169,726,939,541,378,600 | Iterates over all entries in this Attribute
Returns data from one entry at a time, starting at end and going
to beginning.
@note: Returned in entry-number order. | pycdf/__init__.py | __reversed__ | cpiker/condaCDF | python | def __reversed__(self, current=None):
'Iterates over all entries in this Attribute\n\n Returns data from one entry at a time, starting at end and going\n to beginning.\n @note: Returned in entry-number order.\n '
if (current is None):
current = self.max_idx()
while (curre... |
def __len__(self):
'Number of Entries for this Attr. NOT same as max Entry number.\n\n @return: Number of Entries\n @rtype: int\n '
count = ctypes.c_long(0)
self._call(const.GET_, self.ATTR_NUMENTRIES_, ctypes.byref(count))
return count.value | -6,313,870,335,240,138,000 | Number of Entries for this Attr. NOT same as max Entry number.
@return: Number of Entries
@rtype: int | pycdf/__init__.py | __len__ | cpiker/condaCDF | python | def __len__(self):
'Number of Entries for this Attr. NOT same as max Entry number.\n\n @return: Number of Entries\n @rtype: int\n '
count = ctypes.c_long(0)
self._call(const.GET_, self.ATTR_NUMENTRIES_, ctypes.byref(count))
return count.value |
def __repr__(self):
"Returns representation of an attribute\n\n Cannot return anything that can be eval'd to create a copy of the\n attribtute, so just wrap the informal representation in angle brackets.\n @return: all the data in this attribute\n @rtype: str\n "
return (('<\n... | -2,361,089,892,419,540,000 | Returns representation of an attribute
Cannot return anything that can be eval'd to create a copy of the
attribtute, so just wrap the informal representation in angle brackets.
@return: all the data in this attribute
@rtype: str | pycdf/__init__.py | __repr__ | cpiker/condaCDF | python | def __repr__(self):
"Returns representation of an attribute\n\n Cannot return anything that can be eval'd to create a copy of the\n attribtute, so just wrap the informal representation in angle brackets.\n @return: all the data in this attribute\n @rtype: str\n "
return (('<\n... |
def __str__(self):
"Returns a string representation of the attribute\n\n This is an 'informal' representation in that it cannot be evaluated\n directly to create an L{Attr}.\n\n @return: all the data in this attribute\n @rtype: str\n "
if self._cdf_file._opened:
return... | 3,565,218,746,426,250,000 | Returns a string representation of the attribute
This is an 'informal' representation in that it cannot be evaluated
directly to create an L{Attr}.
@return: all the data in this attribute
@rtype: str | pycdf/__init__.py | __str__ | cpiker/condaCDF | python | def __str__(self):
"Returns a string representation of the attribute\n\n This is an 'informal' representation in that it cannot be evaluated\n directly to create an L{Attr}.\n\n @return: all the data in this attribute\n @rtype: str\n "
if self._cdf_file._opened:
return... |
def insert(self, index, data):
'Insert an entry at a particular number\n\n Inserts entry at particular number while moving all subsequent\n entries to one entry number later. Does not close gaps.\n\n Parameters\n ==========\n index : int\n index where to put the new ent... | -8,328,695,212,667,859,000 | Insert an entry at a particular number
Inserts entry at particular number while moving all subsequent
entries to one entry number later. Does not close gaps.
Parameters
==========
index : int
index where to put the new entry
data :
data for the new entry | pycdf/__init__.py | insert | cpiker/condaCDF | python | def insert(self, index, data):
'Insert an entry at a particular number\n\n Inserts entry at particular number while moving all subsequent\n entries to one entry number later. Does not close gaps.\n\n Parameters\n ==========\n index : int\n index where to put the new ent... |
def append(self, data):
'Add an entry to end of attribute\n\n Puts entry after last defined entry (does not fill gaps)\n\n Parameters\n ==========\n data : \n data for the new entry\n '
self[(self.max_idx() + 1)] = data | 4,686,148,227,598,398,000 | Add an entry to end of attribute
Puts entry after last defined entry (does not fill gaps)
Parameters
==========
data :
data for the new entry | pycdf/__init__.py | append | cpiker/condaCDF | python | def append(self, data):
'Add an entry to end of attribute\n\n Puts entry after last defined entry (does not fill gaps)\n\n Parameters\n ==========\n data : \n data for the new entry\n '
self[(self.max_idx() + 1)] = data |
def _call(self, *args, **kwargs):
'Select this CDF and Attr and call the CDF internal interface\n\n @param args: Passed directly to the CDF library interface.\n @type args: various, see :py:mod:`ctypes`.\n @return: CDF status from the library\n @rtype: ctypes.c_long\n @note: Termi... | 6,537,549,419,326,152,000 | Select this CDF and Attr and call the CDF internal interface
@param args: Passed directly to the CDF library interface.
@type args: various, see :py:mod:`ctypes`.
@return: CDF status from the library
@rtype: ctypes.c_long
@note: Terminal NULL_ is automatically added to L{args}.
@raise CDFError: if CDF library reports ... | pycdf/__init__.py | _call | cpiker/condaCDF | python | def _call(self, *args, **kwargs):
'Select this CDF and Attr and call the CDF internal interface\n\n @param args: Passed directly to the CDF library interface.\n @type args: various, see :py:mod:`ctypes`.\n @return: CDF status from the library\n @rtype: ctypes.c_long\n @note: Termi... |
def _entry_len(self, number):
'Number of elements in an Entry\n\n @param number: number of Entry\n @type number: int\n @return: number of elements\n @rtype: int\n '
if (not self.has_entry(number)):
raise IndexError((('list index ' + str(number)) + ' out of range.'))
... | -6,886,153,673,019,426,000 | Number of elements in an Entry
@param number: number of Entry
@type number: int
@return: number of elements
@rtype: int | pycdf/__init__.py | _entry_len | cpiker/condaCDF | python | def _entry_len(self, number):
'Number of elements in an Entry\n\n @param number: number of Entry\n @type number: int\n @return: number of elements\n @rtype: int\n '
if (not self.has_entry(number)):
raise IndexError((('list index ' + str(number)) + ' out of range.'))
... |
def type(self, number, new_type=None):
"Find or change the CDF type of a particular Entry number\n\n Parameters\n ==========\n number : int\n number of Entry to check or change\n\n Other Parameters\n ================\n new_type\n type to change this En... | 7,315,560,073,932,372,000 | Find or change the CDF type of a particular Entry number
Parameters
==========
number : int
number of Entry to check or change
Other Parameters
================
new_type
type to change this Entry to, from :mod:`~pycdf.const`.
Omit to only check type.
Returns
=======
out : int
CDF variable type, see :... | pycdf/__init__.py | type | cpiker/condaCDF | python | def type(self, number, new_type=None):
"Find or change the CDF type of a particular Entry number\n\n Parameters\n ==========\n number : int\n number of Entry to check or change\n\n Other Parameters\n ================\n new_type\n type to change this En... |
def has_entry(self, number):
'Check if this attribute has a particular Entry number\n\n Parameters\n ==========\n number : int\n number of Entry to check or change\n\n Returns\n =======\n out : bool\n True if ``number`` is a valid entry number; False i... | 9,026,472,186,154,819,000 | Check if this attribute has a particular Entry number
Parameters
==========
number : int
number of Entry to check or change
Returns
=======
out : bool
True if ``number`` is a valid entry number; False if not | pycdf/__init__.py | has_entry | cpiker/condaCDF | python | def has_entry(self, number):
'Check if this attribute has a particular Entry number\n\n Parameters\n ==========\n number : int\n number of Entry to check or change\n\n Returns\n =======\n out : bool\n True if ``number`` is a valid entry number; False i... |
def max_idx(self):
'Maximum index of Entries for this Attr\n\n Returns\n =======\n out : int\n maximum Entry number\n '
count = ctypes.c_long(0)
self._call(const.GET_, self.ATTR_MAXENTRY_, ctypes.byref(count))
return count.value | 8,873,607,757,283,282,000 | Maximum index of Entries for this Attr
Returns
=======
out : int
maximum Entry number | pycdf/__init__.py | max_idx | cpiker/condaCDF | python | def max_idx(self):
'Maximum index of Entries for this Attr\n\n Returns\n =======\n out : int\n maximum Entry number\n '
count = ctypes.c_long(0)
self._call(const.GET_, self.ATTR_MAXENTRY_, ctypes.byref(count))
return count.value |
def new(self, data, type=None, number=None):
'Create a new Entry in this Attribute\n\n .. note:: If ``number`` is provided and an Entry with that number\n already exists, it will be overwritten.\n\n Parameters\n ==========\n data\n data to put in the Entry\n\n... | 658,827,983,585,143,700 | Create a new Entry in this Attribute
.. note:: If ``number`` is provided and an Entry with that number
already exists, it will be overwritten.
Parameters
==========
data
data to put in the Entry
Other Parameters
================
type : int
type of the new Entry, from :mod:`~pycdf.const`
(otherw... | pycdf/__init__.py | new | cpiker/condaCDF | python | def new(self, data, type=None, number=None):
'Create a new Entry in this Attribute\n\n .. note:: If ``number`` is provided and an Entry with that number\n already exists, it will be overwritten.\n\n Parameters\n ==========\n data\n data to put in the Entry\n\n... |
def number(self):
'Find the attribute number for this attribute\n\n Returns\n =======\n out : int\n attribute number\n '
no = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.ATTR_NUMBER_, self._name, ctypes.byref(no))
return no.value | 8,211,779,153,915,523,000 | Find the attribute number for this attribute
Returns
=======
out : int
attribute number | pycdf/__init__.py | number | cpiker/condaCDF | python | def number(self):
'Find the attribute number for this attribute\n\n Returns\n =======\n out : int\n attribute number\n '
no = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.ATTR_NUMBER_, self._name, ctypes.byref(no))
return no.value |
def global_scope(self):
'Determine scope of this attribute.\n\n Returns\n =======\n out : bool\n True if global (i.e. gAttr), False if zAttr\n '
return self._cdf_file.attr_num(self._name)[1] | -504,907,318,242,927,500 | Determine scope of this attribute.
Returns
=======
out : bool
True if global (i.e. gAttr), False if zAttr | pycdf/__init__.py | global_scope | cpiker/condaCDF | python | def global_scope(self):
'Determine scope of this attribute.\n\n Returns\n =======\n out : bool\n True if global (i.e. gAttr), False if zAttr\n '
return self._cdf_file.attr_num(self._name)[1] |
def rename(self, new_name):
'Rename this attribute\n\n Renaming a zAttribute renames it for *all* zVariables in this CDF!\n\n Parameters\n ==========\n new_name : str\n the new name of the attribute\n '
try:
enc_name = new_name.encode('ascii')
except At... | -8,552,523,158,711,291,000 | Rename this attribute
Renaming a zAttribute renames it for *all* zVariables in this CDF!
Parameters
==========
new_name : str
the new name of the attribute | pycdf/__init__.py | rename | cpiker/condaCDF | python | def rename(self, new_name):
'Rename this attribute\n\n Renaming a zAttribute renames it for *all* zVariables in this CDF!\n\n Parameters\n ==========\n new_name : str\n the new name of the attribute\n '
try:
enc_name = new_name.encode('ascii')
except At... |
def _get_entry(self, number):
'Read an Entry associated with this L{Attr}\n\n @param number: number of Entry to return\n @type number: int\n @return: data from entry numbered L{number}\n @rtype: list or str\n '
if (not self.has_entry(number)):
raise IndexError((('list ... | -45,498,371,164,057,220 | Read an Entry associated with this L{Attr}
@param number: number of Entry to return
@type number: int
@return: data from entry numbered L{number}
@rtype: list or str | pycdf/__init__.py | _get_entry | cpiker/condaCDF | python | def _get_entry(self, number):
'Read an Entry associated with this L{Attr}\n\n @param number: number of Entry to return\n @type number: int\n @return: data from entry numbered L{number}\n @rtype: list or str\n '
if (not self.has_entry(number)):
raise IndexError((('list ... |
def _write_entry(self, number, data, cdf_type, dims, elements):
'Write an Entry to this Attr.\n\n @param number: number of Entry to write\n @type number: int\n @param data: data to write\n @param cdf_type: the CDF type to write, from :py:mod:`pycdf.const`\n @param dims: dimensions... | 6,380,333,655,318,013,000 | Write an Entry to this Attr.
@param number: number of Entry to write
@type number: int
@param data: data to write
@param cdf_type: the CDF type to write, from :py:mod:`pycdf.const`
@param dims: dimensions of L{data}
@type dims: list
@param elements: number of elements in L{data}, 1 unless it is a string
@type elements... | pycdf/__init__.py | _write_entry | cpiker/condaCDF | python | def _write_entry(self, number, data, cdf_type, dims, elements):
'Write an Entry to this Attr.\n\n @param number: number of Entry to write\n @type number: int\n @param data: data to write\n @param cdf_type: the CDF type to write, from :py:mod:`pycdf.const`\n @param dims: dimensions... |
def _delete(self):
'Delete this Attribute\n\n Also deletes all Entries associated with it.\n '
self._call(const.DELETE_, const.ATTR_)
self._cdf_file.clear_attr_from_cache(self._name)
self._name = None | 9,112,160,062,937,282,000 | Delete this Attribute
Also deletes all Entries associated with it. | pycdf/__init__.py | _delete | cpiker/condaCDF | python | def _delete(self):
'Delete this Attribute\n\n Also deletes all Entries associated with it.\n '
self._call(const.DELETE_, const.ATTR_)
self._cdf_file.clear_attr_from_cache(self._name)
self._name = None |
def insert(self, index, data):
'Insert entry at particular index number\n\n Since there can only be one zEntry per zAttr, this cannot be\n implemented.\n\n Raises\n ======\n NotImplementedError : always\n '
raise NotImplementedError | -741,755,126,920,673,400 | Insert entry at particular index number
Since there can only be one zEntry per zAttr, this cannot be
implemented.
Raises
======
NotImplementedError : always | pycdf/__init__.py | insert | cpiker/condaCDF | python | def insert(self, index, data):
'Insert entry at particular index number\n\n Since there can only be one zEntry per zAttr, this cannot be\n implemented.\n\n Raises\n ======\n NotImplementedError : always\n '
raise NotImplementedError |
def append(self, index, data):
'Add entry to end of attribute list\n\n Since there can only be one zEntry per zAttr, this cannot be\n implemented.\n\n Raises\n ======\n NotImplementedError : always\n '
raise NotImplementedError | -5,759,425,197,374,058,000 | Add entry to end of attribute list
Since there can only be one zEntry per zAttr, this cannot be
implemented.
Raises
======
NotImplementedError : always | pycdf/__init__.py | append | cpiker/condaCDF | python | def append(self, index, data):
'Add entry to end of attribute list\n\n Since there can only be one zEntry per zAttr, this cannot be\n implemented.\n\n Raises\n ======\n NotImplementedError : always\n '
raise NotImplementedError |
def __init__(self, cdf_file, special_entry=None):
'Initialize the attribute collection\n\n @param cdf_file: CDF these attributes are in\n @type cdf_file: :py:class:`pycdf.CDF`\n @param special_entry: callable which returns a "special" entry number,\n used to limit results for zAttrs to t... | 8,878,471,010,203,278,000 | Initialize the attribute collection
@param cdf_file: CDF these attributes are in
@type cdf_file: :py:class:`pycdf.CDF`
@param special_entry: callable which returns a "special" entry number,
used to limit results for zAttrs to those which match the zVar
(i.e. the var number)
@type special_entry: callable | pycdf/__init__.py | __init__ | cpiker/condaCDF | python | def __init__(self, cdf_file, special_entry=None):
'Initialize the attribute collection\n\n @param cdf_file: CDF these attributes are in\n @type cdf_file: :py:class:`pycdf.CDF`\n @param special_entry: callable which returns a "special" entry number,\n used to limit results for zAttrs to t... |
def __getitem__(self, name):
'Find an Attribute by name\n\n @param name: name of the Attribute to return\n @type name: str\n @return: attribute named L{name}\n @rtype: L{Attr}\n @raise KeyError: if there is no attribute named L{name}\n @raise CDFError: other errors in CDF l... | 9,057,941,628,773,863,000 | Find an Attribute by name
@param name: name of the Attribute to return
@type name: str
@return: attribute named L{name}
@rtype: L{Attr}
@raise KeyError: if there is no attribute named L{name}
@raise CDFError: other errors in CDF library | pycdf/__init__.py | __getitem__ | cpiker/condaCDF | python | def __getitem__(self, name):
'Find an Attribute by name\n\n @param name: name of the Attribute to return\n @type name: str\n @return: attribute named L{name}\n @rtype: L{Attr}\n @raise KeyError: if there is no attribute named L{name}\n @raise CDFError: other errors in CDF l... |
def __setitem__(self, name, data):
'Create an Attribute or change its entries\n\n @param name: name of Attribute to change\n @type name: str\n @param data: Entries to populate this Attribute with.\n Any existing Entries will be deleted!\n Another C{Attr} ... | -6,857,911,443,514,409,000 | Create an Attribute or change its entries
@param name: name of Attribute to change
@type name: str
@param data: Entries to populate this Attribute with.
Any existing Entries will be deleted!
Another C{Attr} may be specified, in which
case all its entries are copied.
@type data: s... | pycdf/__init__.py | __setitem__ | cpiker/condaCDF | python | def __setitem__(self, name, data):
'Create an Attribute or change its entries\n\n @param name: name of Attribute to change\n @type name: str\n @param data: Entries to populate this Attribute with.\n Any existing Entries will be deleted!\n Another C{Attr} ... |
def __delitem__(self, name):
'Delete an Attribute (and all its entries)\n\n @param name: name of Attribute to delete\n @type name: str\n '
try:
attr = self.AttrType(self._cdf_file, name)
except CDFError:
(t, v, tb) = sys.exc_info()
if (v.status == const.NO_SUCH_A... | 8,571,057,697,993,914,000 | Delete an Attribute (and all its entries)
@param name: name of Attribute to delete
@type name: str | pycdf/__init__.py | __delitem__ | cpiker/condaCDF | python | def __delitem__(self, name):
'Delete an Attribute (and all its entries)\n\n @param name: name of Attribute to delete\n @type name: str\n '
try:
attr = self.AttrType(self._cdf_file, name)
except CDFError:
(t, v, tb) = sys.exc_info()
if (v.status == const.NO_SUCH_A... |
def __iter__(self, current=0):
'Iterates over all Attr in this CDF or variable\n\n Returns name of one L{Attr} at a time until reaches the end.\n @note: Returned in number order.\n '
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMATTRS_, ctypes.byref(count))
... | 4,581,430,574,521,517,600 | Iterates over all Attr in this CDF or variable
Returns name of one L{Attr} at a time until reaches the end.
@note: Returned in number order. | pycdf/__init__.py | __iter__ | cpiker/condaCDF | python | def __iter__(self, current=0):
'Iterates over all Attr in this CDF or variable\n\n Returns name of one L{Attr} at a time until reaches the end.\n @note: Returned in number order.\n '
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMATTRS_, ctypes.byref(count))
... |
def __repr__(self):
"Returns representation of attribute list\n\n Cannot return anything that can be eval'd to create a copy of the\n list, so just wrap the informal representation in angle brackets.\n @return: all the data in this list of attributes\n @rtype: str\n "
return (... | -8,416,242,787,242,972,000 | Returns representation of attribute list
Cannot return anything that can be eval'd to create a copy of the
list, so just wrap the informal representation in angle brackets.
@return: all the data in this list of attributes
@rtype: str | pycdf/__init__.py | __repr__ | cpiker/condaCDF | python | def __repr__(self):
"Returns representation of attribute list\n\n Cannot return anything that can be eval'd to create a copy of the\n list, so just wrap the informal representation in angle brackets.\n @return: all the data in this list of attributes\n @rtype: str\n "
return (... |
def __str__(self):
"Returns a string representation of the attribute list\n\n This is an 'informal' representation in that it cannot be evaluated\n directly to create an L{AttrList}.\n\n @return: all the data in this list of attributes\n @rtype: str\n "
if self._cdf_file._open... | 8,633,169,659,997,861,000 | Returns a string representation of the attribute list
This is an 'informal' representation in that it cannot be evaluated
directly to create an L{AttrList}.
@return: all the data in this list of attributes
@rtype: str | pycdf/__init__.py | __str__ | cpiker/condaCDF | python | def __str__(self):
"Returns a string representation of the attribute list\n\n This is an 'informal' representation in that it cannot be evaluated\n directly to create an L{AttrList}.\n\n @return: all the data in this list of attributes\n @rtype: str\n "
if self._cdf_file._open... |
def clone(self, master, name=None, new_name=None):
'\n Clones another attribute list, or one attribute from it, into this\n list.\n\n Parameters\n ==========\n master : AttrList\n the attribute list to copy from. This can be any dict-like object.\n\n Other Parame... | -7,891,908,609,073,791,000 | Clones another attribute list, or one attribute from it, into this
list.
Parameters
==========
master : AttrList
the attribute list to copy from. This can be any dict-like object.
Other Parameters
================
name : str (optional)
name of attribute to clone (default: clone entire list)
new_name : str (op... | pycdf/__init__.py | clone | cpiker/condaCDF | python | def clone(self, master, name=None, new_name=None):
'\n Clones another attribute list, or one attribute from it, into this\n list.\n\n Parameters\n ==========\n master : AttrList\n the attribute list to copy from. This can be any dict-like object.\n\n Other Parame... |
def copy(self):
'\n Create a copy of this attribute list\n\n Returns\n =======\n out : dict\n copy of the entries for all attributes in this list\n '
return dict(((key, (value[:] if isinstance(value, Attr) else value)) for (key, value) in self.items())) | 6,992,348,364,719,334,000 | Create a copy of this attribute list
Returns
=======
out : dict
copy of the entries for all attributes in this list | pycdf/__init__.py | copy | cpiker/condaCDF | python | def copy(self):
'\n Create a copy of this attribute list\n\n Returns\n =======\n out : dict\n copy of the entries for all attributes in this list\n '
return dict(((key, (value[:] if isinstance(value, Attr) else value)) for (key, value) in self.items())) |
def new(self, name, data=None, type=None):
'\n Create a new Attr in this AttrList\n\n Parameters\n ==========\n name : str\n name of the new Attribute\n\n Other Parameters\n ================\n data\n data to put into the first entry in the new A... | 2,512,112,050,731,910,700 | Create a new Attr in this AttrList
Parameters
==========
name : str
name of the new Attribute
Other Parameters
================
data
data to put into the first entry in the new Attribute
type
CDF type of the first entry from :mod:`~pycdf.const`.
Only used if data are specified.
Raises
======
KeyError... | pycdf/__init__.py | new | cpiker/condaCDF | python | def new(self, name, data=None, type=None):
'\n Create a new Attr in this AttrList\n\n Parameters\n ==========\n name : str\n name of the new Attribute\n\n Other Parameters\n ================\n data\n data to put into the first entry in the new A... |
def rename(self, old_name, new_name):
'\n Rename an attribute in this list\n\n Renaming a zAttribute renames it for *all* zVariables in this CDF!\n\n Parameters\n ==========\n old_name : str\n the current name of the attribute\n new_name : str\n the ne... | -8,892,377,292,410,608,000 | Rename an attribute in this list
Renaming a zAttribute renames it for *all* zVariables in this CDF!
Parameters
==========
old_name : str
the current name of the attribute
new_name : str
the new name of the attribute | pycdf/__init__.py | rename | cpiker/condaCDF | python | def rename(self, old_name, new_name):
'\n Rename an attribute in this list\n\n Renaming a zAttribute renames it for *all* zVariables in this CDF!\n\n Parameters\n ==========\n old_name : str\n the current name of the attribute\n new_name : str\n the ne... |
def from_dict(self, in_dict):
'\n Fill this list of attributes from a dictionary\n\n .. deprecated:: 0.1.5\n Use :meth:`~pycdf.AttrList.clone` instead; it supports\n cloning from dictionaries.\n\n Parameters\n ==========\n in_dict : dict\n Attribute ... | 1,740,887,903,258,037,800 | Fill this list of attributes from a dictionary
.. deprecated:: 0.1.5
Use :meth:`~pycdf.AttrList.clone` instead; it supports
cloning from dictionaries.
Parameters
==========
in_dict : dict
Attribute list is populated entirely from this dictionary;
all existing attributes are deleted. | pycdf/__init__.py | from_dict | cpiker/condaCDF | python | def from_dict(self, in_dict):
'\n Fill this list of attributes from a dictionary\n\n .. deprecated:: 0.1.5\n Use :meth:`~pycdf.AttrList.clone` instead; it supports\n cloning from dictionaries.\n\n Parameters\n ==========\n in_dict : dict\n Attribute ... |
def _clone_attr(self, master, name, new_name=None):
'Clones a single attribute from one in this list or another\n\n Copies data and types from the master attribute to the new one\n\n @param master: attribute list to copy attribute from\n @type master: L{AttrList}\n @param name: name of a... | 4,593,757,647,274,060,300 | Clones a single attribute from one in this list or another
Copies data and types from the master attribute to the new one
@param master: attribute list to copy attribute from
@type master: L{AttrList}
@param name: name of attribute to copy
@type name: str
@param new_name: name of the new attribute, default L{name}
@t... | pycdf/__init__.py | _clone_attr | cpiker/condaCDF | python | def _clone_attr(self, master, name, new_name=None):
'Clones a single attribute from one in this list or another\n\n Copies data and types from the master attribute to the new one\n\n @param master: attribute list to copy attribute from\n @type master: L{AttrList}\n @param name: name of a... |
def _clone_list(self, master):
'Clones this attribute list from another\n\n @param master: the attribute list to copy from\n @type master: L{AttrList}\n '
for name in master:
self._clone_attr(master, name)
for name in list(self):
if (not (name in master)):
de... | 1,735,739,518,964,436,200 | Clones this attribute list from another
@param master: the attribute list to copy from
@type master: L{AttrList} | pycdf/__init__.py | _clone_list | cpiker/condaCDF | python | def _clone_list(self, master):
'Clones this attribute list from another\n\n @param master: the attribute list to copy from\n @type master: L{AttrList}\n '
for name in master:
self._clone_attr(master, name)
for name in list(self):
if (not (name in master)):
de... |
def _get_or_create(self, name):
"Retrieve L{Attr} or create it if it doesn't exist\n\n @param name: name of the attribute to look up or create\n @type name: str\n @return: attribute with this name\n @rtype: L{Attr}\n "
attr = None
try:
attr = self.AttrType(self._cd... | -3,932,049,490,588,742,700 | Retrieve L{Attr} or create it if it doesn't exist
@param name: name of the attribute to look up or create
@type name: str
@return: attribute with this name
@rtype: L{Attr} | pycdf/__init__.py | _get_or_create | cpiker/condaCDF | python | def _get_or_create(self, name):
"Retrieve L{Attr} or create it if it doesn't exist\n\n @param name: name of the attribute to look up or create\n @type name: str\n @return: attribute with this name\n @rtype: L{Attr}\n "
attr = None
try:
attr = self.AttrType(self._cd... |
def __len__(self):
'\n Number of gAttributes in this CDF\n\n Returns\n =======\n out : int\n number of gAttributes in the CDF\n '
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMgATTRS_, ctypes.byref(count))
return count.value | 1,307,565,771,030,060,800 | Number of gAttributes in this CDF
Returns
=======
out : int
number of gAttributes in the CDF | pycdf/__init__.py | __len__ | cpiker/condaCDF | python | def __len__(self):
'\n Number of gAttributes in this CDF\n\n Returns\n =======\n out : int\n number of gAttributes in the CDF\n '
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMgATTRS_, ctypes.byref(count))
return count.value |
def __init__(self, zvar):
'Initialize the attribute collection\n\n @param zvar: zVariable these attributes are in\n @param zvar: :py:class:`pycdf.Var`\n '
super(zAttrList, self).__init__(zvar.cdf_file, zvar._num)
self._zvar = zvar | 6,613,242,305,066,177,000 | Initialize the attribute collection
@param zvar: zVariable these attributes are in
@param zvar: :py:class:`pycdf.Var` | pycdf/__init__.py | __init__ | cpiker/condaCDF | python | def __init__(self, zvar):
'Initialize the attribute collection\n\n @param zvar: zVariable these attributes are in\n @param zvar: :py:class:`pycdf.Var`\n '
super(zAttrList, self).__init__(zvar.cdf_file, zvar._num)
self._zvar = zvar |
def __getitem__(self, name):
'Find an zEntry by name\n\n @param name: name of the zAttribute to return\n @type name: str\n @return: attribute named L{name}\n @rtype: L{zAttr}\n @raise KeyError: if there is no attribute named L{name} associated\n with this z... | 3,835,158,616,355,306,500 | Find an zEntry by name
@param name: name of the zAttribute to return
@type name: str
@return: attribute named L{name}
@rtype: L{zAttr}
@raise KeyError: if there is no attribute named L{name} associated
with this zVariable
@raise CDFError: other errors in CDF library | pycdf/__init__.py | __getitem__ | cpiker/condaCDF | python | def __getitem__(self, name):
'Find an zEntry by name\n\n @param name: name of the zAttribute to return\n @type name: str\n @return: attribute named L{name}\n @rtype: L{zAttr}\n @raise KeyError: if there is no attribute named L{name} associated\n with this z... |
def __delitem__(self, name):
'Delete an zEntry by name\n\n @param name: name of the zEntry to delete\n @type name: str\n @raise KeyError: if there is no attribute named L{name} associated\n with this zVariable\n @raise CDFError: other errors in CDF library\n ... | 4,448,042,545,029,496,300 | Delete an zEntry by name
@param name: name of the zEntry to delete
@type name: str
@raise KeyError: if there is no attribute named L{name} associated
with this zVariable
@raise CDFError: other errors in CDF library
@note: If this is the only remaining entry, the Attribute will be
deleted. | pycdf/__init__.py | __delitem__ | cpiker/condaCDF | python | def __delitem__(self, name):
'Delete an zEntry by name\n\n @param name: name of the zEntry to delete\n @type name: str\n @raise KeyError: if there is no attribute named L{name} associated\n with this zVariable\n @raise CDFError: other errors in CDF library\n ... |
def __setitem__(self, name, data):
'Sets a zEntry by name\n\n The type of the zEntry is guessed from L{data}. The type is chosen to\n match the data; subject to that constraint, it will try to match\n (in order):\n 1. existing zEntry corresponding to this zVar\n 2. other zEntries ... | -8,386,760,686,779,896,000 | Sets a zEntry by name
The type of the zEntry is guessed from L{data}. The type is chosen to
match the data; subject to that constraint, it will try to match
(in order):
1. existing zEntry corresponding to this zVar
2. other zEntries in this zAttribute
3. the type of this zVar
4. data-matching constraints described in ... | pycdf/__init__.py | __setitem__ | cpiker/condaCDF | python | def __setitem__(self, name, data):
'Sets a zEntry by name\n\n The type of the zEntry is guessed from L{data}. The type is chosen to\n match the data; subject to that constraint, it will try to match\n (in order):\n 1. existing zEntry corresponding to this zVar\n 2. other zEntries ... |
def __len__(self):
'Number of zAttributes in this variable\n\n @return: number of zAttributes in the CDF\n which have entries for this variable.\n @rtype: int\n '
length = 0
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMATTRS_, ctypes.byref(c... | 4,828,795,206,108,122,000 | Number of zAttributes in this variable
@return: number of zAttributes in the CDF
which have entries for this variable.
@rtype: int | pycdf/__init__.py | __len__ | cpiker/condaCDF | python | def __len__(self):
'Number of zAttributes in this variable\n\n @return: number of zAttributes in the CDF\n which have entries for this variable.\n @rtype: int\n '
length = 0
count = ctypes.c_long(0)
self._cdf_file._call(const.GET_, const.CDF_NUMATTRS_, ctypes.byref(c... |
def type(self, name, new_type=None):
"Find or change the CDF type of a zEntry in this zVar\n\n @param name: name of the zAttr to check or change\n @type name: str\n @param new_type: type to change it to, see :py:mod:`pycdf.const`\n @type new_type: ctypes.c_long\n @return: CDF vari... | 683,384,987,073,141,900 | Find or change the CDF type of a zEntry in this zVar
@param name: name of the zAttr to check or change
@type name: str
@param new_type: type to change it to, see :py:mod:`pycdf.const`
@type new_type: ctypes.c_long
@return: CDF variable type, see :py:mod:`pycdf.const`
@rtype: int
@note: If changing types, old and new m... | pycdf/__init__.py | type | cpiker/condaCDF | python | def type(self, name, new_type=None):
"Find or change the CDF type of a zEntry in this zVar\n\n @param name: name of the zAttr to check or change\n @type name: str\n @param new_type: type to change it to, see :py:mod:`pycdf.const`\n @type new_type: ctypes.c_long\n @return: CDF vari... |
def _clone_attr(self, master, name, new_name=None):
'Clones a single attribute from one in this list or another\n\n Copies data and types from the master attribute to the new one\n\n @param master: attribute list to copy attribute from\n @type master: L{zAttrList}\n @param name: name of ... | 6,926,953,596,347,258,000 | Clones a single attribute from one in this list or another
Copies data and types from the master attribute to the new one
@param master: attribute list to copy attribute from
@type master: L{zAttrList}
@param name: name of attribute to copy
@type name: str
@param new_name: name of the new attribute, default L{name}
@... | pycdf/__init__.py | _clone_attr | cpiker/condaCDF | python | def _clone_attr(self, master, name, new_name=None):
'Clones a single attribute from one in this list or another\n\n Copies data and types from the master attribute to the new one\n\n @param master: attribute list to copy attribute from\n @type master: L{zAttrList}\n @param name: name of ... |
def _GetUserInit(allow_privileged):
'Gets user-init metadata value for COS image.'
allow_privileged_val = ('true' if allow_privileged else 'false')
return (USER_INIT_TEMPLATE % allow_privileged_val) | -9,055,961,458,231,454,000 | Gets user-init metadata value for COS image. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _GetUserInit | bopopescu/JobSniperRails | python | def _GetUserInit(allow_privileged):
allow_privileged_val = ('true' if allow_privileged else 'false')
return (USER_INIT_TEMPLATE % allow_privileged_val) |
def ValidateUserMetadata(metadata):
'Validates if user-specified metadata.\n\n Checks if it contains values which may conflict with container deployment.\n Args:\n metadata: user-specified VM metadata.\n\n Raises:\n InvalidMetadataKeyException: if there is conflict with user-provided\n metadata\n '
... | 2,603,807,631,856,674,300 | Validates if user-specified metadata.
Checks if it contains values which may conflict with container deployment.
Args:
metadata: user-specified VM metadata.
Raises:
InvalidMetadataKeyException: if there is conflict with user-provided
metadata | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | ValidateUserMetadata | bopopescu/JobSniperRails | python | def ValidateUserMetadata(metadata):
'Validates if user-specified metadata.\n\n Checks if it contains values which may conflict with container deployment.\n Args:\n metadata: user-specified VM metadata.\n\n Raises:\n InvalidMetadataKeyException: if there is conflict with user-provided\n metadata\n '
... |
def CreateTagsMessage(messages, tags):
'Create tags message with parameters for container VM or VM templates.'
if tags:
return messages.Tags(items=tags) | 7,419,058,106,280,878,000 | Create tags message with parameters for container VM or VM templates. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | CreateTagsMessage | bopopescu/JobSniperRails | python | def CreateTagsMessage(messages, tags):
if tags:
return messages.Tags(items=tags) |
def GetLabelsMessageWithCosVersion(labels, image_uri, resources, resource_class):
'Returns message with labels for instance / instance template.\n\n Args:\n labels: dict, labels to assign to the resource.\n image_uri: URI of image used as a base for the resource. The function\n extracts COS ver... | -5,469,485,270,292,029,000 | Returns message with labels for instance / instance template.
Args:
labels: dict, labels to assign to the resource.
image_uri: URI of image used as a base for the resource. The function
extracts COS version from the URI and uses it as a value of
`container-vm` label.
resources: object t... | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | GetLabelsMessageWithCosVersion | bopopescu/JobSniperRails | python | def GetLabelsMessageWithCosVersion(labels, image_uri, resources, resource_class):
'Returns message with labels for instance / instance template.\n\n Args:\n labels: dict, labels to assign to the resource.\n image_uri: URI of image used as a base for the resource. The function\n extracts COS ver... |
def ExpandCosImageFlag(compute_client):
'Select a COS image to run Docker.'
compute = compute_client.apitools_client
images = compute_client.MakeRequests([(compute.images, 'List', compute_client.messages.ComputeImagesListRequest(project=COS_PROJECT))])
return _SelectNewestCosImage(images) | 6,538,690,885,852,462,000 | Select a COS image to run Docker. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | ExpandCosImageFlag | bopopescu/JobSniperRails | python | def ExpandCosImageFlag(compute_client):
compute = compute_client.apitools_client
images = compute_client.MakeRequests([(compute.images, 'List', compute_client.messages.ComputeImagesListRequest(project=COS_PROJECT))])
return _SelectNewestCosImage(images) |
def _SelectNewestCosImage(images):
'Selects newest COS image from the list.'
cos_images = sorted([image for image in images if image.name.startswith(COS_MAJOR_RELEASE)], key=(lambda x: times.ParseDateTime(x.creationTimestamp)))
if (not cos_images):
raise NoCosImageException()
return cos_images[(... | 1,021,848,419,324,734,500 | Selects newest COS image from the list. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _SelectNewestCosImage | bopopescu/JobSniperRails | python | def _SelectNewestCosImage(images):
cos_images = sorted([image for image in images if image.name.startswith(COS_MAJOR_RELEASE)], key=(lambda x: times.ParseDateTime(x.creationTimestamp)))
if (not cos_images):
raise NoCosImageException()
return cos_images[(- 1)].selfLink |
def _ValidateAndParsePortMapping(port_mappings):
'Parses and validates port mapping.'
ports_config = []
for port_mapping in port_mappings:
mapping_match = re.match('^(\\d+):(\\d+):(\\S+)$', port_mapping)
if (not mapping_match):
raise calliope_exceptions.InvalidArgumentException('... | 1,751,126,288,136,252,000 | Parses and validates port mapping. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _ValidateAndParsePortMapping | bopopescu/JobSniperRails | python | def _ValidateAndParsePortMapping(port_mappings):
ports_config = []
for port_mapping in port_mappings:
mapping_match = re.match('^(\\d+):(\\d+):(\\S+)$', port_mapping)
if (not mapping_match):
raise calliope_exceptions.InvalidArgumentException('--port-mappings', 'Port mappings sho... |
def ExpandKonletCosImageFlag(compute_client):
'Select a COS image to run Konlet.\n\n This function scans three families in order:\n - stable\n - beta\n - dev\n looking for the first image with version at least _MIN_PREFERRED_COS_VERSION.\n\n Args:\n compute_client: ClientAdapter, The Compute API client ada... | -6,864,573,768,492,050,000 | Select a COS image to run Konlet.
This function scans three families in order:
- stable
- beta
- dev
looking for the first image with version at least _MIN_PREFERRED_COS_VERSION.
Args:
compute_client: ClientAdapter, The Compute API client adapter
Returns:
COS image at version _MIN_PREFERRED_COS_VERSION or later.... | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | ExpandKonletCosImageFlag | bopopescu/JobSniperRails | python | def ExpandKonletCosImageFlag(compute_client):
'Select a COS image to run Konlet.\n\n This function scans three families in order:\n - stable\n - beta\n - dev\n looking for the first image with version at least _MIN_PREFERRED_COS_VERSION.\n\n Args:\n compute_client: ClientAdapter, The Compute API client ada... |
def _ReadDictionary(filename):
'Read environment variable from file.\n\n File format:\n\n It is intended (but not guaranteed) to follow standard docker format\n [](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)\n but without capturing environment variabl... | 7,033,727,727,017,680,000 | Read environment variable from file.
File format:
It is intended (but not guaranteed) to follow standard docker format
[](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
but without capturing environment variables from host machine.
Lines starting by "#" charac... | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _ReadDictionary | bopopescu/JobSniperRails | python | def _ReadDictionary(filename):
'Read environment variable from file.\n\n File format:\n\n It is intended (but not guaranteed) to follow standard docker format\n [](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)\n but without capturing environment variabl... |
def _AddMountedDisksToManifest(container_mount_disk, volumes, volume_mounts, used_names=None, disks=None):
'Add volume specs from --container-mount-disk.'
used_names = (used_names or [])
disks = (disks or [])
idx = 0
for mount_disk in container_mount_disk:
while (_GetPersistentDiskName(idx) ... | -7,435,622,479,589,784,000 | Add volume specs from --container-mount-disk. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _AddMountedDisksToManifest | bopopescu/JobSniperRails | python | def _AddMountedDisksToManifest(container_mount_disk, volumes, volume_mounts, used_names=None, disks=None):
used_names = (used_names or [])
disks = (disks or [])
idx = 0
for mount_disk in container_mount_disk:
while (_GetPersistentDiskName(idx) in used_names):
idx += 1
de... |
def _CreateContainerManifest(args, instance_name, container_mount_disk_enabled=False, container_mount_disk=None):
'Create container manifest from argument namespace and instance name.'
container = {'image': args.container_image, 'name': instance_name}
if (args.container_command is not None):
contain... | -7,928,636,929,376,096,000 | Create container manifest from argument namespace and instance name. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _CreateContainerManifest | bopopescu/JobSniperRails | python | def _CreateContainerManifest(args, instance_name, container_mount_disk_enabled=False, container_mount_disk=None):
container = {'image': args.container_image, 'name': instance_name}
if (args.container_command is not None):
container['command'] = [args.container_command]
if (args.container_arg is... |
def DumpYaml(data):
'Dumps data dict to YAML in format expected by Konlet.'
return (MANIFEST_DISCLAIMER + yaml.dump(data)) | -8,401,266,490,021,556,000 | Dumps data dict to YAML in format expected by Konlet. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | DumpYaml | bopopescu/JobSniperRails | python | def DumpYaml(data):
return (MANIFEST_DISCLAIMER + yaml.dump(data)) |
def _CreateYamlContainerManifest(args, instance_name, container_mount_disk_enabled=False, container_mount_disk=None):
'Helper to create the container manifest.'
return DumpYaml(_CreateContainerManifest(args, instance_name, container_mount_disk_enabled=container_mount_disk_enabled, container_mount_disk=container... | 7,151,514,943,391,603,000 | Helper to create the container manifest. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _CreateYamlContainerManifest | bopopescu/JobSniperRails | python | def _CreateYamlContainerManifest(args, instance_name, container_mount_disk_enabled=False, container_mount_disk=None):
return DumpYaml(_CreateContainerManifest(args, instance_name, container_mount_disk_enabled=container_mount_disk_enabled, container_mount_disk=container_mount_disk)) |
def CreateKonletMetadataMessage(messages, args, instance_name, user_metadata, container_mount_disk_enabled=False, container_mount_disk=None):
'Helper to create the metadata for konlet.'
konlet_metadata = {GCE_CONTAINER_DECLARATION: _CreateYamlContainerManifest(args, instance_name, container_mount_disk_enabled=c... | 8,358,982,699,455,497,000 | Helper to create the metadata for konlet. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | CreateKonletMetadataMessage | bopopescu/JobSniperRails | python | def CreateKonletMetadataMessage(messages, args, instance_name, user_metadata, container_mount_disk_enabled=False, container_mount_disk=None):
konlet_metadata = {GCE_CONTAINER_DECLARATION: _CreateYamlContainerManifest(args, instance_name, container_mount_disk_enabled=container_mount_disk_enabled, container_moun... |
def UpdateInstance(holder, client, instance_ref, instance, args, container_mount_disk_enabled=False, container_mount_disk=None):
'Update an instance and its container metadata.'
for metadata in instance.metadata.items:
if (metadata.key == GCE_CONTAINER_DECLARATION):
UpdateMetadata(holder, me... | -4,849,458,390,674,768,000 | Update an instance and its container metadata. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | UpdateInstance | bopopescu/JobSniperRails | python | def UpdateInstance(holder, client, instance_ref, instance, args, container_mount_disk_enabled=False, container_mount_disk=None):
for metadata in instance.metadata.items:
if (metadata.key == GCE_CONTAINER_DECLARATION):
UpdateMetadata(holder, metadata, args, instance, container_mount_disk_ena... |
def _StopVm(holder, client, instance_ref):
'Stop the Virtual Machine.'
operation = client.apitools_client.instances.Stop(client.messages.ComputeInstancesStopRequest(**instance_ref.AsDict()))
operation_ref = holder.resources.Parse(operation.selfLink, collection='compute.zoneOperations')
operation_poller ... | -966,852,758,988,458,400 | Stop the Virtual Machine. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _StopVm | bopopescu/JobSniperRails | python | def _StopVm(holder, client, instance_ref):
operation = client.apitools_client.instances.Stop(client.messages.ComputeInstancesStopRequest(**instance_ref.AsDict()))
operation_ref = holder.resources.Parse(operation.selfLink, collection='compute.zoneOperations')
operation_poller = poller.Poller(client.apit... |
def _StartVm(holder, client, instance_ref):
'Start the Virtual Machine.'
operation = client.apitools_client.instances.Start(client.messages.ComputeInstancesStartRequest(**instance_ref.AsDict()))
operation_ref = holder.resources.Parse(operation.selfLink, collection='compute.zoneOperations')
operation_pol... | 6,301,015,718,287,988,000 | Start the Virtual Machine. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _StartVm | bopopescu/JobSniperRails | python | def _StartVm(holder, client, instance_ref):
operation = client.apitools_client.instances.Start(client.messages.ComputeInstancesStartRequest(**instance_ref.AsDict()))
operation_ref = holder.resources.Parse(operation.selfLink, collection='compute.zoneOperations')
operation_poller = poller.Poller(client.a... |
def UpdateMetadata(holder, metadata, args, instance, container_mount_disk_enabled=False, container_mount_disk=None):
'Update konlet metadata entry using user-supplied data.'
manifest = yaml.load(metadata.value)
if args.IsSpecified('container_image'):
manifest['spec']['containers'][0]['image'] = args... | 6,245,330,564,401,157,000 | Update konlet metadata entry using user-supplied data. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | UpdateMetadata | bopopescu/JobSniperRails | python | def UpdateMetadata(holder, metadata, args, instance, container_mount_disk_enabled=False, container_mount_disk=None):
manifest = yaml.load(metadata.value)
if args.IsSpecified('container_image'):
manifest['spec']['containers'][0]['image'] = args.container_image
if args.IsSpecified('container_comm... |
def _UpdateMounts(holder, manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk, disks):
'Updates mounts in container manifest.'
_CleanupMounts(manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk=container_... | 3,652,365,875,387,263,500 | Updates mounts in container manifest. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _UpdateMounts | bopopescu/JobSniperRails | python | def _UpdateMounts(holder, manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk, disks):
_CleanupMounts(manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk=container_mount_disk)
used_names = [volume['n... |
def _CleanupMounts(manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk=None):
'Remove all specified mounts from container manifest.'
container_mount_disk = (container_mount_disk or [])
mount_paths_to_remove = remove_container_mounts[:]
for host_path ... | 1,538,221,688,976,093,400 | Remove all specified mounts from container manifest. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _CleanupMounts | bopopescu/JobSniperRails | python | def _CleanupMounts(manifest, remove_container_mounts, container_mount_host_path, container_mount_tmpfs, container_mount_disk=None):
container_mount_disk = (container_mount_disk or [])
mount_paths_to_remove = remove_container_mounts[:]
for host_path in container_mount_host_path:
mount_paths_to_r... |
def _UpdateEnv(manifest, remove_container_env, container_env_file, container_env):
'Update environment variables in container manifest.'
current_env = {}
for env_val in manifest['spec']['containers'][0].get('env', []):
current_env[env_val['name']] = env_val['value']
for env in remove_container_e... | 5,229,501,345,475,472,000 | Update environment variables in container manifest. | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/compute/containers_utils.py | _UpdateEnv | bopopescu/JobSniperRails | python | def _UpdateEnv(manifest, remove_container_env, container_env_file, container_env):
current_env = {}
for env_val in manifest['spec']['containers'][0].get('env', []):
current_env[env_val['name']] = env_val['value']
for env in remove_container_env:
current_env.pop(env, None)
current_en... |
def SaveNewActiveConfig(config):
'Serialize and saves the configuration as new active config file.'
json_config = (json.dumps(config, indent=2, separators=(',', ': '), sort_keys=True) + '\n')
json_name = ('umpire.%s.json' % hashlib.md5(json_config.encode('utf-8')).hexdigest())
json_path = os.path.join('... | 4,456,873,084,780,837,000 | Serialize and saves the configuration as new active config file. | py/umpire/server/migrations/0010.py | SaveNewActiveConfig | arccode/factory | python | def SaveNewActiveConfig(config):
json_config = (json.dumps(config, indent=2, separators=(',', ': '), sort_keys=True) + '\n')
json_name = ('umpire.%s.json' % hashlib.md5(json_config.encode('utf-8')).hexdigest())
json_path = os.path.join('resources', json_name)
with open(os.path.join(_ENV_DIR, json_p... |
def list(self, resource_group_name, virtual_network_name, subnet_name, **kwargs):
'Gets a list of service association links for a subnet.\n\n :param resource_group_name: The name of the resource group.\n :type resource_group_name: str\n :param virtual_network_name: The name of the virtual netwo... | 3,377,442,895,401,322,000 | Gets a list of service association links for a subnet.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param virtual_network_name: The name of the virtual network.
:type virtual_network_name: str
:param subnet_name: The name of the subnet.
:type subnet_name: str
:keyword cal... | sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_04_01/operations/_service_association_links_operations.py | list | 4thel00z/microsoft-crap-that-doesnt-work | python | def list(self, resource_group_name, virtual_network_name, subnet_name, **kwargs):
'Gets a list of service association links for a subnet.\n\n :param resource_group_name: The name of the resource group.\n :type resource_group_name: str\n :param virtual_network_name: The name of the virtual netwo... |
@yaz.task(choice__choices=['yes', 'no', 'unknown'])
def required_choice(self, choice):
'This is the documentation for the required_choice task'
return self.choices[choice] | 5,762,619,045,657,838,000 | This is the documentation for the required_choice task | yaz/test/test_task_configuration.py | required_choice | boudewijn-zicht/yaz | python | @yaz.task(choice__choices=['yes', 'no', 'unknown'])
def required_choice(self, choice):
return self.choices[choice] |
@yaz.task
def one_line_doc_string(self):
'This is the documentation for the one_line_doc_string task'
pass | -5,348,532,464,028,702,000 | This is the documentation for the one_line_doc_string task | yaz/test/test_task_configuration.py | one_line_doc_string | boudewijn-zicht/yaz | python | @yaz.task
def one_line_doc_string(self):
pass |
@yaz.task
def multi_line_doc_string(self):
'\n This is the documentation for the multi_line_doc_string task\n\n This is the long description, for example:\n bla bla,\n etc...\n '
pass | -7,576,571,247,808,248,000 | This is the documentation for the multi_line_doc_string task
This is the long description, for example:
bla bla,
etc... | yaz/test/test_task_configuration.py | multi_line_doc_string | boudewijn-zicht/yaz | python | @yaz.task
def multi_line_doc_string(self):
'\n This is the documentation for the multi_line_doc_string task\n\n This is the long description, for example:\n bla bla,\n etc...\n '
pass |
@yaz.task(choice__help='This is the documentation for the choice parameter of the parameter_help task')
def parameter_help(self, choice):
'This is the documentation for the parameter_help task'
pass | 5,651,753,683,150,569,000 | This is the documentation for the parameter_help task | yaz/test/test_task_configuration.py | parameter_help | boudewijn-zicht/yaz | python | @yaz.task(choice__help='This is the documentation for the choice parameter of the parameter_help task')
def parameter_help(self, choice):
pass |
def test_010_plugin_help(self):
'Should show plugin help texts from docstring or configuration'
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('--help')
stdout.seek(0)... | 398,901,382,774,434,300 | Should show plugin help texts from docstring or configuration | yaz/test/test_task_configuration.py | test_010_plugin_help | boudewijn-zicht/yaz | python | def test_010_plugin_help(self):
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('--help')
stdout.seek(0)
output = stdout.read()
print(output)
self.asse... |
def test_020_task_help__docstring(self):
'Should show task help texts from docstring or configuration'
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('multi-line-doc-string', ... | 893,196,513,617,972,100 | Should show task help texts from docstring or configuration | yaz/test/test_task_configuration.py | test_020_task_help__docstring | boudewijn-zicht/yaz | python | def test_020_task_help__docstring(self):
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('multi-line-doc-string', '--help')
stdout.seek(0)
output = stdout.read... |
def test_030_task_help__parameter(self):
'Should show task help texts from docstring or configuration'
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('parameter-help', '--help... | -6,580,420,490,779,309,000 | Should show task help texts from docstring or configuration | yaz/test/test_task_configuration.py | test_030_task_help__parameter | boudewijn-zicht/yaz | python | def test_030_task_help__parameter(self):
caller = self.get_caller([ConfigurationPlugin])
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as stdout:
with self.assertRaises(SystemExit):
caller('parameter-help', '--help')
stdout.seek(0)
output = stdout.read()
... |
def test_040_choices_configuration(self):
'Should accept predefined choices'
caller = self.get_caller([ConfigurationPlugin])
self.assertTrue(caller('required-choice', 'yes'))
with unittest.mock.patch('sys.stderr', new=io.StringIO()):
with self.assertRaises(SystemExit):
caller('requir... | -8,754,675,025,409,857,000 | Should accept predefined choices | yaz/test/test_task_configuration.py | test_040_choices_configuration | boudewijn-zicht/yaz | python | def test_040_choices_configuration(self):
caller = self.get_caller([ConfigurationPlugin])
self.assertTrue(caller('required-choice', 'yes'))
with unittest.mock.patch('sys.stderr', new=io.StringIO()):
with self.assertRaises(SystemExit):
caller('required-choice', 'unavailable') |
def rzz(self, theta, ctl, tgt):
'Apply RZZ to circuit.'
if (isinstance(ctl, QuantumRegister) and isinstance(tgt, QuantumRegister) and (len(ctl) == len(tgt))):
instructions = InstructionSet()
for i in range(ctl.size):
instructions.add(self.rzz(theta, (ctl, i), (tgt, i)))
retur... | 6,492,097,230,245,868,000 | Apply RZZ to circuit. | qiskit/extensions/standard/rzz.py | rzz | christians94/qiskit-sdk-py | python | def rzz(self, theta, ctl, tgt):
if (isinstance(ctl, QuantumRegister) and isinstance(tgt, QuantumRegister) and (len(ctl) == len(tgt))):
instructions = InstructionSet()
for i in range(ctl.size):
instructions.add(self.rzz(theta, (ctl, i), (tgt, i)))
return instructions
self... |
def __init__(self, theta, ctl, tgt, circ=None):
'Create new rzz gate.'
super().__init__('rzz', [theta], [ctl, tgt], circ) | 7,741,249,714,310,723,000 | Create new rzz gate. | qiskit/extensions/standard/rzz.py | __init__ | christians94/qiskit-sdk-py | python | def __init__(self, theta, ctl, tgt, circ=None):
super().__init__('rzz', [theta], [ctl, tgt], circ) |
def qasm(self):
'Return OPENQASM string.'
ctl = self.arg[0]
tgt = self.arg[1]
theta = self.param[0]
return self._qasmif(('rzz(%s) %s[%d],%s[%d];' % (theta, ctl[0].name, ctl[1], tgt[0].name, tgt[1]))) | 6,049,907,832,970,613,000 | Return OPENQASM string. | qiskit/extensions/standard/rzz.py | qasm | christians94/qiskit-sdk-py | python | def qasm(self):
ctl = self.arg[0]
tgt = self.arg[1]
theta = self.param[0]
return self._qasmif(('rzz(%s) %s[%d],%s[%d];' % (theta, ctl[0].name, ctl[1], tgt[0].name, tgt[1]))) |
def inverse(self):
'Invert this gate.'
self.param[0] = (- self.param[0])
return self | -6,188,600,865,367,955,000 | Invert this gate. | qiskit/extensions/standard/rzz.py | inverse | christians94/qiskit-sdk-py | python | def inverse(self):
self.param[0] = (- self.param[0])
return self |
def reapply(self, circ):
'Reapply this gate to corresponding qubits in circ.'
self._modifiers(circ.rzz(self.param[0], self.arg[0], self.arg[1])) | -5,694,214,718,569,381,000 | Reapply this gate to corresponding qubits in circ. | qiskit/extensions/standard/rzz.py | reapply | christians94/qiskit-sdk-py | python | def reapply(self, circ):
self._modifiers(circ.rzz(self.param[0], self.arg[0], self.arg[1])) |
def _projection_simplex(v, z=1):
'\n Old implementation for test and benchmark purposes.\n The arguments v and z should be a vector and a scalar, respectively.\n '
n_features = v.shape[0]
u = np.sort(v)[::(- 1)]
cssv = (np.cumsum(u) - z)
ind = (np.arange(n_features) + 1)
cond = ((u - (c... | 2,615,208,293,314,532,000 | Old implementation for test and benchmark purposes.
The arguments v and z should be a vector and a scalar, respectively. | smoothot/tests/test_projection.py | _projection_simplex | cptq/smooth-ot | python | def _projection_simplex(v, z=1):
'\n Old implementation for test and benchmark purposes.\n The arguments v and z should be a vector and a scalar, respectively.\n '
n_features = v.shape[0]
u = np.sort(v)[::(- 1)]
cssv = (np.cumsum(u) - z)
ind = (np.arange(n_features) + 1)
cond = ((u - (c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.