Skip to content

Conversation

@OkonSamuel
Copy link
Member

DictTable are just the julia Dicts which doesn't preserve ordering.
This PR replaces DictTable with DictColumnTable which preseve key ordering.

@OkonSamuel
Copy link
Member Author

@ablaom a review would be appreciated.

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2023

Codecov Report

Merging #59 (4526f8e) into dev (eb29518) will decrease coverage by 0.22%.
The diff coverage is 44.44%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##              dev      #59      +/-   ##
==========================================
- Coverage   92.94%   92.73%   -0.22%     
==========================================
  Files           4        4              
  Lines         397      399       +2     
==========================================
+ Hits          369      370       +1     
- Misses         28       29       +1     
Impacted Files Coverage Δ
src/NearestNeighborModels.jl 100.00% <ø> (ø)
src/models.jl 91.17% <44.44%> (-0.41%) ⬇️

StatsBase = "^0.33, 0.34"
Tables = "^1.2"
julia = "1.6"
julia = "1.3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we reverting to Julia 1.3 support?

return dict_table
cols = Tables.dictcolumntable(target_table)
colnames = Tables.columnnames(cols)
dict = OrderedDict{Symbol, AbstractVector}(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re AbstractVector, remind me, why cannot we not have a concrete type here?

dict = OrderedDict{Symbol, AbstractVector}(
nm => func(weights, Tables.getcolumn(cols, nm), idxsvec) for nm in colnames
)
dict_table = Tables.DictColumnTable(Tables.Schema(colnames, eltype.(values(dict))), dict)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure DictColumnTable constructor is strictly public. Maybe we should be using Tables.dictcolumntable instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object DictColumnTable is public. So I don't see any harm in using the constructor.
The other alternative is to create my own table as Tables.dictcolumntable isn't a constructor, it a utility method that converts other tables into a DictColumnTable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it safest to construct your own table and use dictcolumntable.


function univariate_table(::Type{T}, weights, target_table, idxsvec) where {T}
table = if T <: DictTable
table = if T <: DictColumnTable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but maybe type dispatch instead of if...else...end is more usual?

* `output_type::Type{<:MultiUnivariateFinite}=DictTable` : One of
(`ColumnTable`, `DictTable`). The type of table type to use for predictions.
* `output_type::Type{<:MultiUnivariateFinite}=DictColumnTable` : One of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In docs I recommend you qualify DictColumnTable as Tables.DictColumnTable or otherwise explain that this type is owned by 3rd party package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants