Skip to content

Commit

Permalink
Merge pull request #135 from CurricularAnalytics/refactor_degree_types
Browse files Browse the repository at this point in the history
Refactor Degree type to be an AbstractString
  • Loading branch information
haydenfree authored Aug 29, 2022
2 parents 4d66b1b + 73ba4e0 commit 9ff4b51
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 46 deletions.
53 changes: 29 additions & 24 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ version = "0.7.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "44c37b4636bc54afac5c574d2d02b625349d6582"
git-tree-sha1 = "78bee250c6826e1cf805a88b7f1e86025275d208"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.41.0"
version = "3.46.0"

[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[DataAPI]]
git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
git-tree-sha1 = "fb5f5316dd3fd4c5e7c30a24d50643b73e37cd40"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.9.0"
version = "1.10.0"

[[DataFrames]]
deps = ["CategoricalArrays", "Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "Missings", "PooledArrays", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
Expand All @@ -56,9 +56,9 @@ version = "0.21.8"

[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "3daef5523dd2e769dad2365274f760ff5f282c7d"
git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.11"
version = "0.18.13"

[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
Expand Down Expand Up @@ -99,14 +99,14 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[Graphs]]
deps = ["ArnoldiMethod", "Compat", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"]
git-tree-sha1 = "d727758173afef0af878b29ac364a0eca299fc6b"
git-tree-sha1 = "a6d30bdc378d340912f48abf01281aab68c0dec8"
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
version = "1.5.1"
version = "1.7.2"

[[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
git-tree-sha1 = "5cd07aab533df5170988219191dfad0519391428"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
version = "0.1.2"
version = "0.1.3"

[[InteractiveUtils]]
deps = ["Markdown"]
Expand All @@ -130,9 +130,9 @@ version = "0.4.3"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"
version = "0.21.3"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
Expand Down Expand Up @@ -249,9 +249,9 @@ uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "15dfe6b103c2a993be24404124b8791a09460983"
git-tree-sha1 = "db8481cf5d6278a121184809e9eb1628943c7704"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.3.11"
version = "1.3.13"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand Down Expand Up @@ -280,20 +280,25 @@ deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "a635a9333989a094bddc9f940c04c549cd66afcf"
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "dfec37b90740e3b9aa5dc2613892a3fc155c3b42"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.3.4"
version = "1.5.6"

[[StaticArraysCore]]
git-tree-sha1 = "ec2bd695e905a3c755b33026954b119ea17f2d22"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.3.0"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "d24a825a95a6d98c385001212dc9020d609f2d4f"
git-tree-sha1 = "82d3ea0d0211c13b1da2e05a41f39bfc54062890"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.8.1"
version = "1.9.1"

[[TOML]]
deps = ["Dates"]
Expand All @@ -306,10 +311,10 @@ uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"

[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "bb1064c9a84c52e277f1096cf41434b675cd368b"
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"]
git-tree-sha1 = "5ce79ce186cc678bbb5c5681ca3379d1ddae11a1"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.6.1"
version = "1.7.0"

[[Tar]]
deps = ["ArgTools", "SHA"]
Expand All @@ -321,9 +326,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
git-tree-sha1 = "8a75929dcd3c38611db2f8d08546decb514fcadf"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"
version = "0.9.9"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
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]>", "Orhan Abar <[email protected]>", "Will Thompson <[email protected]>"]
version = "1.3.3"
version = "1.4.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
4 changes: 2 additions & 2 deletions src/CurricularAnalytics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include("DegreePlanAnalytics.jl")
include("DegreePlanCreation.jl")
include("Simulation/Simulation.jl")

export AA, AAS, AS, AbstractCourse, AbstractRequirement, BA, BS, Course, CourseCollection, CourseCatalog, CourseRecord, CourseSet, Curriculum, Degree, DegreePlan,
export AA, AAS, AS, AbstractCourse, AbstractRequirement, BA, BS, Course, CourseCollection, CourseCatalog, CourseRecord, CourseSet, Curriculum, DegreePlan,
EdgeClass, Enrollment, Grade, LearningOutcome, PassRate, RequirementSet, Requisite, Student, StudentRecord, Simulation, System, Term, TransferArticulation,
add_course!, add_lo_requisite!, add_requisite!, add_transfer_catalog, add_transfer_course, all_paths, back_edge, basic_metrics, basic_statistics,
bin_filling, blocking_factor, centrality, co, compare_curricula, convert_ids, complexity, course, course_from_id, course_from_vertex, course_id,
Expand Down Expand Up @@ -695,7 +695,7 @@ courses must be identical (at the level of memory allocation). Allowable match c
"""
function merge_curricula(name::AbstractString, c1::Curriculum, c2::Curriculum, match_criteria::Array{String}=Array{String,1}();
learning_outcomes::Array{LearningOutcome}=Array{LearningOutcome,1}(), degree_type::Degree=BS, system_type::System=semester,
learning_outcomes::Array{LearningOutcome}=Array{LearningOutcome,1}(), degree_type::AbstractString=BS, system_type::System=semester,
institution::AbstractString="", CIP::AbstractString="")
merged_courses = deepcopy(c1.courses)
extra_courses = Array{Course,1}() # courses in c2 but not in c1
Expand Down
14 changes: 7 additions & 7 deletions src/DataHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ function read_csv(file_path::AbstractString)
if typeof(file_path) == Bool && !file_path
return false
end
dict_curric_degree_type = Dict("AA"=>AA, "AS"=>AS, "AAS"=>AAS, "BA"=>BA, "BS"=>BS, ""=>BS)
# dict_curric_degree_type = Dict("AA"=>AA, "AS"=>AS, "AAS"=>AAS, "BA"=>BA, "BS"=>BS, ""=>BS)
dict_curric_system = Dict("semester"=>semester, "quarter"=>quarter, ""=>semester)
dp_name = ""
dp_add_courses = Array{Course,1}()
curric_name = ""
curric_inst = ""
curric_dtype = dict_curric_degree_type["BS"]
curric_dtype = "BS"
curric_stype = dict_curric_system["semester"]
curric_CIP = ""
courses_header = 1
Expand Down Expand Up @@ -64,7 +64,7 @@ function read_csv(file_path::AbstractString)
courses_header += 1
end
if read_line[1] == "Degree Type"
curric_dtype = dict_curric_degree_type[uppercase(read_line[2])]
curric_dtype = read_line[2]
read_line = csv_line_reader(readline(csv_file), ',')
courses_header += 1
end
Expand Down Expand Up @@ -198,7 +198,7 @@ function read_csv(file_path::AbstractString)
for course in additional_courses
push!(ac_arr, course[2])
end
curric = Curriculum(curric_name, all_courses_arr, learning_outcomes = curric_learning_outcomes, degree_type= curric_dtype,
curric = Curriculum(curric_name, all_courses_arr, learning_outcomes = curric_learning_outcomes, degree_type = curric_dtype,
system_type=curric_stype, institution=curric_inst, CIP=curric_CIP)
terms = read_terms(df_all_courses, all_courses, all_courses_arr)
#If some courses has term informations but some does not
Expand All @@ -215,7 +215,7 @@ function read_csv(file_path::AbstractString)
return false
end
curric_courses_arr = [course[2] for course in curric_courses]
curric = Curriculum(curric_name, curric_courses_arr, learning_outcomes = curric_learning_outcomes, degree_type= curric_dtype,
curric = Curriculum(curric_name, curric_courses_arr, learning_outcomes = curric_learning_outcomes, degree_type = curric_dtype,
system_type=curric_stype, institution=curric_inst, CIP=curric_CIP)
output = curric
end
Expand Down Expand Up @@ -289,7 +289,7 @@ end


function write_csv_content(csv_file, program, is_degree_plan; metrics=false)
dict_curric_degree_type = Dict(AA=>"AA", AS=>"AS", AAS=>"AAS", BA=>"BA", BS=>"BS")
# dict_curric_degree_type = Dict(AA=>"AA", AS=>"AS", AAS=>"AAS", BA=>"BA", BS=>"BS")
dict_curric_system = Dict(semester=>"semester", quarter=>"quarter")
# Write Curriculum Name
if is_degree_plan
Expand All @@ -313,7 +313,7 @@ function write_csv_content(csv_file, program, is_degree_plan; metrics=false)
write(csv_file, curric_ins)

# Write Degree Type
curric_dtype = "\nDegree Type," *"\""* string(dict_curric_degree_type[curric.degree_type]) * "\""*",,,,,,,,,"
curric_dtype = "\nDegree Type," *"\""* string(curric.degree_type) * "\""*",,,,,,,,,"
write(csv_file,curric_dtype)

# Write System Type (Semester or Quarter)
Expand Down
9 changes: 4 additions & 5 deletions src/DataTypes/Curriculum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Required:
- `name::AbstractString` : the name of the curriculum.
- `courses::Array{Course}` : the collection of required courses that comprise the curriculum.
Keyword:
- `degree_type::Degree` : the type of degree, allowable
types: `AA`, `AS`, `AAS`, `BA`, `BS` (default).
- `degree_type::AbstractString` : the type of degree, e.g. BA, BBA, BSc, BEng, etc.
- `institution:AbstractString` : the name of the institution offering the curriculum.
- `system_type::System` : the type of system the institution uses, allowable
types: `semester` (default), `quarter`.
Expand All @@ -30,7 +29,7 @@ mutable struct Curriculum
id::Int # Unique curriculum ID
name::AbstractString # Name of the curriculum (can be used as an identifier)
institution::AbstractString # Institution offering the curriculum
degree_type::Degree # Type of degree_type
degree_type::AbstractString # Type of degree_type
system_type::System # Semester or quarter system
CIP::AbstractString # CIP code associated with the curriculum
courses::Array{AbstractCourse} # Array of required courses in curriculum
Expand All @@ -48,7 +47,7 @@ mutable struct Curriculum

# Constructor
function Curriculum(name::AbstractString, courses::Array{AbstractCourse}; learning_outcomes::Array{LearningOutcome}=Array{LearningOutcome,1}(),
degree_type::Degree=BS, system_type::System=semester, institution::AbstractString="", CIP::AbstractString="",
degree_type::AbstractString="BS", system_type::System=semester, institution::AbstractString="", CIP::AbstractString="",
id::Int=0, sortby_ID::Bool=true)
this = new()
this.name = name
Expand Down Expand Up @@ -86,7 +85,7 @@ mutable struct Curriculum
end

function Curriculum(name::AbstractString, courses::Array{Course}; learning_outcomes::Array{LearningOutcome}=Array{LearningOutcome,1}(),
degree_type::Degree=BS, system_type::System=semester, institution::AbstractString="", CIP::AbstractString="",
degree_type::AbstractString="BS", system_type::System=semester, institution::AbstractString="", CIP::AbstractString="",
id::Int=0, sortby_ID::Bool=true)
Curriculum(name, convert(Array{AbstractCourse},courses), learning_outcomes=learning_outcomes, degree_type=degree_type,
system_type=system_type, institution=institution, CIP=CIP, id=id, sortby_ID=sortby_ID)
Expand Down
2 changes: 1 addition & 1 deletion src/DataTypes/DataTypes.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# file: DataTypes.jl

# Enumerated types
@enum Degree AA AS AAS BA BAAS BAH BBA BDes BE BED BFA BGS BIS BLA BLS BM BME BMS BMus BPS BRIT BS BSAS BSBA BSBE BSCE BSCH BSCP BSCS BSCYS BSE BSEd BSEE BSEV BSIE BSIS BSIT BSME BSN BSPH BSW BTAS
# @enum Degree AA AS AAS BA BAAS BAH BBA BDes BE BED BFA BGS BIS BLA BLS BM BME BMS BMus BPS BRIT BS BSAS BSBA BSBE BSCE BSCH BSCP BSCS BSCYS BSE BSEd BSEE BSEV BSIE BSIS BSIT BSME BSN BSPH BSW BTAS
@enum System semester quarter
@enum Requisite pre co strict_co custom belong_to
@enum EdgeClass tree_edge back_edge forward_edge cross_edge
Expand Down
4 changes: 2 additions & 2 deletions test/DataHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ curric = read_csv("./curriculum.csv")

@test curric.name == "Underwater Basket Weaving"
@test curric.institution == "ACME State University"
@test curric.degree_type == AA
@test curric.degree_type == "AA"
@test curric.system_type == semester
@test curric.CIP == "445786"
@test length(curric.courses) == 12
Expand Down Expand Up @@ -113,7 +113,7 @@ dp = read_csv("degree_plan.csv")
@test dp.name == "4-Term Plan"
@test dp.curriculum.name == "Underwater Basket Weaving"
@test dp.curriculum.institution == "ACME State University"
@test dp.curriculum.degree_type == AA
@test dp.curriculum.degree_type == "AA"
@test dp.curriculum.system_type == semester
@test dp.curriculum.CIP == "445786"
@test length(dp.curriculum.courses)-length(dp.additional_courses) == 12
Expand Down
2 changes: 1 addition & 1 deletion test/DataTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_requisite!(A,C,pre);
# Test Curriciulum creation
@test curric.name == "Underwater Basket Weaving"
@test curric.institution == "ACME State University"
@test curric.degree_type == BS
@test curric.degree_type == "BS"
@test curric.system_type == semester
@test curric.CIP == "445786"
@test curric.num_courses == 8
Expand Down
6 changes: 3 additions & 3 deletions test/GraphAlgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ rtn = dfs(g);
@test rtn[1][Edge(2,3)] == tree_edge

# topological sort w/ no ordering by component size
@test topological_sort(g) == [[1], [4, 2, 6, 10, 5, 3], [7, 11, 8], [9], [12]]
@test CurricularAnalytics.topological_sort(g) == [[1], [4, 2, 6, 10, 5, 3], [7, 11, 8], [9], [12]]
# topological sort w/ ordering by component size in descenting order
@test topological_sort(g, sort = "descending") == [[4, 2, 6, 10, 5, 3], [7, 11, 8], [1], [9], [12]]
@test CurricularAnalytics.topological_sort(g, sort = "descending") == [[4, 2, 6, 10, 5, 3], [7, 11, 8], [1], [9], [12]]
# topological sort w/ ordering by component size in ascending order
@test topological_sort(g, sort = "ascending") == [[1], [9], [12], [7, 11, 8], [4, 2, 6, 10, 5, 3]]
@test CurricularAnalytics.topological_sort(g, sort = "ascending") == [[1], [9], [12], [7, 11, 8], [4, 2, 6, 10, 5, 3]]

# test gad()
t = gad(g);
Expand Down

2 comments on commit 9ff4b51

@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/67313

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.4.0 -m "<description of version>" 9ff4b51bd8c14915e0cbaf579ae2c6a3827af34c
git push origin v1.4.0

Please sign in to comment.