Skip to content

Commit b420d7f

Browse files
committed
Massive refactoring of build.py to merge DesignMatrixBuilder into DesignInfo
Notable changes: - DesignInfo now exposes lots more metadata about how exactly different factors and terms are coded. - In fact, it exposes enough more metadata that you can now reconstruct a design matrix entirely from a DesignInfo, so DesignMatrixBuilder becomes redundant and is removed in favor of DesignInfo. - DesignInfo's constructor is very different; in particular, removed the option of specifying terms as strings, which was only useful for interoperability with competing formula libraries. Four years later, no such competitors have appeared, so I can't be bothered to keep maintaining this. Will re-add later if someone actually wants to use it. This versions works and passes tests, but a bunch more tests need to be added. This fixes #61, and sets us up to implemented pickling support (#26, #67).
1 parent 1139e3a commit b420d7f

File tree

7 files changed

+760
-515
lines changed

7 files changed

+760
-515
lines changed

doc/API-reference.rst

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,35 @@ Design metadata
105105
106106
di.term_slices
107107
108+
.. attribute:: factor_infos
109+
110+
A dict mapping factor objects to :class:`FactorInfo` objects
111+
providing information about each factor. Like :attr:`terms`,
112+
this may be None.
113+
114+
.. ipython:: python
115+
116+
di.term_slices
117+
118+
.. attribute:: term_codings
119+
120+
An :class:`~collections.OrderedDict` mapping each :class:`Term`
121+
object to a list of :class:`SubtermInfo` objects which together
122+
describe how this term is encoded in the final design
123+
matrix. Like :attr:`terms`, this may be None.
124+
125+
.. ipython:: python
126+
127+
di.term_codings
128+
108129
.. attribute:: builder
109130

110-
A :class:`DesignMatrixBuilder` object that can be used to
111-
generate more design matrices of this type (e.g. for
112-
prediction). May be None.
131+
In versions of patsy before 0.4.0, this returned a
132+
``DesignMatrixBuilder`` object which could be passed to
133+
:func:`build_design_matrices`. Starting in 0.4.0,
134+
:func:`build_design_matrices` now accepts :class:`DesignInfo`
135+
objects directly, and writing ``f(design_info.builder)`` is now a
136+
deprecated alias for simply writing ``f(design_info)``.
113137

114138
A number of convenience methods are also provided that take
115139
advantage of the above metadata:
@@ -120,8 +144,14 @@ Design metadata
120144

121145
.. automethod:: slice
122146

147+
.. automethod:: subset
148+
123149
.. automethod:: from_array
124150

151+
.. autoclass:: FactorInfo
152+
153+
.. autoclass:: SubtermInfo
154+
125155
.. autoclass:: DesignMatrix
126156

127157
.. automethod:: __new__

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# General information about the project.
44
project = u'patsy'
5-
copyright = u'2011-2013, Nathaniel J. Smith'
5+
copyright = u'2011-2015, Nathaniel J. Smith'
66

77
import sys
88
print "python exec:", sys.executable

0 commit comments

Comments
 (0)