mockup.mockup module#

class mockup.mockup.Circle(radius)[source]#

Bases: object

A Circle represents the abstract geometric shape.

>>> c = Circle(2.21); c.diameter
4.42
>>> c2 = Circle.from_circumference(100); round(c2.radius, 3)
15.916
PI = 3.14159#
property diameter#
classmethod from_circumference(circumference: int | float) Self[source]#
radius#
mockup.mockup.add_one(number: int) int[source]#

Add 1 to an int, returning the sum.

>>> add_one(9)
10
>>> add_one(-11)
-10
>>> add_one(2**63-1)
9223372036854775808
mockup.mockup.flatten_generic(its: Iterable[Iterable[T]]) Iterable[T][source]#

Given an iterable of iterables, return an iterable of all the inner elements in the inner iterables.

>>> list(flatten_generic(["hi", (4, 2.54)]))
['h', 'i', 4, 2.54]
mockup.mockup.flatten_ints(its: Iterable[Iterable[int]]) Iterable[int][source]#

Given an iterable of iterables of ints, return an iterable of all the ints in the inner iterables.

>>> list(flatten_ints([[9, 11], [12], [4, 5]]))
[9, 11, 12, 4, 5]
>>> list(flatten_ints([[], (), set()]))
[]
mockup.mockup.reciprocal(number: int | float) float | None[source]#

Return the reciprocal of the given number. If the number is zero, return None.

>>> reciprocal(5)
0.2
>>> reciprocal(-20)
-0.05
>>> reciprocal(-0.0) # returns None