... | ... | @@ -587,20 +587,20 @@ def not_so_naive_main(): |
|
|
print(f"{integral_result:16.8f}")
|
|
|
```
|
|
|
|
|
|
Instead of looping over all the points
|
|
|
Instead of looping over all the points...
|
|
|
|
|
|
```python
|
|
|
for i, point in enumerate(generate_random_points(math_f, limit_a, limit_b, num_points)):
|
|
|
```
|
|
|
|
|
|
the generator is assigned to a variable:
|
|
|
the generator is assigned to a variable...
|
|
|
|
|
|
```python
|
|
|
point_sequence = generate_random_points(math_f, limit_a, limit_b, num_points)
|
|
|
```
|
|
|
|
|
|
Since we only need the `y` values from each point... an inline generator
|
|
|
expression can be used
|
|
|
expression can be used...
|
|
|
|
|
|
```python
|
|
|
f_of_x_values = (y for x, y in point_sequence)
|
... | ... | @@ -655,24 +655,12 @@ if __name__ == "__main__": |
|
|
```
|
|
|
|
|
|
|
|
|
## If Time Permits
|
|
|
|
|
|
If time permits... we will discuss a few additional examples:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
## Testing & Development
|
|
|
|
|
|
- [Implementing a Non-Linear Solver](https://www.cs.odu.edu/~tkennedy/cs417/f20/Public/solverDiscussion/)
|
|
|
- A few Python Examples from CS 330 (Object Oriented Programming & Design)
|
|
|
- Test Driven Development
|
|
|
- [Unit Testing & Integration Testing](https://doc.rust-lang.org/book/ch11-03-test-organization.html)
|
|
|
- [Hamcrest Matchers](http://hamcrest.org/)
|
... | ... | |