Utility functions#

Downloading examples#

pyxel.util.download_examples(foldername='pyxel-examples', force=False)[source]#

Download and save examples from Pyxel Data Gitlab repository in the working directory.

Parameters:

Memory usage#

pyxel.util.get_size(obj)[source]#

Recursively calculates object size in bytes using Pympler library.

Parameters:

obj (object) – Any input object.

Returns:

int – Object size in bytes.

pyxel.util.memory_usage_details(obj, *attr_kw, print_result=True, human_readable=True)[source]#

Calculate the memory usage of an object.

Parameters:
  • obj (Any)

  • attr_kw (list of str)

  • print_result (bool, default: True) – Boolean flag indicating whether to print the memory usage details.

  • human_readable (bool, default: True) – Boolean flag indicating whether to print memory usage details in human-readable format.

Returns:

usage (dict)

Raises:

Timing#

pyxel.util.time_pipeline(detector, pipeline)[source]#

Time a single pipeline.

Parameters:
Returns:

df (DataFrame)

Image utilities#

pyxel.util.fit_into_array(array, output_shape, relative_position=(0, 0), align=None, allow_smaller_array=True)[source]#

Fit input array into an output array of specified output shape.

Input array can be either larger or smaller than output array. In the first case the input array will be cropped. The relative position between the arrays in the coordinate system is specified with argument relative_position. It is a tuple with coordinates (Y,X). User can use this argument to specify the position of input array values in the output array. If arrays are to be aligned in the center or one of the corners, it is also possible with argument align and passing a location keyword. User can turn on that smaller arrays than output shape are not allowed by setting allow_smaller_array to False.

Parameters:
  • array (ndarray)

  • output_shape (tuple)

  • relative_position (tuple)

  • align ({'center', 'top_left', 'top_right', 'bottom_left', 'bottom_right'}, default: None)

  • allow_smaller_array (bool)

Returns:

output (ndarray)