mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-27 20:12:20 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
class Leaf(object):
|
||||
def __init__(self, color="green"):
|
||||
self.color = color
|
||||
@@ -25,7 +25,7 @@ class Leaf(object):
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
class MapleLeaf(Leaf):
|
||||
def fall(self):
|
||||
self.color = 'brown'
|
||||
@@ -37,7 +37,7 @@ class MapleLeaf(Leaf):
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
class Acorn(object):
|
||||
def fall(self):
|
||||
print "Plunk!"
|
||||
@@ -48,7 +48,7 @@ class Acorn(object):
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
objects = [Leaf(), MapleLeaf(), Acorn()]
|
||||
|
||||
for obj in objects:
|
||||
@@ -56,7 +56,7 @@ for obj in objects:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
Splat!
|
||||
Splat!
|
||||
Plunk!
|
||||
@@ -69,7 +69,7 @@ Plunk!
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
import numpy as np
|
||||
from scipy.ndimage.measurements import label
|
||||
|
||||
@@ -198,7 +198,7 @@ class InstantBurnForest(BurnableForest):
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
forest = Forest()
|
||||
b_forest = BurnableForest()
|
||||
sb_forest = SlowBurnForest()
|
||||
@@ -219,7 +219,7 @@ for i in xrange(1500):
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
import matplotlib.pyplot as plt
|
||||
%matplotlib inline
|
||||
|
||||
|
||||
Reference in New Issue
Block a user