code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
if old_labels is None:
old_labels = set(mapping)
if new_labels is None:
new_labels = set(itervalues(mapping))
# counter will be used to generate the intermediate labels, as an easy optimization
# we start the counter with a high number because often variables are labeled by
# ... | def resolve_label_conflict(mapping, old_labels=None, new_labels=None) | Resolve a self-labeling conflict by creating an intermediate labeling.
Args:
mapping (dict):
A dict mapping the current variable labels to new ones.
old_labels (set, optional, default=None):
The keys of mapping. Can be passed in for performance reasons. These are not checke... | 3.371398 | 3.091483 | 1.090544 |
try:
from dimod.roof_duality._fix_variables import fix_variables_wrapper
except ImportError:
raise ImportError("c++ extension roof_duality is not built")
if sampling_mode:
method = 2 # roof-duality only
else:
method = 1 # roof-duality and strongly connected compon... | def fix_variables(bqm, sampling_mode=True) | Determine assignments for some variables of a binary quadratic model.
Roof duality finds a lower bound for the minimum of a quadratic polynomial. It
can also find minimizing assignments for some of the polynomial's variables;
these fixed variables take the same values in all optimal solutions [BHT]_ [BH]_.... | 3.786476 | 3.529959 | 1.072668 |
if _is_sampleset_v2(obj):
# in the future we could handle subtypes but right now we just have the
# one
return SampleSet.from_serializable(obj)
elif _is_bqm_v2(obj):
# in the future we could handle subtypes but right now we just have the
# one
return BinaryQu... | def dimod_object_hook(obj) | JSON-decoding for dimod objects.
See Also:
:class:`json.JSONDecoder` for using custom decoders. | 3.668188 | 4.271035 | 0.858852 |
if isinstance(label, list):
return tuple(_decode_label(v) for v in label)
return label | def _decode_label(label) | Convert a list label into a tuple. Works recursively on nested lists. | 3.627795 | 2.178777 | 1.66506 |
if isinstance(label, tuple):
return [_encode_label(v) for v in label]
return label | def _encode_label(label) | Convert a tuple label into a list. Works recursively on nested tuples. | 3.798506 | 2.267231 | 1.675394 |
multiplier, multiplicand, product, aux = variables
return BinaryQuadraticModel({multiplier: -.5,
multiplicand: -.5,
product: -.5,
aux: -1.},
{(multiplier, multiplicand): .5,
... | def _spin_product(variables) | Create a bqm with a gap of 2 that represents the product of two variables.
Note that spin-product requires an auxiliary variable.
Args:
variables (list):
multiplier, multiplicand, product, aux
Returns:
:obj:`.BinaryQuadraticModel` | 3.355827 | 2.659509 | 1.261822 |
multiplier, multiplicand, product = variables
return BinaryQuadraticModel({multiplier: 0.0,
multiplicand: 0.0,
product: 3.0},
{(multiplier, multiplicand): 1.0,
(multiplier, pr... | def _binary_product(variables) | Create a bqm with a gap of 2 that represents the product of two variables.
Args:
variables (list):
multiplier, multiplicand, product
Returns:
:obj:`.BinaryQuadraticModel` | 3.574762 | 2.952704 | 1.210674 |
if bqm is None:
if vartype is None:
raise ValueError("one of vartype and bqm must be provided")
bqm = BinaryQuadraticModel.empty(vartype)
else:
if not isinstance(bqm, BinaryQuadraticModel):
raise TypeError('create_using must be a BinaryQuadraticModel')
... | def make_quadratic(poly, strength, vartype=None, bqm=None) | Create a binary quadratic model from a higher order polynomial.
Args:
poly (dict):
Polynomial as a dict of form {term: bias, ...}, where `term` is a tuple of
variables and `bias` the associated bias.
strength (float):
Strength of the reduction constraint. Insuff... | 2.671674 | 2.706834 | 0.987011 |
if all(len(term) <= 2 for term in poly):
# termination criteria, we are already quadratic
bqm.add_interactions_from(poly)
return bqm
# determine which pair of variables appear most often
paircounter = Counter()
for term in poly:
if len(term) > 2:
for u,... | def _reduce_degree(bqm, poly, vartype, scale) | helper function for make_quadratic | 3.526964 | 3.466671 | 1.017392 |
msg = ("poly_energy is deprecated and will be removed in dimod 0.9.0."
"In the future, use BinaryPolynomial.energy")
warnings.warn(msg, DeprecationWarning)
# dev note the vartype is not used in the energy calculation and this will
# be deprecated in the future
return BinaryPolynomia... | def poly_energy(sample_like, poly) | Calculates energy of a sample from a higher order polynomial.
Args:
sample (samples_like):
A raw sample. `samples_like` is an extension of NumPy's
array_like structure. See :func:`.as_samples`.
poly (dict):
Polynomial as a dict of form {term: bias, ...}, where ... | 6.815462 | 7.397756 | 0.921288 |
msg = ("poly_energies is deprecated and will be removed in dimod 0.9.0."
"In the future, use BinaryPolynomial.energies")
warnings.warn(msg, DeprecationWarning)
# dev note the vartype is not used in the energy calculation and this will
# be deprecated in the future
return BinaryPolyno... | def poly_energies(samples_like, poly) | Calculates energy of samples from a higher order polynomial.
Args:
sample (samples_like):
A collection of raw samples. `samples_like` is an extension of
NumPy's array_like structure. See :func:`.as_samples`.
poly (dict):
Polynomial as a dict of form {term: bias,... | 6.596929 | 8.055868 | 0.818897 |
# step through idx values in adj to pick a random one, random.choice does not work on dicts
n = random_state.randint(len(adj))
for idx, v in enumerate(adj):
if idx == n:
break
start = v
walk = [start]
visited = {start: 0}
while True:
if len(walk) > 1:
... | def _random_cycle(adj, random_state) | Find a cycle using a random graph walk. | 4.299936 | 4.085408 | 1.052511 |
if spin_reversal_variables is not None:
# this kwarg does not actually make sense for multiple SRTs. To
# get the same functionality a user should apply them by hand
# to their BQM before submitting.
import warnings
warnings.warn("'spin_rever... | def sample(self, bqm, num_spin_reversal_transforms=2, spin_reversal_variables=None, **kwargs) | Sample from the binary quadratic model.
Args:
bqm (:obj:`~dimod.BinaryQuadraticModel`):
Binary quadratic model to be sampled from.
num_spin_reversal_transforms (integer, optional, default=2):
Number of spin reversal transform runs.
spin_reve... | 3.53583 | 3.602665 | 0.981448 |
self.items_length += len(header)
if _left:
self.deque.appendleft((header, f))
else:
self.deque.append((header, f)) | def append(self, header, f, _left=False) | Add a column to the table.
Args:
header (str):
Column header
f (function(datum)->str):
Makes the row string from the datum. Str returned by f should
have the same width as header. | 3.85464 | 4.766439 | 0.808704 |
width = len(str(num_rows - 1))
def f(datum):
return str(datum.idx).ljust(width)
header = ' '*width
self.append(header, f) | def append_index(self, num_rows) | Add an index column.
Left justified, width is determined by the space needed to print the
largest index. | 8.429655 | 7.398877 | 1.139315 |
vstr = str(v).rjust(2) # the variable will be len 0, or 1
length = len(vstr)
if vartype is dimod.SPIN:
def f(datum):
return _spinstr(datum.sample[v], rjust=length)
else:
def f(datum):
return _binarystr(datum.sample[v], rj... | def append_sample(self, v, vartype, _left=False) | Add a sample column | 5.563852 | 5.624817 | 0.989161 |
if np.issubdtype(vector.dtype, np.integer):
# determine the length we need
largest = str(max(vector.max(), vector.min(), key=abs))
length = max(len(largest), min(7, len(name))) # how many spaces we need to represent
if len(name) > length:
... | def append_vector(self, name, vector, _left=False) | Add a data vectors column. | 2.21829 | 2.170679 | 1.021934 |
sio = StringIO()
self.fprint(obj, stream=sio, **kwargs)
return sio.getvalue() | def format(self, obj, **kwargs) | Return the formatted representation of the object as a string. | 4.451285 | 3.827863 | 1.162864 |
if stream is None:
stream = sys.stdout
options = self.options
options.update(kwargs)
if isinstance(obj, dimod.SampleSet):
self._print_sampleset(obj, stream, **options)
return
raise TypeError("cannot format type {}".format(type(obj))... | def fprint(self, obj, stream=None, **kwargs) | Prints the formatted representation of the object on stream | 3.67695 | 3.532861 | 1.040785 |
itertup = iter(samplesets)
try:
first = next(itertup)
except StopIteration:
raise ValueError("samplesets must contain at least one SampleSet")
vartype = first.vartype
variables = first.variables
records = [first.record]
records.extend(_iter_records(itertup, vartype, ... | def concatenate(samplesets, defaults=None) | Combine SampleSets.
Args:
samplesets (iterable[:obj:`.SampleSet`):
An iterable of sample sets.
defaults (dict, optional):
Dictionary mapping data vector names to the corresponding default values.
Returns:
:obj:`.SampleSet`: A sample set with the same vartype an... | 7.200865 | 7.296465 | 0.986898 |
if aggregate_samples:
return cls.from_samples(samples_like, vartype, energy,
info=info, num_occurrences=num_occurrences,
aggregate_samples=False,
**vectors).aggregate()
# get... | def from_samples(cls, samples_like, vartype, energy, info=None,
num_occurrences=None, aggregate_samples=False,
sort_labels=True, **vectors) | Build a :class:`SampleSet` from raw samples.
Args:
samples_like:
A collection of raw samples. 'samples_like' is an extension of NumPy's array_like_.
See :func:`.as_samples`.
vartype (:class:`.Vartype`/str/set):
Variable type for the :clas... | 2.632097 | 2.652561 | 0.992285 |
# more performant to do this once, here rather than again in bqm.energies
# and in cls.from_samples
samples_like = as_samples(samples_like)
energies = bqm.energies(samples_like)
return cls.from_samples(samples_like, energy=energies, vartype=bqm.vartype, **kwargs) | def from_samples_bqm(cls, samples_like, bqm, **kwargs) | Build a SampleSet from raw samples using a BinaryQuadraticModel to get energies and vartype.
Args:
samples_like:
A collection of raw samples. 'samples_like' is an extension of NumPy's array_like.
See :func:`.as_samples`.
bqm (:obj:`.BinaryQuadraticModel`... | 4.757988 | 7.889197 | 0.603102 |
obj = cls.__new__(cls)
obj._future = future
if result_hook is None:
def result_hook(future):
return future.result()
elif not callable(result_hook):
raise TypeError("expected result_hook to be callable")
obj._result_hook = result_... | def from_future(cls, future, result_hook=None) | Construct a :class:`SampleSet` referencing the result of a future computation.
Args:
future (object):
Object that contains or will contain the information needed to construct a
:class:`SampleSet`. If `future` has a :meth:`~concurrent.futures.Future.done` method,
... | 2.242282 | 3.638209 | 0.616315 |
return {field: self.record[field] for field in self.record.dtype.names
if field != 'sample'} | def data_vectors(self) | The per-sample data in a vector.
Returns:
dict: A dict where the keys are the fields in the record and the
values are the corresponding arrays.
Examples:
>>> sampleset = dimod.SampleSet.from_samples([[-1, 1], [1, 1]], dimod.SPIN,
... | 7.874732 | 6.88102 | 1.144414 |
try:
return next(self.data(sorted_by='energy', name='Sample'))
except StopIteration:
raise ValueError('{} is empty'.format(self.__class__.__name__)) | def first(self) | Sample with the lowest-energy.
Raises:
ValueError: If empty.
Example:
>>> sampleset = dimod.ExactSolver().sample_ising({'a': 1}, {('a', 'b'): 1})
>>> sampleset.first
Sample(sample={'a': -1, 'b': 1}, energy=-2.0, num_occurrences=1) | 8.964645 | 7.071824 | 1.267657 |
return (not hasattr(self, '_future')) or (not hasattr(self._future, 'done')) or self._future.done() | def done(self) | Return True if a pending computation is done.
Used when a :class:`SampleSet` is constructed with :meth:`SampleSet.from_future`.
Examples:
This example uses a :class:`~concurrent.futures.Future` object directly. Typically
a :class:`~concurrent.futures.Executor` sets the result o... | 5.670046 | 5.792067 | 0.978933 |
if n is not None:
return self.samples(sorted_by=sorted_by)[:n]
if sorted_by is None:
samples = self.record.sample
else:
order = np.argsort(self.record[sorted_by])
samples = self.record.sample[order]
return SamplesArray(samples, s... | def samples(self, n=None, sorted_by='energy') | Return an iterable over the samples.
Args:
n (int, optional, default=None):
Maximum number of samples to return in the view.
sorted_by (str/None, optional, default='energy'):
Selects the record field used to sort the samples. If None,
sam... | 3.173551 | 3.121147 | 1.01679 |
record = self.record
if fields is None:
# make sure that sample, energy is first
fields = self._REQUIRED_FIELDS + [field for field in record.dtype.fields
if field not in self._REQUIRED_FIELDS]
if index:
... | def data(self, fields=None, sorted_by='energy', name='Sample', reverse=False,
sample_dict_cast=True, index=False) | Iterate over the data in the :class:`SampleSet`.
Args:
fields (list, optional, default=None):
If specified, only these fields are included in the yielded tuples.
The special field name 'sample' can be used to view the samples.
sorted_by (str/None, option... | 3.119273 | 3.075504 | 1.014232 |
return self.__class__(self.record.copy(),
self.variables, # a new one is made in all cases
self.info.copy(),
self.vartype) | def copy(self) | Create a shallow copy. | 13.650075 | 11.927248 | 1.144445 |
if not inplace:
return self.copy().change_vartype(vartype, energy_offset, inplace=True)
if energy_offset:
self.record.energy = self.record.energy + energy_offset
if vartype is self.vartype:
return self # we're done!
if vartype is Vartype.S... | def change_vartype(self, vartype, energy_offset=0.0, inplace=True) | Return the :class:`SampleSet` with the given vartype.
Args:
vartype (:class:`.Vartype`/str/set):
Variable type to use for the new :class:`SampleSet`. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`,... | 2.061487 | 2.104606 | 0.979512 |
if not inplace:
return self.copy().relabel_variables(mapping, inplace=True)
self.variables.relabel(mapping)
return self | def relabel_variables(self, mapping, inplace=True) | Relabel the variables of a :class:`SampleSet` according to the specified mapping.
Args:
mapping (dict):
Mapping from current variable labels to new, as a dict. If incomplete mapping is
specified, unmapped variables keep their current labels.
inplace (boo... | 2.92856 | 9.964387 | 0.293903 |
_, indices, inverse = np.unique(self.record.sample, axis=0,
return_index=True, return_inverse=True)
# unique also sorts the array which we don't want, so we undo the sort
order = np.argsort(indices)
indices = indices[order]
recor... | def aggregate(self) | Create a new SampleSet with repeated samples aggregated.
Returns:
:obj:`.SampleSet`
Note:
:attr:`.SampleSet.record.num_occurrences` are accumulated but no
other fields are. | 5.179663 | 4.598803 | 1.126307 |
samples, labels = as_samples(samples_like)
num_samples = len(self)
# we don't handle multiple values
if samples.shape[0] == num_samples:
# we don't need to do anything, it's already the correct shape
pass
elif samples.shape[0] == 1 and num_sampl... | def append_variables(self, samples_like, sort_labels=True) | Create a new sampleset with the given variables with values added.
Not defined for empty sample sets. Note that when `sample_like` is
a :obj:`.SampleSet`, the data vectors and info are ignored.
Args:
samples_like:
Samples to add to the sample set. Should either be a... | 4.405931 | 3.998599 | 1.101869 |
if len(self) == 0:
# empty so all are lowest
return self.copy()
record = self.record
# want all the rows within tolerance of the minimal energy
close = np.isclose(record.energy,
np.min(record.energy),
... | def lowest(self, rtol=1.e-5, atol=1.e-8) | Return a sample set containing the lowest-energy samples.
A sample is included if its energy is within tolerance of the lowest
energy in the sample set. The following equation is used to determine
if two values are equivalent:
absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
... | 5.807034 | 4.922888 | 1.179599 |
schema_version = "2.0.0"
record = {name: array2bytes(vector)
for name, vector in self.data_vectors.items()}
record['sample'] = array2bytes(np.packbits(self.record.sample > 0))
if not use_bytes:
for name in record:
record[name] = ba... | def to_serializable(self, use_bytes=False, bytes_type=bytes) | Convert a :class:`SampleSet` to a serializable object.
Note that the contents of the :attr:`.SampleSet.info` field are assumed
to be serializable.
Args:
use_bytes (bool, optional, default=False):
If True, a compact representation representing the biases as bytes is ... | 4.341419 | 4.145173 | 1.047343 |
schema_version = "2.0.0"
if obj["version"]['sampleset_schema'] == "1.0.0":
import warnings
msg = ("sampleset is serialized with a deprecated format and will no longer "
"work in dimod 0.9.0.")
warnings.warn(msg)
from dimod.se... | def from_serializable(cls, obj) | Deserialize a :class:`SampleSet`.
Args:
obj (dict):
A :class:`SampleSet` serialized by :meth:`~.SampleSet.to_serializable`.
Returns:
:obj:`.SampleSet`
Examples:
This example encodes and decodes using JSON.
>>> import dimod
... | 4.221476 | 4.331661 | 0.974563 |
import pandas as pd
if sample_column:
df = pd.DataFrame(self.data(sorted_by=None, sample_dict_cast=True))
else:
# work directly with the record, it's much faster
df = pd.DataFrame(self.record.sample, columns=self.variables)
for field in... | def to_pandas_dataframe(self, sample_column=False) | Convert a SampleSet to a Pandas DataFrame
Returns:
:obj:`pandas.DataFrame`
Examples:
>>> samples = dimod.SampleSet.from_samples([{'a': -1, 'b': +1, 'c': -1},
... {'a': -1, 'b': -1, 'c': +1}],
... ... | 6.493738 | 6.159123 | 1.054328 |
record = response.record
label_dict = response.variables.index
if len(bqm.info['reduction']) == 0:
return np.array([1] * len(record.sample))
penalty_vector = np.prod([record.sample[:, label_dict[qi]] *
record.sample[:, label_dict[qj]]
... | def penalty_satisfaction(response, bqm) | Creates a penalty satisfaction list
Given a sampleSet and a bqm object, will create a binary list informing
whether the penalties introduced during degree reduction are satisfied for
each sample in sampleSet
Args:
response (:obj:`.SampleSet`): Samples corresponding to provided bqm
bqm... | 5.501566 | 5.2005 | 1.057892 |
record = response.record
penalty_vector = penalty_satisfaction(response, bqm)
original_variables = bqm.variables
if discard_unsatisfied:
samples_to_keep = list(map(bool, list(penalty_vector)))
penalty_vector = np.array([True] * np.sum(samples_to_keep))
else:
samples_to_... | def polymorph_response(response, poly, bqm,
penalty_strength=None,
keep_penalty_variables=True,
discard_unsatisfied=False) | Transforms the sampleset for the higher order problem.
Given a response of a penalized HUBO, this function creates a new sampleset
object, taking into account penalty information and calculates the
energies of samples for the higherorder problem.
Args:
response (:obj:`.SampleSet`): response fo... | 2.929311 | 2.89768 | 1.010916 |
bqm = make_quadratic(poly, penalty_strength, vartype=poly.vartype)
response = self.child.sample(bqm, **parameters)
return polymorph_response(response, poly, bqm,
penalty_strength=penalty_strength,
keep_penalty_variabl... | def sample_poly(self, poly, penalty_strength=1.0,
keep_penalty_variables=False,
discard_unsatisfied=False, **parameters) | Sample from the given binary polynomial.
Takes the given binary polynomial, introduces penalties, reduces the
higher-order problem into a quadratic problem and sends it to its child
sampler.
Args:
poly (:obj:`.BinaryPolynomial`):
A binary polynomial.
... | 3.095687 | 4.10334 | 0.754431 |
if ignored_terms is None:
ignored_terms = set()
else:
ignored_terms = {frozenset(term) for term in ignored_terms}
# scale and normalize happen in-place so we need to make a copy
original, poly = poly, poly.copy()
if scalar is not None:
... | def sample_poly(self, poly, scalar=None, bias_range=1, poly_range=None,
ignored_terms=None, **parameters) | Scale and sample from the given binary polynomial.
If scalar is not given, problem is scaled based on bias and polynomial
ranges. See :meth:`.BinaryPolynomial.scale` and
:meth:`.BinaryPolynomial.normalize`
Args:
poly (obj:`.BinaryPolynomial`): A binary polynomial.
... | 3.665095 | 3.452867 | 1.061464 |
tkw = self._truncate_kwargs
if self._aggregate:
return self.child.sample_poly(poly, **kwargs).aggregate().truncate(**tkw)
else:
return self.child.sample_poly(poly, **kwargs).truncate(**tkw) | def sample_poly(self, poly, **kwargs) | Sample from the binary polynomial and truncate output.
Args:
poly (obj:`.BinaryPolynomial`): A binary polynomial.
**kwargs:
Parameters for the sampling method, specified by the child
sampler.
Returns:
:obj:`dimod.SampleSet` | 5.012397 | 5.5065 | 0.910269 |
itersamples = iter(samples_dicts)
first_sample = next(itersamples)
if labels is None:
labels = list(first_sample)
num_variables = len(labels)
def _iter_samples():
yield np.fromiter((first_sample[v] for v in labels),
count=num_variables, dtype=np.int... | def _samples_dicts_to_array(samples_dicts, labels) | Convert an iterable of samples where each sample is a dict to a numpy 2d array. Also
determines the labels is they are None. | 2.670012 | 2.507655 | 1.064744 |
if not len(sample):
# if samples are empty
sample = np.zeros((0, 0), dtype=np.int8)
else:
sample = np.asarray(sample, dtype=np.int8)
if sample.ndim < 2:
sample = np.expand_dims(sample, 0)
num_samples, num_variables = sample.shape
if 'num_occurrences' n... | def data_struct_array(sample, **vectors): # data_struct_array(sample, *, energy, **vectors) | Combine samples and per-sample data into a numpy structured array.
Args:
sample (array_like):
Samples, in any form that can be converted into a numpy array.
energy (array_like, required):
Required keyword argument. Energies, in any form that can be converted into a numpy
... | 2.977496 | 2.913404 | 1.021999 |
# there is no np.is_array_like so we use a try-except block
try:
# trying to cast it to int8 rules out list of dictionaries. If we didn't try to cast
# then it would just create a vector of np.object
samples = np.asarray(samples_like, dtype=np.int8)
... | def from_samples(cls, samples_like, vectors, info, vartype, variable_labels=None) | Build a response from samples.
Args:
samples_like:
A collection of samples. 'samples_like' is an extension of NumPy's array_like
to include an iterable of sample dictionaries (as returned by
:meth:`.Response.samples`).
data_vectors (dict[... | 6.841155 | 7.531393 | 0.908352 |
'''
.. todo:: add documentation of this method
``config``: doxygen input we're looking for
``required``: if ``True``, must be present. if ``False``, NOT ALLOWED to be present
'''
re_template = r"\s*{config}\s*=.*".format(config=config)
found = re.search(re_template, configs.exhaleDoxygenSt... | def _valid_config(config, required) | .. todo:: add documentation of this method
``config``: doxygen input we're looking for
``required``: if ``True``, must be present. if ``False``, NOT ALLOWED to be present | 10.233698 | 3.802764 | 2.691121 |
'''
This method **assumes** that :func:`~exhale.configs.apply_sphinx_configurations` has
already been applied. It performs minimal sanity checking, and then performs in
order
1. Creates a :class:`~exhale.graph.ExhaleRoot` object.
2. Executes :func:`~exhale.graph.ExhaleRoot.parse` for this obje... | def explode() | This method **assumes** that :func:`~exhale.configs.apply_sphinx_configurations` has
already been applied. It performs minimal sanity checking, and then performs in
order
1. Creates a :class:`~exhale.graph.ExhaleRoot` object.
2. Executes :func:`~exhale.graph.ExhaleRoot.parse` for this object.
3. E... | 3.99386 | 2.263959 | 1.764105 |
if self.kind == "function":
# TODO: breathe bug with templates and overloads, don't know what to do...
return "{name}({parameters})".format(
name=self.name,
parameters=", ".join(self.parameters)
)
return self.name | def breathe_identifier(self) | The unique identifier for breathe directives.
.. note::
This method is currently assumed to only be called for nodes that are
in :data:`exhale.utils.LEAF_LIKE_KINDS` (see also
:func:`exhale.graph.ExhaleRoot.generateSingleNodeRST` where it is used).
**Return**
... | 6.325151 | 5.751553 | 1.099729 |
if self.kind == "function":
return "{template}{return_type} {name}({parameters})".format(
template="template <{0}> ".format(", ".join(self.template)) if self.template else "",
return_type=self.return_type,
name=self.name,
param... | def full_signature(self) | The full signature of a ``"function"`` node.
**Return**
:class:`python:str`
The full signature of the function, including template, return type,
name, and parameter types.
**Raises**
:class:`python:RuntimeError`
If ``self.kind != ... | 2.86436 | 2.404504 | 1.191248 |
'''
.. todo::
document this, create another method for creating this without the need for
generating links, to be used in making the node titles and labels
'''
if not self.template_params:
return None
else:
param_stream = StringIO()
... | def templateParametersStringAsRestList(self, nodeByRefid) | .. todo::
document this, create another method for creating this without the need for
generating links, to be used in making the node titles and labels | 5.566667 | 4.806118 | 1.158246 |
'''
.. todo:: long time from now: intersphinx should be possible here
'''
# lst should either be self.base_compounds or self.derived_compounds
if not lst:
return None
bod_stream = StringIO()
for prot, refid, string in lst:
bod_stream.write... | def baseOrDerivedListString(self, lst, nodeByRefid) | .. todo:: long time from now: intersphinx should be possible here | 3.991021 | 3.497262 | 1.141184 |
'''
Recursive helper function for finding nested namespaces. If this node is a
namespace node, it is appended to ``lst``. Each node also calls each of its
child ``findNestedNamespaces`` with the same list.
:Parameters:
``lst`` (list)
The list each n... | def findNestedNamespaces(self, lst) | Recursive helper function for finding nested namespaces. If this node is a
namespace node, it is appended to ``lst``. Each node also calls each of its
child ``findNestedNamespaces`` with the same list.
:Parameters:
``lst`` (list)
The list each namespace node is to ... | 5.444863 | 1.654322 | 3.291297 |
'''
Recursive helper function for finding nested directories. If this node is a
directory node, it is appended to ``lst``. Each node also calls each of its
child ``findNestedDirectories`` with the same list.
:Parameters:
``lst`` (list)
The list each... | def findNestedDirectories(self, lst) | Recursive helper function for finding nested directories. If this node is a
directory node, it is appended to ``lst``. Each node also calls each of its
child ``findNestedDirectories`` with the same list.
:Parameters:
``lst`` (list)
The list each directory node is t... | 5.677312 | 1.656278 | 3.427752 |
'''
Recursive helper function for finding nested classes and structs. If this node
is a class or struct, it is appended to ``lst``. Each node also calls each of
its child ``findNestedClassLike`` with the same list.
:Parameters:
``lst`` (list)
The li... | def findNestedClassLike(self, lst) | Recursive helper function for finding nested classes and structs. If this node
is a class or struct, it is appended to ``lst``. Each node also calls each of
its child ``findNestedClassLike`` with the same list.
:Parameters:
``lst`` (list)
The list each class or str... | 4.943155 | 1.524103 | 3.243321 |
'''
Recursive helper function for finding nested enums. If this node is a class or
struct it may have had an enum added to its child list. When this occurred, the
enum was removed from ``self.enums`` in the :class:`~exhale.graph.ExhaleRoot`
class and needs to be rediscovered by... | def findNestedEnums(self, lst) | Recursive helper function for finding nested enums. If this node is a class or
struct it may have had an enum added to its child list. When this occurred, the
enum was removed from ``self.enums`` in the :class:`~exhale.graph.ExhaleRoot`
class and needs to be rediscovered by calling this method... | 8.826309 | 1.317811 | 6.697707 |
'''
Recursive helper function for finding nested unions. If this node is a class or
struct it may have had a union added to its child list. When this occurred, the
union was removed from ``self.unions`` in the :class:`~exhale.graph.ExhaleRoot`
class and needs to be rediscovered... | def findNestedUnions(self, lst) | Recursive helper function for finding nested unions. If this node is a class or
struct it may have had a union added to its child list. When this occurred, the
union was removed from ``self.unions`` in the :class:`~exhale.graph.ExhaleRoot`
class and needs to be rediscovered by calling this met... | 8.975955 | 1.306997 | 6.867615 |
'''
Debugging tool for printing hierarchies / ownership to the console. Recursively
calls children ``toConsole`` if this node is not a directory or a file, and
``printChildren == True``.
.. todo:: fmt_spec docs needed. keys are ``kind`` and values are color spec
:Param... | def toConsole(self, level, fmt_spec, printChildren=True) | Debugging tool for printing hierarchies / ownership to the console. Recursively
calls children ``toConsole`` if this node is not a directory or a file, and
``printChildren == True``.
.. todo:: fmt_spec docs needed. keys are ``kind`` and values are color spec
:Parameters:
`... | 3.51556 | 2.130556 | 1.650067 |
'''
Sorts ``self.children`` in place, and has each child sort its own children.
Refer to :func:`~exhale.graph.ExhaleRoot.deepSortList` for more information on
when this is necessary.
'''
self.children.sort()
for c in self.children:
c.typeSort() | def typeSort(self) | Sorts ``self.children`` in place, and has each child sort its own children.
Refer to :func:`~exhale.graph.ExhaleRoot.deepSortList` for more information on
when this is necessary. | 7.761649 | 1.746968 | 4.442926 |
'''
Whether or not this node should be included in the class view hierarchy. Helper
method for :func:`~exhale.graph.ExhaleNode.toHierarchy`. Sets the member
variable ``self.in_class_hierarchy`` to True if appropriate.
:Return (bool):
True if this node should be inc... | def inClassHierarchy(self) | Whether or not this node should be included in the class view hierarchy. Helper
method for :func:`~exhale.graph.ExhaleNode.toHierarchy`. Sets the member
variable ``self.in_class_hierarchy`` to True if appropriate.
:Return (bool):
True if this node should be included in the class v... | 7.11984 | 2.619694 | 2.717814 |
'''
Whether or not this node should be included in the file view hierarchy. Helper
method for :func:`~exhale.graph.ExhaleNode.toHierarchy`. Sets the member
variable ``self.in_file_hierarchy`` to True if appropriate.
:Return (bool):
True if this node should be inclu... | def inFileHierarchy(self) | Whether or not this node should be included in the file view hierarchy. Helper
method for :func:`~exhale.graph.ExhaleNode.toHierarchy`. Sets the member
variable ``self.in_file_hierarchy`` to True if appropriate.
:Return (bool):
True if this node should be included in the file view... | 6.461352 | 1.925473 | 3.355722 |
'''
The first method that should be called after creating an ExhaleRoot object. The
Breathe graph is parsed first, followed by the Doxygen xml documents. By the
end of this method, all of the ``self.<breathe_kind>``, ``self.all_compounds``,
and ``self.all_nodes`` lists as well ... | def parse(self) | The first method that should be called after creating an ExhaleRoot object. The
Breathe graph is parsed first, followed by the Doxygen xml documents. By the
end of this method, all of the ``self.<breathe_kind>``, ``self.all_compounds``,
and ``self.all_nodes`` lists as well as the ``self.node_b... | 4.883 | 1.885476 | 2.589798 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.discoverAllNodes`. If the node
is not in self.all_nodes yet, add it to both self.all_nodes as well as the
corresponding ``self.<breathe_kind>`` list.
:Parameters:
``node`` (ExhaleNode)
The node to... | def trackNodeIfUnseen(self, node) | Helper method for :func:`~exhale.graph.ExhaleRoot.discoverAllNodes`. If the node
is not in self.all_nodes yet, add it to both self.all_nodes as well as the
corresponding ``self.<breathe_kind>`` list.
:Parameters:
``node`` (ExhaleNode)
The node to begin tracking if n... | 2.312263 | 1.498292 | 1.543266 |
'''
Fixes some of the parental relationships lost in parsing the Breathe graph.
File relationships are recovered in
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery`. This method simply calls in
this order:
1. :func:`~exhale.graph.ExhaleRoot.reparentUnions`
2. :... | def reparentAll(self) | Fixes some of the parental relationships lost in parsing the Breathe graph.
File relationships are recovered in
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery`. This method simply calls in
this order:
1. :func:`~exhale.graph.ExhaleRoot.reparentUnions`
2. :func:`~exhale.graph.... | 4.347672 | 1.51403 | 2.871589 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Namespaces and
classes should have the unions defined in them to be in the child list of itself
rather than floating around. Union nodes that are reparented (e.g. a union
defined in a class) will be removed fro... | def reparentUnions(self) | Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Namespaces and
classes should have the unions defined in them to be in the child list of itself
rather than floating around. Union nodes that are reparented (e.g. a union
defined in a class) will be removed from the list ``self.un... | 6.903361 | 3.187922 | 2.165473 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Iterates over the
``self.class_like`` list and adds each object as a child to a namespace if the
class, or struct is a member of that namespace. Many classes / structs will be
reparented to a namespace node, the... | def reparentClassLike(self) | Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Iterates over the
``self.class_like`` list and adds each object as a child to a namespace if the
class, or struct is a member of that namespace. Many classes / structs will be
reparented to a namespace node, these will remain in ``... | 4.499157 | 1.540169 | 2.921211 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Adds
subdirectories as children to the relevant directory ExhaleNode. If a node in
``self.dirs`` is added as a child to a different directory node, it is removed
from the ``self.dirs`` list.
'''
... | def reparentDirectories(self) | Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Adds
subdirectories as children to the relevant directory ExhaleNode. If a node in
``self.dirs`` is added as a child to a different directory node, it is removed
from the ``self.dirs`` list. | 3.893753 | 2.354201 | 1.653959 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Some compounds in
Breathe such as functions and variables do not have the namespace name they are
declared in before the name of the actual compound. This method prepends the
appropriate (nested) namespace name ... | def renameToNamespaceScopes(self) | Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Some compounds in
Breathe such as functions and variables do not have the namespace name they are
declared in before the name of the actual compound. This method prepends the
appropriate (nested) namespace name before the name of a... | 6.746808 | 1.48365 | 4.54744 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Adds nested
namespaces as children to the relevant namespace ExhaleNode. If a node in
``self.namespaces`` is added as a child to a different namespace node, it is
removed from the ``self.namespaces`` list. Bec... | def reparentNamespaces(self) | Helper method for :func:`~exhale.graph.ExhaleRoot.reparentAll`. Adds nested
namespaces as children to the relevant namespace ExhaleNode. If a node in
``self.namespaces`` is added as a child to a different namespace node, it is
removed from the ``self.namespaces`` list. Because these are remov... | 3.699821 | 2.159757 | 1.713073 |
'''
The real name of this method should be ``reparentFiles``, but to avoid confusion
with what stage this must happen at it is called this instead. After the
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery` method has been called, each
file will have its location parsed. This ... | def filePostProcess(self) | The real name of this method should be ``reparentFiles``, but to avoid confusion
with what stage this must happen at it is called this instead. After the
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery` method has been called, each
file will have its location parsed. This method reparents fil... | 5.435958 | 2.961779 | 1.835369 |
# Keys: string refid of either namespace or file nodes
# Values: list of function objects that should be defined there
parent_to_func = {}
for func in self.functions:
# Case 1: it is a function inside a namespace, the function information
# is in the name... | def parseFunctionSignatures(self) | Search file and namespace node XML contents for function signatures. | 3.912431 | 3.828655 | 1.021881 |
'''
Sort all internal lists (``class_like``, ``namespaces``, ``variables``, etc)
mostly how doxygen would, alphabetical but also hierarchical (e.g. structs
appear before classes in listings). Some internal lists are just sorted, and
some are deep sorted (:func:`~exhale.graph.Exh... | def sortInternals(self) | Sort all internal lists (``class_like``, ``namespaces``, ``variables``, etc)
mostly how doxygen would, alphabetical but also hierarchical (e.g. structs
appear before classes in listings). Some internal lists are just sorted, and
some are deep sorted (:func:`~exhale.graph.ExhaleRoot.deepSortList... | 7.157285 | 2.520052 | 2.840134 |
'''
This method creates the root library api file that will include all of the
different hierarchy views and full api listing. If ``self.root_directory`` is
not a current directory, it is created first. Afterward, the root API file is
created and its title is written, as well a... | def generateAPIRootHeader(self) | This method creates the root library api file that will include all of the
different hierarchy views and full api listing. If ``self.root_directory`` is
not a current directory, it is created first. Afterward, the root API file is
created and its title is written, as well as the value of
... | 4.840727 | 2.514243 | 1.925322 |
'''
Creates all of the reStructuredText documents related to types parsed by
Doxygen. This includes all leaf-like documents (``class``, ``struct``,
``enum``, ``typedef``, ``union``, ``variable``, and ``define``), as well as
namespace, file, and directory pages.
During t... | def generateNodeDocuments(self) | Creates all of the reStructuredText documents related to types parsed by
Doxygen. This includes all leaf-like documents (``class``, ``struct``,
``enum``, ``typedef``, ``union``, ``variable``, and ``define``), as well as
namespace, file, and directory pages.
During the reparenting phase... | 8.248937 | 1.564186 | 5.27363 |
'''
Generates the reStructuredText document for every namespace, including nested
namespaces that were removed from ``self.namespaces`` (but added as children
to one of the namespaces in ``self.namespaces``).
The documents generated do not use the Breathe namespace directive, bu... | def generateNamespaceNodeDocuments(self) | Generates the reStructuredText document for every namespace, including nested
namespaces that were removed from ``self.namespaces`` (but added as children
to one of the namespaces in ``self.namespaces``).
The documents generated do not use the Breathe namespace directive, but instead
li... | 6.451226 | 2.397125 | 2.691235 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateNamespaceNodeDocuments`.
Writes the reStructuredText file for the given namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node to create the reStructuredText document for.
'''
... | def generateSingleNamespace(self, nspace) | Helper method for :func:`~exhale.graph.ExhaleRoot.generateNamespaceNodeDocuments`.
Writes the reStructuredText file for the given namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node to create the reStructuredText document for. | 4.293704 | 3.360738 | 1.277607 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, ... | def generateNamespaceChildrenString(self, nspace) | Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variable... | 2.852701 | 2.012674 | 1.417369 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateNamespaceChildrenString`.
Used to build up a continuous string with all of the children separated out into
titled sections.
This generates a new titled section with ``sectionTitle`` and puts a link to
every no... | def generateSortedChildListString(self, stream, sectionTitle, lst) | Helper method for :func:`~exhale.graph.ExhaleRoot.generateNamespaceChildrenString`.
Used to build up a continuous string with all of the children separated out into
titled sections.
This generates a new titled section with ``sectionTitle`` and puts a link to
every node found in ``lst`` ... | 5.16213 | 1.782648 | 2.895766 |
'''
Generates all of the directory reStructuredText documents.
'''
all_dirs = []
for d in self.dirs:
d.findNestedDirectories(all_dirs)
for d in all_dirs:
self.generateDirectoryNodeRST(d) | def generateDirectoryNodeDocuments(self) | Generates all of the directory reStructuredText documents. | 6.524462 | 4.266243 | 1.529323 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateDirectoryNodeDocuments`.
Generates the reStructuredText documents for the given directory node.
Directory nodes will only link to files and subdirectories within it.
:Parameters:
``node`` (ExhaleNode)
... | def generateDirectoryNodeRST(self, node) | Helper method for :func:`~exhale.graph.ExhaleRoot.generateDirectoryNodeDocuments`.
Generates the reStructuredText documents for the given directory node.
Directory nodes will only link to files and subdirectories within it.
:Parameters:
``node`` (ExhaleNode)
The dire... | 2.906052 | 2.533778 | 1.146924 |
'''
When creating nodes, the filename needs to be relative to ``conf.py``, so it
will include ``self.root_directory``. However, when generating the API, the
file we are writing to is in the same directory as the generated node files so
we need to remove the directory path from a... | def gerrymanderNodeFilenames(self) | When creating nodes, the filename needs to be relative to ``conf.py``, so it
will include ``self.root_directory``. However, when generating the API, the
file we are writing to is in the same directory as the generated node files so
we need to remove the directory path from a given ExhaleNode's ... | 8.208669 | 1.656057 | 4.956754 |
'''
Wrapper method to create the view hierarchies. Currently it just calls
:func:`~exhale.graph.ExhaleRoot.generateClassView` and
:func:`~exhale.graph.ExhaleRoot.generateDirectoryView` --- if you want to implement
additional hierarchies, implement the additionaly hierarchy metho... | def generateViewHierarchies(self) | Wrapper method to create the view hierarchies. Currently it just calls
:func:`~exhale.graph.ExhaleRoot.generateClassView` and
:func:`~exhale.graph.ExhaleRoot.generateDirectoryView` --- if you want to implement
additional hierarchies, implement the additionaly hierarchy method and call it
... | 5.176383 | 1.709306 | 3.028354 |
'''
Generates the class view hierarchy, writing it to ``self.class_hierarchy_file``.
'''
class_view_stream = StringIO()
for n in self.namespaces:
n.toHierarchy(True, 0, class_view_stream)
# Add everything that was not nested in a namespace.
missing =... | def generateClassView(self) | Generates the class view hierarchy, writing it to ``self.class_hierarchy_file``. | 3.543362 | 3.21169 | 1.10327 |
'''
Generates the file view hierarchy, writing it to ``self.file_hierarchy_file``.
'''
file_view_stream = StringIO()
for d in self.dirs:
d.toHierarchy(False, 0, file_view_stream)
# add potential missing files (not sure if this is possible though)
mis... | def generateDirectoryView(self) | Generates the file view hierarchy, writing it to ``self.file_hierarchy_file``. | 4.106856 | 3.568967 | 1.150713 |
'''
Helper function for :func:`~exhale.graph.ExhaleRoot.generateUnabridgedAPI`.
Simply writes a subsection to ``openFile`` (a ``toctree`` to the ``file_name``)
of each ExhaleNode in ``sorted(lst)`` if ``len(lst) > 0``. Otherwise, nothing
is written to the file.
:Paramet... | def enumerateAll(self, subsectionTitle, lst, openFile) | Helper function for :func:`~exhale.graph.ExhaleRoot.generateUnabridgedAPI`.
Simply writes a subsection to ``openFile`` (a ``toctree`` to the ``file_name``)
of each ExhaleNode in ``sorted(lst)`` if ``len(lst) > 0``. Otherwise, nothing
is written to the file.
:Parameters:
``s... | 4.634601 | 1.776973 | 2.608144 |
'''
Convenience function for printing out the entire API being generated to the
console. Unused in the release, but is helpful for debugging ;)
'''
fmt_spec = {
"class": utils.AnsiColors.BOLD_MAGENTA,
"struct": utils.AnsiColors.BOLD_CYAN,
... | def toConsole(self) | Convenience function for printing out the entire API being generated to the
console. Unused in the release, but is helpful for debugging ;) | 1.86018 | 1.640301 | 1.134048 |
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.toConsole`. Prints the given
``sectionTitle`` and calls :func:`~exhale.graph.ExhaleNode.toConsole` with ``0``
as the level for every ExhaleNode in ``lst``.
**Parameters**
``sectionTitle`` (str)
Th... | def consoleFormat(self, sectionTitle, lst, fmt_spec) | Helper method for :func:`~exhale.graph.ExhaleRoot.toConsole`. Prints the given
``sectionTitle`` and calls :func:`~exhale.graph.ExhaleNode.toConsole` with ``0``
as the level for every ExhaleNode in ``lst``.
**Parameters**
``sectionTitle`` (str)
The title that will be... | 5.10704 | 2.123314 | 2.405221 |
'''
Generates a string ``.. contents::`` directives according to the rules outlined in
the :ref:`using_contents_directives` section.
**Parameters**
``kind`` (str)
The ``kind`` of the compound (one of :data:`~exhale.utils.AVAILABLE_KINDS`).
**Return**
``str`` or ``None``... | def contentsDirectiveOrNone(kind) | Generates a string ``.. contents::`` directives according to the rules outlined in
the :ref:`using_contents_directives` section.
**Parameters**
``kind`` (str)
The ``kind`` of the compound (one of :data:`~exhale.utils.AVAILABLE_KINDS`).
**Return**
``str`` or ``None``
... | 5.699548 | 2.439874 | 2.336001 |
'''
Creates the "pickleable" dictionary that will be used with
:data:`~exhale.configs.customSpecificationsMapping` supplied to ``exhale_args`` in
your ``conf.py``.
**Parameters**
``func`` (types.FunctionType)
A callable function that takes as input a string from
:dat... | def makeCustomSpecificationsMapping(func) | Creates the "pickleable" dictionary that will be used with
:data:`~exhale.configs.customSpecificationsMapping` supplied to ``exhale_args`` in
your ``conf.py``.
**Parameters**
``func`` (types.FunctionType)
A callable function that takes as input a string from
:data:`~exhale.u... | 5.990117 | 2.869396 | 2.087588 |
return name.replace(
"<", "<"
).replace(
">", ">"
).replace(
"&", "&"
).replace(
"< ", "<"
).replace(
" >", ">"
).replace(
" &", "&"
).replace(
"& ", "&"
) | def sanitize(name) | Sanitize the specified ``name`` for use with breathe directives.
**Parameters**
``name`` (:class:`python:str`)
The name to be sanitized.
**Return**
:class:`python:str`
The input ``name`` sanitized to use with breathe directives (primarily for use
with ``.. doxygenfunction::``... | 2.341747 | 2.350867 | 0.996121 |
'''
Given an input location and language specification, acquire the Pygments lexer to
use for this file.
1. If :data:`configs.lexerMapping <exhale.configs.lexerMapping>` has been specified,
then :data:`configs._compiled_lexer_mapping <exhale.configs._compiled_lexer_mapping>`
will be queri... | def doxygenLanguageToPygmentsLexer(location, language) | Given an input location and language specification, acquire the Pygments lexer to
use for this file.
1. If :data:`configs.lexerMapping <exhale.configs.lexerMapping>` has been specified,
then :data:`configs._compiled_lexer_mapping <exhale.configs._compiled_lexer_mapping>`
will be queried first usi... | 4.264505 | 1.336225 | 3.191458 |
'''
Based on :data:`~exhale.configs.alwaysColorize`, returns the colorized or
non-colorized output when ``output_stream`` is not a TTY (e.g. redirecting
to a file).
**Parameters**
``msg`` (str)
The message that is going to be printed by the caller of this method.
``ansi... | def _use_color(msg, ansi_fmt, output_stream) | Based on :data:`~exhale.configs.alwaysColorize`, returns the colorized or
non-colorized output when ``output_stream`` is not a TTY (e.g. redirecting
to a file).
**Parameters**
``msg`` (str)
The message that is going to be printed by the caller of this method.
``ansi_fmt`` (str)... | 4.303155 | 1.531517 | 2.809734 |
''' A simple enumeration of the colors to the console to help decide :) '''
for elem in cls.__dict__:
# ignore specials such as __class__ or __module__
if not elem.startswith("__"):
color_fmt = cls.__dict__[elem]
if isinstance(color_fmt, six.string... | def printAllColorsToConsole(cls) | A simple enumeration of the colors to the console to help decide :) | 6.047865 | 4.304467 | 1.405021 |
'''
Parses the ``node`` XML document and returns a reStructuredText formatted
string. Helper method for :func:`~exhale.parse.getBriefAndDetailedRST`.
.. todo:: actually document this
'''
if soupTag.para:
children = soupTag.findChildren(recursive=False)
for child in children:
... | def convertDescriptionToRST(textRoot, node, soupTag, heading) | Parses the ``node`` XML document and returns a reStructuredText formatted
string. Helper method for :func:`~exhale.parse.getBriefAndDetailedRST`.
.. todo:: actually document this | 6.559717 | 3.771461 | 1.739304 |
'''
Given an input ``node``, return a tuple of strings where the first element of
the return is the ``brief`` description and the second is the ``detailed``
description.
.. todo:: actually document this
'''
node_xml_contents = utils.nodeCompoundXMLContents(node)
if not node_xml_contents... | def getBriefAndDetailedRST(textRoot, node) | Given an input ``node``, return a tuple of strings where the first element of
the return is the ``brief`` description and the second is the ``detailed``
description.
.. todo:: actually document this | 5.296006 | 4.450863 | 1.189883 |
try:
path = self.endpoints[endpoint]
except KeyError:
msg = 'Unknown endpoint `{0}`'
raise ValueError(msg.format(endpoint))
absolute_url = urljoin(self.target, path)
return absolute_url | def _build_url(self, endpoint) | Builds the absolute URL using the target and desired endpoint. | 3.595913 | 2.973742 | 1.209222 |
url = self._build_url(constants.ADD_VERSION_ENDPOINT)
data = {
'project': project,
'version': version
}
files = {
'egg': egg
}
json = self.client.post(url, data=data, files=files,
timeout=self.ti... | def add_version(self, project, version, egg) | Adds a new project egg to the Scrapyd service. First class, maps to
Scrapyd's add version endpoint. | 3.658107 | 3.162836 | 1.156591 |
url = self._build_url(constants.CANCEL_ENDPOINT)
data = {
'project': project,
'job': job,
}
if signal is not None:
data['signal'] = signal
json = self.client.post(url, data=data, timeout=self.timeout)
return json['prevstate'] | def cancel(self, project, job, signal=None) | Cancels a job from a specific project. First class, maps to
Scrapyd's cancel job endpoint. | 3.206613 | 3.100116 | 1.034352 |
url = self._build_url(constants.DELETE_PROJECT_ENDPOINT)
data = {
'project': project,
}
self.client.post(url, data=data, timeout=self.timeout)
return True | def delete_project(self, project) | Deletes all versions of a project. First class, maps to Scrapyd's
delete project endpoint. | 3.841215 | 3.2331 | 1.18809 |
url = self._build_url(constants.DELETE_VERSION_ENDPOINT)
data = {
'project': project,
'version': version
}
self.client.post(url, data=data, timeout=self.timeout)
return True | def delete_version(self, project, version) | Deletes a specific version of a project. First class, maps to
Scrapyd's delete version endpoint. | 3.178209 | 2.889252 | 1.100011 |
all_jobs = self.list_jobs(project)
for state in constants.JOB_STATES:
job_ids = [job['id'] for job in all_jobs[state]]
if job_id in job_ids:
return state
return '' | def job_status(self, project, job_id) | Retrieves the 'status' of a specific job specified by its id. Derived,
utilises Scrapyd's list jobs endpoint to provide the answer. | 2.969967 | 3.044077 | 0.975654 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.