






'''simple docstring'''





import math
import unittest






def    lowerCamelCase_     (    lowercase__):
 assert isinstance(lowercase__				,     lowercase__) and (
     number >= 0
 ), "'number' must been an int and positive"

 if 1 < number < 4:
  # 2 and 3 are primes
  return True
 elif number < 2 or number % 2 == 0 or number % 3 == 0:
  # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
  return False

 # All primes number are in format of 6k +/- 1
 for i in range(5				,     int(math.sqrt(lowercase__) + 1)				,     6):
  if number % i == 0 or number % (i + 2) == 0:
   return False
 return True
class 				lowercase       (							unittest.TestCase      ):


    '''simple docstring'''

    def    a__				(					self     :     List[Any]     )							->							str:

     '''simple docstring'''




     self.assertTrue(is_prime(2     )     )
     self.assertTrue(is_prime(3     )     )
     self.assertTrue(is_prime(5     )     )
     self.assertTrue(is_prime(7     )     )
     self.assertTrue(is_prime(11     )     )
     self.assertTrue(is_prime(13     )     )
     self.assertTrue(is_prime(17     )     )
     self.assertTrue(is_prime(19     )     )
     self.assertTrue(is_prime(23     )     )
     self.assertTrue(is_prime(29     )     )




    def    a__				(					self     :     Union[str, Any]     )							->							Optional[int]:

     '''simple docstring'''




     with self.assertRaises(__lowerCamelCase     ):
      is_prime(-19     )
     self.assertFalse(
         is_prime(0     )				,     "Zero doesn't have any positive factors, primes must have exactly two."				,     )
     self.assertFalse(
         is_prime(1     )				,     "One only has 1 positive factor, primes must have exactly two."				,     )
     self.assertFalse(is_prime(2 * 2     )     )
     self.assertFalse(is_prime(2 * 3     )     )
     self.assertFalse(is_prime(3 * 3     )     )
     self.assertFalse(is_prime(3 * 5     )     )
     self.assertFalse(is_prime(3 * 5 * 7     )     )


if __name__ == "__main__":
 unittest.main()









'''simple docstring'''





from __future__ import annotations
class 				lowercase       :


    '''simple docstring'''

    def __init__(					self     :     Optional[int]				,     __lowerCamelCase     :     int     )							->							None:

     '''simple docstring'''




     lowerCamelCase__  =     order

     # a_{0} ... a_{k}
     lowerCamelCase__  =     [1.0] + [0.0] * order
     # b_{0} ... b_{k}
     lowerCamelCase__  =     [1.0] + [0.0] * order

     # x[n-1] ... x[n-k]
     lowerCamelCase__  =     [0.0] * self.order
     # y[n-1] ... y[n-k]
     lowerCamelCase__  =     [0.0] * self.order

    def    a__				(					self     :     Dict				,     __lowerCamelCase     :     list[float]				,     __lowerCamelCase     :     list[float]     )							->							None:

     '''simple docstring'''




     if len(__lowerCamelCase     ) < self.order:
      lowerCamelCase__  =     [1.0, *a_coeffs]

     if len(__lowerCamelCase     ) != self.order + 1:
      lowerCamelCase__  =     (
          f'''Expected a_coeffs to have {self.order + 1} elements '''
          f'''for {self.order}-order filter, got {len(__lowerCamelCase     )}'''
      )
      raise ValueError(__lowerCamelCase     )

     if len(__lowerCamelCase     ) != self.order + 1:
      lowerCamelCase__  =     (
          f'''Expected b_coeffs to have {self.order + 1} elements '''
          f'''for {self.order}-order filter, got {len(__lowerCamelCase     )}'''
      )
      raise ValueError(__lowerCamelCase     )

     lowerCamelCase__  =     a_coeffs
     lowerCamelCase__  =     b_coeffs




    def    a__				(					self     :     Dict				,     __lowerCamelCase     :     float     )							->							float:

     '''simple docstring'''




     lowerCamelCase__  =     0.0

     # Start at index 1 and do index 0 at the end.
     for i in range(1				,     self.order + 1     ):
      result += (
          self.b_coeffs[i] * self.input_history[i - 1]
          - self.a_coeffs[i] * self.output_history[i - 1]
      )

     lowerCamelCase__  =     (result + self.b_coeffs[0] * sample) / self.a_coeffs[0]

     lowerCamelCase__  =     self.input_history[:-1]
     lowerCamelCase__  =     self.output_history[:-1]

     lowerCamelCase__  =     sample
     lowerCamelCase__  =     result

     return result

