API

This page provides comprehensive API documentation for the package, automatically generated from numpy-style docstrings using Sphinx’s autodoc and napoleon extensions.

Hello World module demonstrating numpy-style docstrings.

This module provides example functions and classes with comprehensive numpy-style docstrings for documentation generation.

Examples

>>> from cvx_package_template.hello_world import hello_world, Calculator
>>> hello_world()
'Hello, World!'
>>> calc = Calculator(10)
>>> calc.add(5)
15.0
class cvx_package_template.hello_world.Calculator(initial_value: float = 0)[source]

Bases: object

A simple calculator class demonstrating numpy-style docstrings.

This class provides basic arithmetic operations and maintains a running total that can be manipulated through various methods.

Parameters

initial_valueint or float, optional

The starting value for the calculator. Default is 0.

Attributes

valuefloat

The current value stored in the calculator.

historylist of str

A history of operations performed on the calculator.

Examples

>>> calc = Calculator(10)
>>> calc.add(5)
15.0
>>> calc.multiply(2)
30.0
>>> calc.get_history()
['Initialized with 10', 'Added 5', 'Multiplied by 2']

Notes

All arithmetic operations modify the internal state and return the new value for convenience.

add(x: float) float[source]

Add a value to the current calculator value.

Parameters

xint or float

The value to add.

Returns

float

The new calculator value after addition.

Raises

TypeError

If x is not a number.

Examples

>>> calc = Calculator(10)
>>> calc.add(5)
15.0
get_history() list[str][source]

Get the operation history.

Returns

list of str

A list of strings describing each operation performed.

Examples

>>> calc = Calculator(5)
>>> calc.add(3)
8.0
>>> calc.get_history()
['Initialized with 5', 'Added 3']
greet(name: str = 'Calculator') str[source]

Generate a greeting from the calculator.

Parameters

namestr, optional

The name to greet. Default is “Calculator”.

Returns

str

A greeting message including the current calculator value.

Examples

>>> calc = Calculator(42)
>>> calc.greet("Alice")
'Hello Alice! My current value is 42.0'
multiply(x: float) float[source]

Multiply the current calculator value by a factor.

Parameters

xint or float

The factor to multiply by.

Returns

float

The new calculator value after multiplication.

Raises

TypeError

If x is not a number.

Examples

>>> calc = Calculator(10)
>>> calc.multiply(3)
30.0
reset(new_value: float = 0) float[source]

Reset the calculator to a new value.

Parameters

new_valueint or float, optional

The value to reset to. Default is 0.

Returns

float

The new calculator value.

Raises

TypeError

If new_value is not a number.

Examples

>>> calc = Calculator(10)
>>> calc.add(5)
15.0
>>> calc.reset()
0.0
cvx_package_template.hello_world.calculate_statistics(data: list[int | float]) dict[str, float][source]

Calculate basic statistics for a list of numbers.

Computes mean, median, standard deviation, minimum, and maximum values for the input data.

Parameters

datalist of int or float

Input data for statistical analysis. Must contain at least one numeric value.

Returns

dict

Dictionary containing the following statistics:

  • ‘mean’float

    Arithmetic mean of the data

  • ‘median’float

    Median value of the data

  • ‘std’float

    Standard deviation of the data

  • ‘min’float

    Minimum value in the data

  • ‘max’float

    Maximum value in the data

Raises

ValueError

If data is empty or contains non-numeric values.

TypeError

If data is not a list.

Examples

>>> data = [1, 2, 3, 4, 5]
>>> stats = calculate_statistics(data)
>>> stats['mean']
3.0
>>> stats['median']
3.0

Notes

This function uses numpy for numerical computations when available, falling back to built-in functions otherwise.

cvx_package_template.hello_world.hello_world(name: str | None = None, count: int = 1) str[source]

Generate a greeting message.

This function creates a customizable greeting message that can be personalized with a name and repeated multiple times.

Parameters

namestr, optional

The name to include in the greeting. If None, uses “World”. Default is None.

countint, optional

Number of times to repeat the greeting. Must be positive. Default is 1.

Returns

str

The formatted greeting message. If count > 1, greetings are separated by newlines.

Raises

ValueError

If count is not a positive integer.

TypeError

If name is not a string or None.

Examples

>>> hello_world()
'Hello, World!'
>>> hello_world("Alice")
'Hello, Alice!'
>>> result = hello_world("Bob", count=2)
>>> print(result)
Hello, Bob!
Hello, Bob!

Notes

This function demonstrates proper numpy-style docstring formatting for API documentation generation.

See Also

Calculator.greet : Another greeting method in this module