MyClass1

class package_helper_test_2022_01_18_17h12.MyClass1(a: float, b: float)[source]

A whatever-you-are-doing.

Parameters
  • a (float) – The a of the system. Must be non-negative.

  • b (float) – The b of the system.

my_string

A nice string.

Type

str

Raises

ValueError – If a is negative.

Notes

Document the __init__() method in the docstring of the class itself, because the docstring of the __init__() method does not appear in the documentation.

Examples

>>> my_object = MyClass1(a=5, b=3)
A_NICE_CONSTANT = 42

This is a nice constant.

A_VERY_NICE_CONSTANT = 51
property a_square: float

The square of a.

addition() float[source]

Add a and b.

Returns

The sum of a and b.

Return type

Number

Examples

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.addition()
8
>>> MyClass1(a=40, b=2)
MyClass1(a=40, b=2)
>>> MyClass1(a=50, b=1)
MyClass1(a=50, b=1)
divide_a_by_c_and_add_d(c: float, d: float) float[source]

Divide a by something and add something else.

Parameters
  • c (Number) – A non-zero number. You can say many things about this parameter in several indented lines, like this.

  • d (Number) – A beautiful number.

Returns

The result of a / c + d.

Return type

Number

Raises

ZeroDivisionError – If c = 0.

Notes

This function gives an example of documentation with typical features.

Examples

We can write some text to explain the following example:

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.divide_a_by_c_and_add_d(c=2, d=10)
12.5

And we can explain a second example here:

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.divide_a_by_c_and_add_d(c=2, d=20)
22.5
update_b_from_class_2(object_of_class_2)[source]

Update b from a MyClass2 object.

Parameters

object_of_class_2 (MyClass2) –

An object from the other class. The purpose of this function is essentially to show how to document when an argument is an object of another class.

N.B.: for the type of an argument, you can enter only the name of the class, e.g. MyClass2. However, in the rest of the documentation, you must use the full syntax, like :class:`MyClass2`.

Examples

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.update_b_from_class_2(MyClass2(42, 51))
>>> my_object.b
51