当前位置: 首页>>代码示例>>Python>>正文


Python Course.get_all_by_crn方法代码示例

本文整理汇总了Python中course.Course.get_all_by_crn方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get_all_by_crn方法的具体用法?Python Course.get_all_by_crn怎么用?Python Course.get_all_by_crn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course.Course的用法示例。


在下文中一共展示了Course.get_all_by_crn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __make_schedule

# 需要导入模块: from course import Course [as 别名]
# 或者: from course.Course import get_all_by_crn [as 别名]
	def __make_schedule(requirements, current_schedule):
		if len(requirements) == 0:
			return current_schedule

		requirement = requirements[0]
		requirements = requirements[1:]

		for course in requirement.valid_courses:
			if len(Course.get_all_by_crn(course)) == 0:
				raise Exception("No class in catalog; %s" % course)
			for c in Course.get_all_by_crn(course):
				# Check to see if this course conflicts with anything
				conflicts = False
				for c2 in current_schedule:
					if c.timeslot.conflicts(c2.timeslot):
						conflicts = True
						break

				if not conflicts:
					# Make sure we can take it, then recurse
					schedule = []
					if not c.can_take(current_schedule, credit_hour_limit=max_credits):
						schedule =  __make_schedule(requirements, current_schedule)
						if schedule == False:
							continue
						# If we still can't take it, continue
						if not c.can_take(schedule, credit_hour_limit=max_credits):
							continue
						schedule += [c]
					else:
						schedule = __make_schedule(requirements, current_schedule + [c])
					if schedule != False:
						return schedule
		return False
开发者ID:chuck211991,项目名称:teamblue_xinformatics,代码行数:36,代码来源:schedule.py

示例2: test_get_courses_by_crn

# 需要导入模块: from course import Course [as 别名]
# 或者: from course.Course import get_all_by_crn [as 别名]
	def test_get_courses_by_crn(self):
		# Timeslot can be empty for this
		c1 = Course("CSCI2121", None)
		c2 = Course("CSCI2121", None)
		c3 = Course("CSCI2121", None)
		c4 = Course("CSCI2122", None)
		
		self.assertEquals(3, len(Course.get_all_by_crn("CSCI2121")))
开发者ID:chuck211991,项目名称:teamblue_xinformatics,代码行数:10,代码来源:test_course.py

示例3: get_worst_crn

# 需要导入模块: from course import Course [as 别名]
# 或者: from course.Course import get_all_by_crn [as 别名]
	def get_worst_crn(self):
		lowest = self.valid_courses[0]
		for c in self.valid_courses[1:]:
			if len(Course.get_all_by_crn(c)) < len(Course.get_all_by_crn(lowest)):
				lowest = c
		return len(Course.get_all_by_crn(lowest))
开发者ID:hayntopdawg,项目名称:teamblue_xinformatics,代码行数:8,代码来源:requirement.py


注:本文中的course.Course.get_all_by_crn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。