コード例 #1
0
ファイル: assignment7.py プロジェクト: bk1051/assignment7
    def question_1():
        """Outputs responses to Question 1"""
        array = sa.wrapped_array(1, 15, 3)
        print "\n\nInitial Array:\n", array

        def question_1a(superarray):
            print superarray.select_rows((1, 3))

        def question_1b(superarray):
            print superarray.select_cols([1])

        def question_1c(superarray):
            print superarray.select((1, 0), (3, 2))

        def question_1d(superarray):
            print superarray.filter_array(lambda x: 3 <= x <= 11)

        print "\n\nQuestion 1a:\n"
        question_1a(array)

        print "\n\nQuestion 1b:\n"
        question_1b(array)

        print "\n\nQuestion 1c:\n"
        question_1c(array)

        print "\n\nQuestion 1d:\n"
        question_1d(array)
コード例 #2
0
    def question_1():
        '''Outputs responses to Question 1'''
        array = sa.wrapped_array(1, 15, 3)
        print "\n\nInitial Array:\n", array

        def question_1a(superarray):
            print superarray.select_rows((1, 3))

        def question_1b(superarray):
            print superarray.select_cols([1])

        def question_1c(superarray):
            print superarray.select((1, 0), (3, 2))

        def question_1d(superarray):
            print superarray.filter_array(lambda x: 3 <= x <= 11)

        print "\n\nQuestion 1a:\n"
        question_1a(array)

        print "\n\nQuestion 1b:\n"
        question_1b(array)

        print "\n\nQuestion 1c:\n"
        question_1c(array)

        print "\n\nQuestion 1d:\n"
        question_1d(array)
コード例 #3
0
ファイル: test_superarray.py プロジェクト: bk1051/assignment7
	def test_wrapped_array(self):
		test_array = sa.wrapped_array(1, 15, 3)
		success = sa.SuperArray(
			[[1,  6, 11],
			 [2,  7, 12],
			 [3,  8, 13],
			 [4,  9, 14],
			 [5, 10, 15]]
			)
		# Assert all elements of arrays are equal
		self.assertTrue((test_array==success).all())