From the course: Testing Python Data Science Code

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Test with hypothesis

Solution: Test with hypothesis - Python Tutorial

From the course: Testing Python Data Science Code

Solution: Test with hypothesis

(upbeat background music) - [Teacher] So I'm importing numpy hypothesis given and floats and composite and our code that we tested, the geo. And I'm using a composite strategy. So the latitudes gets the draw. And we are going to draw from floats between minus 90 and 90, not including max. Longitudes is about the same only between minus 180 and 180. And now I have a given with latitudes, longitudes and again, latitudes, longitudes. So two coordinates. And now I'm doing the distance as the harversine. And now I need to think about a heuristic. So my heuristic is that the distance is not zero. Not that even though there are no nuns in the input, there might be nuns in the output, due to some calculation with floating points. Let's run it. And awesome, another green test.

Contents