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

Options cleanup. #61

Merged
merged 6 commits into from
Feb 13, 2018
Merged

Options cleanup. #61

merged 6 commits into from
Feb 13, 2018

Conversation

tpapp
Copy link
Collaborator

@tpapp tpapp commented Feb 9, 2018

  • intoduce a type alias, making code lines significantly shorter.

  • this also serves as a default constructor, since {Any, Any} are the default parameters

  • move all options-related code to a single file (no substantial changes otherwise)

  • add a few docstrings, especially @pgf

- intoduce a type alias, making code lines significantly shorter.

- this also serves as a default constructor, since {Any, Any} are the
  default parameters

- move all options-related code to a single file (no substantial
  changes otherwise)

- add a few docstrings, especially @pgf
@codecov-io
Copy link

codecov-io commented Feb 9, 2018

Codecov Report

Merging #61 into master will not change coverage.
The diff coverage is 75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #61   +/-   ##
=======================================
  Coverage   77.75%   77.75%           
=======================================
  Files           8        9    +1     
  Lines         472      472           
=======================================
  Hits          367      367           
  Misses        105      105
Impacted Files Coverage Δ
src/utilities.jl 92.85% <ø> (+0.4%) ⬆️
src/PGFPlotsX.jl 82.35% <ø> (+24.01%) ⬆️
src/tikzpicture.jl 91.66% <0%> (ø) ⬆️
src/tikzdocument.jl 55% <0%> (ø) ⬆️
src/axiselements.jl 91.39% <100%> (ø) ⬆️
src/axislike.jl 78.12% <50%> (ø) ⬆️
src/options.jl 78.26% <78.26%> (ø)

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 43458c7...79be436. Read the comment docs.

src/options.jl Outdated
Contents emitted in `key = value` form, or `key` when `value ≡ nothing`. Also
see the [`@pgf`](@ref) convenience macro.
"""
const Options = OrderedDict
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't this be OrderedDict{Any, Any} for it to be concrete?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't understand what the advantage of it being concrete would be, can you please clarify?

This way I can use it for both the constructor (empty Options()) and dispatch. Perhaps I should use an UnionAll type explicitly?

Copy link
Owner

Choose a reason for hiding this comment

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

It probably doesn't matter. Would save dynamic dispatch when accessing the options field but it shouldn't really have any relevance.

Copy link
Owner

Choose a reason for hiding this comment

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

But I don't understand why you couldn't use it for a constructor and dispatch even if it was concrete?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since in the original code some methods were dispatched on ::OrderedDict, I thought that the implicit expectation was that we would take any <: OrderedDict, hence the UnionAll type.

If that's not required, I can make it concrete, no problem.

Copy link
Owner

Choose a reason for hiding this comment

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

I think they will always be {Any, Any}.

Copy link
Owner

Choose a reason for hiding this comment

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

At least if we use the Option type everywhere, they will be by construction.

src/options.jl Outdated
`key = value`, `key : value`, or `key => value` pairs enclosed in `{ ... }`,
anywhere in the expression.

Multi-word keys need to be quoted.
Copy link
Owner

Choose a reason for hiding this comment

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

Actually, you can use e.g. only_marks for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@tpapp
Copy link
Collaborator Author

tpapp commented Feb 13, 2018

I thought about it and think that the cleanest solution would be that instead of an alias, to have a thin wrapper

struct Options
    options::OrderedDict{Any, Any}
end

with neat show etc methods, and not expose that this is an OrderedDict anywhere to the user. What do you think? I think I can do a clean rebase after #62 is merged.

@KristofferC
Copy link
Owner

Could do that. Not sure how much it matters, the OrderedDict is never really exposed to a user as it is, right now.

@tpapp
Copy link
Collaborator Author

tpapp commented Feb 13, 2018

OK, made it concrete, will shelve the options wrapper for another day, so I am ready to merge; should I wait for #62? They look very orthogonal and I think it will be clean in any order.

@KristofferC
Copy link
Owner

Rebased with online editor... let's see if I made it.

@KristofferC
Copy link
Owner

Nope, failed. Should work now.

@test pgf.Table(x, y, z) ≅ pgf.Table(pgf.Options(),
hcat(pgf.matrix_xyz(x, y, z)...),
@test Table(x, y, z) ≅ Table(PGFPlotsX.Options(),
hcat(PGFPlotsX..matrix_xyz(x, y, z)...),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

looks like an extra . here

Copy link
Owner

@KristofferC KristofferC Feb 13, 2018

Choose a reason for hiding this comment

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

Aaargh, it is impossible to use the online editor. Never again.

hopefully this runs now
@tpapp tpapp merged commit dd09bcb into master Feb 13, 2018
@tpapp tpapp deleted the tp/options-reorg branch February 13, 2018 11:03
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