Пример #1
0
 def test_2は3から8の閉区間には含まれない(self):
     x=section.Section(3,8)
     assert (not x.num_in(2))
Пример #2
0
 def test_8は3から8の閉区間には含まれる(self):
     x=section.Section(3,8)
     assert (x.num_in(8))
Пример #3
0
 def test_8から3の閉区間は作れない(self):
     try:
         x=section.Section(8,3)
         assert False
     except:
         assert True
Пример #4
0
 def test_3から8の閉区間の文字列表現を返せる(self):
     x=section.Section(3,8)
     assert isinstance(x.toString(),str)
     assert str([3,8]) == x.toString()
Пример #5
0
 def 文字列_あ_や_い_では閉区間は作れない(self):
     try:
         x=section.Section("あ","い")
         assert False
     except:
         assert True
Пример #6
0
 def test_小数3_1から8_1の閉区間は作れない(self):
     with pytest.raises(ValueError):
         x=section.Section(3.1,8.1)
Пример #7
0
    def __init__(self, section_id):
        self.section_id = section_id # CS 100_006
        self.enrolled_students = []

    def enroll(self, studentName):
        self.enrolled_students.append(studentName)

    def is_enrolled(self, studentName):
        if studentName in self.enrolled_students:
            return True
        else:
            return False

# Part B
import section
section1 = section.Section("Math111_101")
section1.enroll("Joe Joesephson")
section1.enroll("Mary Smith")
print(section1.is_enrolled("Mary Josephson"))

# Quesstion 2
class State:
    def __init__(self, name):
        self.name = name
        self.universities = []

    def addUniversity(self, universityName):
        self.universities.append(universityName)

    def is_home_of(self, universityName):
        if universityName in self.universities:
Пример #8
0
    def __init__(self):
        # LED strip configuration:
        LED_COUNT = 442  # Number of LED pixels.
        LED_PIN = 18  # GPIO pin connected to the pixels (18 uses PWM!).
        LED_FREQ_HZ = 800000  # LED signal frequency in hertz (usually 800khz)
        LED_DMA = 10  # DMA channel to use for generating signal (try 10)
        LED_BRIGHTNESS = 64  # Set to 0 for darkest and 255 for brightest
        LED_INVERT = False  # True to invert the signal (when using NPN transistor level shift)
        LED_CHANNEL = 0  # set to '1' for GPIOs 13, 19, 41, 45 or 53
        LED_STRIP = ws.SK6812_STRIP_GRBW
        self.strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ,
                                       LED_DMA, LED_INVERT, LED_BRIGHTNESS,
                                       LED_CHANNEL)  # RGB Strip
        #self.strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP) # RGBW Strip
        self.backRightTop = section.Section("backRight", 0, 26, True,
                                            "StepGreen")  #Starting point Up
        self.backRightBottom = section.Section("backRight", 26, 53, False,
                                               "StepGreen")  #Starting point Up

        self.backLeftTop = section.Section("backLeft", 53, 79, True,
                                           "MeteorRainRed")  #Up
        self.backLeftBottom = section.Section("backLeft", 79, 106, False,
                                              "MeteorRainRed")  #Down

        self.lapelLeftTop = section.Section("lapelLeft", 106, 141, True,
                                            "StepRed")  #Up
        self.lapelLeftBottom = section.Section("lapelLeft", 141, 175, False,
                                               "StepRed")  #Down

        self.collarLeftBottom = section.Section("collarLeft", 175, 207, True,
                                                "StepGreen")  #Up 65
        self.collarLeftTop = section.Section("collarLeft", 207, 240, False,
                                             "StepGreen")  #Down

        self.collarRightTop = section.Section("collarRight", 240, 272, True,
                                              "StepGreen")  #Up
        self.collarRightBottom = section.Section("collarRight", 272, 305,
                                                 False, "StepGreen")  #Down

        self.lapelRightBottom = section.Section("lapelRight", 305, 331, True,
                                                "StepRed")  #Up
        self.lapelRightTop = section.Section("lapelRight", 331, 374, False,
                                             "StepRed")  #Down

        self.__senistivity = 0.5
        self.spectrumanalyzer = SpectrumAnalyzer(
            1000000, self.__senistivity, 1024
        )  #Creat new spectum analyzer (Sample Hz Rate, Senistive in amplitude, sample size)
        self.sectionsList = [
            self.backLeftTop, self.backLeftBottom, self.backRightTop,
            self.backRightBottom, self.lapelRightTop, self.lapelRightBottom,
            self.collarRightTop, self.collarRightBottom, self.collarLeftTop,
            self.collarLeftBottom, self.lapelLeftTop, self.lapelLeftBottom
        ]  #Populate the list of LED sections (in shared memory
        self.__name = "Suit"
Пример #9
0
Sw = -1.28276
Iw = 1.00748
Iww = 0.796819
Aw = 0.247913

# 读取模型文件
xlsx = pd.ExcelFile('Data.xlsx')
nod = xlsx.parse('Node', index_col=0)
ele = xlsx.parse('Element', index_col=0)
cons = xlsx.parse('Constraint', index_col=0)
nLoad = xlsx.parse('nLoad', index_col=0)
eLoad = xlsx.parse('eLoad', index_col=0)

# 定义材料特性与截面几何特性
mat = material.Material(E, mu, gamma, alpha)
sec = section.Section(A, I, Aw, Sw, Iw, Iww)

# 计算局部坐标系下的单元刚度矩阵
beam = element.ShearLag(mat, sec, nod, ele)
Ke = beam.stiffness()

# # 计算自由度和单元定位向量
DOF = core.getDOF(cons, nod.shape[0])
LOC = core.getLOC(DOF, ele)

# 计算整体坐标系下的单元刚度矩阵
stru = model.Model(beam, LOC)
Kmat = stru.assemble()

# 计算综合节点荷载列阵
load = stru.load(nLoad, eLoad)