Example #1
0
 def test_rectangles_can_be_of_different_sizes(self):
     self.assertEqual(
         rectangles([
             "+------+----+",
             "|      |    |",
             "+---+--+    |",
             "|   |       |",
             "+---+-------+",
         ]),
         3,
     )
Example #2
0
 def test_corner_is_required_for_a_rectangle_to_be_complete(self):
     self.assertEqual(
         rectangles([
             "+------+----+",
             "|      |    |",
             "+------+    |",
             "|   |       |",
             "+---+-------+",
         ]),
         2,
     )
Example #3
0
def task1(N, M, h_f, x_in, x_out, f_in):

    plot_complex(x_in, f_in, 'f(x)')

    # интегральное решение
    integral_out = rectangles.rectangles(N, h_f, x_in, f_in, x_out)
    plot_complex(x_out, integral_out, 'integral')

    # через бпф
    f_out = fft.fft(N, M, f_in, h_f)
    plot_complex(x_out, f_out, 'F(x)')

    # сравнение
    plot_complex_comparison(x_out, integral_out, f_out, 'comparison')
Example #4
0
 def test_large_input_with_many_rectangles(self):
     self.assertEqual(
         rectangles([
             "+---+--+----+",
             "|   +--+----+",
             "+---+--+    |",
             "|   +--+----+",
             "+---+--+--+-+",
             "+---+--+--+-+",
             "+------+  | |",
             "          +-+",
         ]),
         60,
     )
Example #5
0
 def test_only_complete_rectangles_are_counted(self):
     self.assertEqual(
         rectangles(["  +-+", "    |", "+-+-+", "| | -", "+-+-+"]), 1)
Example #6
0
 def test_1x1_square_is_counted(self):
     self.assertEqual(rectangles(["++", "++"]), 1)
Example #7
0
 def test_rectangle_of_width_1_is_counted(self):
     self.assertEqual(rectangles(["++", "||", "++"]), 1)
Example #8
0
 def test_rectangle_of_height_1_is_counted(self):
     self.assertEqual(rectangles(["+--+", "+--+"]), 1)
Example #9
0
 def test_five_rectangles_with_shared_parts(self):
     self.assertEqual(
         rectangles(["  +-+", "  | |", "+-+-+", "| | |", "+-+-+"]), 5)
Example #10
0
 def test_two_rectangles_without_shared_parts(self):
     self.assertEqual(
         rectangles(["  +-+", "  | |", "+-+-+", "| |  ", "+-+  "]), 2)
Example #11
0
 def test_rectangle_of_height_1_is_counted(self):
     strings = ['+--+', '+--+']
     self.assertEqual(rectangles(strings), 1)
Example #12
0
 def test_one_rectangle(self):
     strings = ['+-+', '| |', '+-+']
     self.assertEqual(rectangles(strings), 1)
Example #13
0
 def test_rectangles_can_be_of_different_sizes(self):
     strings = [
         '+------+----+', '|      |    |', '+---+--+    |', '|   |       |',
         '+---+-------+'
     ]
     self.assertEqual(rectangles(strings), 3)
Example #14
0
 def test_corner_is_required_for_a_rectangle_to_be_complete(self):
     strings = [
         '+------+----+', '|      |    |', '+------+    |', '|   |       |',
         '+---+-------+'
     ]
     self.assertEqual(rectangles(strings), 2)
Example #15
0
 def test_only_complete_rectangles_are_counted(self):
     strings = ['  +-+', '    |', '+-+-+', '| | -', '+-+-+']
     self.assertEqual(rectangles(strings), 1)
Example #16
0
 def test_1x1_square_is_counted(self):
     strings = ['++', '++']
     self.assertEqual(rectangles(strings), 1)
Example #17
0
 def test_rectangle_of_width_1_is_counted(self):
     strings = ['++', '||', '++']
     self.assertEqual(rectangles(strings), 1)
Example #18
0
 def test_two_rectangles_without_shared_parts(self):
     strings = ['  +-+', '  | |', '+-+-+', '| |  ', '+-+  ']
     self.assertEqual(rectangles(strings), 2)
Example #19
0
 def test_one_rectangle(self):
     self.assertEqual(rectangles(["+-+", "| |", "+-+"]), 1)
Example #20
0
 def test_large_input_with_many_rectangles(self):
     strings = [
         '+---+--+----+', '|   +--+----+', '+---+--+    |', '|   +--+----+',
         '+---+--+--+-+', '+---+--+--+-+', '+------+  | |', '          +-+'
     ]
     self.assertEqual(rectangles(strings), 60)
Example #21
0
 def test_five_rectangles_with_shared_parts(self):
     strings = ['  +-+', '  | |', '+-+-+', '| | |', '+-+-+']
     self.assertEqual(rectangles(strings), 5)
Example #22
0
 def test_no_rows(self):
     self.assertEqual(rectangles([]), 0)
Example #23
0
 def test_no_columns(self):
     self.assertEqual(rectangles([""]), 0)