Skip to content

Commit 55330c2

Browse files
committed
Update rest of documentation for changes to EvalFactor and memorize_passes_needed().
1 parent 5b816a2 commit 55330c2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

doc/expert-model-specification.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ things are.)
7878
from patsy import (ModelDesc, EvalEnvironment, Term, EvalFactor,
7979
LookupFactor, demo_data, dmatrix)
8080
data = demo_data("a", "x")
81-
env = EvalEnvironment.capture()
8281
8382
# LookupFactor takes a dictionary key:
8483
a_lookup = LookupFactor("a")
8584
# EvalFactor takes arbitrary Python code:
86-
x_transform = EvalFactor("np.log(x ** 2)", env)
85+
x_transform = EvalFactor("np.log(x ** 2)")
8786
# First argument is empty list for dmatrix; we would need to put
8887
# something there if we were calling dmatrices.
8988
desc = ModelDesc([],
@@ -157,7 +156,7 @@ The full interface looks like this:
157156
:term:`hashable`. These methods will determine which factors
158157
Patsy considers equal for purposes of redundancy elimination.
159158

160-
.. method:: memorize_passes_needed(state)
159+
.. method:: memorize_passes_needed(state, eval_env)
161160

162161
Return the number of passes through the data that this factor
163162
will need in order to set up any :ref:`stateful-transforms`.
@@ -171,6 +170,9 @@ The full interface looks like this:
171170
will be passed back in to all memorization and evaluation
172171
methods.
173172

173+
`eval_env` is an :class:`EvalEnvironment` object, describing
174+
the Python environment where the factor is being evaluated.
175+
174176
.. method:: memorize_chunk(state, which_pass, data)
175177

176178
Called repeatedly with each 'chunk' of data produced by the

doc/formulas.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ To make this more concrete, here's how you could manually construct
5858
the same objects that Patsy will construct if given the above
5959
formula::
6060

61-
from patsy import EvalEnvironment, ModelDesc
62-
env = EvalEnvironment.capture()
63-
ModelDesc([Term([EvalFactor("y", env)])],
61+
from patsy import ModelDesc
62+
ModelDesc([Term([EvalFactor("y")])],
6463
[Term([]),
65-
Term([EvalFactor("a", env)]),
66-
Term([EvalFactor("a", env), EvalFactor("b", env)]),
67-
Term([EvalFactor("np.log(x)", env)])])
64+
Term([EvalFactor("a")]),
65+
Term([EvalFactor("a"), EvalFactor("b")]),
66+
Term([EvalFactor("np.log(x)")])])
6867

6968
Compare to what you get from parsing the above formula::
7069

0 commit comments

Comments
 (0)