File tree Expand file tree Collapse file tree 6 files changed +62
-2
lines changed
Expand file tree Collapse file tree 6 files changed +62
-2
lines changed Original file line number Diff line number Diff line change 88/docs /site /
99/docs /Manifest.toml
1010.vscode
11+ LocalPreferences.toml
Original file line number Diff line number Diff line change 1+ authors = [" Anthony D. Blaom <anthony.blaom@gmail.com>" ]
12name = " LearnAPI"
23uuid = " 92ad9a40-7767-427a-9ee6-6e577f1266cb"
3- authors = [" Anthony D. Blaom <anthony.blaom@gmail.com>" ]
44version = " 2.0.0"
55
66[compat ]
7+ Preferences = " 1.5.0"
78julia = " 1.10"
89
10+ [deps ]
11+ Preferences = " 21216c6a-2e73-6563-6e65-726566657250"
12+
913[extras ]
1014Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
1115
1216[targets ]
13- test = [" Test" , ]
17+ test = [" Test" ]
Original file line number Diff line number Diff line change 11module LearnAPI
22
3+ using Preferences
4+
5+ include (" preferences.jl" )
36include (" types.jl" )
47include (" tools.jl" )
58include (" predict_transform.jl" )
Original file line number Diff line number Diff line change 1+ const VERBOSITY = @load_preference " verbosity" 1
2+
3+ INFO_VERBOSITY_IS (verbosity) =
4+ " Currently the baseline verbosity is $verbosity . "
5+ INFO_VERBOSITY_WILL_BE (verbosity) =
6+ " After restarting Julia, this will be changed to $verbosity . "
7+
8+ """
9+ LearnAPI.default_verbosity()
10+
11+ Return the default verbosity for training LearnAPI learners.
12+
13+ The value is determined at compile time by a Preferences.jl-style preference, with key
14+ "verbosity".
15+
16+ """
17+ default_verbosity () = VERBOSITY
18+
19+ """
20+ LearnAPI.default_verbosity(level)
21+
22+ Set the default verbosity for training LearnAPI learners to `level`. Changes do not take
23+ effect until the next Julia session.
24+
25+ """
26+ function default_verbosity (level)
27+ @info INFO_VERBOSITY_IS (VERBOSITY)
28+ @set_preferences! " verbosity" => level
29+ @info INFO_VERBOSITY_WILL_BE (level)
30+ end
Original file line number Diff line number Diff line change 1+ using LearnAPI
2+ using Preferences
3+
4+ @testset " default_verbosity" begin
5+ @test LearnAPI. default_verbosity () == LearnAPI. VERBOSITY
6+ @test_logs (
7+ (:info , LearnAPI. INFO_VERBOSITY_IS (LearnAPI. default_verbosity ())),
8+ (:info , LearnAPI. INFO_VERBOSITY_WILL_BE (3 )),
9+ LearnAPI. default_verbosity (3 ),
10+ )
11+ @test load_preference (LearnAPI, " verbosity" ) == 3
12+
13+ # restore active preference:
14+ @test_logs (
15+ (:info , LearnAPI. INFO_VERBOSITY_IS (LearnAPI. default_verbosity ())),
16+ (:info , LearnAPI. INFO_VERBOSITY_WILL_BE (LearnAPI. VERBOSITY)),
17+ LearnAPI. default_verbosity (LearnAPI. VERBOSITY),
18+ )
19+ end
20+
21+ true
Original file line number Diff line number Diff line change 11using Test
22
33test_files = [
4+ " preferences.jl" ,
45 " tools.jl" ,
56 " traits.jl" ,
67 " clone.jl" ,
You can’t perform that action at this time.
0 commit comments