Misc Utility Functions

class arcade.utils.ByteRangeError(var_name: str, value: int)[source]

Bases: IntOutsideRangeError

An int was outside the range of 0 to 255 inclusive

Parameters:
  • var_name – the name of the variable or argument

  • value – the value to fall outside the expected range

class arcade.utils.FloatOutsideRangeError(var_name: str, value: float, lower: float, upper: float)[source]

Bases: OutsideRangeError

A float value was outside an expected range

Parameters:
  • var_name – the name of the variable or argument

  • value – the value to fall outside the expected range

  • lower – the lower bound, inclusive, of the range

  • upper – the upper bound, inclusive, of the range

class arcade.utils.IntOutsideRangeError(var_name: str, value: int, lower: int, upper: int)[source]

Bases: OutsideRangeError

An integer was outside an expected range

This class was originally intended to assist deserialization from data packed into ints, such as Color.

Parameters:
  • var_name – the name of the variable or argument

  • value – the value to fall outside the expected range

  • lower – the lower bound, inclusive, of the range

  • upper – the upper bound, inclusive, of the range

class arcade.utils.NormalizedRangeError(var_name: str, value: float)[source]

Bases: FloatOutsideRangeError

A float was not between 0.0 and 1.0, inclusive

Note that normalized floats should not normally be bound-checked as before drawing as this is taken care of on the GPU side.

The exceptions to this are when processing data on the Python side, especially when it is cheaper to bound check two floats than call clamping functions.

Parameters:
  • var_name – the name of the variable or argument

  • value – the value to fall outside the expected range

class arcade.utils.OutsideRangeError(var_name: str, value: _CT, lower: _CT, upper: _CT)[source]

Bases: ValueError

Raised when a value is outside and expected range

This class and its subclasses are intended to be arcade-internal helpers to clearly signal exactly what went wrong. Each helps type annotate and template a string describing exactly what went wrong.

Parameters:
  • var_name – the name of the variable or argument

  • value – the value to fall outside the expected range

  • lower – the lower bound, inclusive, of the range

  • upper – the upper bound, inclusive, of the range

class arcade.utils.PerformanceWarning[source]

Bases: Warning

Use this for issuing performance warnings.

class arcade.utils.ReplacementWarning[source]

Bases: Warning

Use this for issuing warnings about naming and functionality changes.

arcade.utils.copy_dunders_unimplemented(decorated_type: _TType) _TType[source]

Decorator stubs dunders raising NotImplementedError.

Temp fixes https://github.com/pythonarcade/arcade/issues/2074 by stubbing the following instance methods:

Example usage:

import copy
from arcade,utils import copy_dunders_unimplemented
from arcade.hypothetical_module import HypotheticalNasty

# Example usage
@copy_dunders_unimplemented
class CantCopy:
     def __init__(self, nasty_state: HypotheticalNasty):
         self.nasty_state = nasty_state

instance = CantCopy(HypotheticalNasty())

# These raise NotImplementedError
this_line_raises = copy.deepcopy(instance)
this_line_also_raises = copy.copy(instance)
arcade.utils.generate_uuid_from_kwargs(**kwargs) str[source]

Given key/pair combos, returns a string in “UUID” format. With inputs such as text=’hi’, size=32 it will return “text=hi|size=32”. This function does NOT return a random unique ID. It must be called with parameters, and will raise an error if passed no keyword arguments.

arcade.utils.get_raspberry_pi_info() Tuple[bool, str, str][source]

Determine if the host is a raspberry pi with additional info.

Returns:

3 component tuple. bool (is host a raspi) str (architecture) str (model name)

arcade.utils.is_raspberry_pi() bool[source]

Determine if the host is a raspberry pi.

Returns:

bool

arcade.utils.warning(warning_type: Type[Warning], message: str = '', **kwargs)[source]
arcade.configure_logging(level: int | None = None)[source]

Set up basic logging. :param level: The log level. Defaults to DEBUG.