Skip to content

Commit b26c243

Browse files
authored
Create a prettytable alias, which is the one that is now exported. (#1798)
Do this to avoid conflicts when the PrettyTables package is loaded.
1 parent e93760e commit b26c243

13 files changed

Lines changed: 96 additions & 104 deletions

src/GMT.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ export
202202
Date, DateTime, Year, Month, Week, Day, Hour, Minute, Second, year, month, week, day, hour, minute, second, now, today,
203203
bissextile,
204204

205+
prettytable,
206+
205207
@?, @G, @dir
206208

207209
include("common_docs.jl")

src/PrettyTables.jl

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# and no longer need a > 10 MB PT precomp cache DLL.
88
############################################################################################
99

10-
export pretty_table
10+
#export pretty_table
1111

1212
#const _REGEX_ANSI_SEQUENCES = r"\x1B(?:]8;;[^\x1B]*\x1B\\|[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])"
1313

@@ -294,6 +294,8 @@ function pretty_table(@nospecialize(io::IO), @nospecialize(data::Any); header::U
294294
return _print_table(io, pdata; header = pheader, kwargs...)
295295
end
296296

297+
const prettytable = pretty_table # Alias
298+
297299
# --------------------------------------------------------------------------------
298300
@kwdef struct TextFormat
299301
up_right_corner::Char = ''
@@ -1040,13 +1042,7 @@ function _check_hline(ptable::ProcessedTable, hlines::Vector{Int}, body_hlines::
10401042
end
10411043

10421044
function _check_hline(ptable::ProcessedTable, hlines::Symbol, body_hlines::AbstractVector, i::Int)
1043-
if hlines == :all
1044-
return true
1045-
elseif hlines == :none
1046-
return _check_hline(ptable, Int[], body_hlines, i)
1047-
else
1048-
error("`hlines` must be `:all`, `:none`, or a vector of integers.")
1049-
end
1045+
return (hlines == :all) ? true : (hlines == :none) ? _check_hline(ptable, Int[], body_hlines, i) : error("`hlines` must be `:all`, `:none`, or a vector of integers.")
10501046
end
10511047

10521048
function _check_vline(ptable::ProcessedTable, vlines::AbstractVector, j::Int)
@@ -1064,13 +1060,7 @@ function _check_vline(ptable::ProcessedTable, vlines::AbstractVector, j::Int)
10641060
end
10651061

10661062
function _check_vline(ptable::ProcessedTable, vlines::Symbol, j::Int)
1067-
if vlines == :all
1068-
return true
1069-
elseif vlines == :none
1070-
return false
1071-
else
1072-
error("`vlines` must be `:all`, `:none`, or a vector of integers.")
1073-
end
1063+
return (vlines == :all) ? true : (vlines == :none) ? false : error("`vlines` must be `:all`, `:none`, or a vector of integers.")
10741064
end
10751065

10761066
function _count_hlines(ptable::ProcessedTable, hlines::Vector{Int}, body_hlines::Vector{Int})
@@ -2551,8 +2541,7 @@ function _print_custom_text_cell!(display::Display, cell_data::CustomTextCell, c
25512541
# Write it to the display.
25522542
_write_to_display!(display, rendered_str, suffix, new_lstr + textwidth(suffix))
25532543

2554-
# Print the padding character after the cell and return if the display has reached
2555-
# end-of-line.
2544+
# Print the padding character after the cell and return if the display has reached end-of-line.
25562545
return _p!(display, " ", false, 1)
25572546
end
25582547

@@ -2805,9 +2794,8 @@ function ProcessedTable(data::Any, header::Any;
28052794
elseif show_header
28062795
num_header_columns = length(first(header))
28072796

2808-
if num_data_columns != num_header_columns
2797+
(num_data_columns != num_header_columns) &&
28092798
error("The number of columns in the header ($num_header_columns) must be equal to that of the table ($num_data_columns).")
2810-
end
28112799

28122800
num_header_rows = show_subheader ? length(header) : 1
28132801
end

src/proj_utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,9 @@ function helper_geoglimits(prj::String, region::Vector{Float64})::Vector{Float64
10161016
Gdal.CPLPushErrorHandler(@cfunction(Gdal.CPLQuietErrorHandler, Cvoid, (UInt32, Cint, Cstring)))
10171017
opts = ["-s_srs", prj, "-t_srs", prj4WGS84, "-overwrite"]
10181018
ds = Gdal.get_gdaldataset([region[1] region[3]], opts, false)[1]
1019-
o1 = Gdal.gdalvectortranslate(ds, opts; dest="/vsimem/tmp", gdataset=true)
1019+
o1 = Gdal.gdalvectortranslate(ds, opts; dest="/vsimem/tmp", gdataset=true)::GMT.Gdal.IDataset
10201020
ds = Gdal.get_gdaldataset([region[2] region[4]], opts, false)[1]
1021-
o2 = Gdal.gdalvectortranslate(ds, opts; dest="/vsimem/tmp", gdataset=true)
1021+
o2 = Gdal.gdalvectortranslate(ds, opts; dest="/vsimem/tmp", gdataset=true)::GMT.Gdal.IDataset
10221022
if (o1.ptr == C_NULL || o2.ptr == C_NULL) # Diagonals failed, probably a Mollweide or alike projection
10231023
t = xy2lonlat([region[1] min(0,region[4]); region[2] min(0,region[4]);
10241024
0 region; 0 region], s_srs=prj, t_srs=prj4WGS84)

src/spatial_funs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ end
346346
See `? getbyattrib`
347347
"""
348348
Base.:filter(D::Vector{<:GMTdataset}; kw...) = getbyattrib(D; kw...)
349+
349350
# ---------------------------------------------------------------------------------------------------
350351
"""
351352
findall(D::Vector{<:GMTdataset}; kw...)

src/utils_types.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ does not need explicit coordinates to place the text.
6767
- `segnan` or `nanseg`: Boolean. If true make a multi-segment made out of segments separated by NaNs.
6868
- `datatype`: Keep the original data type of `mat`. Default converts to Float64.
6969
- `geom`: The data geometry. By default, we set `wkbUnknown` but try to do some basic guess.
70-
- `proj` or `proj4`: A proj4 string for dataset SRS.
71-
- `wkt`: A WKT SRS.
70+
- `proj` or `proj4`: A proj4 string for dataset SRS. Default is empty. To set it to lon,lat in WGS84 use ``proj=prj4WGS84``
71+
- `wkt`: A WKT SRS string.
72+
- `epsg`: An integer EPSG code. _e.g._ ``epsg=4326`` for lon,lat in WGS84. Default is 0.
7273
- `colnames`: Optional string vector with names for each column of `mat`.
7374
- `attrib`: Optional dictionary{String, String} with attributes of this dataset.
7475
- `ref:` Pass in a reference GMTdataset from which we'll take the georeference info as well as `attrib` and `colnames`

test/test_PT_alignments.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data = Any[1 false 1.0 0x01 ;
2626
│ 6 │ true │ 6.0 │ 6 │
2727
└────────┴────────┴────────┴────────┘
2828
"""
29-
result = pretty_table(String, data; alignment = :l)
29+
result = prettytable(String, data; alignment = :l)
3030
@test result == expected
3131

3232
# == Center ============================================================================
@@ -42,7 +42,7 @@ data = Any[1 false 1.0 0x01 ;
4242
│ 6 │ true │ 6.0 │ 6 │
4343
└────────┴────────┴────────┴────────┘
4444
"""
45-
result = pretty_table(String, data; alignment = :c)
45+
result = prettytable(String, data; alignment = :c)
4646
@test result == expected
4747

4848
# == Per Column Configuration ==========================================================
@@ -59,7 +59,7 @@ data = Any[1 false 1.0 0x01 ;
5959
│ 6 │ true │ 6.0 │ 6 │
6060
└────────┴────────┴────────┴────────┘
6161
"""
62-
result = pretty_table(String, data; alignment = [:l, :r, :c, :r])
62+
result = prettytable(String, data; alignment = [:l, :r, :c, :r])
6363
@test result == expected
6464

6565
# == Cell Override =====================================================================
@@ -76,7 +76,7 @@ data = Any[1 false 1.0 0x01 ;
7676
│ 6 │ true │ 6.0 │ 6 │
7777
└────────┴────────┴────────┴────────┘
7878
"""
79-
result = pretty_table(
79+
result = prettytable(
8080
String,
8181
data;
8282
alignment = [:l, :r, :c, :r],
@@ -110,7 +110,7 @@ data = Any[1 false 1.0 0x01 ;
110110
└───────────┴───────────┴───────────┴───────────┘
111111
"""
112112

113-
result = pretty_table(
113+
result = prettytable(
114114
String,
115115
data;
116116
header = header,
@@ -142,7 +142,7 @@ data = Any[1 false 1.0 0x01 ;
142142
└───────────┴───────────┴───────────┴───────────┘
143143
"""
144144

145-
result = pretty_table(
145+
result = prettytable(
146146
String, data;
147147
header = header,
148148
alignment = [:l, :r, :c, :r],
@@ -183,15 +183,15 @@ end
183183
└────────────┴────────────┴──────────────┴──────────────┴────────────────┴────────────────┴────────────────┘
184184
"""
185185

186-
result = pretty_table(
186+
result = prettytable(
187187
String,
188188
matrix;
189189
alignment_anchor_regex = Dict(0 => [r"\."])
190190
)
191191

192192
@test result == expected
193193

194-
result = pretty_table(
194+
result = prettytable(
195195
String,
196196
matrix;
197197
alignment_anchor_regex = Dict(i => [r"\."] for i in 1:7)
@@ -213,7 +213,7 @@ end
213213
└───────────┴───────────┴─────────────┴─────────────┴───────────────┴───────────────┴───────────────┘
214214
"""
215215

216-
result = pretty_table(
216+
result = prettytable(
217217
String,
218218
matrix;
219219
alignment_anchor_regex = Dict(0 => [r"\.", r"^"])
@@ -237,7 +237,7 @@ end
237237
└─────┴─────────┴─────────┴─────────┴─────────────┴──────────┴──────────┴──────────┘
238238
"""
239239

240-
result = pretty_table(
240+
result = prettytable(
241241
String,
242242
matrix,
243243
alignment_anchor_regex = Dict(4 => [r"\.", r"^"]),
@@ -260,7 +260,7 @@ end
260260
└─────┴───┴─────────┴─────────┴─────────┴─────────────┴──────────┴──────────┴──────────┘
261261
"""
262262

263-
result = pretty_table(
263+
result = prettytable(
264264
String,
265265
matrix,
266266
alignment_anchor_regex = Dict(4 => [r"\.", r"^"]),
@@ -286,7 +286,7 @@ end
286286
└─────────┴─────────┴─────────┴──────────────────────┴──────────┴──────────┴──────────┘
287287
"""
288288

289-
result = pretty_table(
289+
result = prettytable(
290290
String,
291291
matrix;
292292
alignment_anchor_regex = Dict(4 => [r"\.", r"^"]),
@@ -309,7 +309,7 @@ end
309309
└─────────┴─────────┴─────────┴──────────────────────┴──────────┴──────────┴──────────┘
310310
"""
311311

312-
result = pretty_table(
312+
result = prettytable(
313313
String,
314314
matrix;
315315
alignment = :c,
@@ -333,7 +333,7 @@ end
333333
└─────────┴─────────┴─────────┴──────────────────────┴──────────┴──────────┴──────────┘
334334
"""
335335

336-
result = pretty_table(
336+
result = prettytable(
337337
String,
338338
matrix;
339339
alignment = :l,
@@ -359,7 +359,7 @@ end
359359
└─────────────────┴─────────────────┴─────────────────┴─────────────────┴─────────────────┴─────────────────┴─────────────────┘
360360
"""
361361

362-
result = pretty_table(
362+
result = prettytable(
363363
String,
364364
matrix;
365365
alignment_anchor_regex = Dict(4 => [r"\.", r"^"]),
@@ -382,7 +382,7 @@ end
382382
└─────────┴─────────┴─────────┴────────────┴──────────┴──────────┴──────────┘
383383
"""
384384

385-
result = pretty_table(
385+
result = prettytable(
386386
String,
387387
matrix;
388388
alignment_anchor_regex = Dict(4 => [r"\.", r"^"]),
@@ -407,7 +407,7 @@ end
407407
└──────────┴──────────┴───────────┴──────────┴────────────┴────────────┴────────────┘
408408
"""
409409

410-
result = pretty_table(
410+
result = prettytable(
411411
String,
412412
matrix;
413413
alignment_anchor_regex = Dict(i => [r"\."] for i in 1:7),
@@ -430,7 +430,7 @@ end
430430
└──────────────┴──────────────┴──────────────┴─────────────┴────────────┴───────────┴─────────────┘
431431
"""
432432

433-
result = pretty_table(
433+
result = prettytable(
434434
String,
435435
matrix;
436436
alignment_anchor_regex = Dict(i => [r"\."] for i in 1:7),
@@ -453,7 +453,7 @@ end
453453
└────────────┴──────────┴──────────────┴─────────────┴────────────────┴────────────────┴────────────────┘
454454
"""
455455

456-
result = pretty_table(
456+
result = prettytable(
457457
String,
458458
matrix;
459459
alignment_anchor_regex = Dict(0 => [r"\."]),
@@ -476,7 +476,7 @@ end
476476
└──────────┴──────────┴───────────┴─────────────┴────────────────┴────────────┴────────────┘
477477
"""
478478

479-
result = pretty_table(
479+
result = prettytable(
480480
String,
481481
matrix;
482482
alignment_anchor_regex = Dict(0 => [r"\."]),
@@ -502,7 +502,7 @@ end
502502
└─────┴──────────┴──────────┴───────────┴─────────────┴────────────────┴────────────┴────────────┘
503503
"""
504504

505-
result = pretty_table(
505+
result = prettytable(
506506
String,
507507
matrix;
508508
alignment_anchor_regex = Dict(0 => [r"\."]),
@@ -527,7 +527,7 @@ end
527527
└───────┴──────────┴──────────┴───────────┴─────────────┴────────────────┴────────────┴────────────┘
528528
"""
529529

530-
result = pretty_table(
530+
result = prettytable(
531531
String,
532532
matrix;
533533
alignment_anchor_regex = Dict(0 => [r"\."]),

test/test_PT_column_width.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ data = Any[1 false 1.0 0x01 ;
3030
└──────┴───────┴──────┴──────┘
3131
"""
3232

33-
result = pretty_table(
33+
result = prettytable(
3434
String,
3535
data;
3636
header = header,
@@ -53,7 +53,7 @@ data = Any[1 false 1.0 0x01 ;
5353
└────┴────┴────┴────┘
5454
"""
5555

56-
result = pretty_table(
56+
result = prettytable(
5757
String,
5858
data;
5959
header = header,
@@ -77,7 +77,7 @@ data = Any[1 false 1.0 0x01 ;
7777
└────┴───────┴────────┴──────────┘
7878
"""
7979

80-
result = pretty_table(
80+
result = prettytable(
8181
String,
8282
data;
8383
header = header,
@@ -100,7 +100,7 @@ data = Any[1 false 1.0 0x01 ;
100100
└──────────┴──────────┴──────────┴──────────┘
101101
"""
102102

103-
result = pretty_table(
103+
result = prettytable(
104104
String,
105105
data;
106106
header = header,
@@ -124,7 +124,7 @@ data = Any[1 false 1.0 0x01 ;
124124
└───┴─────┴─────┴───┘
125125
"""
126126

127-
result = pretty_table(
127+
result = prettytable(
128128
String,
129129
data;
130130
header = header,
@@ -147,7 +147,7 @@ data = Any[1 false 1.0 0x01 ;
147147
└───┴────┴─────┴──────┘
148148
"""
149149

150-
result = pretty_table(
150+
result = prettytable(
151151
String,
152152
data;
153153
header = header,
@@ -171,7 +171,7 @@ data = Any[1 false 1.0 0x01 ;
171171
└───┴─────┴────┴───┘
172172
"""
173173

174-
result = pretty_table(
174+
result = prettytable(
175175
String,
176176
data;
177177
header = header,
@@ -194,7 +194,7 @@ data = Any[1 false 1.0 0x01 ;
194194
└─────┴─────┴─────┴─────┘
195195
"""
196196

197-
result = pretty_table(
197+
result = prettytable(
198198
String,
199199
data;
200200
header = header,

0 commit comments

Comments
 (0)