Skip to content

Commit 4c0f02c

Browse files
committed
update this branch with develop
2 parents f16a0c0 + f30c584 commit 4c0f02c

113 files changed

Lines changed: 328 additions & 273 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

make/tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ endif
3838

3939
##
4040
# Adding a test for multiple translation units. If this fails,
41-
# a new function is probably missing an inline
41+
# a public umbrella header likely exposes a new non-inline external definition.
4242
##
4343

4444
ifneq ($(OS),Windows_NT)

runChecks.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,47 @@ def check_non_test_files_in_test():
142142
return errors
143143

144144

145+
def check_rev_test_fixtures():
146+
test_files = [
147+
x for x in files_in_folder("test/unit/math/rev")
148+
if os.path.isfile(x) and x.endswith(testsfx)
149+
]
150+
errors = []
151+
for filepath in test_files:
152+
line_num = 0
153+
multi_line_comment = False
154+
old_state_multi_line_comment = False
155+
with open(filepath, "r") as f:
156+
for line in f:
157+
line_num += 1
158+
if multi_line_comment:
159+
if re.search("\*/", line):
160+
multi_line_comment = False
161+
else:
162+
if re.search("/\*", line):
163+
multi_line_comment = True
164+
if not multi_line_comment or (
165+
multi_line_comment and not old_state_multi_line_comment
166+
):
167+
if (
168+
not re.search(r".*\bTEST\(.*\*/.*", line)
169+
and not re.search(r".*/\*.*\bTEST\(", line)
170+
and not re.search(r".*//.*\bTEST\(", line)
171+
and re.search(r"\bTEST\(", line)
172+
):
173+
errors.append(
174+
filepath
175+
+ " at line "
176+
+ str(line_num)
177+
+ ":\n\t[rev-tests] Reverse-mode tests in "
178+
+ "test/unit/math/rev must use a cleanup fixture. "
179+
+ "Replace raw TEST(...) with TEST_F(AgradRev, ...) "
180+
+ "or another approved fixture-based form."
181+
)
182+
old_state_multi_line_comment = multi_line_comment
183+
return errors
184+
185+
145186
def main():
146187
errors = []
147188
# Check for files inside stan/math/prim that contain stan/math/rev or stan/math/fwd
@@ -242,6 +283,7 @@ def main():
242283
)
243284

244285
errors.extend(check_non_test_files_in_test())
286+
errors.extend(check_rev_test_fixtures())
245287

246288
errors.extend(check_non_unique_test_names())
247289

stan/math/fwd/fun/atan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ inline fvar<T> atan(const fvar<T>& x) {
2222
*
2323
* @tparam T autodiff value type
2424
* @param[in] z argument
25-
* @return arc tanget of the argument
25+
* @return arc tangent of the argument
2626
*/
2727
template <typename T>
2828
inline std::complex<fvar<T>> atan(const std::complex<fvar<T>>& z) {

stan/math/fwd/fun/read_fvar.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class read_fvar_functor {
3232

3333
/**
3434
* Function applying the read_fvar_functor to extract the values
35-
* and tangets of a given fvar matrix into separate matrices.
35+
* and tangents of a given fvar matrix into separate matrices.
3636
*
3737
* @tparam EigFvar type of the Eigen container of fvar.
3838
* @tparam EigOut type of the Eigen containers to copy to

stan/math/fwd/functor/finite_diff.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ inline auto aggregate_tangent(const FuncTangent& tangent, const InputArg& arg) {
5151

5252
/**
5353
* Construct an fvar<T> where the tangent is calculated by finite-differencing.
54-
* Finite-differencing is only perfomed where the scalar type to be evaluated is
55-
* `fvar<T>.
54+
* Finite-differencing is only performed where the scalar type to be evaluated
55+
* is `fvar<T>.
5656
*
5757
* Higher-order inputs (i.e., fvar<var> & fvar<fvar<T>>) are also implicitly
5858
* supported through auto-diffing the finite-differencing process.
@@ -95,8 +95,8 @@ inline auto finite_diff(const F& func, const TArgs&... args) {
9595

9696
/**
9797
* Construct an fvar<T> where the tangent is calculated by finite-differencing.
98-
* Finite-differencing is only perfomed where the scalar type to be evaluated is
99-
* `fvar<T>.
98+
* Finite-differencing is only performed where the scalar type to be evaluated
99+
* is `fvar<T>.
100100
*
101101
* This overload is used when no fvar<T> arguments are passed and simply
102102
* evaluates the functor with the provided arguments.

stan/math/fwd/meta/is_fvar.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ struct is_fvar<T,
2121
std::enable_if_t<internal::is_fvar_impl<std::decay_t<T>>::value>>
2222
: std::true_type {};
2323

24-
template <typename T>
25-
inline constexpr bool is_fvar_v = is_fvar<T>::value;
2624

2725
} // namespace stan
2826
#endif

stan/math/memory/stack_alloc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class stack_alloc {
254254
/**
255255
* Return number of bytes allocated to this instance by the heap.
256256
* This is not the same as the number of bytes allocated through
257-
* calls to memalloc_. The latter number is not calculatable
257+
* calls to memalloc_. The latter number is not calculable
258258
* because space is wasted at the end of blocks if the next
259259
* alloc request doesn't fit. (Perhaps we could trim down to
260260
* what is actually used?)

stan/math/opencl/kernel_generator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* into a single OpenCL kernel. This is much simpler than writing
1111
* multi-operation kernels by hand.
1212
*
13-
* Because global GPU memory loads and stores are relativly slow compared to
13+
* Because global GPU memory loads and stores are relatively slow compared to
1414
* calculations in a kernel, using one kernel for multiple operations is faster
1515
* than using one kernel per operation.
1616
*
@@ -27,13 +27,13 @@
2727
* Element-wise functions can be added using one of the macros in
2828
* `elt_functions.hpp`.
2929
*
30-
* New kernel generator classes must satsify the conditions below:
30+
* New kernel generator classes must satisfy the conditions below:
3131
*
3232
* 1. The class must be derived from a class inheriting from `operation_cl`.
3333
* Optionally, if the operation should support being assigned to, it can be
3434
* derived from a class inheriting `operation_cl_lhs` instead.
3535
* 2. It's parent template arguments should be set to derived type, type of
36-
* scalar and types of any expression arguements.
36+
* scalar and types of any expression arguments.
3737
* 3. Member type `Scalar` should be defined as scalar type of the result of
3838
* the operation.
3939
* 4. Member function `deep_copy` should make a copy of the expression.
@@ -97,7 +97,7 @@
9797
*
9898
* A new operation should also have a user-facing function that accepts
9999
* arguments to the operation and returns the operation object. Arguments should
100-
* be passed trough function `as_operation_cl` so that they are wrapped in
100+
* be passed through function `as_operation_cl` so that they are wrapped in
101101
* operations if they are not operations themselves. If the operation defines
102102
* `modify_argument_indices` this function should make copies of arguments by
103103
* calling `deep_copy()` on them internally.

stan/math/opencl/kernel_generator/broadcast.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class broadcast_
6161
}
6262

6363
/**
64-
* Sets index/indices along broadcasted dimmension(s) to 0.
64+
* Sets index/indices along broadcasted dimension(s) to 0.
6565
* @param[in, out] row_index_name row index
6666
* @param[in, out] col_index_name column index
6767
*/
@@ -129,7 +129,7 @@ inline auto broadcast(T&& a) {
129129
}
130130

131131
/**
132-
* Broadcast an expression in rowwise dimmension. The argument must have single
132+
* Broadcast an expression in rowwise dimension. The argument must have single
133133
* column. Further expressions can use this expression as if it had any number
134134
* of columns, repeating the values.
135135
*
@@ -147,7 +147,7 @@ inline auto rowwise_broadcast(T&& a) {
147147
}
148148

149149
/**
150-
* Broadcast an expression in colwise dimmension. The argument must have single
150+
* Broadcast an expression in colwise dimension. The argument must have single
151151
* row. Further expressions can use this expression as if it had any number of
152152
* rows, repeating the values.
153153
*

stan/math/opencl/kernel_generator/check_cl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class check_cl_ : public operation_cl_lhs<check_cl_<T>, bool> {
142142

143143
/**
144144
* Adds all write events on any matrices used by nested expression to a list.
145-
* Ignores read events anc clears no events.
145+
* Ignores read events and clears no events.
146146
* @param[out] events List of all events.
147147
*/
148148
inline void get_clear_read_write_events(
@@ -189,7 +189,7 @@ class check_cl_ : public operation_cl_lhs<check_cl_<T>, bool> {
189189
/**
190190
* Assignment of a scalar bool triggers the scalar check.
191191
* @param condition whether the state is ok.
192-
* @throws std::domain_error condition is false (chack failed).
192+
* @throws std::domain_error condition is false (check failed).
193193
*/
194194
void operator=(bool condition); // implemented in multi_result_kernel.hpp
195195
};

0 commit comments

Comments
 (0)