Skip to content

Commit ec8022c

Browse files
Merge pull request #10 from bcrawford39GT/add_class_doc_updates
updated and fixed class docstring and modified class name to be the s…
2 parents 7d131cd + 68b0177 commit ec8022c

File tree

6 files changed

+52
-30
lines changed

6 files changed

+52
-30
lines changed

examples_to_run/examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from github_tutorial.main_functions.main_functions import math_function_class
1+
from github_tutorial.main_functions.main_functions import MathFunctionClass
22

33
# enter the two (2) values to use
44
entered_value_0 = 100
55
entered_value_1 = 2
66

7-
# set the math_function_class
8-
math_variable = math_function_class(entered_value_0, entered_value_1)
7+
# set the MathFunctionClass
8+
math_variable = MathFunctionClass(entered_value_0, entered_value_1)
99

10-
# print the math_variable (i.e., math_function_class) and list its type
10+
# print the math_variable (i.e., MathFunctionClass) and list its type
1111
print(f"\n")
1212
print(f"math_variable = {math_variable}")
1313
print(f"type(math_variable) = {type(math_variable)}\n")

examples_to_run/interactive_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

22
# to make each cell add '# %%' to the above section
33
# %%
4-
from github_tutorial.main_functions.main_functions import math_function_class
4+
from github_tutorial.main_functions.main_functions import MathFunctionClass
55

66
# %%
77
# enter the two (2) values to use
88
entered_value_0 = 100
99
entered_value_1 = 2
1010

1111
# %%
12-
# set the math_function_class
13-
math_variable = math_function_class(entered_value_0, entered_value_1)
12+
# set the MathFunctionClass
13+
math_variable = MathFunctionClass(entered_value_0, entered_value_1)
1414

1515
# %%
16-
# print the math_variable (i.e., math_function_class) and list its type
16+
# print the math_variable (i.e., MathFunctionClass) and list its type
1717
print(f"\n")
1818
print(f"math_variable = {math_variable}")
1919
print(f"type(math_variable) = {type(math_variable)}\n")

github_tutorial/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""The main math functions from this tutorial"""
22
from github_tutorial.main_functions import main_functions
3-
from github_tutorial.main_functions.main_functions import math_function_class
3+
from github_tutorial.main_functions.main_functions import MathFunctionClass
44
from github_tutorial.utils.math import (add_2_numbers, multiple_of_2_numbers)
55

66
__version__ = "0.0.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""main math functions"""
22
from github_tutorial.utils.math import (add_2_numbers, multiple_of_2_numbers)
3-
from github_tutorial.main_functions.main_functions import math_function_class
3+
from github_tutorial.main_functions.main_functions import MathFunctionClass

github_tutorial/main_functions/main_functions.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,40 @@ def _add_1_to_value(initial_value):
3535
return final_value
3636

3737
# This is the main math Class
38-
class math_function_class:
39-
"""Add 1 to to any value.
38+
class MathFunctionClass:
39+
"""Math class stores attributes/values and performs other functions.
4040
41-
This function adds 1 to the entered value.
41+
This class stores the initial two (2) values, and also
42+
the initial two (2) values added and multiplied together.
43+
Additionally, it has a function that adds one(1) to each
44+
of the initial two (2) values and multiplies them together.
4245
4346
Parameters
4447
----------
4548
initial_value: int or float
4649
The first integer or float that 1 will be added to.
47-
48-
Returns
50+
51+
Attributes
52+
----------
53+
value_0: float or int
54+
The first initial value entered in this class, which
55+
will be used in the math operations.
56+
value_1: float or int
57+
The second initial value entered in this class, which
58+
will be used in the math operations.
59+
added_numbers: float or int
60+
The first and second initial values added together.
61+
multiplied_numbers: float or int
62+
The first and second initial values multiplied together.
63+
64+
Methods
4965
-------
50-
final_value: int or float
51-
The initial value plus 1.
66+
def __init__(self, value_0, value_1):
67+
MathFunctionClass Class Constructor to initializes the object.
68+
69+
def add_1_to_both_numbers_and_multiply(self): int or float
70+
This function adds 1 to each of value_0 and value_1
71+
and multiplies them together.
5272
"""
5373
def __init__(
5474
self,
@@ -58,13 +78,13 @@ def __init__(
5878

5979
if not isinstance(value_0, (int, float)):
6080
raise TypeError(
61-
f"ERROR: In the 'math_function_class' class, the {'value_0'} "
81+
f"ERROR: In the 'MathFunctionClass' class, the {'value_0'} "
6282
f"is a {type(value_0)} and not a int or float."
6383
)
6484

6585
if not isinstance(value_1, (int, float)):
6686
raise TypeError(
67-
f"ERROR: In the 'math_function_class' class, the {'value_1'} "
87+
f"ERROR: In the 'MathFunctionClass' class, the {'value_1'} "
6888
f"is a {type(value_1)} and not a int or float."
6989
)
7090

@@ -77,12 +97,14 @@ def __init__(
7797
def add_1_to_both_numbers_and_multiply(self):
7898
"""Add 1 to both value_0 and value_1 and multiply them together.
7999
80-
This function adds 1 to each of value_0 and value_1 and multiplies them together.
100+
This function adds 1 to each of value_0 and value_1
101+
and multiplies them together.
81102
82103
Returns
83104
-------
84105
add_1_to_both_numbers_and_multiply: int or float
85-
This function adds 1 to each of value_0 and value_1 and multiplies them together.
106+
This function adds 1 to each of value_0 and value_1
107+
and multiplies them together.
86108
"""
87109

88110
add_1_to_to_each_value_and_mulitipy = _add_1_to_value(self.value_0) * _add_1_to_value(self.value_1)

github_tutorial/tests/test_main_functions.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from github_tutorial.tests.base_test import BaseTest
44
#from github_tutorial.utils.math import (add_2_numbers, multiple_of_2_numbers)
5-
from github_tutorial.main_functions.main_functions import (math_function_class, _add_1_to_value)
5+
from github_tutorial.main_functions.main_functions import (MathFunctionClass, _add_1_to_value)
66

77
class TestMainFunction(BaseTest):
88
def test__add_1_to_value_int(self):
@@ -67,11 +67,11 @@ def test__add_1_to_value_val_0_value_greater_equal_100000(self):
6767

6868
value = _add_1_to_value(val_0)
6969

70-
def test_math_function_class(self):
70+
def test_MathFunctionClass(self):
7171
val_0 = 1
7272
val_1 = 2
7373

74-
math_variable = math_function_class(val_0, val_1)
74+
math_variable = MathFunctionClass(val_0, val_1)
7575

7676
assert np.isclose(math_variable.added_numbers, 3)
7777
assert isinstance(math_variable.added_numbers, (int, float))
@@ -80,24 +80,24 @@ def test_math_function_class(self):
8080
assert np.isclose(math_variable.add_1_to_both_numbers_and_multiply(), 6)
8181
assert isinstance(math_variable.add_1_to_both_numbers_and_multiply(), (int, float))
8282

83-
def test_math_function_class_val_0_str(self):
83+
def test_MathFunctionClass_val_0_str(self):
8484
with pytest.raises(
8585
TypeError,
86-
match=f"ERROR: In the 'math_function_class' class, the value_0 is a {type('value_0')} "
86+
match=f"ERROR: In the 'MathFunctionClass' class, the value_0 is a {type('value_0')} "
8787
f"and not a int or float",
8888
):
8989
val_0 = '1.5'
9090
val_1 = 2.0
9191

92-
math_variable = math_function_class(val_0, val_1)
92+
math_variable = MathFunctionClass(val_0, val_1)
9393

94-
def test_math_function_class_val_1_str(self):
94+
def test_MathFunctionClass_val_1_str(self):
9595
with pytest.raises(
9696
TypeError,
97-
match=f"ERROR: In the 'math_function_class' class, the value_1 is a {type('value_1')} "
97+
match=f"ERROR: In the 'MathFunctionClass' class, the value_1 is a {type('value_1')} "
9898
f"and not a int or float",
9999
):
100100
val_0 = 1.5
101101
val_1 = '2.0'
102102

103-
math_variable = math_function_class(val_0, val_1)
103+
math_variable = MathFunctionClass(val_0, val_1)

0 commit comments

Comments
 (0)