Skip to content

Commit 8c947c3

Browse files
committed
repr change
1 parent a187dfb commit 8c947c3

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

Data Science from Scratch/numpy_recreate.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,13 @@ def data(self, value):
2020
self._data = value
2121

2222
def __repr__(self):
23-
def my_format(x):
24-
if type(x) == bool:
25-
return str(x)
26-
else:
27-
return '{}'.format(round(x, 6))
28-
29-
if len(self) > 10:
30-
string = ', '.join(my_format(x) for x in self.data[:5]) + \
31-
' ..., ' + \
32-
', '.join(my_format(x) for x in self.data[-5:])
33-
else:
34-
string = ', '.join(my_format(x) for x in self.data)
35-
return 'Array1D([' + string + '])'
23+
return 'Array1D(' + repr(self.data) + ')'
3624

3725
def __len__(self):
3826
return len(self.data)
3927

4028
def __iter__(self):
41-
for d in self.data:
42-
yield d
29+
return iter(self.data)
4330

4431
def __getitem__(self, index):
4532
if type(index) == int:

0 commit comments

Comments
 (0)