Skip to content

Commit

Permalink
Merge pull request #563 from willow-ahrens/wma/fix-coo-binsparse
Browse files Browse the repository at this point in the history
indexing mistake in binsparse
  • Loading branch information
willow-ahrens authored May 16, 2024
2 parents 8b88109 + e67fd2f commit 125b35e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/interface/fileio/binsparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)")
Expand Down
57 changes: 26 additions & 31 deletions src/symbolic/symbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit 125b35e

@willow-ahrens
Copy link
Collaborator Author

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/107070

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.6.28 -m "<description of version>" 125b35e1746a3659d04b058d49ad87d13e90dac0
git push origin v0.6.28

Please sign in to comment.