bairstow package

Submodules

bairstow.autocorr module

bairstow.autocorr.extract_autocorr(vr: vector2) vector2[source]

Extract the quadratic function where its roots are within a unit circle

x^2 + r*x + t or x^2 + (r/t) * x + (1/t)

(x + a1)(x + a2) = x^2 + (a1 + a2) x + a1 * a2

Parameters:

vr (vector2) – [description]

Returns:

[description]

Return type:

vector2

bairstow.autocorr.initial_autocorr(pa: List[float]) List[vector2][source]

[summary]

Parameters:

pa (List[float]) – [description]

Returns:

[description]

Return type:

List[vector2]

bairstow.autocorr.pbairstow_autocorr(pa: ~typing.List[float], vrs: ~typing.List[~bairstow.vector2.vector2], options: ~bairstow.rootfinding.Options = <bairstow.rootfinding.Options object>)[source]

[summary]

Parameters:
  • pa (List[float]) – [description]

  • vrs (List[vector2]) – [description]

  • options (Options, optional) – [description]. Defaults to Options().

Returns:

[description]

Return type:

[type]

bairstow.matrix2 module

class bairstow.matrix2.matrix2(x: vector2, y: vector2)[source]

Bases: vector2

det() float[source]

determinant

Returns:

[description]

Return type:

float

mdot(rhs: vector2) vector2[source]

matrix-vector product

Parameters:

rhs (vector2) – [description]

Returns:

[description]

Return type:

vector2

bairstow.rootfinding module

class bairstow.rootfinding.Options[source]

Bases: object

max_iter: int = 2000
tol: float = 1e-12
bairstow.rootfinding.delta(vA: vector2, vr: vector2, vp: vector2) vector2[source]

[summary]

r * p - m -p q * p -m

Parameters:
Returns:

[description]

Return type:

vector2

bairstow.rootfinding.find_rootq(vr: vector2) Tuple[float, float][source]

[summary]

x^2 + r*x + t

(x - x1)(x - x2) = x^2 - (x1 + x2) x + x1 * x2

Parameters:

vr (vector2) – [description]

Returns:

[description]

Return type:

Tuple[float, float]

bairstow.rootfinding.horner(pa: List[float], vr: vector2) Tuple[vector2, List[float]][source]

[summary]

Parameters:
  • pa (List[float]) – [description]

  • vr (vector2) – [description]

Returns:

[description]

Return type:

vector2

bairstow.rootfinding.horner_eval(pa: List[float], r: float) float[source]

[summary]

Parameters:
  • pa (List[float]) – [description]

  • r (float) – [description]

Returns:

[description]

Return type:

float

bairstow.rootfinding.initial_guess(pa: List[float]) List[vector2][source]

[summary]

Parameters:

pa (List[float]) – [description]

Returns:

[description]

Return type:

List[vector2]

bairstow.rootfinding.pbairstow_even(pa: ~typing.List[float], vrs: ~typing.List[~bairstow.vector2.vector2], options: ~bairstow.rootfinding.Options = <bairstow.rootfinding.Options object>)[source]

[summary]

Parameters:
  • pa (List[float]) – [description]

  • vrs (List[vector2]) – [description]

  • options (Options, optional) – [description]. Defaults to Options().

Returns:

[description]

Return type:

[type]

bairstow.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 = bairstow.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 skeleton file can be safely removed if not needed!

References

bairstow.skeleton.fib(n)[source]

Fibonacci example function

Parameters:

n (int) – integer

Returns:

n-th Fibonacci number

Return type:

int

bairstow.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"]).

bairstow.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

bairstow.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.

bairstow.skeleton.setup_logging(loglevel)[source]

Setup basic logging

Parameters:

loglevel (int) – minimum loglevel for emitting messages

bairstow.vector2 module

class bairstow.vector2.vector2(x, y)[source]

Bases: object

dot(rhs)[source]

[summary]

Parameters:

rhs ([type]) – [description]

Returns:

[description]

Return type:

[type]

property x

[summary]

Returns:

[description]

Return type:

[type]

property y

[summary]

Returns:

[description]

Return type:

[type]

Module contents