Skip to content
Snippets Groups Projects
Commit d1d79384 authored by Maël Madon's avatar Maël Madon
Browse files

refac: python convention public/private methods

parent 2bc77b84
Branches
Tags
No related merge requests found
...@@ -41,8 +41,8 @@ class User: ...@@ -41,8 +41,8 @@ class User:
self.max_nb_res = 0 self.max_nb_res = 0
#@private ######## Private methods ########
def is_new_session(self, date_now): def __is_new_session(self, date_now):
"""Checks if a new session should be started according to the delimitation approach (see Zackay and Feitelson 2013)""" """Checks if a new session should be started according to the delimitation approach (see Zackay and Feitelson 2013)"""
if self.delim_approach == 'arrival': if self.delim_approach == 'arrival':
...@@ -57,12 +57,11 @@ class User: ...@@ -57,12 +57,11 @@ class User:
think_time = date_now - self.max_finish_time think_time = date_now - self.max_finish_time
return (think_time > self.delim_threshold) return (think_time > self.delim_threshold)
def sessions_finished_at_time(self, t): def __sessions_finished_at_time(self, t):
"""Return the list of session that were finished at time t""" """Return the list of session that were finished at time t"""
return [s for s in self.sessions.values() if s.max_finish_time <= t] return [s for s in self.sessions.values() if s.max_finish_time <= t]
#@private def __update_session_graph(self, date_now):
def update_session_graph(self, date_now):
"""Add the dependencies for the active session""" """Add the dependencies for the active session"""
active_session = self.sessions[self.active_session_id] active_session = self.sessions[self.active_session_id]
...@@ -72,7 +71,7 @@ class User: ...@@ -72,7 +71,7 @@ class User:
if not self.dynamic_reduction: if not self.dynamic_reduction:
# For all sessions that were finished when the current session was # For all sessions that were finished when the current session was
# started, add a directed edge weighted by the thinking time # started, add a directed edge weighted by the thinking time
for finish_sess in self.sessions_finished_at_time(date_now): for finish_sess in self.__sessions_finished_at_time(date_now):
think_time = date_now - finish_sess.max_finish_time # >=0 think_time = date_now - finish_sess.max_finish_time # >=0
active_session.preceding_sessions.append(finish_sess.id) active_session.preceding_sessions.append(finish_sess.id)
...@@ -109,8 +108,7 @@ class User: ...@@ -109,8 +108,7 @@ class User:
sess.id, sess.id,
weight=think_time) weight=think_time)
#@private def __create_new_session(self, date_now):
def create_new_session(self, date_now):
"""Create a new active session and achive the old one""" """Create a new active session and achive the old one"""
if self.active_session_id > 0: if self.active_session_id > 0:
...@@ -125,12 +123,11 @@ class User: ...@@ -125,12 +123,11 @@ class User:
new_session = Session(self.active_session_id, date_now) new_session = Session(self.active_session_id, date_now)
self.sessions[self.active_session_id] = new_session self.sessions[self.active_session_id] = new_session
#@private def __add_job_to_active_session(self, job):
def add_job_to_active_session(self, job):
active_sess = self.sessions[self.active_session_id] active_sess = self.sessions[self.active_session_id]
active_sess.add_job(job) active_sess.add_job(job)
#@public ######## Public methods ########
def add_job(self, job): def add_job(self, job):
"""Add a job to the job list of the user, creating a new session and """Add a job to the job list of the user, creating a new session and
handling its dependencies, if needed.""" handling its dependencies, if needed."""
...@@ -140,10 +137,10 @@ class User: ...@@ -140,10 +137,10 @@ class User:
date_now = job.submit_time date_now = job.submit_time
# does the job start a new session? # does the job start a new session?
if self.is_new_session(date_now): if self.__is_new_session(date_now):
self.create_new_session(date_now) self.__create_new_session(date_now)
self.update_session_graph(date_now) self.__update_session_graph(date_now)
self.add_job_to_active_session(job) self.__add_job_to_active_session(job)
# Updating variables # Updating variables
self.last_submit_time = job.submit_time self.last_submit_time = job.submit_time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment