Skip to content

Commit

Permalink
Merge pull request #147 from CurricularAnalytics/add_remove_course_fu…
Browse files Browse the repository at this point in the history
…nction

add remove_course! function
  • Loading branch information
haydenfree authored Jul 10, 2024
2 parents 67e8405 + 59ed99a commit 88bfa3c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CurricularAnalytics"
uuid = "593ffa3d-269e-5d81-88bc-c3b6809c35a6"
authors = ["Greg Heileman <[email protected]>", "Hayden Free <[email protected]>"]
version = "1.5.2"
version = "1.5.3"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
2 changes: 1 addition & 1 deletion src/CurricularAnalytics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export AA, AAS, AS, AbstractCourse, AbstractRequirement, BA, BS, Course, CourseC
gad, grade, homology, is_duplicate, is_valid, isvalid_curriculum, isvalid_degree_plan, level, longest_path, longest_paths, merge_curricula, pass_table, passrate_table,
pre, postorder_traversal, preorder_traversal, print_plan, quarter, reach, reach_subgraph, reachable_from, reachable_from_subgraph, reachable_to, reachable_to_subgraph,
read_csv, requisite_distance, requisite_type, semester, set_passrates, set_passrate_for_course, set_passrates_from_csv, show_requirements, similarity, simple_students,
simulate, simulation_report, strict_co, topological_sort, total_credits, transfer_equiv, tree_edge, write_csv, knowledge_transfer, csv_stream
simulate, simulation_report, strict_co, topological_sort, total_credits, transfer_equiv, tree_edge, write_csv, knowledge_transfer, csv_stream, remove_course!

"""
extraneous_requisites(c::Curriculum; print=false)
Expand Down
24 changes: 24 additions & 0 deletions src/DataTypes/CourseCatalog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,36 @@ function add_course!(cc::CourseCatalog, course::Course)
!is_duplicate(cc, course) ? cc.catalog[course.id] = course : nothing
end

"""
remove_course!(cc::CourseCatalog, course::Course)
Remove `course` from the course catalog `cc` if it exists in the catalog.
Otherwise, do nothing.
"""
function remove_course!(cc::CourseCatalog, course::Course)
if is_duplicate(cc, course)
delete!(cc.catalog, course.id)
end
end

function add_course!(cc::CourseCatalog, courses::Array{Course,1})
for course in courses
add_course!(cc, course)
end
end

"""
remove_course!(cc::CourseCatalog, courses::Array{Course,1})
Remove all courses in `courses` from the course catalog `cc` if they exist in the catalog.
Otherwise, do nothing.
"""
function remove_course!(cc::CourseCatalog, courses::Array{Course,1})
for course in courses
remove_course!(cc, course)
end
end

function is_duplicate(cc::CourseCatalog, course::Course)
course.id in keys(cc.catalog) ? true : false
end
Expand Down
9 changes: 9 additions & 0 deletions test/DataTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ add_course!(CCat, [E,F,G]);
@test (CCat.date_range[2] - CCat.date_range[1]) == Dates.Day(365)
@test A == course(CCat, "BW", "110", "Introduction to Baskets")

# Test remove_course! functions
remove_course!(CCat, E);
@test length(CCat.catalog) == 6
remove_course!(CCat, [F,G]);
@test length(CCat.catalog) == 4

# add the courses back for later testing
add_course!(CCat, [E,F,G]);

# Test DegreePlan creation, other degree plan functions tested in ./test/DegreePlanAnalytics.jl
@test dp.name == "2019 Plan"
@test dp.curriculum === curric # tests that they're the same object in memory
Expand Down

2 comments on commit 88bfa3c

@haydenfree
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/110843

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.5.3 -m "<description of version>" 88bfa3cb7a09b9707862bae185003dfd6ecb6b83
git push origin v1.5.3

Also, note the warning: Version 1.5.3 skips over 1.5.2
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.