Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pja/externalize-cus…
Browse files Browse the repository at this point in the history
…tom-generators
  • Loading branch information
willow-ahrens committed Jan 11, 2022
2 parents 429a92b + d1788e7 commit 533f61e
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MatrixDepot"
uuid = "b51810bb-c9f3-55da-ae3c-350fc1fbce05"
version = "1.0.4"
version = "1.0.5"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand All @@ -15,7 +15,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
CodecZlib = "0.6, 0.7"
DataFrames = "0.20, 0.22, 0.21, 1.1"
DataFrames = "0.20, 0.22, 0.21, 1.1, 1.2, 1.3"
MAT = "0.7, 0.8, 0.9, 0.10"
Scratch = "1"
julia = "1"
Expand Down
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ start with a letter and contain only letters, digits, and `'_'`.

Every matrix has a numeric identifier, which is unique for its area:

* `builtin(id)` - one of the built-in matrix generators - currently `id ∈ 1:59`.

* `user(id)` - a user-defined matrix generator - starting with `1`.
* `builtin(id)` - one of the built-in matrix generators - currently `id ∈ 1:59`.

* `sp(id)` - one of the `SuiteSparse` collection. The integer ids are the
* `user(id)` - a user-defined matrix generator - starting with `1`.

* `sp(id)` - one of the `SuiteSparse` collection. The integer ids are the
'official' ident numbers assigned by the collection. Currently `id ∈ 1:3000`.

* `mm(id)` - one of the `MatrixMarket` collection. Here id follows the ordering
* `mm(id)` - one of the `MatrixMarket` collection. Here id follows the ordering
of the index file of the collection.

### Sets of Matrix Names - Pattern
Expand All @@ -105,7 +105,7 @@ The following pattern types are supported:
1. `"name"` - a string matching exactly a matrix name
2. `"shell-pattern"` - a string with shell wildcards `'?', '*', "[...]"` included.

3. `r"egular expression"` - a regular expression to match the matrix name.
3. `r"egular expression"` - a regular expression to match the matrix name.

4. `:group` - one of the defined group names; match all matrices in the group

Expand All @@ -131,10 +131,12 @@ The set of all known matrices can be expressed as empty tuple `()`. In a shell-
pattern the double `**` matches also slash characters, in contrast to the single `*`.

A convenient form of a predicate-generator is

```julia
@pred(expression)
```
where expression is a valid `Julia` boolean expression, which may access all

where expression is a valid `Julia` boolean expression, which may access all
properties of `MatrixData` as literal variable names.

Examples:
Expand All @@ -144,15 +146,15 @@ Examples:

`@pred(500_000 <= n * m < 1_000_000)` restricts the size of matched matrices.

`@pred(10^4 <= n <= 2*10^4 && n == m && nnz / n > 10 )` in average more than 10 entries per row
`@pred(10^4 <= n <= 2*10^4 && n == m && nnz / n > 10 )` in average more than 10 entries per row

There is s set of predefined predicate functions including:
`(issymmetric, ishermitian, isgeneral, isskew, isreal, iscomplex, isboolean,
islocal, isremote, isloaded, isunloaded, isbuiltin, isuser, issparse)`

Special predicate generators `keyword(word...)` and `hasdata(symbol...)` allow to
support keyword-search and check for the existence of meta-data.
For example: `hasdata(:x) & ~keyword("fluid")` provides solution (x) and does not mention "fluid".
For example: `hasdata(:x) & ~keyword("fluid"` provides solution (x) and does not mention "fluid".

## Accessing Data

Expand Down Expand Up @@ -185,34 +187,34 @@ mdinfo(pattern) # individual documentation about matrix(es) matching pattern

In general the first form is preferrable, if only the pure matrix is required.
For remote collections no arguments are used.

The second form allows to access all types of 'meta-data', which may be available for some local or remote matrices.

Examples:

`md = mdopen("spikes", 5, false); A = md.A; b = md.b; x = md.x`
`md = mdopen("spikes", 5, false); A = md.A; b = md.b; x = md.x`

`md = mdopen("Rommes/bips07_1998"); A = md.A; v = md.iv; title = md.data.title;
nodenames = md("nodename.txt")`

The last example shows, how to access textual meta-data, when the name contains
`Julia` non-word characters. Also if the metadata-name is stored in a variable,
`Julia` non-word characters. Also if the metadata-name is stored in a varaible,
the last form has to be used.

`meta = metasymbols(md)[2]; sec_matrix = md(meta)`

The function `metasymbols` returns a list of all symbols denoting metadata
provided by `md`. Wether expressed as symbols or strings does not matter.

The system function `propertynames(md)` returns all data of `md`. That includes
The system function `propertynames(md)` returns all data of `md`. That includes
size information and metadata.

`propertynames(md.data)` gives an overview about all attributes of the
`md.data::MatrixData`, which can for example be used in the `@pred` definitions.

### Backoffice Jobs

The remote data are originally stored at the remote web-site of one of the
The remote data are originally stored at the remote web-site of one of the
matrix collections. Before they are presented to the user, they are downloaded
to local disk storage, which serves as a permanent cache.

Expand Down Expand Up @@ -276,7 +278,6 @@ Example:
`MatrixDepot.load(sp(:) & @pred(nnz < 100_000))` to download only problems with given
number of stored entries in the main matrix.


## Sample Session

To see an overview of the matrices in the collection, type
Expand All @@ -288,7 +289,7 @@ julia> mdinfo()
Currently loaded Matrices
–––––––––––––––––––––––––––

builtin(#)
builtin(#)
–––––––––– ––––––––––– ––––––––––– ––––––––––– –––––––––– –––––––––––– ––––––––––– ––––––––––– ––––––––––––– ––––––––––––
1 baart 7 circul 13 fiedler 19 gravity 25 invhilb 31 magic 37 parter 43 randcorr 49 shaw 55 ursell
2 binomial 8 clement 14 forsythe 20 grcar 26 invol 32 minij 38 pascal 44 rando 50 smallworld 56 vand
Expand All @@ -301,15 +302,15 @@ user(#)
–––––––––
1 randsym

Groups
Groups
–––––– ––––––– ––––– –––– ––––– ––––– ––––––– ––––––– –––––– –––––– ––––––– –––––– –––––––––
all builtin local user eigen graph illcond inverse posdef random regprob sparse symmetric

Suite Sparse of
–––––––––––– ––––
2770 2833

MatrixMarket of
MatrixMarket of
–––––––––––– –––
488 498

Expand All @@ -320,8 +321,8 @@ We can generate a 4-by-4 Hilbert matrix by typing
```julia
julia> matrixdepot("hilb", 4)
4x4 Array{Float64,2}:
1.0 0.5 0.333333 0.25
0.5 0.333333 0.25 0.2
1.0 0.5 0.333333 0.25
0.5 0.333333 0.25 0.2
0.333333 0.25 0.2 0.166667
0.25 0.2 0.166667 0.142857
```
Expand Down Expand Up @@ -360,7 +361,7 @@ We can also specify the data type for locally generated matrices.
julia> matrixdepot("hilb", Float16, 5, 3)
5x3 Array{Float16,2}:
1.0 0.5 0.33325
0.5 0.33325 0.25
0.5 0.33325 0.25
0.33325 0.25 0.19995
0.25 0.19995 0.16663
0.19995 0.16663 0.14282
Expand Down Expand Up @@ -429,30 +430,29 @@ and define [new groups of matrices](http://matrixdepotjl.readthedocs.org/en/late
## References
- Weijian Zhang and Nicholas J. Higham,
* Weijian Zhang and Nicholas J. Higham,
"Matrix Depot: An Extensible Test Matrix Collection for Julia",
*PeerJ Comput. Sci.*, 2:e58 (2016),
[[pdf]](https://peerj.com/articles/cs-58/)
- Nicholas J. Higham,
* Nicholas J. Higham,
"Algorithm 694, A Collection of Test Matrices in MATLAB",
*ACM Trans. Math. Software*,
vol. 17. (1991), pp 289-305
[[pdf]](http://www.maths.manchester.ac.uk/~higham/narep/narep172.pdf)
[[doi]](https://dx.doi.org/10.1145/114697.116805)
- T.A. Davis and Y. Hu,
* T.A. Davis and Y. Hu,
"The University of Florida Sparse Matrix Collection",
*ACM Transaction on Mathematical Software*,
vol. 38, Issue 1, (2011), pp 1:1-1:25
[[pdf]](http://www.cise.ufl.edu/research/sparse/techreports/matrices.pdf)
- R.F. Boisvert, R. Pozo, K. A. Remington, R. F. Barrett, & J. Dongarra,
* R.F. Boisvert, R. Pozo, K. A. Remington, R. F. Barrett, & J. Dongarra,
" Matrix Market: a web resource for test matrix collections",
*Quality of Numerical Software* (1996) (pp. 125-137).
[[pdf]](http://www.netlib.org/utk/people/JackDongarra/pdf/matrixmarket.pdf)
- Per Christian Hansen,
* Per Christian Hansen,
"Test Matrices for Regularization Methods",
*SIAM Journal on Scientific Computing*,
vol. 16, 2, (1995) pp.506-512.
Expand Down
6 changes: 3 additions & 3 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ const UF_REMOTE = TURemoteType(RemoteParameters(
))

const MM_REMOTE = MMRemoteType(RemoteParameters(
"http://math.nist.gov/MatrixMarket",
"ftp://math.nist.gov/pub/MatrixMarket2",
"http://math.nist.gov/MatrixMarket/matrices.html",
"https://math.nist.gov/MatrixMarket",
"https://math.nist.gov/pub/MatrixMarket2",
"https://math.nist.gov/MatrixMarket/matrices.html",
"""<TITLE>The Matrix Market Matrices by Name</TITLE>""",
("M", """<A HREF="/MatrixMarket/data/""", 2, ".html", 3, nothing),
".mtx.gz"
Expand Down
4 changes: 2 additions & 2 deletions src/downloadmm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function parse_headerinfo(akku::Dict{AbstractString,AbstractString}, count::Inte
nnz = toint("nonzeros")
kind = get(akku, "kind", "")
datestr = get(akku, "date", "0")
date = match(r"^\d+$", datestr) != nothing ? parse(Int, datestr) : 0
date = match(r"^\d+$", datestr) !== nothing ? parse(Int, datestr) : 0
id, MetaInfo(m, n, nnz, 0, kind, date, "", "", "", "", "")
end

Expand All @@ -53,7 +53,7 @@ function extract_names(db::MatrixDatabase, matrices::AbstractString)
end
_, grepex, spquote, ending, parts, regexinf = remote.params.scan
m = regexinf === nothing ? nothing : match(regexinf, line)
if m != nothing
if m !== nothing
pname = length(m.captures) == 2 ? m.captures[1] : "id"
akku[pname] = m.captures[end]
end
Expand Down
2 changes: 1 addition & 1 deletion src/markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function mdinfo(data::GeneratedMatrixData)
md = Docs.doc(data.func)
# As md is cached internally, need to make copies
mdh, md = _mdheader(md, nothing, md)
if mdh != nothing
if mdh !== nothing
mdh, md = Markdown.Header(copy(mdh.text)), copy(md)
push!(mdh.text, " ($(data.name))")
md.content[1] = mdh
Expand Down
4 changes: 2 additions & 2 deletions src/matrixmarket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ function push_hdr!(hdr, line::AbstractString, field::Symbol)
end
reg = r"^% *([^:[]+): *(.*)$"
regtitle = r"^% *\[([^]]*)]"
if (m = match(reg, line)) != nothing
if (m = match(reg, line)) !== nothing
s = Symbol(m[1])
if s in (:name, :kind, :ed, :fields, :author, :date)
field = s
Expand All @@ -343,7 +343,7 @@ function push_hdr!(hdr, line::AbstractString, field::Symbol)
elseif s == :notes
field = s
end
elseif (m = match(regtitle, line)) != nothing
elseif (m = match(regtitle, line)) !== nothing
field = :title
value = m[1]
hdr[field] = value
Expand Down
8 changes: 4 additions & 4 deletions test/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import MatrixDepot: load, loadinfo, loadsvd
"Harwell-Boeing/smtape/bp___200", "Pajek/Journals"]

# read data
@test matrixdepot("HB/1138_bus") != nothing
@test matrixdepot("HB/1138_bus") !== nothing
@test mdlist("**/1138_bus") == ["HB/1138_bus", "Harwell-Boeing/psadmit/1138_bus"]
@test string(mdinfo("Harwell-Boeing/psadmit/662_bus")) ==
"# Harwell-Boeing/psadmit/662_bus\n\n" *
Expand All @@ -33,8 +33,8 @@ import MatrixDepot: load, loadinfo, loadsvd
@test_throws DataError MatrixDepot.metareader(mdopen("that is nothing"))

@test load("Bates/C*") == 2
@test mdinfo("Bates/Chem97Zt") != nothing
@test matrixdepot("Bates/Chem97Zt") != nothing
@test mdinfo("Bates/Chem97Zt") !== nothing
@test matrixdepot("Bates/Chem97Zt") !== nothing
@test "Bates/Chem97Zt" in mdlist(isloaded)
@test length(mdlist(isloaded)) == 6

Expand Down Expand Up @@ -67,7 +67,7 @@ A2 = mdesc.A

# read a format array file
@test MatrixDepot.mmreadheader(abspath(MatrixDepot.matrixfile(mdesc.data),
"..", string("cavity14_b.mtx"))) != nothing
"..", string("cavity14_b.mtx"))) !== nothing

mdesc = mdopen("blur", 10, false)
@test mdesc.A isa AbstractMatrix
Expand Down
2 changes: 1 addition & 1 deletion test/include_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MatrixDepot.publish_user_generators()

n = rand(1:8)
@test matrixdepot("randsym", n) !== nothing
@test mdinfo("randsym") != nothing
@test mdinfo("randsym") !== nothing
@test "randsym" in MatrixDepot.mdlist(:random)
@test "randsym" in MatrixDepot.mdlist(:symmetric)

Expand Down
4 changes: 2 additions & 2 deletions test/number.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
n = rand(1:38)
@test mdinfo(builtin(n)) != nothing
@test mdinfo(builtin(1:n)) != nothing
@test mdinfo(builtin(n)) !== nothing
@test mdinfo(builtin(1:n)) !== nothing
4 changes: 2 additions & 2 deletions test/property.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@test mdinfo(:symmetric | :posdef) != nothing
@test mdinfo(:symmetric | :posdef) !== nothing

@test mdinfo(isloaded) != nothing
@test mdinfo(isloaded) !== nothing

4 changes: 2 additions & 2 deletions test/regu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ n = 7 # rand(1:10)
r = mdopen("deriv2", n, false)
@test r !== nothing && r.A !== nothing
rf32 = mdopen("deriv2", Float32, n, false)
@test rf32 !== nothing && rf32.A != nothing
@test rf32 !== nothing && rf32.A !== nothing

r2 = mdopen("deriv2", Float32, n, 2, false)
@test r2 !== nothing && r2.b != nothing
@test r2 !== nothing && r2.b !== nothing
@test mdopen("deriv2", Float32, (n ÷ 2) * 2, 3, false).A !== nothing

@test_throws ArgumentError matrixdepot("deriv2", Float64, n, 4, false)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ include("generators.jl")
println("mv $xdir $xtmpdir")
mv(xdir, xtmpdir, force=true)
toggle_db()
@test mdopen(sp(1)) != nothing
@test mdopen(sp(1)) !== nothing
mv(xtmpdir, xdir, force=true)
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_rando.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A = matrixdepot("rando", Int, n, 1)
B = matrixdepot("rando", Int, n, 2)
C = matrixdepot("rando", Int, n, 3)

for i in length(A)
for i in 1:length(A)
@test A[i] == 0 || A[i] == 1
end

Expand Down

0 comments on commit 533f61e

Please sign in to comment.