Skip to content

Add regions - #9

Merged
timj merged 26 commits into
u/timj/phase6-resamplefrom
u/timj/phase7-regions
Dec 3, 2026
Merged

timj merged 26 commits into
u/timj/phase6-resamplefrom
u/timj/phase7-regions

Conversation

@timj

@timj timj commented Nov 19, 2026

Copy link
Copy Markdown
Member

No description provided.

@timj
timj added this pull request to stack #4 November 19, 2026 18:50
timj and others added 26 commits December 3, 2026 09:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port the Frame machinery the Region classes call: lineDef, lineOffset,
lineCrossing and lineContains (straight lines in a Frame, great circles
on a SkyFrame), normBox (a SkyFrame takes in the poles, a CmpFrame asks
each component, a FrameSet its current Frame) and frameGrid, with the
package-private PointSet that holds a Region's defining points in its
description, registered for loading.

Expected values come from the new C probe frame_line_probe.c; the four
CmpFrame NormBox tests of test_cmpframe.rs are translated, and the
deferred lists no longer name PointSet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Region is the abstract Frame of every Region shape: it encapsulates a
FrameSet and forwards Frame behaviour to its current Frame as region.c
does, with the Region attributes, attribute setting that remaps only an
Adaptive Region, the uncertainty (SetUnc, GetUnc, GetUncFrm, GetDefUnc),
bounds, points, mesh and grid, the protected and public MapRegion, the
generic Simplify, Equal, Cast, PickAxes, dump and load. Box is ported
from box.c without its own Simplify and MapMerge. Overlap, the masks
and ShowMesh are declared and raise AST__INTER.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The fixtures that needed only Box now read, round-trip and transform as
C's do, and leave the deferred lists; the lists' reasons no longer name
Box. Rust tests translated with Box leave rust-tests.txt, those that
need SelectorMap say so, and the Box tests that expect the Box's own
simplification are listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port region.c's generic Overlap/OverlapX and BndBaseMesh (RegionOverlap),
Mask<X> through phase 6's Resample (RegionMask), and ShowMesh, replacing
the Region stubs. jniast's generic mask dispatches on the array type with
its IllegalArgumentException; the array and bound checks are Resample's.
As C does, OverlapX and Mask<X> negate a Region in place and back.

Tests: the region_overlap, region_mask, region_mapregion and
region_showmesh oracles (Box cases, counts asserted), the overlap column
of region_equal, mask argument rules, and a new C probe of Box overlap
and masking and of the negated copy an Adaptive Region keeps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
NullRegion (nullregion.c), Interval (interval.c) and PointList
(pointlist.c), with their own Transform, bounds, mesh, uncertainty,
RegPins, RegBasePick, Overlap (NullRegion's OverlapX, Interval's
axis-by-axis comparison and BndBaseMesh) and PointList's Mask<X>;
Simplify is the Region-generic one until each class's own is added.
The tests translate test_nullregion.rs, test_interval.rs,
test_pointlist.rs and the region_interval, region_nulltran and
region_bounded oracles, raise the case counts of the shared oracles,
and take C's values for the constructors' checks, membership, masks,
overlaps and dumps from the new region_null_interval_pointlist_probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The deferred lists lose the fixtures and cases whose only missing
classes were NullRegion, Interval and PointList, and keep the rest
with those classes dropped from their reasons; rust-tests.txt gains the
Rust tests of these classes that still need Circle, Prism, the classes'
own simplification, astGetRegionDisc or astGetRegionMesh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Circle and Ellipse are ported from circle.c and ellipse.c: the jniast
constructors, with C's checks of form, axes and bad coordinates;
membership; bounds and boundary meshes made with the Frame's geodesics
(astOffset2, astAxDistance, astNormBox), so that sky Regions across RA 0
or round a pole match C; re-centring; the boundary test (RegPins); dump
and load. The best-fit conversions astBestCircle and astBestEllipse are
package-private for the classes' own simplification. A NullRegion's
default uncertainty is now C's zero-radius Circle.

New C probes, region_sky_probe.c (Boxes and Circles across RA 0 and
round the poles) and region_circle_ellipse_probe.c (linked with
ellipse.c's RegCentre indexing corrected, since C's crashes), give the
expected values; the region_ellipse and region_frame oracles are
converted; the shared oracles and the tests that skipped Circle now run
its cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The deferred lists lose the fixtures and cases whose only missing
classes were Circle and Ellipse, and keep the rest with those classes
dropped from their reasons; rust-tests.txt loses the Rust tests that
now run, and gains those of test_circle.rs and the disc and EllipsePars
oracles that need astCirclePars, astGetRegionDisc or astEllipsePars
(not in jniast), and the rotated-boundary test of test_ellipse.rs,
whose result the platform's last bit decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Each Region class's own Simplify as C's: Box (PermMap slices to Box,
Interval or NullRegion; the best-fitting Box, the Polygon of the
corners, or a Prism of separable axes otherwise), Interval (its Box,
or redefined in the current Frame), PointList, Circle and Ellipse
(best-fit Circle or Ellipse), Prism (merged components, or each
component on its own axes) and CmpRegion (null, infinite, identical
and nested components). RegionMerge holds the MapMerge of Box,
Interval, NullRegion and PointList, which merges neighbouring Regions
in parallel (MergeBox, MergeInterval, MergeNullRegion,
MergePointList), and Prism gains astConvertToPrism.

Translates the Rust tests that waited for simplification and jniast's
own RegionTest, and compares a simplified Ellipse with the reference's
end of its primary axis, which rounding decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The 29 rows of fixtures/simplify/cases.txt and the 8 Rust tests that
needed Region simplification now match C and leave the deferred
lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The checks of testregions.c that the class tests do not cover, with
checkEllipse's Errors 15 to 17, which the Rust port excludes, giving
C's result. check_remove_regions waits for astRemoveRegions, and
region_gaps_still_differ checks a Rust gap Java does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
RegionsTest holds the tests of test_regions.rs that exercise Region
simplification: the uncertainty a Prism carries to its simplification,
the MeshSize and FillFactor of a parallel merge, and a sky Circle in a
changed System simplified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
RegionsTest now holds every test of test_regions.rs but those needing
astGetRegionDisc, astRemoveRegions or astConvex, which are listed in
deferred/rust-tests.txt. The probe regions_cross_probe.c records C's
results for the checks testregions.c does not make: C gives each overlap
and sky membership the Rust tests expect, its bounds replace the Rust
tests' looser ones, and for the negated CmpRegion whose square is given
by its bounds C keeps the boundary point (0, 0.5) the Rust test expects
to be bad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
List every Rust test of the Moc, MocChan, Stc, SelectorMap and
astRemoveRegions files, and the Region trait checks, in rust-tests.txt;
name only SelectorMap where it was listed as a Region.
Translate test_frame_in_map_slot.rs's Region-in-CmpMap control and run
the CmpRegion and Prism cases of the object ID oracle.
Say in the remaining SelectorMap skips that only SelectorMap is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
A probe whose output moved from one form to the other left a copy of the .out among the compiled test resources, which ProbeOutput then took.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
FitsMakeIntWorld, TimeFrame and KeyMapConvert each had a copy of C's round, identical in behaviour; CmpFrame, RegionMask, SwitchMap and the FITS classes reached FitsMakeIntWorld's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
winmap.c PermGet and fitschan.c's readers of WCSAXES call round(), so
WinMapMerge and FitsWcsKeywords use CMath.roundHalfAway in place of
their private floor(x + 0.5) helpers. A header whose WCSAXES is
0.49999999999999994 now fails as WCSAXES = 0 does, as in C; the new
fitschan_wcsaxes_round_probe pins it. PermGet's values are whole axis
indices, so no input reaches the difference there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Masking a Region through a PermMap that drops an axis its inverse
leaves bad differs from C because region.c MapRegion releases the
split Mapping twice. The new region_mapregion_drop_axis_probe, linked
with a region.c whose second release is guarded, gives Java's mapped
Regions and masks for a Box and a PointList, which
RegionMapRegionDropAxisTest pins with Java's AST__INTER for a Circle.
docs/rust-c-differences.md records the C bug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
@timj
timj force-pushed the u/timj/phase7-regions branch from 55eba4c to bd27df6 Compare December 3, 2026 17:26
@timj
timj merged commit ea94bcc into main Dec 3, 2026
8 checks passed
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.

1 participant