Skip to content

Commit 97a4107

Browse files
committed
Finished Task5
1 parent 5a60f81 commit 97a4107

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

11808206_exercise_1.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def month(self, date):
477477
# Finds the rows that are have the matching month for further operations
478478
aggregateRows = []
479479
month = date.month
480+
480481
for row in self.observations:
481482
datefromRow = datetime.datetime.strptime(row[0], "%d.%m.%Y")
482483
if datefromRow.month == month:
@@ -762,17 +763,17 @@ def evaluate():
762763

763764
# TODO: your changes here
764765
# object oriented
765-
print("Objectoriented")
766+
#print("Objectoriented")
766767
obs_oo = WeatherObservationsObjectOriented()
767768
times_oo = time_steps(obs_oo, datetime.date(2012, 1, 1))
768769

769770
# data oriented
770-
print("\nDataoriented")
771+
#print("\nDataoriented")
771772
obs_do = WeatherObservationsDataOriented()
772773
times_do = time_steps(obs_do, datetime.date(2012, 1, 1))
773774

774775
# data oriented w/ numpy
775-
print("\nNumpy")
776+
#print("\nNumpy")
776777
obs_np = WeatherObservationsDataOrientedNumpy()
777778
times_np = time_steps(obs_np, datetime.date(2012, 1, 1))
778779

@@ -816,7 +817,12 @@ def solution_task_5():
816817
"""
817818
# TODO: your changes here
818819
return '''
819-
TODO: Fill in your solution for Task 5 here.
820+
Object oriented is for single element operations in its best state because of the dictionary (which contains as key a given date) it as fast and simple as possible.
821+
For the calculation of the mean for every field for a given month, week, year is already quite sophisticated, because I'm saving the data in an object with the given date and month. So accessing the iterating the data, for example for a given year, it can be done easily.
822+
The only difference between the Object oriented approach and the self written data oriented is only that one uses objects and the other one is based on matrixes and that instead of using a dictionary I'm using a list in Task 2. So to keep the data consistent and avoid redundancy in the dataset I implemented an additional list which contains all the indices.
823+
824+
The only way to improve both the tasks is to pre-calculate the week and store it as an additional field in an object or as an additional column in a matrix. But this will affect the speed of the loading process. That is the reason why i did not implemented it.
825+
Another potential, but sadly impossible way to improve the data oriented approach would be if it could be possible to slice arrays like with numpy. Sadly, that's not possible so the only efficient way is to iterate over the list.
820826
'''
821827

822828

0 commit comments

Comments
 (0)