Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested enumeration container #213

Merged
merged 6 commits into from
Dec 10, 2019
Merged

Nested enumeration container #213

merged 6 commits into from
Dec 10, 2019

Conversation

guimarqu
Copy link
Contributor

@guimarqu guimarqu commented Dec 8, 2019

Structure to create a tree of duty using UInt instead of types. It'll allow us to have VarData and ConstrData bitstype.

Syntax to create a tree :

Coluna.@nestedenum VarConstrDuty,
    A  VarConstrDuty,
        A1  A,
        A2  A,
        A3  A,
    B  VarConstrDuty,
        B1  B,
        B2  B,
        B3  B,
            B3A  B3,
            B3B  B3,
            B3C  B3,

Syntax to know if duty inherits from another :

A1  A # Return true
A1  B # Return false
!(A1  B) # Return true

@vitornesello your opinion about the syntax ?

@vitornesello
Copy link
Collaborator

vitornesello commented Dec 9, 2019

I don't like too much the arrows. Can we change it to something easy to find in the keyboard? like <= or =>. Also to keep some sort of consistency with dicts

begin and end are missing

@guimarqu
Copy link
Contributor Author

guimarqu commented Dec 9, 2019

I don't like too much the arrows. Can we change it to something easy to find in the keyboard? like <= or =>. Also to keep some sort of consistency with dicts

begin and end are missing

Ok for <=. My first idea was to use <: but it's not possible to overload this operator.
It works without begin and end.

@vitornesello
Copy link
Collaborator

so begin and end are optional?

@guimarqu
Copy link
Contributor Author

guimarqu commented Dec 9, 2019

so begin and end are optional?

Yes because I use commas. Maybe it's better without commas and using a block expression ?

@vitornesello
Copy link
Collaborator

yeah, I prefer the block. It is also more common I think

@guimarqu guimarqu marked this pull request as ready for review December 9, 2019 22:01
@guimarqu guimarqu requested a review from vitornesello December 9, 2019 22:01
@codecov-io
Copy link

codecov-io commented Dec 9, 2019

Codecov Report

Merging #213 into master will increase coverage by 0.22%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #213      +/-   ##
==========================================
+ Coverage      85%   85.22%   +0.22%     
==========================================
  Files          43       44       +1     
  Lines        2620     2659      +39     
==========================================
+ Hits         2227     2266      +39     
  Misses        393      393
Impacted Files Coverage Δ
src/Coluna.jl 100% <ø> (ø) ⬆️
src/containers/nestedenum.jl 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7105b1f...a55c9cb. Read the comment docs.

return
end

function _compute_values!(values, parent_pos, primes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a small comment to this function?


function _compute_values!(values, parent_pos, primes)
for i in 1:length(parent_pos)
factor = 1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it not an Int?

Copy link
Collaborator

@vitornesello vitornesello left a comment

Choose a reason for hiding this comment

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

Would be nice to have a quick explanation saying that internally the macro builds a tree for which the nodes are indexed using prime numbers. And the interest of using prime numbers is to be able to recover all the parents of a given node.
Also, it would be nice to have a comment explaining what is what here : i, names, parent_pos, leaves, primes

     O
   /   \
  O     O
 / \   / \
O   O  O  O

@vitornesello
Copy link
Collaborator

why do you need leaves?

@guimarqu guimarqu merged commit 89d19dd into master Dec 10, 2019
@guimarqu guimarqu deleted the nestedenum branch December 10, 2019 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants