Skip to content

Commit d2348d0

Browse files
Rename Within --> Crop (#1021)
* Rename Within --> Crop * Update test/transforms.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7789658 commit d2348d0

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

docs/src/transforms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ viz(fig[1,2], disk)
176176
fig
177177
```
178178

179-
## Within
179+
## Crop
180180

181181
```@docs
182-
Within
182+
Crop
183183
```
184184

185185
```@example transforms
186186
grid = CartesianGrid(10, 10)
187-
subgrid = grid |> Within(x=(1.5, 6.5), y=(3.5, 8.5))
187+
subgrid = grid |> Crop(x=(1.5, 6.5), y=(3.5, 8.5))
188188
189189
fig = Mke.Figure(size = (800, 400))
190190
viz(fig[1,1], grid)

src/Meshes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export
534534
Proj,
535535
LengthUnit,
536536
Shadow,
537-
Within,
537+
Crop,
538538
Repair,
539539
Bridge,
540540
LambdaMuSmoothing,

src/transforms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ include("transforms/stdcoords.jl")
9696
include("transforms/proj.jl")
9797
include("transforms/lengthunit.jl")
9898
include("transforms/shadow.jl")
99-
include("transforms/within.jl")
99+
include("transforms/crop.jl")
100100
include("transforms/repair.jl")
101101
include("transforms/bridge.jl")
102102
include("transforms/smoothing.jl")

src/transforms/within.jl renamed to src/transforms/crop.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ------------------------------------------------------------------
44

55
"""
6-
Within(x=(xmin, xmax), y=(ymin, ymax), z=(zmin, zmax))
6+
Crop(x=(xmin, xmax), y=(ymin, ymax), z=(zmin, zmax))
77
88
Retain the domain geometries that intersect with `x` limits [`xmax`,`xmax`],
99
`y` limits [`ymax`,`ymax`] and `z` limits [`zmin`,`zmax`] in length units
@@ -12,31 +12,31 @@ Retain the domain geometries that intersect with `x` limits [`xmax`,`xmax`],
1212
## Examples
1313
1414
```julia
15-
Within(x=(2, 4))
16-
Within(x=(1u"km", 3u"km"))
17-
Within(y=(1.2, 1.8), z=(2.4, 3.0))
15+
Crop(x=(2, 4))
16+
Crop(x=(1u"km", 3u"km"))
17+
Crop(y=(1.2, 1.8), z=(2.4, 3.0))
1818
```
1919
"""
20-
struct Within{X,Y,Z} <: GeometricTransform
20+
struct Crop{X,Y,Z} <: GeometricTransform
2121
x::X
2222
y::Y
2323
z::Z
2424
end
2525

26-
Within(; x=nothing, y=nothing, z=nothing) =
27-
Within(isnothing(x) ? x : _aslen.(x), isnothing(y) ? y : _aslen.(y), isnothing(z) ? z : _aslen.(z))
26+
Crop(; x=nothing, y=nothing, z=nothing) =
27+
Crop(isnothing(x) ? x : _aslen.(x), isnothing(y) ? y : _aslen.(y), isnothing(z) ? z : _aslen.(z))
2828

29-
parameters(t::Within) = (; x=t.x, y=t.y, z=t.z)
29+
parameters(t::Crop) = (; x=t.x, y=t.y, z=t.z)
3030

31-
function preprocess(t::Within, d::Domain)
31+
function preprocess(t::Crop, d::Domain)
3232
bbox = boundingbox(d)
3333
bbox₁ = _overlaps(1, t.x, bbox)
3434
bbox₂ = _overlaps(2, t.y, bbox₁)
3535
bbox₃ = _overlaps(3, t.z, bbox₂)
3636
indices(d, bbox₃)
3737
end
3838

39-
function apply(t::Within, d::Domain)
39+
function apply(t::Crop, d::Domain)
4040
inds = preprocess(t, d)
4141
n = view(d, inds)
4242
n, nothing

test/transforms.jl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,21 +1638,20 @@
16381638
@test r == SimpleMesh(f.(vertices(d)), topology(d))
16391639
end
16401640

1641-
@testset "Within" begin
1642-
@test !isaffine(Within(x=(T(2), T(4))))
1643-
@test !TB.isrevertible(Within(x=(T(2), T(4))))
1644-
@test !TB.isinvertible(Within(x=(T(2), T(4))))
1645-
@test TB.parameters(Within(x=(T(2), T(4)))) == (x=(T(2) * u"m", T(4) * u"m"), y=nothing, z=nothing)
1646-
@test TB.parameters(Within(y=(T(2) * u"km", T(4) * u"km"))) ==
1647-
(x=nothing, y=(T(2) * u"km", T(4) * u"km"), z=nothing)
1648-
@test TB.parameters(Within(z=(2, 4))) == (x=nothing, y=nothing, z=(2.0u"m", 4.0u"m"))
1649-
@test_throws ArgumentError Within(x=(T(2) * u"°", T(4) * u"°"))
1641+
@testset "Crop" begin
1642+
@test !isaffine(Crop(x=(T(2), T(4))))
1643+
@test !TB.isrevertible(Crop(x=(T(2), T(4))))
1644+
@test !TB.isinvertible(Crop(x=(T(2), T(4))))
1645+
@test TB.parameters(Crop(x=(T(2), T(4)))) == (x=(T(2) * u"m", T(4) * u"m"), y=nothing, z=nothing)
1646+
@test TB.parameters(Crop(y=(T(2) * u"km", T(4) * u"km"))) == (x=nothing, y=(T(2) * u"km", T(4) * u"km"), z=nothing)
1647+
@test TB.parameters(Crop(z=(2, 4))) == (x=nothing, y=nothing, z=(2.0u"m", 4.0u"m"))
1648+
@test_throws ArgumentError Crop(x=(T(2) * u"°", T(4) * u"°"))
16501649

16511650
# ---------
16521651
# POINTSET
16531652
# ---------
16541653

1655-
f = Within(x=(T(1.5), T(3.5)))
1654+
f = Crop(x=(T(1.5), T(3.5)))
16561655
d = PointSet([cart(1, 0), cart(2, 1), cart(3, 1), cart(4, 0)])
16571656
r, c = TB.apply(f, d)
16581657
@test r == PointSet([cart(2, 1), cart(3, 1)])
@@ -1661,7 +1660,7 @@
16611660
# GEOMETRYSET
16621661
# ------------
16631662

1664-
f = Within(x=(T(1.5), T(3.5)))
1663+
f = Crop(x=(T(1.5), T(3.5)))
16651664
t1 = Triangle(cart(0, 0), cart(1, 0), cart(0, 1))
16661665
t2 = t1 |> Translate(T(2), T(2))
16671666
t3 = t2 |> Translate(T(2), T(2))
@@ -1673,7 +1672,7 @@
16731672
# CARTESIANGRID
16741673
# --------------
16751674

1676-
f = Within(z=(T(1.5), T(4.5)))
1675+
f = Crop(z=(T(1.5), T(4.5)))
16771676
d = cartgrid(10, 10, 10)
16781677
r, c = TB.apply(f, d)
16791678
@test r == CartesianGrid((10, 10, 4), cart(0, 0, 1), T.((1, 1, 1)))
@@ -1682,7 +1681,7 @@
16821681
# RECTILINEARGRID
16831682
# ----------------
16841683

1685-
f = Within(y=(T(3.5), T(6.5)))
1684+
f = Crop(y=(T(3.5), T(6.5)))
16861685
d = convert(RectilinearGrid, cartgrid(10, 10))
16871686
r, c = TB.apply(f, d)
16881687
@test r == convert(RectilinearGrid, CartesianGrid((10, 4), cart(0, 3), T.((1, 1))))
@@ -1691,7 +1690,7 @@
16911690
# STRUCTUREDGRID
16921691
# ---------------
16931692

1694-
f = Within(x=(T(5.5), T(8.5)))
1693+
f = Crop(x=(T(5.5), T(8.5)))
16951694
d = convert(StructuredGrid, cartgrid(10, 10))
16961695
r, c = TB.apply(f, d)
16971696
@test r == convert(StructuredGrid, CartesianGrid((4, 10), cart(5, 0), T.((1, 1))))
@@ -1700,7 +1699,7 @@
17001699
# SIMPLEMESH
17011700
# -----------
17021701

1703-
f = Within(x=(T(1.5), T(4.5)), y=(T(3.5), T(6.5)))
1702+
f = Crop(x=(T(1.5), T(4.5)), y=(T(3.5), T(6.5)))
17041703
d = convert(SimpleMesh, cartgrid(10, 10))
17051704
r, c = TB.apply(f, d)
17061705
@test r == convert(SimpleMesh, CartesianGrid((4, 4), cart(1, 3), T.((1, 1))))

0 commit comments

Comments
 (0)