... | @@ -587,20 +587,20 @@ def not_so_naive_main(): |
... | @@ -587,20 +587,20 @@ def not_so_naive_main(): |
|
print(f"{integral_result:16.8f}")
|
|
print(f"{integral_result:16.8f}")
|
|
```
|
|
```
|
|
|
|
|
|
Instead of looping over all the points
|
|
Instead of looping over all the points...
|
|
|
|
|
|
```python
|
|
```python
|
|
for i, point in enumerate(generate_random_points(math_f, limit_a, limit_b, num_points)):
|
|
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
|
|
```python
|
|
point_sequence = generate_random_points(math_f, limit_a, limit_b, num_points)
|
|
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
|
|
Since we only need the `y` values from each point... an inline generator
|
|
expression can be used
|
|
expression can be used...
|
|
|
|
|
|
```python
|
|
```python
|
|
f_of_x_values = (y for x, y in point_sequence)
|
|
f_of_x_values = (y for x, y in point_sequence)
|
... | @@ -655,25 +655,13 @@ if __name__ == "__main__": |
... | @@ -655,25 +655,13 @@ if __name__ == "__main__": |
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## If Time Permits
|
|
|
|
|
|
|
|
If time permits... we will discuss a few additional examples:
|
|
|
|
|
|
|
|
- [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/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## Testing & Development
|
|
|
|
|
|
|
|
- Test Driven Development
|
|
|
|
- [Unit Testing & Integration Testing](https://doc.rust-lang.org/book/ch11-03-test-organization.html)
|
|
|
|
- [Hamcrest Matchers](http://hamcrest.org/)
|
|
|
|
|
|
|