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: Testing numerical code - Python Tutorial
From the course: Testing Python Data Science Code
Solution: Testing numerical code
(upbeat music) - [Instructor] Let's have a look at my solution. So I'm importing pandera, and then I'm defining the schema. The time is a column. The type is pretty complicated. It's daytime TZDtype, which is in nanoseconds, and it defaults to UTC. I did it by first loading the data frame, and then poking around the values to see what they are. Next, the metrics. They are strings, and they should be either CPU or memory. And finally, the values are floats, and they should be bigger than zero. And now, I can end the decorator of the check_output to the load_metrics. The rest of the code stays the same. And now, we can run the code. So Run, Run Without Debugging, and we see that the code passes.
Contents
-
-
-
-
-
-
Using schemas2m 51s
-
(Locked)
Truth values2m 35s
-
(Locked)
Floating point wonders1m 46s
-
(Locked)
Approximate testing1m 18s
-
(Locked)
Dealing with randomness1m 45s
-
(Locked)
Comparing pandas DataFrames1m 31s
-
(Locked)
Challenge: Testing numerical code56s
-
(Locked)
Solution: Testing numerical code51s
-
-
-
-