-
Notifications
You must be signed in to change notification settings - Fork 29
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
refactor: Rework parametric types for more flexibility #807
Closed
adigitoleo
wants to merge
2
commits into
GenericMappingTools:master
from
adigitoleo:parametric-types
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
|
||
#[compat] | ||
#Documenter = "~0.25" | ||
GMT = "5752ebe1-31b9-557e-87aa-f909b540aa54" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
using Pkg | ||
Pkg.activate("$(@__DIR__)") | ||
Pkg.update() | ||
|
||
using Documenter, GMT, GMT.Drawing, GMT.Gdal | ||
|
||
makedocs( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,10 @@ | ||
# The GMT.jl types | ||
|
||
Grid type | ||
--------- | ||
```@docs | ||
GMTgrid | ||
GMTimage | ||
GMTdataset | ||
GMTcpt | ||
GMTps | ||
``` | ||
|
||
type GMTgrid{T<:Real,N} <: AbstractArray{T,N} # The type holding a local header and data of a GMT grid | ||
proj4::String # Projection string in PROJ4 syntax (Optional) | ||
wkt::String # Projection string in WKT syntax (Optional) | ||
epsg::Int # EPSG code | ||
range::Array{Float64,1} # 1x6[8] vector with [x_min, x_max, y_min, y_max, z_min, z_max [, v_min, v_max]] | ||
inc::Array{Float64,1} # 1x2[3] vector with [x_inc, y_inc [,v_inc]] | ||
registration::Int # Registration type: 0 -> Grid registration; 1 -> Pixel registration | ||
nodata::Float64 # The value of nodata | ||
title::String # Title (Optional) | ||
comment::String # Remark (Optional) | ||
command::String # Command used to create the grid (Optional) | ||
names::Vector{String} # To use whith multi-layered and when layers have names (Optional) | ||
x::Array{Float64,1} # [1 x n_columns] vector with XX coordinates | ||
y::Array{Float64,1} # [1 x n_rows] vector with YY coordinates | ||
v::Array{Float64,1} # [v x n_bands] vector with VV (vertical for 3D grids) coordinates | ||
z::Array{Float32,2} # [n_rows x n_columns] grid array | ||
x_units::String # Units of XX axis (Optional) | ||
y_units::String # Units of YY axis (Optional) | ||
v_units::String # Units of Vertical axis (Optional) | ||
z_units::String # Units of z vlues (Optional) | ||
layout::String # A three character string describing the grid memory layout | ||
scale::Union{Float64, Float32} # When saving in file apply `z = z * scale + offset` | ||
offset::Union{Float64, Float32} | ||
pad::Int # When != 0 means that the array is placed in a padded array of PAD rows/cols | ||
end | ||
|
||
Image type | ||
---------- | ||
|
||
type GMTimage{T<:Unsigned, N} <: AbstractArray{T,N} # The type holding a local header and data of a GMT image | ||
proj4::String # Projection string in PROJ4 syntax (Optional) | ||
wkt::String # Projection string in WKT syntax (Optional) | ||
epsg::Int # EPSG code | ||
range::Array{Float64,1} # 1x6 vector with [x_min x_max y_min y_max z_min z_max] | ||
inc::Array{Float64,1} # 1x2 vector with [x_inc y_inc] | ||
registration::Int # Registration type: 0 -> Grid registration; 1 -> Pixel registration | ||
nodata::Unsigned # The value of nodata | ||
color_interp::String # If equal to "Gray" an indexed image with no cmap will get a gray cmap | ||
metadata::Vector{String} # To store any metadata that can eventually be passed to GDAL (Optional) | ||
names::Vector{String} # To use whith multi-band and when bands have names (Optional) | ||
x::Array{Float64,1} # [1 x n_columns] vector with XX coordinates | ||
y::Array{Float64,1} # [1 x n_rows] vector with YY coordinates | ||
v::Array{Float64,1} # [v x n_bands] vector with vertical coords or wavelengths in hypercubes (Optional) | ||
image::Array{T,N} # [n_rows x n_columns x n_bands] image array | ||
colormap::Array{Int32,1} # | ||
alpha::Array{UInt8,2} # A [n_rows x n_columns] alpha array | ||
layout::String # A four character string describing the image memory layout | ||
pad::Int # When != 0 means that the array is placed in a padded array of PAD rows/cols | ||
end | ||
|
||
Dataset type | ||
------------ | ||
|
||
type GMTdataset{T<:Real, N} <: AbstractArray{T,N} | ||
data::Array{T,N} # Mx2 Matrix with segment data | ||
ds_bbox::Vector{Float64} # Global BoundingBox (for when there are many segments) | ||
bbox::Vector{Float64} # Segment BoundingBox | ||
attrib::Dict{String, String} # Dictionary with attributes/values (optional) | ||
colnames::Vector{String} # Column names. Antecipate using this with a future Tables inerface | ||
text::Vector{String} # Array with text after data coordinates (mandatory only when plotting Text) | ||
header::String # String with segment header (Optional but sometimes very useful) | ||
comment::Vector{String} # Array with any dataset comments [empty after first segment] | ||
proj4::String # Projection string in PROJ4 syntax (Optional) | ||
wkt::String # Projection string in WKT syntax (Optional) | ||
geom::Integer # Geometry type. One of the GDAL's enum (wkbPoint, wkbPolygon, etc...) | ||
end | ||
|
||
CPT type | ||
-------- | ||
|
||
type GMTcpt | ||
colormap::Array{Float64,2} | ||
alpha::Array{Float64,1} | ||
range::Array{Float64,2} | ||
minmax::Array{Float64,1} | ||
bfn::Array{Float64,2} | ||
depth::Cint | ||
hinge::Cdouble | ||
cpt::Array{Float64,2} | ||
label::Vector{String} # Labels of a Categorical CPT | ||
key::Vector{String} # Keys of a Categorical CPT | ||
model::String | ||
comment::Array{Any,1} # Cell array with any comments | ||
end | ||
|
||
Postscript type | ||
--------------- | ||
|
||
type GMTps | ||
postscript::String # Actual PS plot (text string) | ||
length::Int # Byte length of postscript | ||
mode::Int # 1 = Has header, 2 = Has trailer, 3 = Has both | ||
comment::Array{Any,1} # Cell array with any comments | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this would loose the descriptions of each field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should, from this commit you can run
julia --project
and in the REPL do a?GMTgrid
. This shows the fields as I have added to the source docstrings, e.g. https://github.com/GenericMappingTools/GMT.jl/pull/807/files/8699804706c9979b804e20ad82be0787f98cd972#diff-f757a5fd59739f474cf66fd576eab2d7099ebc0bd28dda3ad57e92bfa6ca7829R1-R32I'm pretty sure that documenter shows the same information, and also now they are accessible via REPL help.
OH I think I see what you mean now, we lose the default output of e.g.
?GMTgrid
:I still think the version with descriptions is more valuable. The other option is to document each field and use DocStringExtensions to automatically merge the field docstrings into the type docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having field descriptions on REPL would be nice but no big deal. Before there no description at all of the type.
And I missed to see that you had added docstrings in
gmt_main.jl
, hence my previous comment.