code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def from_range_10( a: ArrayLike, scale_factor: ArrayLike = 10, dtype: Type[DTypeFloat] | None = None, ) -> NDArray: """ Scale specified array :math:`a` from range **'10'**, used by *Munsell Renotation System*. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'*...
Scale specified array :math:`a` from range **'10'**, used by *Munsell Renotation System*. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'**, the definition is entirely by-passed. - If *Colour* domain-range scale is **'1'**, array :math:`a` is divided ...
from_range_10
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def from_range_100( a: ArrayLike, scale_factor: ArrayLike = 100, dtype: Type[DTypeFloat] | None = None, ) -> NDArray: """ Scale specified array :math:`a` from range **'100'**. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'** or **'100'** (currently ...
Scale specified array :math:`a` from range **'100'**. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'** or **'100'** (currently unsupported private value only used for unit tests), the definition is entirely by-passed. - If *Colour* domain-range scale...
from_range_100
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def from_range_degrees( a: ArrayLike, scale_factor: ArrayLike = 360, dtype: Type[DTypeFloat] | None = None, ) -> NDArray: """ Scale specified array :math:`a` from degrees range. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'**, the definition is ent...
Scale specified array :math:`a` from degrees range. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'**, the definition is entirely by-passed. - If *Colour* domain-range scale is **'1'**, array :math:`a` is divided by ``scale_factor``, typically 360. ...
from_range_degrees
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def from_range_int( a: ArrayLike, bit_depth: ArrayLike = 8, dtype: Type[DTypeFloat] | None = None, ) -> NDArray: """ Scale specified array :math:`a` from int range. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'**, the definition is entirely by-passed. ...
Scale specified array :math:`a` from int range. The behaviour is as follows: - If *Colour* domain-range scale is **'Reference'**, the definition is entirely by-passed. - If *Colour* domain-range scale is **'1'**, array :math:`a` is converted to :class:`np.ndarray` and divided by :math:...
from_range_int
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def set_ndarray_copy_enable(enable: bool) -> None: """ Set *Colour* :class:`numpy.ndarray` copy enabled state. Parameters ---------- enable Whether to enable *Colour* :class:`numpy.ndarray` copy. Examples -------- >>> with ndarray_copy_enable(is_ndarray_copy_enabled()): ......
Set *Colour* :class:`numpy.ndarray` copy enabled state. Parameters ---------- enable Whether to enable *Colour* :class:`numpy.ndarray` copy. Examples -------- >>> with ndarray_copy_enable(is_ndarray_copy_enabled()): ... print(is_ndarray_copy_enabled()) ... set_ndar...
set_ndarray_copy_enable
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def ndarray_copy(a: NDArray) -> NDArray: """ Return a :class:`numpy.ndarray` copy if the relevant *Colour* state is enabled: Various API objects return a copy of their internal :class:`numpy.ndarray` for safety purposes but this can be a slow operation impacting performance. Parameters ----...
Return a :class:`numpy.ndarray` copy if the relevant *Colour* state is enabled: Various API objects return a copy of their internal :class:`numpy.ndarray` for safety purposes but this can be a slow operation impacting performance. Parameters ---------- a Array :math:`a` to return a...
ndarray_copy
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def closest_indexes(a: ArrayLike, b: ArrayLike) -> NDArray: """ Return the array :math:`a` closest element indexes to the reference array :math:`b` elements. Parameters ---------- a Array :math:`a` to search for the closest element indexes. b Reference array :math:`b`. ...
Return the array :math:`a` closest element indexes to the reference array :math:`b` elements. Parameters ---------- a Array :math:`a` to search for the closest element indexes. b Reference array :math:`b`. Returns ------- :class:`numpy.ndarray` Closest arra...
closest_indexes
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def closest(a: ArrayLike, b: ArrayLike) -> NDArray: """ Return the closest array :math:`a` elements to the reference array :math:`b` elements. Parameters ---------- a Array :math:`a` to search for the closest element. b Reference array :math:`b`. Returns ------- ...
Return the closest array :math:`a` elements to the reference array :math:`b` elements. Parameters ---------- a Array :math:`a` to search for the closest element. b Reference array :math:`b`. Returns ------- :class:`numpy.ndarray` Closest array :math:`a` ele...
closest
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def interval(distribution: ArrayLike, unique: bool = True) -> NDArray: """ Return the interval size of specified distribution. Parameters ---------- distribution Distribution to retrieve the interval. unique Whether to return unique intervals if the distribution is non-...
Return the interval size of specified distribution. Parameters ---------- distribution Distribution to retrieve the interval. unique Whether to return unique intervals if the distribution is non-uniformly spaced or the complete intervals Returns ------- :class...
interval
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def in_array(a: ArrayLike, b: ArrayLike, tolerance: Real = EPSILON) -> NDArray: """ Return whether each element of the array :math:`a` is also present in the array :math:`b` within specified tolerance. Parameters ---------- a Array :math:`a` to test the elements from. b The ...
Return whether each element of the array :math:`a` is also present in the array :math:`b` within specified tolerance. Parameters ---------- a Array :math:`a` to test the elements from. b The array :math:`b` against which to test the elements of array :math:`a`. tole...
in_array
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def tstack( a: ArrayLike, dtype: Type[DTypeBoolean] | Type[DTypeReal] | None = None, ) -> NDArray: """ Stack specified array of arrays :math:`a` along the last axis (tail) to produce a stacked array. It is used to stack an array of arrays produced by the :func:`colour.utilities.tsplit` defi...
Stack specified array of arrays :math:`a` along the last axis (tail) to produce a stacked array. It is used to stack an array of arrays produced by the :func:`colour.utilities.tsplit` definition. Parameters ---------- a Array of arrays :math:`a` to stack along the last axis. d...
tstack
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def tsplit( a: ArrayLike, dtype: Type[DTypeBoolean] | Type[DTypeReal] | None = None, ) -> NDArray: """ Split specified stacked array :math:`a` along the last axis (tail) to produce an array of arrays. It is used to split a stacked array produced by the :func:`colour.utilities.tstack` defini...
Split specified stacked array :math:`a` along the last axis (tail) to produce an array of arrays. It is used to split a stacked array produced by the :func:`colour.utilities.tstack` definition. Parameters ---------- a Stacked array :math:`a` to split. dtype :class:`num...
tsplit
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def row_as_diagonal(a: ArrayLike) -> NDArray: """ Return the rows of specified array :math:`a` as diagonal matrices. Parameters ---------- a Array :math:`a` to returns the rows of as diagonal matrices. Returns ------- :class:`numpy.ndarray` Array :math:`a` rows as diago...
Return the rows of specified array :math:`a` as diagonal matrices. Parameters ---------- a Array :math:`a` to returns the rows of as diagonal matrices. Returns ------- :class:`numpy.ndarray` Array :math:`a` rows as diagonal matrices. References ---------- :cit...
row_as_diagonal
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def orient( a: ArrayLike, orientation: ( Literal["Ignore", "Flip", "Flop", "90 CW", "90 CCW", "180"] | str ) = "Ignore", ) -> NDArray: """ Orient specified array :math:`a` according to specified orientation. Parameters ---------- a Array :math:`a` to orient. orientat...
Orient specified array :math:`a` according to specified orientation. Parameters ---------- a Array :math:`a` to orient. orientation Orientation to perform. Returns ------- :class:`numpy.ndarray` Oriented array. Examples -------- >>> a = np.tile(np....
orient
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def centroid(a: ArrayLike) -> NDArrayInt: """ Return the centroid indexes of specified array :math:`a`. Parameters ---------- a Array :math:`a` to returns the centroid indexes of. Returns ------- :class:`numpy.ndarray` Array :math:`a` centroid indexes. Examples ...
Return the centroid indexes of specified array :math:`a`. Parameters ---------- a Array :math:`a` to returns the centroid indexes of. Returns ------- :class:`numpy.ndarray` Array :math:`a` centroid indexes. Examples -------- >>> a = np.tile(np.arange(0, 5), (5...
centroid
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def fill_nan( a: ArrayLike, method: Literal["Interpolation", "Constant"] | str = "Interpolation", default: Real = 0, ) -> NDArray: """ Fill specified array :math:`a` NaN values according to specified method. Parameters ---------- a Array :math:`a` to fill the NaNs of. method...
Fill specified array :math:`a` NaN values according to specified method. Parameters ---------- a Array :math:`a` to fill the NaNs of. method *Interpolation* method linearly interpolates through the NaN values, *Constant* method replaces NaN values with ``default``. defa...
fill_nan
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def ndarray_write(a: ArrayLike) -> Generator: """ Define a context manager setting specified array :math:`a` writeable to operate one and then read-only. Parameters ---------- a Array :math:`a` to operate on. Yields ------ Generator Array :math:`a` operated. Ex...
Define a context manager setting specified array :math:`a` writeable to operate one and then read-only. Parameters ---------- a Array :math:`a` to operate on. Yields ------ Generator Array :math:`a` operated. Examples -------- >>> a = np.linspace(0, 1, 10)...
ndarray_write
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def zeros( shape: int | Sequence[int], dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", ) -> NDArray: """ Wrap :func:`np.zeros` definition to create an array with the active :class:`numpy.dtype` defined by the :attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. P...
Wrap :func:`np.zeros` definition to create an array with the active :class:`numpy.dtype` defined by the :attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. Parameters ---------- shape Shape of the new array, e.g., ``(2, 3)`` or ``2``. dtype :class:`numpy.dtype` to use fo...
zeros
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def ones( shape: int | Sequence[int], dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", ) -> NDArray: """ Wrap :func:`np.ones` definition to create an array with the active :class:`numpy.dtype` defined by the :attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. Par...
Wrap :func:`np.ones` definition to create an array with the active :class:`numpy.dtype` defined by the :attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. Parameters ---------- shape Shape of the new array, e.g., ``(2, 3)`` or ``2``. dtype :class:`numpy.dtype` to use for...
ones
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def full( shape: int | Sequence[int], fill_value: Real, dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", ) -> NDArray: """ Wrap :func:`np.full` definition to create an array with the active type defined by the:attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. Pa...
Wrap :func:`np.full` definition to create an array with the active type defined by the:attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. Parameters ---------- shape Shape of the new array, e.g., ``(2, 3)`` or ``2``. fill_value Fill value. dtype :class:`numpy.dty...
full
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def index_along_last_axis(a: ArrayLike, indexes: ArrayLike) -> NDArray: """ Reduce the dimension of array :math:`a` by one, by using an array of indexes to pick elements off the last axis. Parameters ---------- a Array :math:`a` to be indexed. indexes *integer* array with th...
Reduce the dimension of array :math:`a` by one, by using an array of indexes to pick elements off the last axis. Parameters ---------- a Array :math:`a` to be indexed. indexes *integer* array with the same shape as `a` but with one dimension fewer, containing indices to...
index_along_last_axis
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def format_array_as_row(a: ArrayLike, decimals: int = 7, separator: str = " ") -> str: """ Format specified array :math:`a` as a row. Parameters ---------- a Array to format. decimals Decimal count to use when formatting as a row. separator Separator used to join the...
Format specified array :math:`a` as a row. Parameters ---------- a Array to format. decimals Decimal count to use when formatting as a row. separator Separator used to join the array :math:`a` items. Returns ------- :class:`str` Array formatted as a...
format_array_as_row
python
colour-science/colour
colour/utilities/array.py
https://github.com/colour-science/colour/blob/master/colour/utilities/array.py
BSD-3-Clause
def __setattr__(self, name: str, value: Any) -> None: """ Set specified value to the attribute with specified name. Parameters ---------- attribute Attribute to set the value of. value Value to set the attribute with. """ if hasat...
Set specified value to the attribute with specified name. Parameters ---------- attribute Attribute to set the value of. value Value to set the attribute with.
__setattr__
python
colour-science/colour
colour/utilities/callback.py
https://github.com/colour-science/colour/blob/master/colour/utilities/callback.py
BSD-3-Clause
def unregister_callback(self, attribute: str, name: str) -> None: """ Unregister the callback with specified name for specified attribute. Parameters ---------- attribute Attribute to unregister the callback for. name Callback name. Examp...
Unregister the callback with specified name for specified attribute. Parameters ---------- attribute Attribute to unregister the callback for. name Callback name. Examples -------- >>> class WithCallback(MixinCallback): ....
unregister_callback
python
colour-science/colour
colour/utilities/callback.py
https://github.com/colour-science/colour/blob/master/colour/utilities/callback.py
BSD-3-Clause
def set_caching_enable(enable: bool) -> None: """ Set *Colour* caching enabled state. Parameters ---------- enable Whether to enable *Colour* caching. Examples -------- >>> with caching_enable(True): ... print(is_caching_enabled()) ... set_caching_enable(False) ...
Set *Colour* caching enabled state. Parameters ---------- enable Whether to enable *Colour* caching. Examples -------- >>> with caching_enable(True): ... print(is_caching_enabled()) ... set_caching_enable(False) ... print(is_caching_enabled()) True ...
set_caching_enable
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def __str__(self) -> str: """ Return a formatted string representation of the cache registry. Returns ------- :class:`str` Formatted string representation. """ return pformat( { name: f"{len(self._registry[name])} item(s)"...
Return a formatted string representation of the cache registry. Returns ------- :class:`str` Formatted string representation.
__str__
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def handle_numpy_errors(**kwargs: Any) -> Callable: """ Decorate a function to handle *Numpy* errors. Other Parameters ---------------- kwargs Keywords arguments. Returns ------- Callable References ---------- :cite:`Kienzle2011a` Examples -------- >>>...
Decorate a function to handle *Numpy* errors. Other Parameters ---------------- kwargs Keywords arguments. Returns ------- Callable References ---------- :cite:`Kienzle2011a` Examples -------- >>> import numpy >>> @handle_numpy_errors(all="ignore") ...
handle_numpy_errors
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def ignore_python_warnings(function: Callable) -> Callable: """ Decorate a function to ignore *Python* warnings. Parameters ---------- function Function to decorate. Returns ------- Callable Examples -------- >>> @ignore_python_warnings ... def f(): ... ...
Decorate a function to ignore *Python* warnings. Parameters ---------- function Function to decorate. Returns ------- Callable Examples -------- >>> @ignore_python_warnings ... def f(): ... warnings.warn("This is an ignored warning!") >>> f()
ignore_python_warnings
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def batch(sequence: Sequence, k: int | Literal[3] = 3) -> Generator: """ Generate batches from specified sequence. Parameters ---------- sequence Sequence to create batches from. k Batch size. Yields ------ Generator Batch generator. Examples ------...
Generate batches from specified sequence. Parameters ---------- sequence Sequence to create batches from. k Batch size. Yields ------ Generator Batch generator. Examples -------- >>> batch(tuple(range(10)), 3) # doctest: +ELLIPSIS <generator o...
batch
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def __enter__(self) -> Self: """ Disable *Colour* multiprocessing state upon entering the context manager. """ global _MULTIPROCESSING_ENABLED # noqa: PLW0603 _MULTIPROCESSING_ENABLED = False return self
Disable *Colour* multiprocessing state upon entering the context manager.
__enter__
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def __exit__(self, *args: Any) -> None: """ Enable *Colour* multiprocessing state upon exiting the context manager. """ global _MULTIPROCESSING_ENABLED # noqa: PLW0603 _MULTIPROCESSING_ENABLED = True
Enable *Colour* multiprocessing state upon exiting the context manager.
__exit__
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def _initializer(kwargs: Any) -> None: """ Initialize a multiprocessing pool. It is used to ensure that processes on *Windows* inherit correctly from the current domain-range scale. Parameters ---------- kwargs Initialisation arguments. """ # NOTE: No coverage information ...
Initialize a multiprocessing pool. It is used to ensure that processes on *Windows* inherit correctly from the current domain-range scale. Parameters ---------- kwargs Initialisation arguments.
_initializer
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def multiprocessing_pool(*args: Any, **kwargs: Any) -> Generator: """ Define a context manager providing a multiprocessing pool. Other Parameters ---------------- args Arguments. kwargs Keywords arguments. Yields ------ Generator Multiprocessing pool. E...
Define a context manager providing a multiprocessing pool. Other Parameters ---------------- args Arguments. kwargs Keywords arguments. Yields ------ Generator Multiprocessing pool. Examples -------- >>> from functools import partial >>> def _a...
multiprocessing_pool
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def map( self, func: Callable, iterable: Sequence, chunksize: int | None = None, # noqa: ARG002 ) -> list[Any]: """Apply specified function to each element of specified iterable.""" return [func(a) for a in iterable]
Apply specified function to each element of specified iterable.
map
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def is_numeric(a: Any) -> bool: """ Determine whether specified variable :math:`a` is a :class:`Real`-like variable. Parameters ---------- a Variable :math:`a` to test. Returns ------- :class:`bool` Whether variable :math:`a` is a :class:`Real`-like variable. E...
Determine whether specified variable :math:`a` is a :class:`Real`-like variable. Parameters ---------- a Variable :math:`a` to test. Returns ------- :class:`bool` Whether variable :math:`a` is a :class:`Real`-like variable. Examples -------- >>> is_numeric...
is_numeric
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def filter_kwargs(function: Callable, **kwargs: Any) -> dict: """ Filter keyword arguments incompatible with the specified function signature. Parameters ---------- function Callable to filter the incompatible keyword arguments. Other Parameters ---------------- kwargs ...
Filter keyword arguments incompatible with the specified function signature. Parameters ---------- function Callable to filter the incompatible keyword arguments. Other Parameters ---------------- kwargs Keywords arguments. Returns ------- dict Filtere...
filter_kwargs
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def filter_mapping(mapping: Mapping, names: str | Sequence[str]) -> dict: """ Filter specified mapping with specified names. Parameters ---------- mapping Mapping to filter. names Name for specified mapping elements or a list of names. Returns ------- dict F...
Filter specified mapping with specified names. Parameters ---------- mapping Mapping to filter. names Name for specified mapping elements or a list of names. Returns ------- dict Filtered mapping elements. Notes ----- - If the mapping passed is a...
filter_mapping
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def filter_mapping_with_name(mapping: Mapping, name: str) -> dict: """ Filter specified mapping with specified name. Parameters ---------- mapping Mapping to filter. name Name for specified mapping elements. Returns ------- ...
Filter specified mapping with specified name. Parameters ---------- mapping Mapping to filter. name Name for specified mapping elements. Returns ------- dict Filtered mapping elements.
filter_mapping_with_name
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def copy_definition(definition: Callable, name: str | None = None) -> Callable: """ Copy a definition using the same code, globals, defaults, closure, and name. Parameters ---------- definition Definition to be copied. name Optional definition copy name. Returns ---...
Copy a definition using the same code, globals, defaults, closure, and name. Parameters ---------- definition Definition to be copied. name Optional definition copy name. Returns ------- Callable Definition copy.
copy_definition
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def validate_method( method: str, valid_methods: tuple, message: str = '"{0}" method is invalid, it must be one of {1}!', as_lowercase: bool = True, ) -> str: """ Validate whether specified method exists in the specified valid methods and optionally returns the method lower cased. Param...
Validate whether specified method exists in the specified valid methods and optionally returns the method lower cased. Parameters ---------- method Method to validate. valid_methods Valid methods. message Message for the exception. as_lowercase Whether t...
validate_method
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def optional(value: T | None, default: T) -> T: """ Handle optional argument value by providing a default value. Parameters ---------- value Optional argument value. default Default argument value if ``value`` is *None*. Returns ------- T Argument value. ...
Handle optional argument value by providing a default value. Parameters ---------- value Optional argument value. default Default argument value if ``value`` is *None*. Returns ------- T Argument value. Examples -------- >>> optional("Foo", "Bar") ...
optional
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def slugify(object_: Any, allow_unicode: bool = False) -> str: """ Generate a *SEO* friendly and human-readable slug from specified object. Convert to ASCII if ``allow_unicode`` is *False*. Convert spaces or repeated dashes to single dashes. Remove characters that aren't alphanumerics, underscores,...
Generate a *SEO* friendly and human-readable slug from specified object. Convert to ASCII if ``allow_unicode`` is *False*. Convert spaces or repeated dashes to single dashes. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing...
slugify
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def int_digest( args: ( # noqa: ARG001 str | bytes | bytearray | memoryview | array.ArrayType[int] ), seed: int = 0, # noqa: ARG001 ) -> int: """ Generate an integer digest for specified argument using *xxhash* if availabl...
Generate an integer digest for specified argument using *xxhash* if available or falling back to :func:`hash` if not. Parameters ---------- args Argument to generate the int digest of. seed Seed used to alter resul...
int_digest
python
colour-science/colour
colour/utilities/common.py
https://github.com/colour-science/colour/blob/master/colour/utilities/common.py
BSD-3-Clause
def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. Returns ------- :class:`str` Formatted string representation. """ return ( f'"{self.name}" object is deprecated and will be renamed to ' ...
Return a formatted string representation of the deprecation type. Returns ------- :class:`str` Formatted string representation.
__str__
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def __getattr__(self, attribute: str) -> Any: """ Return specified attribute value while handling deprecation. Parameters ---------- attribute Attribute name. Returns ------- :class:`object` Attribute value. Raises ...
Return specified attribute value while handling deprecation. Parameters ---------- attribute Attribute name. Returns ------- :class:`object` Attribute value. Raises ------ AttributeError If the attrib...
__getattr__
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def __dir__(self) -> list: """ Return the list of names in the module local scope filtered according to the changes. Returns ------- :class:`list` Filtered list of names in the module local scope. """ return [ attribute ...
Return the list of names in the module local scope filtered according to the changes. Returns ------- :class:`list` Filtered list of names in the module local scope.
__dir__
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def get_attribute(attribute: str) -> Any: """ Return specified attribute value. Parameters ---------- attribute Attribute to retrieve, ``attribute`` must have a namespace module, e.g., *colour.models.oetf_inverse_BT2020*. Returns ------- :class:`object` Retrieve...
Return specified attribute value. Parameters ---------- attribute Attribute to retrieve, ``attribute`` must have a namespace module, e.g., *colour.models.oetf_inverse_BT2020*. Returns ------- :class:`object` Retrieved attribute value. Examples -------- ...
get_attribute
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def build_API_changes(changes: dict) -> dict: """ Build the effective API changes for a desired API changes mapping. Parameters ---------- changes Dictionary of desired API changes. Returns ------- :class:`dict` API changes Examples -------- >>> from pprint...
Build the effective API changes for a desired API changes mapping. Parameters ---------- changes Dictionary of desired API changes. Returns ------- :class:`dict` API changes Examples -------- >>> from pprint import pprint >>> changes = { ... "Objec...
build_API_changes
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def handle_arguments_deprecation(changes: dict, **kwargs: Any) -> dict: """ Handle arguments deprecation according to desired API changes mapping. Parameters ---------- changes Dictionary of desired API changes. Other Parameters ---------------- kwargs Keywords argument...
Handle arguments deprecation according to desired API changes mapping. Parameters ---------- changes Dictionary of desired API changes. Other Parameters ---------------- kwargs Keywords arguments to handle. Returns ------- :class:`dict` Handled keyword...
handle_arguments_deprecation
python
colour-science/colour
colour/utilities/deprecation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/deprecation.py
BSD-3-Clause
def is_documentation_building() -> bool: """ Return whether the documentation is being built by checking whether the *READTHEDOCS* or *COLOUR_SCIENCE__DOCUMENTATION_BUILD* environment variables are defined, their value is not accounted for. Returns ------- :class:`bool` Whether the ...
Return whether the documentation is being built by checking whether the *READTHEDOCS* or *COLOUR_SCIENCE__DOCUMENTATION_BUILD* environment variables are defined, their value is not accounted for. Returns ------- :class:`bool` Whether the documentation is being built. Examples ...
is_documentation_building
python
colour-science/colour
colour/utilities/documentation.py
https://github.com/colour-science/colour/blob/master/colour/utilities/documentation.py
BSD-3-Clause
def metric_mse( a: ArrayLike, b: ArrayLike, axis: int | Tuple[int] | None = None, ) -> NDArrayFloat: """ Compute the mean squared error (MSE) or mean squared deviation (MSD) between specified variables :math:`a` and :math:`b`. Parameters ---------- a Variable :math:`a`. ...
Compute the mean squared error (MSE) or mean squared deviation (MSD) between specified variables :math:`a` and :math:`b`. Parameters ---------- a Variable :math:`a`. b Variable :math:`b`. axis Axis or axes along which the means are computed. The default is to ...
metric_mse
python
colour-science/colour
colour/utilities/metrics.py
https://github.com/colour-science/colour/blob/master/colour/utilities/metrics.py
BSD-3-Clause
def metric_psnr( a: ArrayLike, b: ArrayLike, max_a: Real = 1, axis: int | Tuple[int] | None = None, ) -> NDArrayFloat: """ Compute the peak signal-to-noise ratio (PSNR) between specified variables :math:`a` and :math:`b`. Parameters ---------- a Variable :math:`a`. b...
Compute the peak signal-to-noise ratio (PSNR) between specified variables :math:`a` and :math:`b`. Parameters ---------- a Variable :math:`a`. b Variable :math:`b`. max_a Maximum possible pixel value of the :math:`a` variable. axis Axis or axes along whi...
metric_psnr
python
colour-science/colour
colour/utilities/metrics.py
https://github.com/colour-science/colour/blob/master/colour/utilities/metrics.py
BSD-3-Clause
def __new__(cls, *args: Any, **kwargs: Any) -> Self: # noqa: ARG003 """ Return a new instance of the :class:`colour.utilities.Node` class. Other Parameters ---------------- args Arguments. kwargs Keywords arguments. """ instance ...
Return a new instance of the :class:`colour.utilities.Node` class. Other Parameters ---------------- args Arguments. kwargs Keywords arguments.
__new__
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def parent(self, value: Self | None) -> None: """Setter for the **self.parent** property.""" from colour.utilities import attest if value is not None: attest( issubclass(value.__class__, TreeNode), f'"parent" property: "{value}" is not a ' ...
Setter for the **self.parent** property.
parent
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def children(self, value: List[Self]) -> None: """Setter for the **self.children** property.""" from colour.utilities import attest attest( isinstance(value, list), f'"children" property: "{value}" type is not a "list" instance!', ) for element in value...
Setter for the **self.children** property.
children
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def root(self) -> Self: """ Getter property for the node tree. Returns ------- :class:`TreeNode` Node root. """ if self.is_root(): return self return list(self.walk_hierarchy(ascendants=True))[-1]
Getter property for the node tree. Returns ------- :class:`TreeNode` Node root.
root
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def leaves(self) -> Generator: """ Getter property for the node leaves. Yields ------ Generator Node leaves. """ if self.is_leaf(): return (node for node in (self,)) return (node for node in self.walk_hierarchy() if node.is_leaf(...
Getter property for the node leaves. Yields ------ Generator Node leaves.
leaves
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def siblings(self) -> Generator: """ Getter property for the node siblings. Returns ------- Generator Node siblings. """ if self.parent is None: return (sibling for sibling in ()) return (sibling for sibling in self.parent.childr...
Getter property for the node siblings. Returns ------- Generator Node siblings.
siblings
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def walk_hierarchy(self, ascendants: bool = False) -> Generator: """ Return a generator used to walk into :class:`colour.utilities.Node` tree. Parameters ---------- ascendants Whether to walk up the node tree. Yields ------ Generator ...
Return a generator used to walk into :class:`colour.utilities.Node` tree. Parameters ---------- ascendants Whether to walk up the node tree. Yields ------ Generator Node tree walker. Examples -------- >>>...
walk_hierarchy
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def render(self, tab_level: int = 0) -> str: """ Render the current node and its children as a string. Parameters ---------- tab_level Initial indentation level Returns ------- :class:`str` Rendered node tree. Examples ...
Render the current node and its children as a string. Parameters ---------- tab_level Initial indentation level Returns ------- :class:`str` Rendered node tree. Examples -------- >>> node_a = TreeNode("Node A") ...
render
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def value(self) -> Any: """ Getter and setter property for the port value. Parameters ---------- value Value to set the port value with. Returns ------- :class:`object` Port value. """ # NOTE: Assumption is that i...
Getter and setter property for the port value. Parameters ---------- value Value to set the port value with. Returns ------- :class:`object` Port value.
value
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def value(self, value: Any) -> None: """Setter for the **self.value** property.""" self._value = value if self._node is not None: self.log(f'Dirtying "{self._node}".', "debug") self._node.dirty = True # NOTE: Setting the port value implies that all the connecte...
Setter for the **self.value** property.
value
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def node(self, value: PortNode | None) -> None: """Setter for the **self.node** property.""" attest( value is None or isinstance(value, PortNode), f'"node" property: "{value}" is not "None" or ' f'its type is not "PortNode"!', ) self._node = value
Setter for the **self.node** property.
node
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def __str__(self) -> str: """ Return a formatted string representation of the port. Returns ------- :class:`str` Formatted string representation of the port. Examples -------- >>> print(Port("a")) None.a (-> []) >>> print(Port...
Return a formatted string representation of the port. Returns ------- :class:`str` Formatted string representation of the port. Examples -------- >>> print(Port("a")) None.a (-> []) >>> print(Port("a", node=PortNode("Port Node"))) ...
__str__
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def is_input_port(self) -> bool: """ Return whether the port is an input port. Returns ------- :class:`bool` Whether the port is an input port. Examples -------- >>> Port().is_input_port() False >>> node = PortNode() >...
Return whether the port is an input port. Returns ------- :class:`bool` Whether the port is an input port. Examples -------- >>> Port().is_input_port() False >>> node = PortNode() >>> node.add_input_port("a").is_input_port() ...
is_input_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def is_output_port(self) -> bool: """ Return whether the port is an output port. Returns ------- :class:`bool` Whether the port is an output port. Examples -------- >>> Port().is_output_port() False >>> node = PortNode() ...
Return whether the port is an output port. Returns ------- :class:`bool` Whether the port is an output port. Examples -------- >>> Port().is_output_port() False >>> node = PortNode() >>> node.add_output_port("output").is_outp...
is_output_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def connect(self, port: Port) -> None: """ Connect the port to the other specified port. Parameters ---------- port Port to connect to. Raises ------ ValueError if an attempt is made to connect an input port to multiple output ...
Connect the port to the other specified port. Parameters ---------- port Port to connect to. Raises ------ ValueError if an attempt is made to connect an input port to multiple output ports. Examples --------...
connect
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def disconnect(self, port: Port) -> None: """ Disconnect the port from the other specified port. Parameters ---------- port Port to disconnect from. Examples -------- >>> port_a = Port() >>> port_b = Port() >>> port_a.connect(...
Disconnect the port from the other specified port. Parameters ---------- port Port to disconnect from. Examples -------- >>> port_a = Port() >>> port_b = Port() >>> port_a.connect(port_b) >>> port_a.connections # doctest: +E...
disconnect
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def dirty(self, value: bool) -> None: """Setter for the **self.dirty** property.""" attest( isinstance(value, bool), f'"dirty" property: "{value}" type is not "bool"!', ) self._dirty = value
Setter for the **self.dirty** property.
dirty
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def edges( self, ) -> Tuple[Dict[Tuple[Port, Port], None], Dict[Tuple[Port, Port], None]]: """ Return the edges of the node. Each edge represent a port and one of its connections. Returns ------- :class:`tuple` Edges of the node as a tuple of inp...
Return the edges of the node. Each edge represent a port and one of its connections. Returns ------- :class:`tuple` Edges of the node as a tuple of input and output edge dictionaries.
edges
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def add_input_port( self, name: str, value: Any = None, description: str = "", port_type: Type[Port] = Port, ) -> Port: """ Add an input port with specified name and value to the node. Parameters ---------- name Name of the...
Add an input port with specified name and value to the node. Parameters ---------- name Name of the input port. value Value of the input port description Description of the input port. port_type Type of the input p...
add_input_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def remove_input_port( self, name: str, ) -> Port: """ Remove the input port with specified name from the node. Parameters ---------- name Name of the input port. Returns ------- :class:`colour.utilities.Port` ...
Remove the input port with specified name from the node. Parameters ---------- name Name of the input port. Returns ------- :class:`colour.utilities.Port` Input port. Examples -------- >>> node = PortNode() ...
remove_input_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def add_output_port( self, name: str, value: Any = None, description: str = "", port_type: Type[Port] = Port, ) -> Port: """ Add an output port with specified name and value to the node. Parameters ---------- name Name of t...
Add an output port with specified name and value to the node. Parameters ---------- name Name of the output port. value Value of the output port description Description of the output port. port_type Type of the out...
add_output_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def remove_output_port( self, name: str, ) -> Port: """ Remove the output port with specified name from the node. Parameters ---------- name Name of the output port. Returns ------- :class:`colour.utilities.Port` ...
Remove the output port with specified name from the node. Parameters ---------- name Name of the output port. Returns ------- :class:`colour.utilities.Port` Output port. Examples -------- >>> node = PortNode() ...
remove_output_port
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def get_input(self, name: str) -> Any: """ Return the value of the input port with specified name. Parameters ---------- name Name of the input port. Returns ------- :class:`object`: Value of the input port. Raises ...
Return the value of the input port with specified name. Parameters ---------- name Name of the input port. Returns ------- :class:`object`: Value of the input port. Raises ------ AssertionError If the...
get_input
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def set_input(self, name: str, value: Any) -> None: """ Set the value of the input port with specified name. Parameters ---------- name Name of the input port. value Value of the input port Raises ------ AssertionError ...
Set the value of the input port with specified name. Parameters ---------- name Name of the input port. value Value of the input port Raises ------ AssertionError If the input port is not a member of the node input po...
set_input
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def get_output(self, name: str) -> Any: """ Return the value of the output port with specified name. Parameters ---------- name Name of the output port. Returns ------- :class:`object`: Value of the output port. Raises ...
Return the value of the output port with specified name. Parameters ---------- name Name of the output port. Returns ------- :class:`object`: Value of the output port. Raises ------ AssertionError If ...
get_output
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def set_output(self, name: str, value: Any) -> None: """ Set the value of the output port with specified name. Parameters ---------- name Name of the output port. value Value of the output port Raises ------ AssertionError...
Set the value of the output port with specified name. Parameters ---------- name Name of the output port. value Value of the output port Raises ------ AssertionError If the output port is not a member of the node outp...
set_output
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def connect( self, source_port: str, target_node: PortNode, target_port: str, ) -> None: """ Connect the specified source port to specified node target port. The source port can be an input port but the target port must be an output port and conversel...
Connect the specified source port to specified node target port. The source port can be an input port but the target port must be an output port and conversely, if the source port is an output port, the target port must be an input port. Parameters ---------- s...
connect
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def disconnect( self, source_port: str, target_node: PortNode, target_port: str, ) -> None: """ Disconnect the specified source port from specified node target port. The source port can be an input port but the target port must be an output port and c...
Disconnect the specified source port from specified node target port. The source port can be an input port but the target port must be an output port and conversely, if the source port is an output port, the target port must be an input port. Parameters ---------- ...
disconnect
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def to_graphviz(self) -> str: """ Return a string representation for visualisation of the node with *Graphviz*. Returns ------- :class:`str` String representation for visualisation of the node with *Graphviz*. Examples -------- >>> no...
Return a string representation for visualisation of the node with *Graphviz*. Returns ------- :class:`str` String representation for visualisation of the node with *Graphviz*. Examples -------- >>> node_1 = PortNode("PortNode") >>> p...
to_graphviz
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def add_node(self, node: PortNode) -> None: """ Add specified node to the node-graph. Parameters ---------- node Node to add to the node-graph. Raises ------ AsssertionError If the node is not a :class:`colour.utilities.PortNode` ...
Add specified node to the node-graph. Parameters ---------- node Node to add to the node-graph. Raises ------ AsssertionError If the node is not a :class:`colour.utilities.PortNode` class instance. Examples -...
add_node
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def remove_node(self, node: PortNode) -> None: """ Remove specified node from the node-graph. The node input and output ports will be disconnected from all their connections. Parameters ---------- node Node to remove from the node-graph. Rai...
Remove specified node from the node-graph. The node input and output ports will be disconnected from all their connections. Parameters ---------- node Node to remove from the node-graph. Raises ------ AsssertionError If ...
remove_node
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def walk_ports(self) -> Generator: """ Return a generator used to walk into the node-graph. The node is walked according to a topological sorted order. A topological sort is a non-unique permutation of the nodes of a directed graph such that an edge from :math:`u` to :math:`v` i...
Return a generator used to walk into the node-graph. The node is walked according to a topological sorted order. A topological sort is a non-unique permutation of the nodes of a directed graph such that an edge from :math:`u` to :math:`v` implies that :math:`u` appears before :...
walk_ports
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def process(self, **kwargs: Dict) -> None: """ Process the node-graph by walking it and calling the :func:`colour.utilities.PortNode.process` method. Other Parameters ---------------- kwargs Keyword arguments. Examples -------- >>> cl...
Process the node-graph by walking it and calling the :func:`colour.utilities.PortNode.process` method. Other Parameters ---------------- kwargs Keyword arguments. Examples -------- >>> class NodeAdd(PortNode): ... def __init__(se...
process
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def to_graphviz(self) -> Dot: # noqa: F821 # pyright: ignore """ Return a visualisation node-graph for *Graphviz*. Returns ------- :class:`pydot.Dot` *Pydot* graph. Examples -------- >>> node_1 = PortNode() >>> port = node_1.add_out...
Return a visualisation node-graph for *Graphviz*. Returns ------- :class:`pydot.Dot` *Pydot* graph. Examples -------- >>> node_1 = PortNode() >>> port = node_1.add_output_port("output") >>> node_2 = PortNode() >>> port = node...
to_graphviz
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def _task_thread(args: Sequence) -> tuple[int, Any]: """ Define the default task for the :class:`colour.utilities.ParallelForThread` loop node. Parameters ---------- args Processing arguments. """ i, element, sub_graph, node = args node.log(f"Index {i}, Element {element}",...
Define the default task for the :class:`colour.utilities.ParallelForThread` loop node. Parameters ---------- args Processing arguments.
_task_thread
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def get_executor( max_workers: int | None = None, ) -> concurrent.futures.ThreadPoolExecutor: """ Return the :class:`concurrent.futures.ThreadPoolExecutor` class instance or create it if not existing. Parameters ---------- max_workers Maximum work...
Return the :class:`concurrent.futures.ThreadPoolExecutor` class instance or create it if not existing. Parameters ---------- max_workers Maximum worker count. Returns ------- :class:`concurrent.futures.ThreadPoolExecutor` Notes ...
get_executor
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def shutdown_executor() -> None: """ Shutdown the :class:`concurrent.futures.ThreadPoolExecutor` class instance. """ if ThreadPoolExecutorManager.ThreadPoolExecutor is not None: ThreadPoolExecutorManager.ThreadPoolExecutor.shutdown(wait=True) ThreadPoolExecutorMa...
Shutdown the :class:`concurrent.futures.ThreadPoolExecutor` class instance.
shutdown_executor
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def _task_multiprocess(args: Sequence) -> tuple[int, Any]: """ Define the default task for the :class:`colour.utilities.ParallelForMultiprocess` loop node. Parameters ---------- args Processing arguments. """ i, element, sub_graph, node = args node.log(f"Index {i}, Element...
Define the default task for the :class:`colour.utilities.ParallelForMultiprocess` loop node. Parameters ---------- args Processing arguments.
_task_multiprocess
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def get_executor( max_workers: int | None = None, ) -> concurrent.futures.ProcessPoolExecutor: """ Return the :class:`concurrent.futures.ProcessPoolExecutor` class instance or create it if not existing. Parameters ---------- max_workers Maximum wo...
Return the :class:`concurrent.futures.ProcessPoolExecutor` class instance or create it if not existing. Parameters ---------- max_workers Maximum worker count. Returns ------- :class:`concurrent.futures.ProcessPoolExecutor` Notes ...
get_executor
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def shutdown_executor() -> None: """ Shutdown the :class:`concurrent.futures.ProcessPoolExecutor` class instance. """ if ProcessPoolExecutorManager.ProcessPoolExecutor is not None: ProcessPoolExecutorManager.ProcessPoolExecutor.shutdown(wait=True) ProcessPoolExec...
Shutdown the :class:`concurrent.futures.ProcessPoolExecutor` class instance.
shutdown_executor
python
colour-science/colour
colour/utilities/network.py
https://github.com/colour-science/colour/blob/master/colour/utilities/network.py
BSD-3-Clause
def is_ctlrender_installed(raise_exception: bool = False) -> bool: """ Return whether *ctlrender* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *ctlrender* is unavailable. Returns ------- :class:`bool` Whether *ctlren...
Return whether *ctlrender* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *ctlrender* is unavailable. Returns ------- :class:`bool` Whether *ctlrender* is installed. Raises ------ :class:`ImportError` ...
is_ctlrender_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_imageio_installed(raise_exception: bool = False) -> bool: """ Return whether *Imageio* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Imageio* is unavailable. Returns ------- :class:`bool` Whether *Imageio* is ...
Return whether *Imageio* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Imageio* is unavailable. Returns ------- :class:`bool` Whether *Imageio* is installed. Raises ------ :class:`ImportError` If *I...
is_imageio_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_openimageio_installed(raise_exception: bool = False) -> bool: """ Return whether *OpenImageIO* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *OpenImageIO* is unavailable. Returns ------- :class:`bool` Whether *...
Return whether *OpenImageIO* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *OpenImageIO* is unavailable. Returns ------- :class:`bool` Whether *OpenImageIO* is installed. Raises ------ :class:`ImportError` ...
is_openimageio_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_matplotlib_installed(raise_exception: bool = False) -> bool: """ Return whether *Matplotlib* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Matplotlib* is unavailable. Returns ------- :class:`bool` Whether *Mat...
Return whether *Matplotlib* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Matplotlib* is unavailable. Returns ------- :class:`bool` Whether *Matplotlib* is installed. Raises ------ :class:`ImportError` ...
is_matplotlib_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_networkx_installed(raise_exception: bool = False) -> bool: """ Return whether *NetworkX* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *NetworkX* is unavailable. Returns ------- :class:`bool` Whether *NetworkX*...
Return whether *NetworkX* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *NetworkX* is unavailable. Returns ------- :class:`bool` Whether *NetworkX* is installed. Raises ------ :class:`ImportError` If...
is_networkx_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_opencolorio_installed(raise_exception: bool = False) -> bool: """ Return whether *OpenColorIO* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *OpenColorIO* is unavailable. Returns ------- :class:`bool` Whether *...
Return whether *OpenColorIO* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *OpenColorIO* is unavailable. Returns ------- :class:`bool` Whether *OpenColorIO* is installed. Raises ------ :class:`ImportError` ...
is_opencolorio_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_pandas_installed(raise_exception: bool = False) -> bool: """ Return whether *Pandas* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Pandas* is unavailable. Returns ------- :class:`bool` Whether *Pandas* is inst...
Return whether *Pandas* is installed and available. Parameters ---------- raise_exception Whether to raise an exception if *Pandas* is unavailable. Returns ------- :class:`bool` Whether *Pandas* is installed. Raises ------ :class:`ImportError` If *Pand...
is_pandas_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause
def is_pydot_installed(raise_exception: bool = False) -> bool: """ Return whether *Pydot* is installed and available. The presence of *Graphviz* will also be tested. Parameters ---------- raise_exception Whether to raise an exception if *Pydot* is unavailable. Returns ------- ...
Return whether *Pydot* is installed and available. The presence of *Graphviz* will also be tested. Parameters ---------- raise_exception Whether to raise an exception if *Pydot* is unavailable. Returns ------- :class:`bool` Whether *Pydot* is installed. Raises ...
is_pydot_installed
python
colour-science/colour
colour/utilities/requirements.py
https://github.com/colour-science/colour/blob/master/colour/utilities/requirements.py
BSD-3-Clause