Module utils¶
c(*args)
¶
Emulate the R c (concatenate) function, somewhat.
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: [description] |
is_common_iterable(obj)
¶
True if an object is iterable but not a string (str)
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/utils.py
mk_full_data_id(*args)
¶
Create swift IDs (dot separated hierarchical naming scheme)
Create swift IDs (dot separated hierarchical naming scheme). Note that the behavior is different than 'paste' for empty characters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Any
|
one or more character vectors. |
()
|
Examples:
TODO
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/utils.py
paste(*lists, sep=' ', collapse=None)
¶
Port of R paste function
paste0(*lists, collapse=None)
¶
paste_2(x, y, sep=' ')
¶
Port of R vectorised paste, for 2 elements
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/utils.py
sort_by(x, unsorted_reference, sorted_reference)
¶
Sort one vector according to the known reordering of another
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Any
|
values to sort |
required |
unsorted_reference |
Any
|
unique 'keys' corresponding to each element in x |
required |
sorted_reference |
Any
|
set of 'keys', identical as a set to unsorted_reference, but sorted |
required |
Returns:
Type | Description |
---|---|
the values in x reordered such that the same reordering of unsorted_reference matches sorted_reference |
Examples:
TODO
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/utils.py
vpaste(root, vars)
¶
vectorised paste for 2 elements; Port of R paste0 in spirit
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root |
VecScalars
|
left hand side(s) of the paste |
required |
vars |
VecScalars
|
right hand side(s) of the paste |
required |
Returns:
Type | Description |
---|---|
Union[str, Sequence[str]]
|
Union[str,Sequence[str]]: pasted scalars |