2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -6,7 +6,7 @@
In [1]:
```
```py
class Leaf(object):
def __init__(self, mass_mg):
self.mass_mg = mass_mg
@@ -22,14 +22,14 @@ class Leaf(object):
In [2]:
```
```py
leaf = Leaf(200)
print leaf.mass_oz
```
```
```py
0.00706
```
@@ -38,14 +38,14 @@ print leaf.mass_oz
In [3]:
```
```py
leaf.mass_mg = 150
print leaf.mass_oz
```
```
```py
0.005295
```
@@ -54,12 +54,12 @@ print leaf.mass_oz
In [4]:
```
```py
leaf.mass_oz()
```
```
```py
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-aac6717ebc82> in <module>()
@@ -72,12 +72,12 @@ TypeError: 'float' object is not callable
In [5]:
```
```py
leaf.mass_oz = 0.001
```
```
```py
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-d232052cd2dc> in <module>()
@@ -90,7 +90,7 @@ AttributeError: can't set attribute
In [6]:
```
```py
import numpy as np
class Forest(object):
@@ -134,7 +134,7 @@ class Forest(object):
In [7]:
```
```py
forest = Forest()
forest.num_cells
@@ -143,7 +143,7 @@ forest.num_cells
Out[7]:
```
```py
22500
```
@@ -151,7 +151,7 @@ Out[7]:
In [8]:
```
```py
small_forest = Forest((10, 10))
small_forest.num_cells
@@ -159,7 +159,7 @@ small_forest.num_cells
Out[8]:
```
```py
100
```
@@ -167,27 +167,27 @@ Out[8]:
In [9]:
```
```py
small_forest.tree_fraction
```
Out[9]:
```
```py
0.0
```
In [10]:
```
```py
small_forest.fire_fraction
```
Out[10]:
```
```py
0.0
```
@@ -197,7 +197,7 @@ Out[10]:
In [11]:
```
```py
class Leaf(object):
def __init__(self, mass_mg):
self.mass_mg = mass_mg
@@ -218,7 +218,7 @@ class Leaf(object):
In [12]:
```
```py
leaf = Leaf(200)
print leaf.mass_oz
@@ -227,7 +227,7 @@ print leaf.mass_oz
```
```
```py
0.00706
0.005295
@@ -237,20 +237,20 @@ print leaf.mass_oz
In [13]:
```
```py
leaf.mass_oz = 0.01
print leaf.mass_mg
```
```
```py
283.28611898
```
一个等价的替代如下:
```
```py
class Leaf(object):
def __init__(self, mass_mg):
self.mass_mg = mass_mg