Skip to content

Commit

Permalink
feat: Adding Reset Data Method in Frequency Table
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherzhafif committed Oct 14, 2024
1 parent 1084073 commit 968dab7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion FrequencyTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ def __init__(self, dataset):
((self.length - 1) * (self.length - 2) * (self.length - 3))) - \
(3 * (self.length - 1) ** 2) / ((self.length - 2) * (self.length - 3))

# Method to reset the processed data
def reset_data(self):
global top, bottom, top_limit, bottom_limit, frequency
global data_range, data_limit, data_midpoint
global bot_cumulative_frequency, top_cumulative_frequency, relative_frequency, mode

# Clear all global variables used for data processing
top.clear()
bottom.clear()
top_limit.clear()
bottom_limit.clear()
frequency.clear()
data_range.clear()
data_limit.clear()
data_midpoint.clear()
bot_cumulative_frequency.clear()
top_cumulative_frequency.clear()
relative_frequency.clear()
mode.clear()

# Base 5 Rounding
def roundy(self, x, base=5):
return base * round(x / base)
Expand All @@ -86,9 +106,12 @@ def find_frequency(self, bot, top):
current += 0.01 # Increment by 0.01 for decimals

return total_frequency

# Populate Grouped Table Frequency Data Method
def PopulateGrouped(self):
# Reset data before populating
self.reset_data()

# Initiating Used Parameter for Frequency Table
old_number = 0
interval = self.interval
Expand Down Expand Up @@ -153,6 +176,9 @@ def PopulateGrouped(self):

# Populate Simple Table Frequency Data Method
def PopulateSimple(self):
# Reset data before populating
self.reset_data()

# Initialize general variables
data = sorted(set(self.dataset)) # Remove duplicates and sort the data

Expand Down

0 comments on commit 968dab7

Please sign in to comment.