Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in python Use python's round () method for rounding in this assignment. Part 1 - class LocalRecord Write a data structure LocalRecord for

Please code in python

image text in transcribed

Use python's round () method for rounding in this assignment. Part 1 - class LocalRecord Write a data structure LocalRecord for storing record temperatures at single grid point. A record needs to support at minimum the methods and variables shown below: Figure 1: Class diagram for a Record. - hash() - returns a hash for this object based on its position - eq() - returns True iff two records are for the same position - add_report(temp) - Updates max and min if appropriate - pos - a tuple representing the latitude and longitude of this record. Incoming weather reports will have arbitrary precision, but any that round to the same (lat, long) should be equal, so you'll need to round before storing. - max - maximum temperature reported for this position - min - minimum temperature reported for this position Go ahead and develop this class using TDD - skeleton code is provided in TestRecordsMap.py. Part 2 - class RecordsMap Write a data structure RecordsMap that allows 0 (1) updating of a collection of records whenever a new report comes in. Keys should be a (lat, long) tuple and values should be a (min, max) tuple. - len - the number of key:value pairs stored - get - returns a tuple of (min, max) temperatures for a given position. - Raises KeyError if a point corresponding to the specified tuple is not in the mapping - contains(pos) - returns True (False) if a given position is (is not) in this RecordsMap. It's fine to pass arbitrary precision (lat, long) positions here - LocalRecord takes care of the rounding. - add_report(pos, temp) - updates max and min temperature for the given position as appropriate. There are 2 inputs here - a 2-tuple for position and a float for temp. - _rehash () - periodically rehash as number of entries increases. Note that this is a private method you do not need to write a unittest for it. However, you should write a test to make sure you're O(1) for add_report/contains/get, to make sure this method is getting called correctly. Use python's round () method for rounding in this assignment. Part 1 - class LocalRecord Write a data structure LocalRecord for storing record temperatures at single grid point. A record needs to support at minimum the methods and variables shown below: Figure 1: Class diagram for a Record. - hash() - returns a hash for this object based on its position - eq() - returns True iff two records are for the same position - add_report(temp) - Updates max and min if appropriate - pos - a tuple representing the latitude and longitude of this record. Incoming weather reports will have arbitrary precision, but any that round to the same (lat, long) should be equal, so you'll need to round before storing. - max - maximum temperature reported for this position - min - minimum temperature reported for this position Go ahead and develop this class using TDD - skeleton code is provided in TestRecordsMap.py. Part 2 - class RecordsMap Write a data structure RecordsMap that allows 0 (1) updating of a collection of records whenever a new report comes in. Keys should be a (lat, long) tuple and values should be a (min, max) tuple. - len - the number of key:value pairs stored - get - returns a tuple of (min, max) temperatures for a given position. - Raises KeyError if a point corresponding to the specified tuple is not in the mapping - contains(pos) - returns True (False) if a given position is (is not) in this RecordsMap. It's fine to pass arbitrary precision (lat, long) positions here - LocalRecord takes care of the rounding. - add_report(pos, temp) - updates max and min temperature for the given position as appropriate. There are 2 inputs here - a 2-tuple for position and a float for temp. - _rehash () - periodically rehash as number of entries increases. Note that this is a private method you do not need to write a unittest for it. However, you should write a test to make sure you're O(1) for add_report/contains/get, to make sure this method is getting called correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Internal Auditors For Stock Brokers

Authors: National Institute Of Securities Markets (NISM)

1st Edition

9350717581, 978-9350717585

More Books

Students also viewed these Accounting questions