numbers_class module

class numbers_class.numberInfo(input_list)

Bases: object

This is a class that provides information about numerical lists.

__init__ sets the list attribute

Attributes:
myList (list or tuple input) maxDiff (max difference between 2 consecutive elements) sumList (sum of the elements) minMax (minimum and maximum of the list)
max_diff()

Function to find the maximum magnitude difference between consecutive elements in a numerical list

Param:self object with a myList attribute
Returns:attribute with maximum magnitude consecutive difference as a

scalar, or a vector if equal maximum difference in positive negative directions

Return type:scalar or array
Raises:ValueError – if the numerical list input is of length less than

2 :raises TypeError: if a non-numerical list is given :raises ImportError: if a required package was not loaded

min_max()

Finds the minimum and maximum values of a numerical list.

Param:

self object with a myList attribute

Returns:

attribute with minimum and maximum values of list

Raises:
  • ImportError – if numpy is not installed
  • TypeError – if a non-numerical list is given
sum_list()

Find the sum of all elements in a list

Param:

self object with a myList attribute

Returns:

attribute with sum of list elements

Raises:
  • ValueError – if infinity is in the input array
  • TypeError – if list is empty or contains non-numerical elements
  • ImportError – if a required package was not loaded