CS1602Introduction to Computation
Lab 15Part 6 Pythonic Python and Modern PracticeAI Level 2

Team Project Development

No separate problems this week — the whole session is project time. But there are four milestones to reach, and TAs will check each pair against them.

Due:Homework 5 · Tue 29 Dec, 23:59
Contents

What this session is for

  • Get the team project’s core functionality working
  • Establish a running test suite
  • Work with an AI using L15’s method, and leave evidence of it
  • Prepare for next week’s demo

How to use the session

Both hours are yours to develop in. TAs are present throughout, so ask.

But it is not free time — the four milestones below must be shown to a TA before the session ends.


Milestone 1: core functionality running (required)

At minimum:

  • Array.__init__ constructs from a nested list and validates that the shape is regular
  • the shape / ndim / size properties
  • __repr__ shows both contents and shape
  • __getitem__ supports at least a[i] and a[i, j]
  • arithmetic: at least __add__ and __mul__, for both Array and scalar operands

Demonstrate to a TA that this runs:

a = Array([[1, 2, 3], [4, 5, 6]])
print(a.shape, a.ndim, a.size)
print(a)
print(a[1, 2])
print(a + a)
print(a * 2)

Milestone 2: tests that run (required)

  • a test_array.py that python3 -m pytest executes
  • at least 15 test cases
  • covering at least: normal arithmetic, shape mismatches raising, empty arrays, single-element arrays
  • at least one test cross-checking against real NumPy

A cross-check looks like this:

import numpy as np
from myarray import Array

def test_add_matches_numpy():
    data_a = [[1, 2, 3], [4, 5, 6]]
    data_b = [[7, 8, 9], [10, 11, 12]]
    mine = Array(data_a) + Array(data_b)
    theirs = np.array(data_a) + np.array(data_b)
    assert mine.tolist() == theirs.tolist()

Milestone 3: a record of AI collaboration (required)

Following L15’s method, complete this cycle at least once and write it up:

  1. you write the interface specification — signature, docstring, three examples including edges
  2. you list the edge cases — without looking at any AI output, at least six of them
  3. hand the specification to an AI and take the implementation
  4. run your edge cases against it
  5. record which ones it missed

Submit a write-up of at most one page containing: your specification, your edge list, the AI’s implementation, the test results, and what it left out.


Milestone 4: division of work and consistency (required)

  • the README opens with a project conventions section: internal representation, naming style, error handling
  • a division-of-work statement: who wrote what
  • review each other once: each of you picks a section the other wrote and asks “why is this line written this way?”

Answer in the mid-point check: during that review, was there anything either of you could not explain? Answer honestly — no marks ride on it.


Practical advice for this week

Make it work before making it impressive

Chasing broadcasting and boolean indexing before the core works is the most common way pairs come unstuck. Milestone 1 first.

Once the representation is fixed, stop changing it

If you are still torn between nested lists and a flat list, settle it today. Changing it next week is too late.

If you cannot decide, take the flat list plus shape tuple — it is far kinder to reshape and transpose, and both are required.

Watch your own complexity

L15 noted that an AI will not volunteer that its dot is O(n³). Measure it yourself: how long does 100×100 take? Is 200×200 eight times slower?

That measurement is itself worth putting in the demo.

Both of you must touch all the code

At the demo you will each be asked about the whole project. If you have never read your partner’s half, next week will be uncomfortable.

Spend twenty minutes today walking each other through your own parts.


Mid-point submission (Sunday, 23:59)

Package up:

  1. all current code
  2. the output of pytest, as text or a screenshot
  3. the milestone 3 AI collaboration write-up (one page)
  4. the README, including conventions and division of work
  5. one sentence: what do you plan to show at next week’s demo?

Next week’s demo

  • 8 minutes per pair: 5 minutes demonstrating, 3 minutes of questions
  • The demonstration should cover: core functionality, any optional parts you built, and the tests running
  • Both partners will be questioned, on any part of the project
  • Be ready for: “why did you choose that internal representation?”