ginger package

Submodules

ginger.aberth module

ginger.autocorr module

ginger.matrix2 module

class ginger.matrix2.Matrix2(x: Vector2, y: Vector2)[source]

Bases: object

det() float[source]

The det function calculates the determinant of a 2x2 matrix. :return: The determinant of the matrix.

Examples

>>> m = Matrix2(Vector2(1.0, 2.0), Vector2(3.0, 4.0))
>>> print(m.det())
-2.0
mdot(rhs: Vector2) Vector2[source]

The mdot function performs a matrix-vector product.

Parameters:

rhs (Vector2) – The parameter rhs is a Vector2 object that represents the right-hand side vector in the matrix-vector product

Returns:

The method mdot returns a Vector2 object.

Examples

>>> m = Matrix2(Vector2(1.0, 2.0), Vector2(3.0, 4.0))
>>> print(m.mdot(Vector2(5.0, 6.0)))
<17.0, 39.0>
property x

The function returns the value of the private variable _x. :return: The property x is returning the value of the private variable _x.

Examples

>>> m = Matrix2(Vector2(1.0, 2.0), Vector2(3.0, 4.0))
>>> print(m.x)
<1.0, 2.0>
property y

The function returns the value of the private variable _y. :return: The property y is returning the value of the private variable _y.

Examples

>>> m = Matrix2(Vector2(1.0, 2.0), Vector2(3.0, 4.0))
>>> print(m.y)
<3.0, 4.0>

ginger.robin module

class ginger.robin.Robin(num_parts: int)[source]

Bases: object

Round Robin

The Robin class implements a round-robin algorithm for cycling through a list of parts, and the exclude method returns an iterator starting from a specified part.

cycle: List[SlNode]
exclude(from_part: int) RobinIterator[source]

The exclude function returns a RobinIterator object that excludes a specified part of a cycle.

Parameters:

from_part (int) – The from_part parameter is an integer that represents the starting index of the cycle that should be excluded

Returns:

The exclude method is returning a RobinIterator object.

Examples

>>> r = Robin(5)
>>> iter = r.exclude(3)
>>> iter.cur.data == 3
True
>>> iter.stop.data == 3
True
class ginger.robin.RobinIterator(node: SlNode)[source]

Bases: object

The RobinIterator class is an iterator that iterates over a singly linked list starting from a given node.

cur: SlNode
next() int[source]

The next function returns the next element in a linked list and raises a StopIteration exception if there are no more elements. :return: The method is returning an integer value.

stop: SlNode
class ginger.robin.SlNode(data: int)[source]

Bases: object

Node for a Singly-linked list The SlNode class represents a node in a singly-linked list, with a next pointer and a data value.

data: int
next: SlNode

ginger.rootfinding module

ginger.skeleton module

This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the [options.entry_points] section in setup.cfg:

console_scripts =
     fibonacci = ginger.skeleton:run

Then run pip install . (or pip install -e . for editable mode) which will install the command fibonacci inside your current environment.

Besides console scripts, the header (i.e. until _logger…) of this file can also be used as template for Python modules.

Note

This file can be renamed depending on your needs or safely removed if not needed.

References

ginger.skeleton.fib(n)[source]

Fibonacci example function

Parameters:

n (int) – integer

Returns:

n-th Fibonacci number

Return type:

int

ginger.skeleton.main(args)[source]

Wrapper allowing fib() to be called with string arguments in a CLI fashion

Instead of returning the value from fib(), it prints the result to the stdout in a nicely formatted message.

Parameters:

args (List[str]) – command line parameters as list of strings (for example ["--verbose", "42"]).

ginger.skeleton.parse_args(args)[source]

Parse command line parameters

Parameters:

args (List[str]) – command line parameters as list of strings (for example ["--help"]).

Returns:

command line parameters namespace

Return type:

argparse.Namespace

ginger.skeleton.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

ginger.skeleton.setup_logging(loglevel)[source]

Setup basic logging

Parameters:

loglevel (int) – minimum loglevel for emitting messages

ginger.vector2 module

class ginger.vector2.Vector2(x, y)[source]

Bases: object

dot(rhs)[source]

The dot function calculates the dot product of two vectors.

Parameters:

rhs – rhs is the right-hand side vector that we want to calculate the dot product with

Returns:

The dot product of the two vectors.

Examples

>>> v1 = Vector2(1, 2)
>>> v2 = Vector2(3, 4)
>>> v1.dot(v2)
11
property x

The function returns the value of the private variable _x. :return: The property x is returning the value of the private variable _x.

property y

The function returns the value of the private variable _y. :return: The method y is returning the value of the attribute _y.

Module contents