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

Remove deprecations; update norm behavior #412

Merged
merged 11 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Changes in v0.14.0

## Breaking changes

* Changes to the `sign` of atoms:
* The sign of `sumlargesteigs` has been changed from `Positive` to `NoSign()` instead of `Positive()`, to allow non-positive-semidefinite inputs. This has the potential
to break code that required that sign to be positive. If you run into this problem, please file an issue so we can figure out a workaround. [#412](https://github.com/jump-dev/Convex.jl/pull/412)
* Removal of deprecations
* `lambdamin` and `lambdamax` has been deprecated to `eigmin` and `eigmax` since Convex v0.13.0. This deprecation has been removed, so your code must be updated to call `eigmin` or `eigmax` instead. [#412](https://github.com/jump-dev/Convex.jl/pull/412)
* `norm(x, p)` where `x` is a matrix expression has been deprecated to `opnorm(x,p)` since Convex v0.8.0. This deprecation has been removed, so your code must be updated to call `opnorm(x, p)` instead. Currently, `norm(x,p)` for a matrix
expression `x` will error, but in Convex.jl v0.15.0 it will return `norm(vec(x), p)`. [#412](https://github.com/jump-dev/Convex.jl/pull/412)
* `Convex.clearmemory()` has been deprecated and unnecessary since Convex v0.12.5. This deprecation has been removed, so if this function is in your code, just delete it. [#412](https://github.com/jump-dev/Convex.jl/pull/412)
* `vecnorm(x, p)` has been deprecated to `norm(vec(x), p)` since Convex v0.8.0. This deprecation has been removed, so your code must be updated to call `norm(vec(x),p)` instead.

## Other changes

* updated `nuclearnorm` and `sumlargesteigs` to allow complex variables, and allow the argument of `sumlargesteigs` to be non-positive-semi-definite [#409](https://github.com/jump-dev/Convex.jl/pull/409). Thanks to @dstahlke!

# Changes in v0.13.8

* add unary `+` for `Sign` and `ComplexSign` to allow single-argument `hcat` and `vcat` to work [#405](https://github.com/jump-dev/Convex.jl/pull/405). Thanks to @dstahlke!
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Convex"
uuid = "f65535da-76fb-5f13-bab9-19810c17039a"
version = "0.13.8"
version = "0.14.0-DEV"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "0.24"
Documenter = "0.26"
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ julia --project=docs -e 'using Pkg; Pkg.instantiate(); include("docs/make.jl")'
to generate the examples notebooks (which will be placed in `docs/notebooks`)
and the documentation itself, which is generated into the `doc/build` folder,
and can be previewed by opening a webserver there. Note that this command can
take some time.
take some time. To generate the documentation without updating the examples,
set `ENV["CONVEX_SKIP_EXAMPLES"]="true"` before including `docs/make.jl`.

To generate a single Jupyter notebook, run e.g.

Expand Down
4 changes: 2 additions & 2 deletions docs/examples_literate/general_examples/huber_regression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if big_example
n = 300
number_tests = 50
else
n = 100
number_tests = 20
n = 50
number_tests = 10
end

# Generate data for Huber regression.
Expand Down
196 changes: 101 additions & 95 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,129 +4,135 @@ using Documenter, Convex, Literate, Pkg
previous_GKSwstype = get(ENV, "GKSwstype", "")
ENV["GKSwstype"] = "100"

@info "Building examples..."

filename(str) = first(splitext(last(splitdir(str))))
filename_to_name(str) = uppercasefirst(replace(replace(filename(str), "-" => " "), "_" => " "))

fix_math_md(content) = replace(content, r"\$\$(.*?)\$\$"s => s"```math\1```")

literate_path = joinpath(@__DIR__(), "examples_literate")
build_path = joinpath(@__DIR__, "src", "examples")
rm(build_path; force=true, recursive=true)
isdir(build_path) || mkdir(build_path)

literate_path = joinpath(@__DIR__(), "examples_literate")
notebooks_path = joinpath(@__DIR__, "notebooks")

@info "[Examples] Preparing notebooks..."
filename(str) = first(splitext(last(splitdir(str))))
filename_to_name(str) = uppercasefirst(replace(replace(filename(str), "-" => " "), "_" => " "))
fix_math_md(content) = replace(content, r"\$\$(.*?)\$\$"s => s"```math\1```")

notebooks_path = joinpath(@__DIR__, "notebooks")
rm(notebooks_path, recursive=true, force=true)
mkdir(notebooks_path)

for dir in readdir(literate_path)
dir_path = joinpath(literate_path, dir)
isdir(dir_path) || continue
@info "Processing directory $dir"
notebook_dir = joinpath(notebooks_path, dir)
isdir(notebook_dir) || mkdir(notebook_dir)
for file in readdir(dir_path)
file_path = joinpath(dir_path, file)
out_path = joinpath(notebooks_path, dir, file)
if endswith(file, ".jl")
Literate.notebook(file_path, notebook_dir, execute=false)
else
cp(file_path, out_path)

SKIP_EXAMPLES = get(ENV, "CONVEX_SKIP_EXAMPLES", false) == "true"

if SKIP_EXAMPLES
@info "Skipping examples"
examples_nav = String[]
else
@info "Building examples..."

@info "[Examples] Preparing notebooks..."

rm(notebooks_path, recursive=true, force=true)
mkdir(notebooks_path)

for dir in readdir(literate_path)
dir_path = joinpath(literate_path, dir)
isdir(dir_path) || continue
@info "Processing directory $dir"
notebook_dir = joinpath(notebooks_path, dir)
isdir(notebook_dir) || mkdir(notebook_dir)
for file in readdir(dir_path)
file_path = joinpath(dir_path, file)
out_path = joinpath(notebooks_path, dir, file)
if endswith(file, ".jl")
Literate.notebook(file_path, notebook_dir, execute=false)
else
cp(file_path, out_path)
end
end
end
end

# Copy `Project.toml` to notebooks
cp(joinpath(@__DIR__, "Project.toml"), joinpath(notebooks_path, "Project.toml"))
# Copy `Project.toml` to notebooks
cp(joinpath(@__DIR__, "Project.toml"), joinpath(notebooks_path, "Project.toml"))

# Add a README file to notebooks
open(joinpath(notebooks_path, "README.md"), "w") do io
print(io, """
# Convex.jl example notebooks
# Add a README file to notebooks
open(joinpath(notebooks_path, "README.md"), "w") do io
print(io, """
# Convex.jl example notebooks

Start Julia in this directory and set the project flag to point to this directory. E.g. run the command
Start Julia in this directory and set the project flag to point to this directory. E.g. run the command

```julia
julia --project=.
```
```julia
julia --project=.
```

in this directory.
in this directory.

Then add `IJulia` if it's not installed already in your global environment by
Then add `IJulia` if it's not installed already in your global environment by

```julia
pkg> add IJulia
```
```julia
pkg> add IJulia
```

Also call `instantiate` to download the required packages:
Also call `instantiate` to download the required packages:

```julia
pkg> instantiate
```
```julia
pkg> instantiate
```

Then launch Jupyter:
Then launch Jupyter:

```julia
julia> using IJulia
```julia
julia> using IJulia

julia> notebook(dir=pwd(); detached=true)
```
julia> notebook(dir=pwd(); detached=true)
```

This should allow you to try any of the notebooks.
""")
end
This should allow you to try any of the notebooks.
""")
end

# zip up the notebooks directory
zip_path = joinpath(build_path, "notebooks.zip")
run(Cmd(`zip $zip_path -r notebooks`; dir = @__DIR__))

@info "[Examples] Preparing markdown files..."

for dir in readdir(literate_path)
dir_path = joinpath(literate_path, dir)
isdir(dir_path) || continue
@info "Processing directory $dir"
build_dir = joinpath(build_path, dir)
isdir(build_dir) || mkdir(build_dir)
for file in readdir(dir_path)
file_path = joinpath(dir_path, file)
out_path = joinpath(build_path, dir, file)
if endswith(file, ".jl")
postprocess = function(content)
"""
All of the examples can be found in Jupyter notebook form [here](../$(filename(zip_path)).zip).

```@setup $(filename(file))
__START_TIME = time_ns()
@info "Starting example $(filename(file))"
```
""" * content * """
```@setup $(filename(file))
__END_TIME = time_ns()
elapsed = string(round((__END_TIME - __START_TIME)*1e-9; sigdigits = 3), "s")
@info "Finished example $(filename(file)) after " * elapsed
```
"""
# zip up the notebooks directory
zip_path = joinpath(build_path, "notebooks.zip")
run(Cmd(`zip $zip_path -r notebooks`; dir = @__DIR__))

@info "[Examples] Preparing markdown files..."

for dir in readdir(literate_path)
dir_path = joinpath(literate_path, dir)
isdir(dir_path) || continue
@info "Processing directory $dir"
build_dir = joinpath(build_path, dir)
isdir(build_dir) || mkdir(build_dir)
for file in readdir(dir_path)
file_path = joinpath(dir_path, file)
out_path = joinpath(build_path, dir, file)
if endswith(file, ".jl")
postprocess = function(content)
"""
All of the examples can be found in Jupyter notebook form [here](../$(filename(zip_path)).zip).

```@setup $(filename(file))
__START_TIME = time_ns()
@info "Starting example $(filename(file))"
```
""" * content * """
```@setup $(filename(file))
__END_TIME = time_ns()
elapsed = string(round((__END_TIME - __START_TIME)*1e-9; sigdigits = 3), "s")
@info "Finished example $(filename(file)) after " * elapsed
```
"""
end
Literate.markdown(file_path, build_dir; preprocess = fix_math_md, documenter = true, postprocess = postprocess)
else
cp(file_path, out_path)
end
Literate.markdown(file_path, build_dir; preprocess = fix_math_md, documenter = true, postprocess = postprocess)
else
cp(file_path, out_path)
end
end
end

@info "Starting `makedocs`"
# Build nav tree for examples
function nav_dir(dir, path)
sort([ joinpath("examples", dir, file) for file in readdir(path) if endswith(file, ".md") && file != "index.md" ])
end

# Build nav tree for examples
function nav_dir(dir, path)
sort([ joinpath("examples", dir, file) for file in readdir(path) if endswith(file, ".md") && file != "index.md" ])
examples_nav = [ filename_to_name(dir) => nav_dir(dir, joinpath(build_path, dir)) for dir in readdir(build_path) if isdir(joinpath(build_path, dir)) ]
end

examples_nav = [ filename_to_name(dir) => nav_dir(dir, joinpath(build_path, dir)) for dir in readdir(build_path) if isdir(joinpath(build_path, dir)) ]
@info "Starting `makedocs`"

makedocs(;
modules = [Convex],
Expand Down
Loading