Returns a batch generator from given iterable.
Parameters: |
|
---|---|
Returns: | Is string_like variable. |
Return type: | bool |
Examples
>>> batch(tuple(range(10)))
<generator object batch at 0x...>
Returns if scipy is installed and available.
Parameters: | raise_exception (bool) – Raise exception if scipy is unavailable. |
---|---|
Returns: | Is scipy installed. |
Return type: | bool |
Raises: | ImportError – If scipy is not installed. |
Returns if given data is a string_like variable.
Parameters: | data (object) – Data to test. |
---|---|
Returns: | Is string_like variable. |
Return type: | bool |
Examples
>>> is_string('I`m a string!')
True
>>> is_string(['I`m a string!'])
False
Bases: dict
Extends dict type to provide a lookup by value(s).
References
[2] | Mansencal, T. (n.d.). Lookup. Retrieved from https://github.com/KelSolaar/Foundations/blob/develop/foundations/data_structures.py |
Examples
>>> person = Lookup(first_name='Doe', last_name='John', gender='male')
>>> person.first_key_from_value('Doe')
'first_name'
>>> persons = Lookup(John='Doe', Jane='Doe', Luke='Skywalker')
>>> sorted(persons.keys_from_value('Doe'))
['Jane', 'John']
Gets the first key with given value.
Parameters: | value (object) – Value. |
---|---|
Returns: | Key. |
Return type: | object |
Gets the keys with given value.
Parameters: | value (object) – Value. |
---|---|
Returns: | Keys. |
Return type: | object |
Bases: dict
Defines an object similar to C/C++ structured type.
Parameters: |
|
---|
References
[1] | Mansencal, T. (n.d.). Structure. Retrieved from https://github.com/KelSolaar/Foundations/blob/develop/foundations/data_structures.py |
Examples
>>> person = Structure(first_name='Doe', last_name='John', gender='male')
>>> # Doctests skip for Python 2.x compatibility.
>>> person.first_name
'Doe'
>>> sorted(person.keys())
['first_name', 'gender', 'last_name']
>>> # Doctests skip for Python 2.x compatibility.
>>> person['gender']
'male'
Deletes both key and sibling attribute.
Parameters: | attribute (object) – Attribute. |
---|
Notes
Deletes both key and sibling attribute.
Parameters: | attribute (object) – Attribute. |
---|
Notes
Returns given attribute value.
Parameters: | attribute (unicode) – Attribute name. |
---|
Notes
Returns: | Attribute value. |
---|---|
Return type: | object |
Raises: | AttributeError – If the attribute is not defined. |
Sets both key and sibling attribute with given value.
Parameters: |
|
---|
Notes
Sets both key and sibling attribute with given value.
Parameters: |
|
---|
Notes
Updates both keys and sibling attributes.
Parameters: |
|
---|
Notes
Bases: _abcoll.MutableMapping
Implements a case-insensitive mutable mapping / dict object.
Allows values retrieving from keys while ignoring the key case. The keys are expected to be unicode or string-like objects supporting the str.lower() method.
Parameters: |
|
---|
Warning
The keys are expected to be unicode or string-like objects.
References
[3] | Reitz, K. (n.d.). CaseInsensitiveDict. Retrieved from https://github.com/kennethreitz/requests/blob/v1.2.3/requests/structures.py#L37 |
Examples
>>> methods = CaseInsensitiveMapping({'McCamy': 1, 'Hernandez': 2})
>>> methods['mccamy']
1
Returns if the mapping contains given item.
Parameters: | item (unicode) – Item name. |
---|---|
Returns: | Is item in mapping. |
Return type: | bool |
Notes
Deletes the item with given name.
The item is deleted from the mapping using its lower name.
Parameters: | item (unicode) – Item name. |
---|
Notes
Returns the equality with given object.
Parameters: | item – Object item. |
---|---|
Returns: | Equality. |
Return type: | bool |
Notes
Returns the value of given item.
The item value is retrieved using its lower name in the mapping.
Parameters: | item (unicode) – Item name. |
---|---|
Returns: | Item value |
Return type: | object |
Notes
Iterates over the items names in the mapping.
The item names returned are the original input ones.
Returns: | Item names. |
---|---|
Return type: | generator |
Notes
Returns the items count.
Returns: | Items count. |
---|---|
Return type: | int |
Notes
Returns the inequality with given object.
Parameters: | item – Object item. |
---|---|
Returns: | Inequality. |
Return type: | bool |
Notes
Returns the mapping representation with the original item names.
Returns: | Mapping representation. |
---|---|
Return type: | unicode |
Notes
Sets given item with given value.
The item is stored as lower in the mapping while the original name and its value are stored together as the value in a tuple:
{“item.lower()”: (“item”, value)}
Parameters: |
|
---|
Notes
Returns a copy of the mapping.
Returns: | Mapping copy. |
---|---|
Return type: | CaseInsensitiveMapping |
Notes
Iterates over the lower items names.
Returns: | Lower item names. |
---|---|
Return type: | generator |
Prints a message inside a box.
Parameters: |
|
---|---|
Returns: | Definition success. |
Return type: | bool |
Examples
>>> message = ('Lorem ipsum dolor sit amet, consectetur adipiscing elit, '
... 'sed do eiusmod tempor incididunt ut labore et dolore magna '
... 'aliqua.')
>>> message_box(message, width=75)
===========================================================================
* *
* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do *
* eiusmod tempor incididunt ut labore et dolore magna aliqua. *
* *
===========================================================================
True
>>> message_box(message, width=60)
============================================================
* *
* Lorem ipsum dolor sit amet, consectetur adipiscing *
* elit, sed do eiusmod tempor incididunt ut labore et *
* dolore magna aliqua. *
* *
============================================================
True
>>> message_box(message, width=75, padding=16)
===========================================================================
* *
* Lorem ipsum dolor sit amet, consectetur *
* adipiscing elit, sed do eiusmod tempor *
* incididunt ut labore et dolore magna *
* aliqua. *
* *
===========================================================================
True
Issues a warning.
Parameters: |
|
---|---|
Returns: | Definition success. |
Return type: | bool |
Examples
>>> colour.utilities.warning('This is a warning!')
/Users/.../colour/utilities/verbose.py:42: UserWarning: This is a warning!