Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doctests #342

Merged
merged 6 commits into from
Dec 24, 2021
Merged

Fix doctests #342

merged 6 commits into from
Dec 24, 2021

Conversation

devmotion
Copy link
Member

No description provided.

@devmotion
Copy link
Member Author

Weird, I ran doctest(MCMCChains; fix=true) locally with Julia 1.7 and everything seems to pass.

@rikhuijzer
Copy link
Contributor

rikhuijzer commented Dec 23, 2021

How about throwing away some compatibility stuff for Julia version 1.6 and lower? We're helping almost no one with that and just making the lives of the few Turing developers more difficult

EDIT: Also, if someone is still on Julia 1.2, it's very unlikely that that person is gonna install the newest MCMCChains version anyway. Those people can just keep using their old MCMCChains version even after bumping the lower compat bound here.

@devmotion
Copy link
Member Author

The main problem is not 1.0. We don't have to do anything special in this package to support it, so I don't think we should drop it.

The main problems are 1) that array printing is different depending on the Julia version, also from 1.6 to 1.6, and 2) the MLJ dependencies for the Rstar tests. Both require fixes even if we would support only >= 1.6.

The XGBoost dependency is annoying (and eg doesn't work on 32bit so we can't run tests there), and hence probably it would be helpful to use some simpler model in the tests (eg in MCMCDiagnosticTools I use Libsvm as well but it also has binary dependencies, so maybe eg naive Bayes would be even better). Additionally, there's a new release of MLJBase that breaks our tests - however, fixing it to an old version breaks our current test setup.

@rikhuijzer
Copy link
Contributor

rikhuijzer commented Dec 23, 2021

The main problem is not 1.0. We don't have to do anything special in this package to support it, so I don't think we should drop it.

This is special:

# Activate test environment on older Julia versions
if VERSION < v"1.2"
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(path=dirname(@__DIR__)))
Pkg.instantiate()
end

if VERSION >= v"1.3" && VERSION < v"1.7" && Sys.WORD_SIZE == 64
# run tests related to rstar statistic
println("Rstar")
Pkg.add("MLJBase")
Pkg.add("MLJXGBoostInterface")
@time include("rstar_tests.jl")

EDIT: Let's move this discussion to the Turing slack. No need for me to spam you here on this PR.

@rikhuijzer
Copy link
Contributor

and eg doesn't work on 32bit so we can't run tests there

Also, who runs 32 bit in this day and age? Apple dropped support for 32-bit in OS X Lion in 2011.

@devmotion
Copy link
Member Author

These specialization are not the problem here, and at least the second one is still needed even if we drop < 1.6.

32bit tests helped to uncover Int32/Int64 issues.

@rikhuijzer
Copy link
Contributor

32bit tests helped to uncover Int32/Int64 issues.

nice okay

@codecov
Copy link

codecov bot commented Dec 23, 2021

Codecov Report

Merging #342 (e94f2df) into master (e7b3db5) will increase coverage by 0.15%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
+ Coverage   82.94%   83.09%   +0.15%     
==========================================
  Files          19       19              
  Lines         979      988       +9     
==========================================
+ Hits          812      821       +9     
  Misses        167      167              
Impacted Files Coverage Δ
src/chains.jl 83.27% <ø> (+0.05%) ⬆️
src/rstar.jl 100.00% <ø> (ø)
src/tables.jl 100.00% <0.00%> (ø)
src/summarize.jl 83.56% <0.00%> (+0.22%) ⬆️
src/utils.jl 95.12% <0.00%> (+0.31%) ⬆️
src/sampling.jl 60.00% <0.00%> (+4.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7b3db5...e94f2df. Read the comment docs.

@devmotion
Copy link
Member Author

I fixed the issues and the annoying binary dependencies by replacing XGBoost with DecisionTree.

There are no additional fixes or workarounds for specific Julia versions needed, and actually now the rstar statistic can be tested with any Julia version and also on 32bit architectures

Doctests are only performed with Julia >= 1.7 and on 64bit which fixes all issues with array printing in different Julia versions (again, not a Julia 1.0 thing but also a problem for Julia 1.6 vs 1.7). IMO doctests really should only be performed with one specific Julia versions due to changes in e.g. print, show, and RNGs (doctest filters can mask outdated documentation since matches in the expected and actual outcome will be removed before comparing them). However, using >= v"1.7" instead of == v"1.7" ensures that we don't silently drop doctests when a new Julia version is released and CI is updated.

@devmotion devmotion requested a review from cpfiffer December 23, 2021 22:53
Copy link
Contributor

@rikhuijzer rikhuijzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good to me. Pure Julia is definitely better than XGBoost with its binary dependency

Comment on lines +71 to +85
# run tests related to rstar statistic
println("Rstar")
@time include("rstar_tests.jl")

# Array printing depends on Julia version and architecture,
# therefore we only run doctests with Julia >= 1.7 and on 64bit where `Int === Int64`
if VERSION >= v"1.7" && Sys.WORD_SIZE == 64
DocMeta.setdocmeta!(
MCMCChains,
:DocTestSetup,
:(using MCMCChains);
recursive = true
)
doctest(MCMCChains)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Great improvement

@devmotion devmotion merged commit 4548b5c into master Dec 24, 2021
@delete-merged-branch delete-merged-branch bot deleted the dw/fix_doctests branch December 24, 2021 10:12
devmotion added a commit that referenced this pull request Dec 24, 2021
* Fix doctests

* Fix Github action

* Ensure that tests and docs use same package versions

* Rearrange test dependencies

* Use DecisionTree instead of XGBoost

* Only run doctests on 64bit architectures
devmotion added a commit that referenced this pull request Dec 24, 2021
* Remove direct dependency on SpecialFunctions

* Fix doctests (#342) (#344)

* Fix doctests

* Fix Github action

* Ensure that tests and docs use same package versions

* Rearrange test dependencies

* Use DecisionTree instead of XGBoost

* Only run doctests on 64bit architectures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants