Skip to content

Commit fda7988

Browse files
committed
refactor!: remove scenario lists from public API
1 parent 4f1fc48 commit fda7988

File tree

9 files changed

+49
-32
lines changed

9 files changed

+49
-32
lines changed

DifferentiationInterface/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12-
- New Arxiv preprint for citation (#795)
12+
- New Arxiv preprint for citation ([#795])
1313

1414
## [0.6.54] - 2025-05-11
1515

DifferentiationInterface/test/testutils.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
using ADTypes
2+
using DifferentiationInterfaceTest
23
using SparseConnectivityTracer
34
using SparseMatrixColorings
45

6+
using DifferentiationInterfaceTest:
7+
default_scenarios,
8+
sparse_scenarios,
9+
complex_scenarios,
10+
complex_sparse_scenarios,
11+
static_scenarios,
12+
component_scenarios,
13+
gpu_scenarios
14+
515
function MyAutoSparse(backend::AbstractADType)
616
return AutoSparse(
717
backend;

DifferentiationInterfaceTest/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Specify preparation arguments in DIT Scenario ([#786])
1313

14+
### Removed
15+
16+
- Remove scenario lists from public API ([#796])
17+
1418
## [0.9.6] - 2025-03-28
1519

1620
### Added
@@ -22,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2226
[unreleased]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.9.6...main
2327
[0.9.6]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterfaceTest-v0.9.5...DifferentiationInterfaceTest-v0.9.6
2428

29+
[#796]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/796
2530
[#786]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/786
2631
[#749]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/749
2732
[#748]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/748

DifferentiationInterfaceTest/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ Make it easy to know, for a given function:
2222

2323
## Features
2424

25-
- Predefined or custom test scenarios
25+
- Definition of custom test scenarios
2626
- Correctness tests
2727
- Type stability tests
2828
- Count calls to the function
2929
- Benchmark runtime and allocations
30-
- Scenarios with weird array types (GPU, static) in package extensions
3130

3231
## Installation
3332

DifferentiationInterfaceTest/docs/src/api.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,16 @@ DifferentiationInterfaceTest
1515
Scenario
1616
test_differentiation
1717
benchmark_differentiation
18-
FIRST_ORDER
19-
SECOND_ORDER
2018
```
2119

2220
## Utilities
2321

2422
```@docs
23+
FIRST_ORDER
24+
SECOND_ORDER
2525
DifferentiationInterfaceTest.DifferentiationBenchmarkDataRow
2626
```
2727

28-
## Pre-made scenario lists
29-
30-
The precise contents of the scenario lists are not part of the API, only their existence.
31-
32-
```@docs
33-
default_scenarios
34-
sparse_scenarios
35-
component_scenarios
36-
gpu_scenarios
37-
static_scenarios
38-
complex_scenarios
39-
complex_sparse_scenarios
40-
```
41-
4228
## Internals
4329

4430
This is not part of the public API.

DifferentiationInterfaceTest/docs/src/tutorial.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ Of course we know the true gradient mapping:
2727
∇f(x::AbstractArray) = cos.(x)
2828
```
2929

30-
DifferentiationInterfaceTest.jl relies with so-called "scenarios", in which you encapsulate the information needed for your test:
30+
DifferentiationInterfaceTest.jl relies with so-called [`Scenario`](@ref)s, in which you encapsulate the information needed for your test:
3131

32-
- the operator category (`:gradient`)
32+
- the operator category (here `:gradient`)
3333
- the behavior of the operator (either `:in` or `:out` of place)
3434
- the function `f`
35-
- the input `x` of the function `f`
36-
- the reference first-order result `res1` of the operator
35+
- the input `x` of the function `f` (and possible tangents or contexts)
36+
- the reference first-order result `res1` (and possible second-order result `res2`) of the operator
37+
- the arguments `prep_args` passed during preparation
3738

3839
```@example tuto
3940
xv = rand(Float32, 3)
@@ -69,4 +70,4 @@ This is made easy by the [`benchmark_differentiation`](@ref) function, whose syn
6970
df = benchmark_differentiation(backends, scenarios);
7071
```
7172

72-
The resulting object is a `DataFrame` from [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl), whose columns correspond to the fields of [`DifferentiationBenchmarkDataRow`](@ref):
73+
The resulting object is a `DataFrame` from [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl), whose columns correspond to the fields of [`DifferentiationBenchmarkDataRow`](@ref).

DifferentiationInterfaceTest/src/DifferentiationInterfaceTest.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,7 @@ include("test_differentiation.jl")
136136

137137
export FIRST_ORDER, SECOND_ORDER
138138
export Scenario
139-
export default_scenarios, sparse_scenarios
140-
export complex_scenarios, complex_sparse_scenarios
141139
export test_differentiation, benchmark_differentiation
142140
export DifferentiationBenchmarkDataRow
143-
# extensions
144-
export static_scenarios
145-
export component_scenarios
146-
export gpu_scenarios
147141

148142
end

DifferentiationInterfaceTest/src/scenarios/scenario.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,21 @@ This generic type should never be used directly: use the specific constructor co
1313
1414
# Constructors
1515
16-
Scenario{op,pl_op}(f, x, [t], contexts...; res1, res2, name)
17-
Scenario{op,pl_op}(f!, y, x, [t,] contexts...; res1, res2, name)
16+
Scenario{op,pl_op}(
17+
f, x, [t], contexts...;
18+
prep_args, res1, res2, name
19+
)
20+
21+
Scenario{op,pl_op}(
22+
f!, y, x, [t,] contexts...;
23+
prep_args, res1, res2, name
24+
)
25+
26+
Default values:
27+
28+
- `prep_args = ` the result of `zero` applied to each execution argument
29+
- `res1 = res2 = nothing`
30+
- `name = nothing`
1831
1932
# Fields
2033

DifferentiationInterfaceTest/test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ using Pkg
55
using SparseConnectivityTracer
66
using Test
77

8+
using DifferentiationInterfaceTest:
9+
default_scenarios,
10+
sparse_scenarios,
11+
complex_scenarios,
12+
complex_sparse_scenarios,
13+
static_scenarios,
14+
component_scenarios,
15+
gpu_scenarios
16+
817
GROUP = get(ENV, "JULIA_DIT_TEST_GROUP", "All")
918

1019
## Main tests

0 commit comments

Comments
 (0)