File tree 4 files changed +126
-0
lines changed
4 files changed +126
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__ /
3
+ * .py [cod ]
4
+ * $py.class
5
+
6
+ # C extensions
7
+ * .so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env /
12
+ build /
13
+ develop-eggs /
14
+ dist /
15
+ downloads /
16
+ eggs /
17
+ .eggs /
18
+ lib /
19
+ lib64 /
20
+ parts /
21
+ sdist /
22
+ var /
23
+ * .egg-info /
24
+ .installed.cfg
25
+ * .egg
26
+
27
+ # PyInstaller
28
+ # Usually these files are written by a python script from a template
29
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
30
+ * .manifest
31
+ * .spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov /
39
+ .tox /
40
+ .coverage
41
+ .coverage. *
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ * ,cover
46
+ .hypothesis /
47
+
48
+ # Translations
49
+ * .mo
50
+ * .pot
51
+
52
+ # logs:
53
+ * .log
54
+
55
+ # Sphinx documentation
56
+ docs /_build /
57
+
58
+ # PyBuilder
59
+ target /
60
+
61
+ # pyenv python configuration file
62
+ .python-version
63
+
64
+ # pycharm
65
+ .idea
66
+
67
+ # linux/osx garbage
68
+ * ~
69
+ * .swp
70
+ .DS_store *
Original file line number Diff line number Diff line change
1
+ # Object-Oriented assignment
2
+
3
+ Object-oriented (OO) programming and design is an entire semester course (or more). The goal of this
4
+ assignment is to give you an idea how to use basic OO features of python.
5
+
6
+ # Task 1: 1D array (10 points)
7
+
8
+ Task1 involved creating a 1D array object pattern after numpy's [ ndarray] ( https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html ) ,
9
+ but much less efficient. Start by looking at task_1.py and filling in the implementation details. You
10
+ can see how your implementation is performing by running ` pytest test_task_1.py ` after installing
11
+ pytest.
12
+
Original file line number Diff line number Diff line change
1
+ """
2
+ A module which implements a gloriously inefficient 1D array class.
3
+ """
4
+
5
+
6
+ class Array1D :
7
+ """
8
+ This class behaves similar to numpy arrays, but for one dimension.
9
+ """
10
+
Original file line number Diff line number Diff line change
1
+ """
2
+ Tests for task_1's Array1D.
3
+
4
+ You need to first install pytest, then run this from the command line
5
+ via: `pytest test_task_1.py`
6
+ """
7
+ import pytest
8
+
9
+ from task_1 import Array1D
10
+
11
+ INPUT_ARRAYS = (
12
+ (1 , 0 , 0 , 1 ),
13
+ (1j + 2 , 0 , 12 ),
14
+ (0.0 , 0.00001 , 0.0 ),
15
+ (None , 10 , - 10.0 ),
16
+ tuple (range (1000 )),
17
+ )
18
+
19
+
20
+ class TestInit :
21
+ """Tests for initializing the Array1D with various parameters."""
22
+
23
+ def test_empty (self ):
24
+ """Should be able to init empty array."""
25
+ ar = Array1D ()
26
+ assert isinstance (ar , Array1D )
27
+
28
+ @pytest .mark .parametrize ("array_input" , INPUT_ARRAYS )
29
+ def test_list (self , array_input ):
30
+ """All INPUT_ARRAY entries should be valid."""
31
+ ar = Array1D (array_input )
32
+ assert isinstance (ar , Array1D )
33
+
34
+
You can’t perform that action at this time.
0 commit comments