Skip to content

Commit cfeaf67

Browse files
committed
Remove underscores from BoolsAsTypes
1 parent 7da7f60 commit cfeaf67

File tree

22 files changed

+69
-69
lines changed

22 files changed

+69
-69
lines changed

GeometryOpsCore/src/apply.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ end
126126
@inline function apply(
127127
f::F, target, geom; calc_extent=false, threaded=false, kw...
128128
) where F
129-
threaded = _booltype(threaded)
130-
calc_extent = _booltype(calc_extent)
129+
threaded = booltype(threaded)
130+
calc_extent = booltype(calc_extent)
131131
_apply(f, TraitTarget(target), geom; threaded, calc_extent, kw...)
132132
end
133133

@@ -139,7 +139,7 @@ end
139139
# For an Array there is nothing else to do but map `_apply` over all values
140140
# _maptasks may run this level threaded if `threaded==true`,
141141
# but deeper `_apply` called in the closure will not be threaded
142-
apply_to_array(i) = _apply(f, target, A[i]; threaded=_False(), kw...)
142+
apply_to_array(i) = _apply(f, target, A[i]; threaded=False(), kw...)
143143
_maptasks(apply_to_array, eachindex(A), threaded)
144144
end
145145
# There is no trait and this is not an AbstractArray.
@@ -150,7 +150,7 @@ end
150150
if Tables.istable(iterable)
151151
_apply_table(f, target, iterable; threaded, kw...)
152152
else # this is probably some form of iterable...
153-
if threaded isa _True
153+
if threaded isa True
154154
# `collect` first so we can use threads
155155
_apply(f, target, collect(iterable); threaded, kw...)
156156
else
@@ -226,14 +226,14 @@ end
226226
# Rewrap all FeatureCollectionTrait feature collections as GI.FeatureCollection
227227
# Maybe use threads to call _apply on component features
228228
@inline function _apply(f::F, target, ::GI.FeatureCollectionTrait, fc;
229-
crs=GI.crs(fc), calc_extent=_False(), threaded
229+
crs=GI.crs(fc), calc_extent=False(), threaded
230230
) where F
231231

232232
# Run _apply on all `features` in the feature collection, possibly threaded
233233
apply_to_feature(i) =
234-
_apply(f, target, GI.getfeature(fc, i); crs, calc_extent, threaded=_False())::GI.Feature
234+
_apply(f, target, GI.getfeature(fc, i); crs, calc_extent, threaded=False())::GI.Feature
235235
features = _maptasks(apply_to_feature, 1:GI.nfeature(fc), threaded)
236-
if calc_extent isa _True
236+
if calc_extent isa True
237237
# Calculate the extent of the features
238238
extent = mapreduce(GI.extent, Extents.union, features)
239239
# Return a FeatureCollection with features, crs and calculated extent
@@ -245,13 +245,13 @@ end
245245
end
246246
# Rewrap all FeatureTrait features as GI.Feature, keeping the properties
247247
@inline function _apply(f::F, target, ::GI.FeatureTrait, feature;
248-
crs=GI.crs(feature), calc_extent=_False(), threaded
248+
crs=GI.crs(feature), calc_extent=False(), threaded
249249
) where F
250250
# Run _apply on the contained geometry
251251
geometry = _apply(f, target, GI.geometry(feature); crs, calc_extent, threaded)
252252
# Get the feature properties
253253
properties = GI.properties(feature)
254-
if calc_extent isa _True
254+
if calc_extent isa True
255255
# Calculate the extent of the geometry
256256
extent = GI.extent(geometry)
257257
# Return a new Feature with the new geometry and calculated extent, but the original properties and crs
@@ -264,36 +264,36 @@ end
264264
# Reconstruct nested geometries,
265265
# maybe using threads to call _apply on component geoms
266266
@inline function _apply(f::F, target, trait, geom;
267-
crs=GI.crs(geom), calc_extent=_False(), threaded
267+
crs=GI.crs(geom), calc_extent=False(), threaded
268268
)::(GI.geointerface_geomtype(trait)) where F
269269
# Map `_apply` over all sub geometries of `geom`
270270
# to create a new vector of geometries
271271
# TODO handle zero length
272-
apply_to_geom(i) = _apply(f, target, GI.getgeom(geom, i); crs, calc_extent, threaded=_False())
272+
apply_to_geom(i) = _apply(f, target, GI.getgeom(geom, i); crs, calc_extent, threaded=False())
273273
geoms = _maptasks(apply_to_geom, 1:GI.ngeom(geom), threaded)
274274
return _apply_inner(geom, geoms, crs, calc_extent)
275275
end
276276
@inline function _apply(f::F, target::TraitTarget{<:PointTrait}, trait::GI.PolygonTrait, geom;
277-
crs=GI.crs(geom), calc_extent=_False(), threaded
277+
crs=GI.crs(geom), calc_extent=False(), threaded
278278
)::(GI.geointerface_geomtype(trait)) where F
279279
# We need to force rebuilding a LinearRing not a LineString
280280
geoms = _maptasks(1:GI.ngeom(geom), threaded) do i
281281
lr = GI.getgeom(geom, i)
282282
points = map(GI.getgeom(lr)) do p
283-
_apply(f, target, p; crs, calc_extent, threaded=_False())
283+
_apply(f, target, p; crs, calc_extent, threaded=False())
284284
end
285285
_linearring(_apply_inner(lr, points, crs, calc_extent))
286286
end
287287
return _apply_inner(geom, geoms, crs, calc_extent)
288288
end
289-
function _apply_inner(geom, geoms, crs, calc_extent::_True)
289+
function _apply_inner(geom, geoms, crs, calc_extent::True)
290290
# Calculate the extent of the sub geometries
291291
extent = mapreduce(GI.extent, Extents.union, geoms)
292292
# Return a new geometry of the same trait as `geom`,
293293
# holding the new `geoms` with `crs` and calculated extent
294294
return rebuild(geom, geoms; crs, extent)
295295
end
296-
function _apply_inner(geom, geoms, crs, calc_extent::_False)
296+
function _apply_inner(geom, geoms, crs, calc_extent::False)
297297
# Return a new geometry of the same trait as `geom`, holding the new `geoms` with `crs`
298298
return rebuild(geom, geoms; crs)
299299
end
@@ -322,7 +322,7 @@ using Base.Threads: nthreads, @threads, @spawn
322322
# Threading utility, modified Mason Protters threading PSA
323323
# run `f` over ntasks, where f receives an AbstractArray/range
324324
# of linear indices
325-
@inline function _maptasks(f::F, taskrange, threaded::_True)::Vector where F
325+
@inline function _maptasks(f::F, taskrange, threaded::True)::Vector where F
326326
ntasks = length(taskrange)
327327
# Customize this as needed.
328328
# More tasks have more overhead, but better load balancing
@@ -349,6 +349,6 @@ to lookup through the closure. This alone makes e.g. `flip` 2.5x faster!
349349
But it caused inference to fail, so we've removed it. No effect on runtime so far as we can tell,
350350
at least in Julia 1.11.
351351
=#
352-
@inline function _maptasks(f::F, taskrange, threaded::_False)::Vector where F
352+
@inline function _maptasks(f::F, taskrange, threaded::False)::Vector where F
353353
map(f, taskrange)
354354
end

GeometryOpsCore/src/applyreduce.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ feature collections and nested geometries.
3434
@inline function applyreduce(
3535
f::F, op::O, target, geom; threaded=false, init=nothing
3636
) where {F, O}
37-
threaded = _booltype(threaded)
37+
threaded = booltype(threaded)
3838
_applyreduce(f, op, TraitTarget(target), geom; threaded, init)
3939
end
4040

4141
@inline _applyreduce(f::F, op::O, target, geom; threaded, init) where {F, O} =
4242
_applyreduce(f, op, target, GI.trait(geom), geom; threaded, init)
4343
# Maybe use threads reducing over arrays
4444
@inline function _applyreduce(f::F, op::O, target, ::Nothing, A::AbstractArray; threaded, init) where {F, O}
45-
applyreduce_array(i) = _applyreduce(f, op, target, A[i]; threaded=_False(), init)
45+
applyreduce_array(i) = _applyreduce(f, op, target, A[i]; threaded=False(), init)
4646
_mapreducetasks(applyreduce_array, op, eachindex(A), threaded; init)
4747
end
4848
# Try to applyreduce over iterables
4949
@inline function _applyreduce(f::F, op::O, target, ::Nothing, iterable::IterableType; threaded, init) where {F, O, IterableType}
5050
if Tables.istable(iterable)
5151
_applyreduce_table(f, op, target, iterable; threaded, init)
5252
else
53-
applyreduce_iterable(i) = _applyreduce(f, op, target, i; threaded=_False(), init)
54-
if threaded isa _True # Try to `collect` and reduce over the vector with threads
53+
applyreduce_iterable(i) = _applyreduce(f, op, target, i; threaded=False(), init)
54+
if threaded isa True # Try to `collect` and reduce over the vector with threads
5555
_applyreduce(f, op, target, collect(iterable); threaded, init)
5656
else
5757
# Try to `mapreduce` the iterable as-is
@@ -77,23 +77,23 @@ function _applyreduce_table(f::F, op::O, target::GI.FeatureTrait, iterable::Iter
7777
end
7878
# Maybe use threads reducing over features of feature collections
7979
@inline function _applyreduce(f::F, op::O, target, ::GI.FeatureCollectionTrait, fc; threaded, init) where {F, O}
80-
applyreduce_fc(i) = _applyreduce(f, op, target, GI.getfeature(fc, i); threaded=_False(), init)
80+
applyreduce_fc(i) = _applyreduce(f, op, target, GI.getfeature(fc, i); threaded=False(), init)
8181
_mapreducetasks(applyreduce_fc, op, 1:GI.nfeature(fc), threaded; init)
8282
end
8383
# Features just applyreduce to their geometry
8484
@inline _applyreduce(f::F, op::O, target, ::GI.FeatureTrait, feature; threaded, init) where {F, O} =
8585
_applyreduce(f, op, target, GI.geometry(feature); threaded, init)
8686
# Maybe use threads over components of nested geometries
8787
@inline function _applyreduce(f::F, op::O, target, trait, geom; threaded, init) where {F, O}
88-
applyreduce_geom(i) = _applyreduce(f, op, target, GI.getgeom(geom, i); threaded=_False(), init)
88+
applyreduce_geom(i) = _applyreduce(f, op, target, GI.getgeom(geom, i); threaded=False(), init)
8989
_mapreducetasks(applyreduce_geom, op, 1:GI.ngeom(geom), threaded; init)
9090
end
9191
# Don't thread over points it won't pay off
9292
@inline function _applyreduce(
9393
f::F, op::O, target, trait::Union{GI.LinearRing,GI.LineString,GI.MultiPoint}, geom;
9494
threaded, init
9595
) where {F, O}
96-
_applyreduce(f, op, target, GI.getgeom(geom); threaded=_False(), init)
96+
_applyreduce(f, op, target, GI.getgeom(geom); threaded=False(), init)
9797
end
9898
# Apply f to the target
9999
@inline function _applyreduce(f::F, op::O, ::TraitTarget{Target}, ::Trait, x; kw...) where {F,O,Target,Trait<:Target}
@@ -124,7 +124,7 @@ import Base.Threads: nthreads, @threads, @spawn
124124
#
125125
# If you absolutely need a single chunk, then `threaded = false` will always decompose
126126
# to straight `mapreduce` without grouping.
127-
@inline function _mapreducetasks(f::F, op, taskrange, threaded::_True; init) where F
127+
@inline function _mapreducetasks(f::F, op, taskrange, threaded::True; init) where F
128128
ntasks = length(taskrange)
129129
# Customize this as needed.
130130
# More tasks have more overhead, but better load balancing
@@ -144,6 +144,6 @@ import Base.Threads: nthreads, @threads, @spawn
144144
# Finally we join the results into a new vector
145145
return mapreduce(fetch, op, tasks; init)
146146
end
147-
Base.@assume_effects :foldable function _mapreducetasks(f::F, op, taskrange, threaded::_False; init) where F
147+
Base.@assume_effects :foldable function _mapreducetasks(f::F, op, taskrange, threaded::False; init) where F
148148
mapreduce(f, op, taskrange; init)
149149
end

GeometryOpsCore/src/types.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Currently, those circumstances are `area` and `segmentize`, but this could be ex
2222

2323
export Planar, Spherical, Geodesic
2424
export TraitTarget
25-
export BoolsAsTypes, _True, _False, _booltype
25+
export BoolsAsTypes, True, False, booltype
2626

2727
"""
2828
abstract type Manifold
@@ -130,7 +130,7 @@ the compiler to separate threaded and non-threaded code paths.
130130
Note that if we didn't include the parent abstract type, this would have been really
131131
type unstable, since the compiler couldn't tell what would be returned!
132132
133-
We had to add the type annotation on the `_booltype(::Bool)` method for this reason as well.
133+
We had to add the type annotation on the `booltype(::Bool)` method for this reason as well.
134134
135135
TODO: should we switch to `Static.jl`?
136136
=#
@@ -142,25 +142,25 @@ TODO: should we switch to `Static.jl`?
142142
abstract type BoolsAsTypes end
143143

144144
"""
145-
struct _True <: BoolsAsTypes
145+
struct True <: BoolsAsTypes
146146
147147
A struct that means `true`.
148148
"""
149-
struct _True <: BoolsAsTypes end
149+
struct True <: BoolsAsTypes end
150150

151151
"""
152-
struct _False <: BoolsAsTypes
152+
struct False <: BoolsAsTypes
153153
154154
A struct that means `false`.
155155
"""
156-
struct _False <: BoolsAsTypes end
156+
struct False <: BoolsAsTypes end
157157

158158
"""
159-
_booltype(x)
159+
booltype(x)
160160
161161
Returns a [`BoolsAsTypes`](@ref) from `x`, whether it's a boolean or a BoolsAsTypes.
162162
"""
163-
function _booltype end
163+
function booltype end
164164

165-
@inline _booltype(x::Bool)::BoolsAsTypes = x ? _True() : _False()
166-
@inline _booltype(x::BoolsAsTypes)::BoolsAsTypes = x
165+
@inline booltype(x::Bool)::BoolsAsTypes = x ? True() : False()
166+
@inline booltype(x::BoolsAsTypes)::BoolsAsTypes = x

docs/src/explanations/peculiarities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ We use the `target` keyword to allow the user to control which kinds of geometry
1414

1515
This also allows for a lot more type stability - when you ask for polygons, we won't return a geometrycollection with line segments. Especially in simulation workflows, this is excellent for simplified data processing.
1616

17-
## `_True` and `_False` (or `BoolsAsTypes`)
17+
## `True` and `False` (or `BoolsAsTypes`)
1818

1919
!!! warning
2020
These are internals and explicitly *not* public API,

ext/GeometryOpsLibGEOSExt/GeometryOpsLibGEOSExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module GeometryOpsLibGEOSExt
33
import GeometryOps as GO, LibGEOS as LG
44
import GeoInterface as GI
55

6-
import GeometryOps: GEOS, enforce, _True, _False, _booltype
6+
import GeometryOps: GEOS, enforce, True, False, booltype
77

88
using GeometryOps
99
# The filter statement is required because in Julia, each module has its own versions of these

ext/GeometryOpsLibGEOSExt/segmentize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ end
2323
# 2 behaviours:
2424
# - enforce: enforce the presence of a kwargs
2525
# - fetch: fetch the value of a kwargs, or return a default value
26-
@inline function GO.segmentize(alg::GEOS, geom; threaded::Union{Bool, GO.BoolsAsTypes} = _False())
26+
@inline function GO.segmentize(alg::GEOS, geom; threaded::Union{Bool, GO.BoolsAsTypes} = False())
2727
max_distance = enforce(alg, :max_distance, GO.segmentize)
2828
return GO.apply(
2929
Base.Fix2(_wrap_and_segmentize_geos, max_distance),

ext/GeometryOpsProjExt/reproject.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import GeometryOps: GI, GeoInterface, reproject, apply, transform, _is3d, _True, _False
1+
import GeometryOps: GI, GeoInterface, reproject, apply, transform, _is3d, True, False
22
import Proj
33

44
function reproject(geom;

src/GeometryOps.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import GeometryOpsCore
66
import GeometryOpsCore:
77
TraitTarget,
88
Manifold, Planar, Spherical, Geodesic,
9-
BoolsAsTypes, _True, _False, _booltype,
9+
BoolsAsTypes, True, False, booltype,
1010
apply, applyreduce,
1111
flatten, reconstruct, rebuild, unwrap, _linearring,
1212
APPLY_KEYWORDS, THREADED_KEYWORD, CRS_KEYWORD, CALC_EXTENT_KEYWORD

src/methods/clipping/clipping_processor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,14 +752,14 @@ function _remove_collinear_points!(polys, remove_idx, poly_a, poly_b)
752752
else
753753
p3 = p
754754
# check if p2 is approximately on the edge formed by p1 and p3 - remove if so
755-
if Predicates.orient(p1, p2, p3; exact = _False()) == 0
755+
if Predicates.orient(p1, p2, p3; exact = False()) == 0
756756
remove_idx[i - 1] = true
757757
end
758758
end
759759
p1, p2 = p2, p3
760760
end
761761
# Check if the first point (which is repeated as the last point) is needed
762-
if Predicates.orient(ring.geom[end - 1], ring.geom[1], ring.geom[2]; exact = _False()) == 0
762+
if Predicates.orient(ring.geom[end - 1], ring.geom[1], ring.geom[2]; exact = False()) == 0
763763
remove_idx[1], remove_idx[end] = true, true
764764
end
765765
# Remove unneeded collinear points

src/methods/clipping/coverage.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ end
7373
_coverage(::Type{T}, ::GI.AbstractGeometryTrait, geom, xmin, xmax, ymin, ymax; kwargs...) where T = zero(T)
7474

7575
# Polygons
76-
function _coverage(::Type{T}, ::GI.PolygonTrait, poly, xmin, xmax, ymin, ymax; exact = _False()) where T
76+
function _coverage(::Type{T}, ::GI.PolygonTrait, poly, xmin, xmax, ymin, ymax; exact = False()) where T
7777
GI.isempty(poly) && return zero(T)
7878
cov_area = _coverage(T, GI.getexterior(poly), xmin, xmax, ymin, ymax; exact)
7979
cov_area == 0 && return cov_area

0 commit comments

Comments
 (0)