Skip to content

Commit

Permalink
add helper for installing sklearn (#11)
Browse files Browse the repository at this point in the history
* add helper for installing sklearn

* pseudo test

* patch bump

* explicitly return nothing

* optional verbosity

Co-authored-by: Alex Arslan <[email protected]>
  • Loading branch information
palday and ararslan authored Apr 8, 2021
1 parent 852196c commit 20c06cd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PyMNE"
uuid = "6c5003b2-cbe8-491c-a0d1-70088e6a0fd6"
authors = ["Beacon Biosignals, Inc."]
version = "0.1.1"
version = "0.1.2"

[deps]
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Expand All @@ -15,4 +15,4 @@ PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["PyCall", "Test"]
test = ["PyCall", "Test"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ be changed via the `ENV["MNEVERSION"] = version_number` for your preferred
the rather rapid API changes and deprecation cycle in MNE and as such, it is
incumbent upon the user to manage these versions accordingly.

Note that MNE-Python uses [scikit-learn](https://scikit-learn.org/stable/) for certain functionality (e.g. ICA and the `decoding` module), but does not install it automatically as a dependency.
If you wish to take advantage of this functionality, the non-exported `install_sklearn` function will install `sklearn`, using the same environment variables as the main installation.

MNE-Python can also be installed them manually ahead of time.
From the shell, use `python -m pip install mne` for the latest stable release
Expand Down
21 changes: 21 additions & 0 deletions src/PyMNE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,25 @@ function __init__()
return nothing
end

"""
install_sklearn(ver="")
Install scikit-learn using the specified version.
The default version is the latest stable version.
"""
function install_sklearn(version="latest"; verbose=false)
verbose && @info "Installing scikit-learn"
pip = pyimport("pip")
flags = split(get(ENV, "PIPFLAGS", ""))
packages = ["scikit-learn" * (version == "latest" ? "" : "==$version")]
if verbose
@info "Package requirements:" packages
@info "Flags for pip install:" flags
@info "scikit-learn version:" version
end
pip.main(["install"; flags; packages])
return nothing
end

end # module
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ using Test

using PyCall: PyError

@testset "sklearn" begin
PyMNE.install_sklearn()
# requires sklearn
@test PyMNE.preprocessing.ICA(method="fastica") isa PyObject
end

@testset "create_info and get_info" begin
dat = zeros(1, 100)
naive_info = PyMNE.mne.create_info([:a], 100)
Expand Down

2 comments on commit 20c06cd

@palday
Copy link
Member Author

@palday palday commented on 20c06cd Apr 8, 2021

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/33872

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 20c06cd4de19948d6238df3e58443fa13ecff0cb
git push origin v0.1.2

Please sign in to comment.