Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mandd/cpm red #52

Merged
merged 27 commits into from
Jan 27, 2025
Merged

Mandd/cpm red #52

merged 27 commits into from
Jan 27, 2025

Conversation

mandd
Copy link
Collaborator

@mandd mandd commented Oct 15, 2024


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)
What are the significant changes in functionality due to this change request?

For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual.
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Regression tests have to complete successfully.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test.
  • 6. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.

@mandd mandd changed the title [WIP] Mandd/cpm red Mandd/cpm red Oct 16, 2024
@mandd mandd requested a review from wangcj05 October 16, 2024 20:09
Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some minor comments for you to consider. @mandd


class Activity:
"""
This is the base class for a single activity
Extended from the original development of Nofar Alfasi
Source https://github.com/nofaralfasi/PERT-CPM-graph
"""
def __init__(self, name, duration):
def __init__(self, name, duration, res=None, childs=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstrings for all arguments in __init__ method

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 26 to 38
self.name = str(name)
self.duration = duration
self.subActivities = []
self.belongsToCP = False
self.resources = res

self.startTime = None
self.endTime = None

if childs is None:
self.childs = []
else:
self.childs = childs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please document all self.variable in this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

else:
self.childs = childs

def printToJsn(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function name is ok, but I think printToJson is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

def updateChilds(self, childs):
"""
Method designed to assign the childs of an activity
@ In, None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring for childs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"""
Method designed to assign the childs of an activity
@ In, None
@ Out, file in jason format
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no return for this function. Please update the docstring here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 758 to 760
"""Partition a directed graph into a list of subgraphs that contain
only entirely supported or entirely unsupported nodes.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the docstring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 762 to 763
supported_nodes = {n for n, d in G.nodes(data="node_type") if d == "supported"}
unsupported_nodes = {n for n, d in G.nodes(data="node_type") if d == "unsupported"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelBack here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


if plotting:
# Plot the stripped graph with the edges removed.
_node_colors = [c for _, c in H.nodes(data="node_color")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelBack?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

)

# Collect all removed edges for reconstruction.
G_minus_H = nx.DiGraph()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelBack here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"""

#For future compatibility with Python 3
from __future__ import division, print_function, unicode_literals, absolute_import
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Collaborator Author

@mandd mandd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangcj05: I think all comments have been addressed

"""
for act in self.forwardDict:
if act.returnResources() not in self.resources.columns:
print("Activity " + str(act.returnName()) + " requires a resource that is not allowed: " + str(act.returnResources()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added but needs to be discussed

"""
Method designed to return the immediate successors of a node
@ In, node, activity, activity being queried
@ Out, list, list of activities that are immediate successors of "node"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"""
Method designed to return the immediate predecessors of a node
@ In, node, activity, activity being queried
@ Out, list, list of activities that are immediate predecessors of "node"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"""
Method designed to return the number of immediate predecessors of a node
@ In, node, activity, activity being queried
@ Out, int, number activities that are immediate predecessors of "node"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 542 to 543
@ In, node, activity, activity to be queried
@ Out, list, list of activities
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

def deleteActivity(self,node):
"""
Method designed to remove an activity from a schedule
@ In, node, activity, activity to be removed
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 725 to 726
@ In, path, list, list of activities
@ In, CP, list, list of activities
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited

@ In, result, list, lis of subpath
@ In, temp_list, list, temporary list of
@ In, particular_list, list, list of element that mark a separation between sub-lists
@ Out, result, list, list of subpaths that are part "path" parallel to "CP"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 758 to 760
"""Partition a directed graph into a list of subgraphs that contain
only entirely supported or entirely unsupported nodes.
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes are good.

@wangcj05
Copy link
Collaborator

changes are good, checklist is good.

@wangcj05 wangcj05 merged commit e401e28 into devel Jan 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants