Example #1
0
 def readContentFile(self, fileName, cfg, limit=5) :
     with open(fileName, 'r') as f :
         curSection = None
         numSections = 0
         for line in f :
             line = line.strip()
             if line == '---' :
                 if curSection :
                     curSection.clamp(self.maxCharacters)
                     self.sections.append(curSection)
                     numSections += 1
                 if numSections >= limit :
                     return
                 curSection = Section()
             else :
                 index = line.find(':')
                 key = line[0:index]
                 val = line[index+2:]
                 curSection.setField(key, val)
                 if key == 'category' :
                     hasProm = cfg.has_option(val, 'prominence')
                     if hasProm :
                         prom = cfg.get(val, 'prominence')
                     else :
                         prom = cfg.get('Default', 'prominence')
                     curSection.prominence = prom
Example #2
0
    def __init__(self, element_id, start_node, end_node, cross_section,
                 n_sections, angle, length):
        self.id = element_id
        self.start_node = start_node
        self.end_node = end_node
        self.cross_section = cross_section
        self.n_sections = n_sections
        self.angle = angle
        self.length = length
        self.sections = np.empty(n_sections, dtype=Section)

        for section_id in range(n_sections):
            section = Section(section_id, cross_section)
            # section.f_section_resist = section.analyze([0, 0])[0]
            section.analyze([0, 0])

            # initk = section.k_section
            # print(initk)
            # break
            self.sections.put(section_id, section)

        if self.n_sections == 3:
            self.wh = [1 / 3, 4 / 3, 1 / 3]
            self.x = [-1, 0, 1]
        elif self.n_sections == 4:
            self.wh = [5 / 6, 1 / 6, 1 / 6, 5 / 6]
            self.x = [-1, -0.447214, 0.447214, 1]
        elif self.n_sections == 5:
            self.wh = [1 / 10, 49 / 90, 32 / 45, 49 / 90, 1 / 10]
            self.x = [-1, -0.654654, 0, 0.654654, 1]
        elif self.n_sections == 6:
            self.wh = [
                0.066667, 0.378475, 0.554858, 0.554858, 0.378475, 0.066667
            ]
            self.x = [-1, -0.765055, -0.285232, 0.285232, 0.765055, 1]
Example #3
0
def main():
    if len(sys.argv) != 3:
        stderr("usage: %s <output-dir> <spec.html>" % sys.argv[0])
        sys.exit(1)

    outdir = sys.argv[1]
    spec_path = sys.argv[2]

    shared.register_output_dir(outdir)

    shared.msg_at_posn_start()

    spec.read_source_file(spec_path)

    spec.doc_node = HTML.parse_and_validate()

    # Now that errors/warnings are interleaved with a copy of the spec text,
    # the order in which we call these functions
    # only matters when two msg_at_posn() calls
    # address the exact same position.

    check_characters()

    check_indentation()
    check_trailing_whitespace()
    check_for_extra_blank_lines()

    check_ids()
    check_dfns()

    Pseudocode.create_all_parsers()

    check_tables()
    records.process_tables()
    Section.make_and_check_sections()
    records.print_schema_hierarchies()
    process_intrinsics_facts()
    check_references_to_intrinsics()
    emu_grammars.do_stuff_with_emu_grammars()
    
    Pseudocode.do_stuff_with_pseudocode()

    check_globals()

    shared.msg_at_posn_finish()

    headers.generate_spec_for_PR_545()

    spec.save()
Example #4
0
def updateProcessing(config):
    """The function that calls processDirectory on the root directory."""

    routines.printAtDepth(0, "Beginning processing...", 5)

    # Load the objects that we'll need

    loadSectionObjects()
    loadTemplates()

    # Figure out the local root

    localRoot = routines.getConfig(config, "LocalRoot")

    routines.printAtDepth(1, "Entering directory \"%s\"..." % localRoot, 2)

    # Get the begining navigation HTML

    nav = Section.Section().makeNavigationHTML("", config, "main")  # HACK!

    # Process

    routines.processDirectorySelector("", nav, 1, config)

    routines.printAtDepth(1, "Leaving directory \"%s\"..." % localRoot, 3)
    routines.printAtDepth(0, "Done Processing!\n", 6)
Example #5
0
    def createSectionsWithUniqueMelodies1 ( self, levers ) : 

        self.wbLevers = collections.OrderedDict()
        for mvNum in range(self.numMovements) : 
            self.wbLevers[mvNum] =  self.element.InitializeWastsonBeatMelodyDetails ( mvNum ) 

        self.uniqLayers = collections.OrderedDict() 


        print() 
        for mvNum in range(self.numMovements) : 
            
            self.uniqLayers[mvNum]  = collections.OrderedDict() 
            print ( "Movement: ", mvNum ) 
            for uniqMelId in self.wbLevers[mvNum] : 
                self.wbLevers[mvNum][uniqMelId] = dict ( self.wbLevers[mvNum][uniqMelId], **levers ) 
                self.wbLevers[mvNum][uniqMelId]['primaryScale'] =  self.wbLevers[mvNum][uniqMelId]['key']
                self.wbLevers[mvNum][uniqMelId]['complexity'] = levers['complexity'][mvNum]
                self.wbLevers[mvNum][uniqMelId]['id'] = uniqMelId
                print ( "Unique Melody: ", uniqMelId, self.wbLevers[mvNum][uniqMelId] ) 
                
                section = Section.Section ( self.wbLevers[mvNum][uniqMelId] )
                section.PrintClassInfo ()                 
                self.uniqLayers[mvNum][uniqMelId] = section.run() 
            print() 


        self.printUniqLayers()
        self.printDetails()
Example #6
0
    def parseNamespaceStatement(self, statement, state):
        state["stype"] = NSPACE_TYPE

        name = statement[9:].lstrip()

        state["sobj"] = Section.Namespace(name)

        return state
Example #7
0
 def listSections(self):
     query_section_sql="SELECT sec.id,sec.course_name,sch.location,sec.section_id FROM section_info AS sec LEFT JOIN school_info AS sch ON sec.school_id=sch.id WHERE sec.teacher_id=\'" + self.getId() + "\'"
     raw=super().readFromDB(query_section_sql)
     
     data={}
     for d in raw:
         section_description=d[1] + " in " + d[2] + " section number " + str(d[3])
         data[section_description] = Section.Section(d[0])
     return data
Example #8
0
	def ReadSections(self,inp):
		currPtr = inp.tell()
		inp.seek(0,2)
		sizeOfInp = inp.tell()
		inp.seek(currPtr)

		while inp.tell() < sizeOfInp:
			section = Section.Section()
			section.Read(inp)
			yield section
Example #9
0
 def openSection(self,name, faculty,sched,start,end,capacity,course):
     if(len(name) <= 3):
         for i in range (len(self.__courses)):
             if(self.__courses[i].getCode().lower() == course.lower()):
                 self.__courses[i].addSection(Section(name, faculty,sched,start,end,
                                                      capacity,self.__courses[i]))
                 return True
     else:
         print("Invalid section format.")
         return False
Example #10
0
 def __pad(self):
     """
     This method adds an empty section at the end of the article.
 
     It is currently used in preparation for something being inserted at the end of the article.
     """
     sentencedata = Sentence_Data(id=-1, text=" ")
     paragraphdata = Paragraph_Data(id=-1, sentences_data=[sentencedata])
     sectiondata = Section_Data(id=-1, paragraphs_data=[paragraphdata])
     insertioniter = self.__sections[-1].getStart()
     section = Section(sectiondata, self.__buf, insertioniter)
     self.__sections.insert(-1, section)
Example #11
0
    def parseEnumStatement(self, statement, state):
        state["stype"] = ENUM_TYPE

        rest = statement[4:].lstrip()

        eclass = False
        if rest.startswith("class"):
            eclass = True
            rest = rest[5:].lstrip()

        state["sobj"] = Section.Enum(rest, eclass)

        return state
Example #12
0
 def listEnrolledSection(self):
     query_section_info_sql='''SELECT sec.id,sec.course_name,sch.location,sec.section_id FROM section_info AS sec LEFT JOIN school_info AS sch ON sec.school_id=sch.id 
                         LEFT JOIN student_info AS stu ON sec.school_id=stu.school_id WHERE stu.id=\'''' + self.getId() + "\'"
     raw=super().readFromDB(query_section_info_sql)
     
     data={}
     for d in raw:
         table_name=d[1]+"_in_"+d[2]+"_"+str(d[3])
         check_id_exists_sql="SELECT 1 FROM " + table_name + " WHERE student_id=\'" + self.getId() + "\' LIMIT 1"
         if super().readFromDB(check_id_exists_sql):
             section_description=d[1] + " in " + d[2] + " section number " + str(d[3])
             data[section_description] = Section.Section(d[0])
     return data
Example #13
0
 def getCourse(self, tableOfValues):
     for value in tableOfValues:
         sectionName = value.find(
             'div', class_=re.compile('section--section-title--*'))
         sectionPreviwedList = value.findAll(
             'div',
             class_=re.compile('section--lecture-title-and-description--*'))
         section = Section.Section(sectionName.next)
         for sectionPreviwedItem in sectionPreviwedList:
             item = Item.Item(sectionPreviwedItem.text)
             section.addSectionItem(item)
         self.addSection(section)
     return self
Example #14
0
def main():
    if len(sys.argv) != 3:
        stderr("usage: %s <output-dir> <spec.html>" % sys.argv[0])
        sys.exit(1)

    outdir = sys.argv[1]
    spec_path = sys.argv[2]

    shared.register_output_dir(outdir)

    shared.msg_at_posn_start()

    spec.read_source_file(spec_path)

    spec.doc_node = HTML.parse_and_validate()

    # It feels like it would make more sense to check characters and indentation
    # before paring/checking markup, because they're more 'primitive' than markup.
    # But when it comes to fixing errors, you should make sure
    # you've got the markup correct before fiddling with indentation.
    # So to encourage that, have markup errors appear before indentation errors,
    # i.e. run the markup checks before indentation checks.
    # (Not sure about characters.)
    check_indentation()
    check_trailing_whitespace()
    check_characters()

    check_ids()

    check_tables()
    check_intrinsics()
    Section.make_and_check_sections()
    emu_grammars.do_stuff_with_emu_grammars()

    Pseudocode.do_stuff_with_pseudocode()

    shared.msg_at_posn_finish()

    spec.save()
Example #15
0
 def insertSection(self, section_data, lociter):
     """
     This method inserts a single section into the article.
     
     The section is represented by section_data, and the insertion point is specified by lociter
 
     The section is inserted into the closest gap to lociter.
     """
     insertionindex = self.__get_best_section(lociter)
     if insertionindex == 0: insertionindex = insertionindex + 1
     insertioniter = self.__sections[insertionindex].getStart()
     section = Section(section_data, self.__buf, insertioniter)
     self.__sections.insert(insertionindex, section)
    def listAvailableSections(cls, student):
        if not isinstance(student, Student.Student):
            raise TypeError("Rejected")

        query_available_section_sql = "SELECT sec.id,sec.course_name,sch.location,sec.section_id FROM section_info AS sec LEFT JOIN student_info AS stu ON sec.school_id=stu.school_id LEFT JOIN school_info AS sch ON sec.school_id=sch.id"
        raw = super().readFromDB(query_available_section_sql)

        data = {}
        for d in raw:
            section_description = d[1] + " in " + d[
                2] + " section number " + str(d[3])
            data[section_description] = Section.Section(d[0])
        return data
Example #17
0
    def __splitSection(self, lociter):
        """
        This method finds the section which contains lociter.
    
        It then finds the closest paragraph gap to lociter.
    
        The section is then split into two sections, one containing all the paragraphs before the gap,
        the other containing all the paragraphs after the gap.
        """
        sectionindex = self.__get_exact_section(lociter)
        section = self.__sections[sectionindex]

        source_article_id = section.source_article_id
        source_section_id = section.source_section_id

        offset = lociter.get_offset()
        section.splitParagraph(lociter)
        lociter = self.__buf.get_iter_at_offset(offset)

        firstdata = section.getDataRange(section.getStart(), lociter)
        seconddata = section.getDataRange(lociter, section.getEnd())
        mark = self.__buf.create_mark(None, lociter, False)
        if firstdata != [] and seconddata != []:
            self.deleteSection(lociter)

            insertioniter = self.__buf.get_iter_at_mark(mark)
            sectiondata = Section_Data(None, source_article_id,
                                       source_section_id, firstdata)
            section = Section(sectiondata, self.__buf, insertioniter)
            self.__sections.insert(sectionindex, section)

            insertioniter = self.__buf.get_iter_at_mark(mark)
            sectiondata = Section_Data(None, source_article_id,
                                       source_section_id, seconddata)
            section = Section(sectiondata, self.__buf, insertioniter)
            self.__sections.insert(sectionindex + 1, section)
Example #18
0
    def __init__(self, course_id):
        # Supress the certificate verification warning
        requests.packages.urllib3.disable_warnings(
            category=InsecureRequestWarning)

        t0 = time.time()
        # Gets API data without certificate verification
        r = requests.get('https://api.umd.io/v1/courses/' + course_id,
                         verify=False).json()[0]

        #out += query_by_Id(course).json()[0].get("course_id"))

        self.course_id = course_id  # The associated course id (ENGL101)
        self.sections = []

        # Concatenates all sections into one string to reduce number of API calls
        sectionStrings = r.get("sections")
        appStr = ""
        for section in sectionStrings:
            appStr += section + ","

        appStr = appStr[:-1]
        secr = requests.get('https://api.umd.io/v1/courses/sections/' + appStr,
                            verify=False).json()

        t1 = time.time()
        print("Request for " + course_id + " took: " + str(t1 - t0)[:5])
        for section in secr:
            self.sections.append(Section.Section(section))

        #self.sections = r.get("sections")                # List of Section objects for the course (0101, 0102, 0201, etc.)
        self.semester = r.get(
            "semester")  # Numeric representation YYYYMM (202001)
        self.credits = r.get(
            "credits")  # Number of credits for the course (2, 3, 4, etc.)
        self.dept_id = r.get(
            "dept_id"
        )  # 4 letter department code, useful for narrowing down search (CMSC, MATH, etc.)
        self.grading_method = r.get(
            "grading_method")  # Can be used to narrow down search as well
        self.core = r.get(
            "core")  # Core requirements that this course fulfills
        self.gen_ed = r.get(
            "gen_ed")  # Gen ed requirements that this course fulfills
        self.relationships = r.get(
            "relationships"
        )  # Dictionary that holds information on coreqs, prereqs, cross-listings, etc.
Example #19
0
    def parseClassStatement(self, statement, state):
        # Section Type = class
        state["stype"] = CLASS_TYPE

        # Parse name
        left = statement[5:].lstrip()
        tstart = left.find("<")
        tparams = []
        if tstart >= 0:
            tparams = self.parseTParams(left[tstart:])
            state["sname"] = left[:tstart]
        else:
            state["sname"] = left

        state["sobj"] = Section.Class(state["sname"], tparams)

        return state
Example #20
0
def _parse_case_page(
        index: str, name: str,
        tree: mwparserfromhell.wikicode.Wikicode) -> Optional[CasePage]:
    diff_sections = tree.get_sections(
        matches=lambda title: title.matches(name))
    if not diff_sections and '<!-- Template:Courtesy blanked -->' in tree:
        return None
    assert len(diff_sections) == 1, tree.filter_headings()
    diff_section = diff_sections[0]
    assert diff_section.nodes[0].level == 2

    excluded = [diff_section]
    unknown = []
    for section in tree.get_sections(include_lead=False):
        if any(section in excl for excl in excluded):
            continue
        if section.nodes[0].title.matches(_IGNORED_HEADINGS):
            excluded.append(section)
        else:
            unknown.append(section)

    unknown = [
        section for section in unknown
        if not any(section in excl for excl in excluded)
    ]
    assert not unknown, [section.nodes[0] for section in unknown]

    sections = {}
    for section in diff_section.get_sections(levels=[3]):
        title = section.nodes[0].title.strip()
        match = re.match(r'^Pages (\d+) through (\d+)$', title)
        assert match, title
        index = f'{match.group(1)}-{match.group(2)}'
        lines = [
            line.strip() for line in section.splitlines()[1:] if line.strip()
        ]
        if _is_collapsed(lines):
            continue
        pages = [_parse_line(line) for line in lines]
        pages = [line for line in pages if line]
        if not pages:
            continue
        sections[index] = Section(title, pages)

    return CasePage(index, sections)
Example #21
0
    def addSection(self, sectionObj=None):

        if (sectionObj is not None):  #add section that has been made.
            if (isinstance(sectionObj, Section.section)
                ):  # Make sure the object being passed is of correct type
                self.sections.append(sectionObj)

        else:
            #add section that also needs to be created
            professor = input("\nEnter class professor's name: ")
            section = input("\nEnter section: ")
            time = input("\nEnter class start time: ")
            duration = input("\nEnter class duration: ")
            location = input("\nEnter class location: ")
            enrollment = input("\nEnter class enrollment: ")

            sectionObj = Section.section(professor, section, time, duration,
                                         location, enrollment)
            self.sections.append(sectionObj)
Example #22
0
    def __init__(self, article_data=Article_Data()):
        """
        Create default text buffer and set to empty 
        """
        self.__buf = Gtk.TextBuffer()
        self.__buf.set_text("")
        insertionpoint = self.__buf.get_end_iter()
        insertionmark = self.__buf.create_mark(None, insertionpoint, False)
        """ 
        Set the attributes such as title, theme, id etc. as specified in the article_data parameter
        """
        self.id = article_data.id
        self.article_title = article_data.article_title
        self.article_theme = article_data.article_theme
        self.source_article_id = article_data.source_article_id
        self.image_list = article_data.get_image_list()
        """
        The article is currently blank, so there are no sections
        """
        self.__sections = []
        """
        Create new sections based on the section data in article_data
        At this level, nothing is actually inserted into the textbuffer.
        The text insertion occurs at the sentence level.
        The sentences are created within the initialisation of the Section object.
        """
        sections_data = article_data.sections_data
        for section_data in sections_data:
            insertioniter = self.__buf.get_iter_at_mark(insertionmark)
            self.__sections.append(
                Section(section_data, self.__buf, insertioniter))

        self.__buf.delete_mark(insertionmark)
        """
        We also append dummy sections, containing nothing, at the start and end of the article.
        """
        startdummy = dummySection(self.__buf, self.__buf.get_start_iter(),
                                  True)
        enddummy = dummySection(self.__buf, self.__buf.get_end_iter(), False)
        self.__sections = [startdummy] + self.__sections + [enddummy]

        self.markmark = None
Example #23
0
    def parse_section(lines, start_index, level, heading):

        index = start_index
        line = lines[index]

        # "Main article(s):"
        main_articles, index = TextParser.find_link_list(
            line, index, TextParser.LINK_LIST_START[LinkType.MAIN_ARTICLE])
        line = lines[index]

        # "See also:"
        see_also, index = TextParser.find_link_list(
            line, index, TextParser.LINK_LIST_START[LinkType.SEE_ALSO])
        line = lines[index]

        # Find section's actual content
        content = ""
        while index < len(lines):
            line = lines[index]
            if not line.startswith(TextParser.HEADER_START):
                content = content + line + "\n"
                index = index + 1
            else:
                break

        # There is no more content by the time we reach either eof or another heading
        section_meta = SectionMeta.SectionMeta(heading, level, main_articles,
                                               see_also)
        section = Section.Section(section_meta, content)

        # Handle nested sections
        if line.startswith(TextParser.HEADER_START):
            sublevel, subheading = TextParser.parse_heading(line)
            if level < sublevel:
                subsection, index = TextParser.parse_section(
                    lines, index + 1, sublevel, subheading)
                section.add_subsection(subsection)

        return section, index
Example #24
0
from Section import *

# Test section from airfoil coordinates
s = Section("../airfoils/SD7062.dat")

s.set_attitude(alpha=10)
s.execute()
assert round(s.lift_coef(), 2) == 1.70
assert round(s.drag_coef(), 3) == 0.000

s.set_attitude()
s.set_reynolds(4.5e5)
s.execute()
assert round(s.lift_coef(), 2) == 0.00
assert round(s.drag_coef(), 3) == 0.015

# Test section from NACA designation
n = Naca("0012")

n.set_reynolds(1e6)
n.set_attitude(alpha=10)
n.execute()
assert round(n.lift_coef(), 2) == 1.08
assert round(n.drag_coef(), 3) == 0.015
Example #25
0
    def populateSections ( self ) : 


        DevServer.Server.run ( self.movements ) # this will be a json object that will be passed to the server


        for mvNum in self.movements : 
            sectionsObj = self.movements[mvNum]['SectionsObj'].mood        
            numUniqCPs  = sectionsObj.numUniqCPs  
            self.movements[mvNum]['layers'] = collections.OrderedDict()             

            print ( "numUniqCPs: ", numUniqCPs ) 

            for uniqCPId in range(numUniqCPs) : 
                pl     = sectionsObj.uniqCPSettings[uniqCPId]['pl'] 
                key    = sectionsObj.uniqCPSettings[uniqCPId]['scale'] 
                #bpm    = sectionsObj.uniqCPSettings[uniqCPId]['bpm'] 
                tse    = sectionsObj.uniqCPSettings[uniqCPId]['tse'] 
                cpSeq  = sectionsObj.uniqCPSettings[uniqCPId]['cpSeq'] 
                layers = sectionsObj.layers 
                percussionSettings = sectionsObj.uniqCPSettings[uniqCPId]['percussionSettings'] 


                #if hasattr( sectionsObj.uniqCPSettings[uniqCPId], 'bassRhythm' ) : 

                if ( 'bassRhythm' in sectionsObj.uniqCPSettings[uniqCPId] ) : 
                    bassRhythmOptions = sectionsObj.uniqCPSettings[uniqCPId]['bassRhythm'] #sectionsObj.bassRhythm
                else : 
                    bassRhythmOptions = None 


                mood  = self.movements[mvNum]['mood'] 
                rhythmSpeed = self.movements[mvNum]['rhythmSpeed'] 
                complexity = self.movements[mvNum]['complexity'] 
                
                wbLevers = {
                    'id'          : uniqCPId,

                    'phraseLength': pl,
                    'tse'         : tse, 
                    'primaryScale': key,
                    'bassRhy'     : cpSeq,

                    'mood'        : mood,
                    'complexity'  : complexity, 
                    'rhythmSpeed' : rhythmSpeed,
                    
                    'layers'      : layers, 

                    'bassRhythmOptions' : bassRhythmOptions,

                    'percussionSettings': percussionSettings, 
                    
                    }

                section = Section.Section ( wbLevers ) 
                self.movements[mvNum]['layers'][uniqCPId] = section.run () 

                
            arrangeSections = ArrangeSections ( mvNum, self.movements[mvNum] ) 
            arrangeSections.arrange() 
Example #26
0
  def run(self):
    #Demonstration of University
    print("University before Alterations:\n")
    self.uni.printUniversity()
    #Add colleges
    self.uni.setCollegeList([self.cas, self.cems])
    #Increase Tuition
    self.uni.increaseTuition(2.0)
    #Change Enrollement
    self.uni.setEnrollment(11500)
    #Delete and then add the same college
    print("Deleting and Adding Colleges from University")
    self.uni.delCollege("CAS")
    self.uni.printCollegeList()
    self.uni.addCollege(self.cas)
    self.uni.printCollegeList()
    #Find a college that doesn't exist
    print("Trying to find a college that doesn't exist")
    index1 = self.uni.findCollege("Grossman")
    if(index1==-1):
        print("Grossman college was not found")
    else:
        print("Grossman college exists at index: " + str(index))
    print("University after Alterations:\n")
    self.uni.printUniversity()

    #Demonstration of College
    print("CEMS before Alterations:\n")
    self.cems.printCollege()
    #Add/Delete Majors
    self.cems.setMajorList(["Computer Science","Mechanical Engineering","Mathematics"])
    self.cems.addMajor("Biomedical Engineering")
    self.cems.delMajor("Mathematics")
    #Add/Delete Professors
    self.cems.setProfList([self.jane, self.john])
    self.cems.addProf(self.sam)
    self.cems.delProf("John Doe")
    #Increase Enrollment
    self.cems.setCollegeEnrollment(3500)
    #Find
    print("Trying to find a major that doesn't exist and a professor that does")
    index2 = self.cems.findProf("Jane Doe")
    if(index2 == -1 ):
        print("Jane Doe is not a professor in CEMS")
    else:
        print("Jane Doe is a professor in CEMS and exists at index " + str(index2))

    index3= self.cems.findMajor("Art Education")
    if(index3 == -1 ):
        print("Art Education is not a major in CEMS")
    else:
        print("Art Education is a major in CEMS and exists at index " + str(index3))
    print("CEMS after Alterations:\n")
    self.cems.printCollege()

    #Demonstration of Professor Class
    print("Professor John Doe Before Alterations:\n")
    self.john.printProfessor()
    #Add and delete courses
    self.john.setCourseList([self.cs127,self.cs319])
    self.john.addCourse(self.cs424)
    self.john.delCourse("CS 127")
    #Update office, tenure, and rating
    self.john.setTenure(1)
    self.john.setRating(4.0)
    self.john.setOffice("Dicovery 501")
    #Try and Find a course
    index4= self.john.findCourse("CS 319")
    if(index4==-1):
        print("John Doe does not teach CS 319")
    else:
        print("John Does does teach CS 319")
    print("Professor John Doe after Alterations:\n")
    self.john.printProfessor()

    #Demonstration of Course and section class
    print("\n\nOriginal course before alterations: \n\n")
    self.cs127.displayCourseInfo()
    #self.cs127.addSection() #Uncomment these to build section manually.
    #self.cs127.addSection()

    self.cs127Section = Section.section("Professor2", "BCD", "time", "duration", "location", -10)
    self.cs127.addSection(self.cs127Section)

    self.cs127.displaySection("A")
    self.cs127.displaySection("B")
    self.cs127.setCourseTitle("cs1127")
    self.cs127.setCredits("4")
    print("\n\nAltered course: \n\n")
    self.cs127.displayCourseInfo()
    self.cs127.displayAllSections()

    self.cs127Section.setDuration("3 hrs")
    print(self.cs127Section.duration)
Example #27
0
            # Blanks for Optimization
            size = np.shape(Shape_Set[:, 0])[0]
            MemberProp = np.zeros((NP, NM, 4))
            GroupShape = np.zeros((NP, size), dtype=np.intc)
            Local_Matrix = np.zeros((NP, NM, 12, 12))
            AgrD = np.zeros(NP)
            AgrDC = np.zeros(NP)
            weight = np.zeros(NP)
            Cost = np.zeros(NP)
            CostC = np.zeros(NP)
            Agr1 = np.zeros(1)
            Agr2 = np.zeros(1)

            # Create Random finesses population
            Section.memgroupsec(NP, GroupShape, Shape_Set)
            # shape properties for each the random cross-sections
            MemberProp[:, :] = Section_Prop[GroupShape[:, Group], :]

            # start timer
            start = timer()

            # Run fitness function for starting population
            Parallel(
                delayed(SolutionStiffnessSpeed.DisplacementCy2)
                (NM, Modules, TransT, Transmatrix, NDOF, MemberCOORDNum, L, Pf,
                 MemberProp[x], Local_Matrix[x], COORDNum, x, AgrD, DNumber,
                 Agr1, Agr2) for x in range(NP))

            # evaluate starting population
            weight[:] = np.sum(Wt[GroupShape[:, Group[:]]] * L,
    def populateSections ( self ) : 


        wbClientData = collections.OrderedDict () 
        for mvNum in self.movements : 
            sectionsObj = self.movements[mvNum]['SectionsObj'].mood        
            numUniqCPs  = sectionsObj.numUniqCPs  

            wbClientData[mvNum] = collections.OrderedDict () 

            print ( "numUniqCPs: ", numUniqCPs )

            for uniqCPId in range(numUniqCPs) : 
                print(uniqCPId)

                wbClientData[mvNum][uniqCPId] = collections.OrderedDict () 

                key    = sectionsObj.uniqCPSettings[uniqCPId]['scale']
                #bpm    = sectionsObj.uniqCPSettings[uniqCPId]['bpm'] 
                tse    = sectionsObj.uniqCPSettings[uniqCPId]['tse'] 
                cpSeq  = sectionsObj.uniqCPSettings[uniqCPId]['cpSeq'] 
                layers = sectionsObj.layers
                pl     = sectionsObj.uniqCPSettings[uniqCPId]['pl']

                percussionSettings = sectionsObj.uniqCPSettings[uniqCPId]['percussionSettings'] 


                #if hasattr( sectionsObj.uniqCPSettings[uniqCPId], 'bassRhythm' ) : 

                if ( 'bassRhythm' in sectionsObj.uniqCPSettings[uniqCPId] ) : 
                    bassRhythmOptions = sectionsObj.uniqCPSettings[uniqCPId]['bassRhythm'] #sectionsObj.bassRhythm
                else : 
                    bassRhythmOptions = None 


                mood  = self.movements[mvNum]['mood'] 
                rhythmSpeed = self.movements[mvNum]['rhythmSpeed'] 
                complexity = self.movements[mvNum]['complexity'] 
                
                wbLevers = {
                    'id'          : uniqCPId,

                    'phraseLength': pl,
                    'tse'         : tse, 
                    'primaryScale': key,
                    'bassRhy'     : cpSeq,

                    'mood'        : mood,
                    'complexity'  : complexity, 
                    'rhythmSpeed' : rhythmSpeed,
                    
                    'layers'      : layers, 

                    'bassRhythmOptions' : bassRhythmOptions,

                    'percussionSettings': percussionSettings, 
                    
                    }

                wbClientData[mvNum][uniqCPId]['wbLevers'] = wbLevers



        # Call the machine learning
        mlResponse = DevServer.Server.run ( json.dumps( wbClientData ), self.midiFilePath ) 
        wbServerData = collections.OrderedDict( json.loads( mlResponse ) )

        #print ( "wbServerResponse text : ", wbServerResponse.text ) 


        for mvNum in self.movements : 
            sectionsObj = self.movements[mvNum]['SectionsObj'].mood        
            numUniqCPs  = sectionsObj.numUniqCPs  
            self.movements[mvNum]['layers'] = collections.OrderedDict()             

            for uniqCPId in range(numUniqCPs) : 
                pl     = sectionsObj.uniqCPSettings[uniqCPId]['pl'] 
                key    = sectionsObj.uniqCPSettings[uniqCPId]['scale'] 
                #bpm    = sectionsObj.uniqCPSettings[uniqCPId]['bpm'] 
                tse    = sectionsObj.uniqCPSettings[uniqCPId]['tse'] 
                cpSeq  = sectionsObj.uniqCPSettings[uniqCPId]['cpSeq'] 
                layers = sectionsObj.layers 
                percussionSettings = sectionsObj.uniqCPSettings[uniqCPId]['percussionSettings'] 


                #if hasattr( sectionsObj.uniqCPSettings[uniqCPId], 'bassRhythm' ) : 

                if ( 'bassRhythm' in sectionsObj.uniqCPSettings[uniqCPId] ) : 
                    bassRhythmOptions = sectionsObj.uniqCPSettings[uniqCPId]['bassRhythm'] #sectionsObj.bassRhythm
                else : 
                    bassRhythmOptions = None 


                mood  = self.movements[mvNum]['mood'] 
                rhythmSpeed = self.movements[mvNum]['rhythmSpeed'] 
                complexity = self.movements[mvNum]['complexity'] 
                
                wbLevers = {
                    'id'          : uniqCPId,

                    'phraseLength': pl,
                    'tse'         : tse, 
                    'primaryScale': key,
                    'bassRhy'     : cpSeq,

                    'mood'        : mood,
                    'complexity'  : complexity, 
                    'rhythmSpeed' : rhythmSpeed,
                    
                    'layers'      : layers, 

                    'bassRhythmOptions' : bassRhythmOptions,

                    'percussionSettings': percussionSettings, 
                    
                    }

                section = Section.Section ( wbLevers, wbServerData[str(mvNum)][str(uniqCPId)] ) 
                self.movements[mvNum]['layers'][uniqCPId] = section.run () 

                
            arrangeSections = ArrangeSections ( mvNum, self.movements[mvNum], self.outDir ) 
            arrangeSections.arrange() 
Example #29
0
def run(wbClientJsonData, midiFile):

    movementsServer = collections.OrderedDict()

    wbClientMovements = collections.OrderedDict(json.loads(wbClientJsonData))

    for mvNum in wbClientMovements:
        numUniqCPs = len(wbClientMovements[(mvNum)])
        movementsServer[mvNum] = collections.OrderedDict()

        for uniqCPId in wbClientMovements[mvNum]:

            section = Section.Section(
                wbClientMovements[mvNum][uniqCPId]['wbLevers'], midiFile)
            movementsServer[mvNum][uniqCPId] = collections.OrderedDict(
                section.run())

        if (1):
            for uniqCPId in wbClientMovements[mvNum]:
                print("Dev Server Movement : ", mvNum, "Uniq Id: ", uniqCPId)
                for layer in movementsServer[mvNum][uniqCPId]:
                    print("\tlayer: ", layer)
                    for chId in movementsServer[mvNum][uniqCPId][layer][0]:
                        print("\t\tChord Id: ", chId)
                        for item in movementsServer[mvNum][uniqCPId][layer][0][
                                chId]:
                            print("\t\t\t", item)

                    print()
                print()

    #print ( movementsServer.items())
    return json.dumps(movementsServer)

    sys.exit(0)

    for mvNum in movements:
        sectionsObj = movements[mvNum]['SectionsObj'].mood
        numUniqCPs = sectionsObj.numUniqCPs

        movementsServer[mvNum] = collections.OrderedDict()

        for uniqCPId in range(numUniqCPs):
            pl = sectionsObj.uniqCPSettings[uniqCPId]['pl']
            key = sectionsObj.uniqCPSettings[uniqCPId]['scale']
            tse = sectionsObj.uniqCPSettings[uniqCPId]['tse']
            cpSeq = sectionsObj.uniqCPSettings[uniqCPId]['cpSeq']
            layers = sectionsObj.layers

            mood = movements[mvNum]['mood']
            complexity = movements[mvNum]['complexity']

            wbLevers = {
                'id': uniqCPId,
                'phraseLength': pl,
                'tse': tse,
                'primaryScale': key,
                'bassRhy': cpSeq,
                'mood': mood,
                'complexity': complexity,
                'layers': layers,
            }

            section = Section.Section(wbLevers, midiFile)
            movementsServer[mvNum][uniqCPId] = collections.OrderedDict(
                section.run())

        if (1):
            for uniqCPId in range(numUniqCPs):
                print("Dev Server Movement : ", mvNum, "Uniq Id: ", uniqCPId)
                for layer in movementsServer[mvNum][uniqCPId]:
                    print("\tlayer: ", layer)
                    for chId in movementsServer[mvNum][uniqCPId][layer][0]:
                        print("\t\tChord Id: ", chId)
                        for item in movementsServer[mvNum][uniqCPId][layer][0][
                                chId]:
                            print("\t\t\t", item)

                    print()
                print()

    #print ( movementsServer.items())
    return json.dumps(movementsServer)
Example #30
0
 def __init__(self):
     Section.__init__(self)  # extend Section init
     self.finalLetterDict = {}
Example #31
0
 def __init__(self):
     Section.__init__(self)
     self.correctChord = learnSection.finalLetterDict[letters[letterIndex]]  #check this for bugs
     self.correctList = HardwareInterface.chordToList(self.correctChord)