| Line 4... |
Line 4... |
| 4 |
\alias{.Other-class}
|
4 |
\alias{.Other-class}
|
| 5 |
\title{
|
5 |
\title{
|
| 6 |
Test for and Report about Selection of Inherited Methods
|
6 |
Test for and Report about Selection of Inherited Methods
|
| 7 |
}
|
7 |
}
|
| 8 |
\description{
|
8 |
\description{
|
| 9 |
A set of distinct inherited signatures is generated to test
|
9 |
A set of distinct inherited signatures is generated to test
|
| 10 |
inheritance for all the methods of a specified generic function. If
|
10 |
inheritance for all the methods of a specified generic function. If
|
| 11 |
method selection is ambiguous for some of these, a summary of the
|
11 |
method selection is ambiguous for some of these, a summary of the
|
| 12 |
ambiguities is attached to the returned object. This test should be
|
12 |
ambiguities is attached to the returned object. This test should be
|
| 13 |
performed by package authors \emph{before} releasing a package.
|
13 |
performed by package authors \emph{before} releasing a package.
|
| 14 |
}
|
14 |
}
|
| 15 |
\usage{
|
15 |
\usage{
|
| 16 |
testInheritedMethods(f, signatures, test = TRUE, virtual = FALSE, groupMethods = TRUE, where = .GlobalEnv)
|
16 |
testInheritedMethods(f, signatures, test = TRUE, virtual = FALSE,
|
| - |
|
17 |
groupMethods = TRUE, where = .GlobalEnv)
|
| 17 |
}
|
18 |
}
|
| 18 |
%- maybe also 'usage' for other objects documented here.
|
- |
|
| 19 |
\arguments{
|
19 |
\arguments{
|
| 20 |
\item{f}{
|
- |
|
| 21 |
a generic function or the character string name of one. By default,
|
20 |
\item{f}{a generic function or the character string name of one. By default,
|
| 22 |
all currently defined subclasses of all the method signatures for this
|
21 |
all currently defined subclasses of all the method signatures for this
|
| 23 |
generic will be examined. The other arguments are mainly options to
|
22 |
generic will be examined. The other arguments are mainly options to
|
| 24 |
modify which inheritance patterns will be examined.
|
23 |
modify which inheritance patterns will be examined.
|
| 25 |
}
|
24 |
}
|
| 26 |
\item{signatures}{
|
25 |
\item{signatures}{
|
| 27 |
An optional set of subclass signatures to use instead of the relevant
|
26 |
An optional set of subclass signatures to use instead of the relevant
|
| 28 |
subclasses computed by \code{testInheritedMethods}. See the Details
|
27 |
subclasses computed by \code{testInheritedMethods}. See the Details
|
| 29 |
for how this is done. This argument might be supplied after a call
|
28 |
for how this is done. This argument might be supplied after a call
|
| 30 |
with \code{test = FALSE}, to test selection in batches.
|
29 |
with \code{test = FALSE}, to test selection in batches.
|
| 31 |
}
|
30 |
}
|
| 32 |
\item{test}{
|
31 |
\item{test}{
|
| 33 |
optional flag to control whether method selection is actually tested.
|
32 |
optional flag to control whether method selection is actually tested.
|
| 34 |
If \code{FALSE}, returns just the list of relevant signatures for
|
33 |
If \code{FALSE}, returns just the list of relevant signatures for
|
| 35 |
subclasses, without calling \code{\link{selectMethod}} for each signature.
|
34 |
subclasses, without calling \code{\link{selectMethod}} for each signature.
|
| 36 |
If there are a very large number of signatures, you may want to collect the full list and then test them in batches.
|
35 |
If there are a very large number of signatures, you may want to collect the full list and then test them in batches.
|
| 37 |
}
|
36 |
}
|
| 38 |
\item{virtual}{
|
37 |
\item{virtual}{
|
| 39 |
should virtual classes be included in the relevant subclasses.
|
38 |
should virtual classes be included in the relevant subclasses.
|
| 40 |
Normally not, since only the classes of actual arguments will trigger
|
39 |
Normally not, since only the classes of actual arguments will trigger
|
| 41 |
the inheritance calculation in a call to the generic function.
|
40 |
the inheritance calculation in a call to the generic function.
|
| 42 |
Including virtual classes may be useful if the class has no current
|
41 |
Including virtual classes may be useful if the class has no current
|
| 43 |
non-virtual subclasses but you anticipate your users may define such
|
42 |
non-virtual subclasses but you anticipate your users may define such
|
| 44 |
classes in the future.
|
43 |
classes in the future.
|
| 45 |
}
|
44 |
}
|
| 46 |
\item{groupMethods}{
|
45 |
\item{groupMethods}{
|
| 47 |
should methods for the group generic function be included?
|
46 |
should methods for the group generic function be included?
|
| 48 |
}
|
47 |
}
|
| 49 |
\item{where}{
|
48 |
\item{where}{
|
| 50 |
the environment in which to look for class definitions. Nearly
|
49 |
the environment in which to look for class definitions. Nearly
|
| 51 |
always, use the default global environment after attaching all the
|
50 |
always, use the default global environment after attaching all the
|
| 52 |
packages with relevant methods and/or class definitions.
|
51 |
packages with relevant methods and/or class definitions.
|
| 53 |
}
|
52 |
}
|
| 54 |
}
|
53 |
}
|
| 55 |
\details{
|
54 |
\details{
|
| 56 |
The following description applies when the optional arguments are
|
55 |
The following description applies when the optional arguments are
|
| 57 |
omitted, the usual case.
|
56 |
omitted, the usual case.
|
| 58 |
First, the defining signatures for all methods are computed by calls
|
57 |
First, the defining signatures for all methods are computed by calls
|
| 59 |
to \code{\link{findMethodSignatures}}.
|
58 |
to \code{\link{findMethodSignatures}}.
|
| 60 |
From these all the known non-virtual subclasses are found for each
|
59 |
From these all the known non-virtual subclasses are found for each
|
| 61 |
class that appears in the signature of some method.
|
60 |
class that appears in the signature of some method.
|
| 62 |
These subclasses are split into groups according to which class they
|
61 |
These subclasses are split into groups according to which class they
|
| 63 |
inherit from, and only one subclass from each group is retained (for
|
62 |
inherit from, and only one subclass from each group is retained (for
|
| 64 |
each argument in the generic signature).
|
63 |
each argument in the generic signature).
|
| 65 |
So if a method was defined with class \code{"vector"} for some
|
64 |
So if a method was defined with class \code{"vector"} for some
|
| 66 |
argument, one actual vector class is chosen arbitrarily.
|
65 |
argument, one actual vector class is chosen arbitrarily.
|
| 67 |
The case of \code{"ANY"} is dealt with specially, since all classes
|
66 |
The case of \code{"ANY"} is dealt with specially, since all classes
|
| 68 |
extend it. A dummy, nonvirtual class, \code{".Other"}, is used to
|
67 |
extend it. A dummy, nonvirtual class, \code{".Other"}, is used to
|
| 69 |
correspond to all classes that have no superclasses among those being
|
68 |
correspond to all classes that have no superclasses among those being
|
| 70 |
tested.
|
69 |
tested.
|
| 71 |
|
70 |
|
| 72 |
All combinations of retained subclasses for the
|
71 |
All combinations of retained subclasses for the
|
| 73 |
arguments in the generic signature are then computed.
|
72 |
arguments in the generic signature are then computed.
|
| 74 |
Each row of the resulting matrix is a signature to be tested by a call
|
73 |
Each row of the resulting matrix is a signature to be tested by a call
|
| 75 |
to \code{\link{selectMethod}}.
|
74 |
to \code{\link{selectMethod}}.
|
| 76 |
To collect information on ambiguous selections,
|
75 |
To collect information on ambiguous selections,
|
| 77 |
\code{testInheritedMethods} establishes a calling handler for the
|
76 |
\code{testInheritedMethods} establishes a calling handler for the
|
| 78 |
special signal \code{"ambiguousMethodSelection"}, by setting the
|
77 |
special signal \code{"ambiguousMethodSelection"}, by setting the
|
| 79 |
corresponding option.
|
78 |
corresponding option.
|
| 80 |
}
|
79 |
}
|
| 81 |
\value{
|
80 |
\value{
|
| 82 |
An object of class \code{"methodSelectionReport"}. The details of
|
81 |
An object of class \code{"methodSelectionReport"}. The details of
|
| 83 |
this class are currently subject to change. It has slots
|
82 |
this class are currently subject to change. It has slots
|
| 84 |
\code{"target"}, \code{"selected"}, \code{"candidates"}, and
|
83 |
\code{"target"}, \code{"selected"}, \code{"candidates"}, and
|
| 85 |
\code{"note"}, all referring to the ambiguous cases (and so of length
|
84 |
\code{"note"}, all referring to the ambiguous cases (and so of length
|
| 86 |
0 if there were none). These slots are intended to be examined by the
|
85 |
0 if there were none). These slots are intended to be examined by the
|
| 87 |
programmer to detect and preferably fix ambiguous method selections.
|
86 |
programmer to detect and preferably fix ambiguous method selections.
|
| 88 |
The object contains in addition slots \code{"generic"}, the name of
|
87 |
The object contains in addition slots \code{"generic"}, the name of
|
| 89 |
the generic function, and
|
88 |
the generic function, and
|
| 90 |
\code{"allSelections"}, giving the vector of labels for all
|
89 |
\code{"allSelections"}, giving the vector of labels for all
|
| 91 |
the signatures tested.
|
90 |
the signatures tested.
|
| 92 |
}
|
91 |
}
|
| 93 |
\references{
|
92 |
\references{
|
| 94 |
Chambers, John M. (2008)
|
93 |
Chambers, John M. (2008)
|
| 95 |
\emph{Software for Data Analysis: Programming with R}
|
94 |
\emph{Software for Data Analysis: Programming with R}
|
| 96 |
Springer. (Section 10.6 for basics of method selection.)
|
95 |
Springer. (Section 10.6 for basics of method selection.)
|
| 97 |
|
96 |
|
| 98 |
Chambers, John M.(2009)
|
97 |
Chambers, John M. (2009)
|
| 99 |
\emph{Class Inheritance in R}
|
98 |
\emph{Class Inheritance in R}
|
| 100 |
\url{http://stat.stanford.edu/~jmc4/classInheritance.pdf} (to be
|
99 |
\url{http://stat.stanford.edu/~jmc4/classInheritance.pdf} (to be
|
| 101 |
submitted to the R Journal).
|
100 |
submitted to the R Journal).
|
| 102 |
|
- |
|
| 103 |
}
|
101 |
}
|
| 104 |
\examples{
|
102 |
\examples{
|
| 105 |
## if no other attached packages have methods for `+` or its group generic
|
103 |
## if no other attached packages have methods for `+` or its group generic
|
| 106 |
## functions, this returns a 16 by 2 matrix of selection patterns (in R 2.9.0)
|
104 |
## functions, this returns a 16 by 2 matrix of selection patterns (in R 2.9.0)
|
| 107 |
testInheritedMethods("+")
|
105 |
testInheritedMethods("+")
|
| 108 |
}
|
106 |
}
|
| 109 |
|
107 |
|
| 110 |
\keyword{programming}
|
108 |
\keyword{programming}
|
| 111 |
\keyword{classes}
|
109 |
\keyword{classes}
|
| 112 |
\keyword{methods}
|
110 |
\keyword{methods}
|
| 113 |
|
- |
|