Skip to content

Commit

Permalink
Merge pull request #138 from invenia/rofinn-patch-1
Browse files Browse the repository at this point in the history
Update Project.toml and DataDep
  • Loading branch information
rofinn authored Aug 30, 2023
2 parents 338775e + 3b5501a commit 687c56a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ jobs:
- os: windows-latest
arch: x86
include:
# Add a 1.5 job because that's what Invenia actually uses
- os: ubuntu-latest
version: 1.5
version: 1.6
arch: x64
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Impute"
uuid = "f7bf1975-0170-51b9-8c5f-a992d46b9575"
authors = ["Invenia Technical Computing"]
version = "0.6.10"
version = "0.6.11"

[deps]
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
Expand All @@ -20,7 +20,7 @@ TableOperations = "ab02a1b2-a7df-11e8-156e-fb1833f50b87"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
AxisKeys = "0.1"
AxisKeys = "0.1, 0.2"
BSON = "0.2, 0.3"
CSV = "0.6, 0.7, 0.8, 0.9, 0.10"
DataDeps = "0.7"
Expand All @@ -32,7 +32,7 @@ NearestNeighbors = "0.4"
StatsBase = "0.32, 0.33, 0.34"
TableOperations = "0.2, 1.0"
Tables = "1"
julia = "1"
julia = "1.6"

[extras]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand Down
7 changes: 4 additions & 3 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ function register_datadep()
DataDep(
"impute-v1.0.0",
"Datasets for testing and demonstrating Impute.jl",
"https://invenia-public-datasets.s3.amazonaws.com/Impute/v1.0.0/datasets.tar.gz",
"938b3705752eb73141476a2abc7a36cfdaba9ec45f99f0796f44e0870e006e1c",
post_fetch_method=unpack,
"https://www.dropbox.com/scl/fi/bgtfqea9qqoug42gcnnsl/datasets.tar.gz?rlkey=11xsae0wi32m8gcfxhbqgo030&dl=0",
"cf1fff2e7f3ce28eb4264060bc7b9ee561bccfce2c5915c4cf758ec48477ddfe",
fetch_method=DataDeps.fetch_base,
post_fetch_method=DataDeps.unpack,
)
)
end
Expand Down
9 changes: 6 additions & 3 deletions src/imputors/knn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ function impute!(data::AbstractMatrix{Union{T, Missing}}, imp::KNN; dims=nothing

# Weight valid neighbors based on inverse distance
neighbor_dists = dists[.!neighbor_mask]
wv = weights(1.0 ./ neighbor_dists)

# Delay creating Weights as they don't support Inf or NaN anymore.
wv = 1.0 ./ neighbor_dists
Σ = sum(wv)

# Only fill with the weighted mean of neighbors if the sum of the weights are
# non-zero and finite.
if isfinite(sum(wv)) && !iszero(sum(wv))
if isfinite(Σ) && !iszero(Σ)
neighbor_vals = X[i, idxs[.!neighbor_mask]]
X[i, j] = mean(neighbor_vals, wv)
X[i, j] = mean(neighbor_vals, Weights(wv, Σ))
end
end
end
Expand Down

2 comments on commit 687c56a

@rofinn
Copy link
Member Author

@rofinn rofinn commented on 687c56a Aug 30, 2023

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

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.11 -m "<description of version>" 687c56ae94f4fe6bed2c9bbf88b1237f58611c99
git push origin v0.6.11

Please sign in to comment.