diff --git a/Project.toml b/Project.toml index bb6df8679..6be85aebd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["Willow Ahrens"] name = "Finch" uuid = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce" -version = "0.6.27" +version = "0.6.28" [compat] AbstractTrees = "0.3.4, 0.4" diff --git a/src/interface/fileio/binsparse.jl b/src/interface/fileio/binsparse.jl index 4f4ce0854..06b6f5c62 100644 --- a/src/interface/fileio/binsparse.jl +++ b/src/interface/fileio/binsparse.jl @@ -386,7 +386,7 @@ function bspwrite_level(f, desc, fmt, lvl::SparseCOOLevel{R}) where {R} bspwrite_data(f, desc, "pointers_to_$(N - n)", indices_one_to_zero(lvl.ptr)) end for r = 1:R - bspwrite_data(f, desc, "indices_$(N - n + r - 1)", indices_one_to_zero(lvl.tbl[r])) + bspwrite_data(f, desc, "indices_$(N - n + R - r)", indices_one_to_zero(lvl.tbl[r])) end fmt["level"] = OrderedDict() bspwrite_level(f, desc, fmt["level"], lvl.lvl) @@ -397,7 +397,7 @@ function bspread_level(f, desc, fmt, ::Val{:sparse}) n = level_ndims(typeof(lvl)) + R N = length(desc["shape"]) tbl = (map(1:R) do r - indices_zero_to_one(bspread_data(f, desc, "indices_$(N - n + r - 1)")) + indices_zero_to_one(bspread_data(f, desc, "indices_$(N - n + R - r)")) end...,) if N - n > 0 ptr = bspread_data(f, desc, "pointers_to_$(N - n)") diff --git a/src/symbolic/symbolic.jl b/src/symbolic/symbolic.jl index 3bb14e0d5..18fb4f88c 100644 --- a/src/symbolic/symbolic.jl +++ b/src/symbolic/symbolic.jl @@ -98,49 +98,44 @@ maxby(a, b) = a[1] < b[1] ? b : a """ rem_nothrow(x, y) -Return the remainder of `x` divided by `y`, and issue a warning if `y` is zero. -If `y` is zero, return zero. +Returns `rem(x, y)` normally, returns zero and issues a warning if `y` is zero. """ -function rem_nothrow(x, y) - if iszero(y) - @warn "Division by zero in rem" - zero(y) - else - rem(x, y) - end -end +rem_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in rem"); zero(y)) : rem(x, y) + +""" + mod_nothrow(x, y) + +Returns `mod(x, y)` normally, returns zero and issues a warning if `y` is zero. +""" +mod_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in mod"); zero(y)) : mod(x, y) + +""" + mod1_nothrow(x, y) + +Returns `mod1(x, y)` normally, returns one and issues a warning if `y` is zero. +""" +mod1_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in mod1"); one(y)) : mod1(x, y) """ fld_nothrow(x, y) -Return the floor of `x` divided by `y`, and issue a warning if `y` is zero. -If `y` is zero, return zero. +Returns `fld(x, y)` normally, returns zero and issues a warning if `y` is zero. """ -function fld_nothrow(x, y) - if iszero(y) - @warn "Division by zero in fld" - zero(y) - else - fld(x, y) - end -end +fld_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in fld"); zero(y)) : fld(x, y) """ - cld_nothrow(x, y) + fld1_nothrow(x, y) -Return the ceiling of `x` divided by `y`, and issue a warning if `y` is zero. -If `y` is zero, return zero. +Returns `fld1(x, y)` normally, returns one and issues a warning if `y` is zero. """ -function cld_nothrow(x, y) - if iszero(y) - @warn "Division by zero in fld" - zero(y) - else - cld(x, y) - end -end +fld1_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in fld1"); one(y)) : fld1(x, y) +""" + cld_nothrow(x, y) +Returns `cld(x, y)` normally, returns zero and issues a warning if `y` is zero. +""" +cld_nothrow(x, y) = iszero(y) ? (@warn("Division by zero in cld"); zero(y)) : cld(x, y) isassociative(alg) = (f) -> isassociative(alg, f) isassociative(alg, f::FinchNode) = f.kind === literal && isassociative(alg, f.val)