text
stringlengths 0
828
|
|---|
----------
|
name: str or list of str
|
The variable names (one variable per array)
|
dims: list with length 1 or list of lists with length 1
|
The dimension of the arrays. Only 1D-Arrays are allowed
|
is_unstructured: bool or list of bool
|
True if the corresponding array is unstructured.
|
Returns
|
-------
|
%(Plotter.check_data.returns)s
|
""""""
|
if isinstance(name, six.string_types) or not is_iterable(name):
|
name = [name]
|
dims = [dims]
|
is_unstructured = [is_unstructured]
|
N = len(name)
|
if N != 1:
|
return [False] * N, [
|
'Number of provided names (%i) must equal 1!' % (N)] * N
|
elif len(dims) != 1:
|
return [False], [
|
'Number of provided dimension lists (%i) must equal 1!' % (
|
len(dims))]
|
elif len(is_unstructured) != 1:
|
return [False], [
|
('Number of provided unstructured information (%i) must '
|
'equal 1!') % (len(is_unstructured))]
|
if name[0] != 0 and not name[0]:
|
return [False], ['At least one variable name must be provided!']
|
# unstructured arrays have only 1 dimension
|
dimlen = cls.allowed_dims
|
if is_unstructured[0]:
|
dimlen -= 1
|
# Check that the array is two-dimensional
|
#
|
# if more than one array name is provided, the dimensions should be
|
# one les than dimlen to have a 2D array
|
if (not isstring(name[0]) and not is_iterable(name[0])
|
and len(name[0]) != 1 and len(dims[0]) != dimlen - 1):
|
return [False], ['Only one name is allowed per array!']
|
# otherwise the number of dimensions must equal dimlen
|
if len(dims[0]) != dimlen:
|
return [False], [
|
'An array with dimension %i is required, not %i' % (
|
dimlen, len(dims[0]))]
|
return [True], ['']"
|
815,"def check_data(cls, name, dims, is_unstructured):
|
""""""
|
A validation method for the data shape
|
Parameters
|
----------
|
name: list of str with length 2
|
The variable names (one for the first, two for the second array)
|
dims: list with length 2 of lists with length 1
|
The dimension of the arrays. Only 2D-Arrays are allowed (or 1-D if
|
an array is unstructured)
|
is_unstructured: bool or list of bool
|
True if the corresponding array is unstructured.
|
Returns
|
-------
|
%(Plotter.check_data.returns)s
|
""""""
|
if isinstance(name, six.string_types) or not is_iterable(name):
|
name = [name]
|
dims = [dims]
|
is_unstructured = [is_unstructured]
|
msg = ('Two arrays are required (one for the scalar and '
|
'one for the vector field)')
|
if len(name) < 2:
|
return [None], [msg]
|
elif len(name) > 2:
|
return [False], [msg]
|
valid1, msg1 = Simple2DBase.check_data(name[:1], dims[0:1],
|
is_unstructured[:1])
|
valid2, msg2 = BaseVectorPlotter.check_data(name[1:], dims[1:],
|
is_unstructured[1:])
|
return valid1 + valid2, msg1 + msg2"
|
816,"def record_diff(old, new):
|
""""""Return a JSON-compatible structure capable turn the `new` record back
|
into the `old` record. The parameters must be structures compatible with
|
json.dumps *or* strings compatible with json.loads. Note that by design,
|
`old == record_patch(new, record_diff(old, new))`""""""
|
old, new = _norm_json_params(old, new)
|
return json_delta.diff(new, old, verbose=False)"
|
817,"def record_patch(rec, diff):
|
""""""Return the JSON-compatible structure that results from applying the
|
changes in `diff` to the record `rec`. The parameters must be structures
|
compatible with json.dumps *or* strings compatible with json.loads. Note
|
that by design, `old == record_patch(new, record_diff(old, new))`""""""
|
rec, diff = _norm_json_params(rec, diff)
|
return json_delta.patch(rec, diff, in_place=False)"
|
818,"def append_diff_hist(diff, diff_hist=list()):
|
""""""Given a diff as generated by record_diff, append a diff record to the
|
list of diff_hist records.""""""
|
diff, diff_hist = _norm_json_params(diff, diff_hist)
|
if not diff_hist:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.