Skip to content

Add missing JNIAST mappings - #7

Open
timj wants to merge 37 commits into
u/timj/phase4-spectralfrom
u/timj/phase5-mappings
Open

timj wants to merge 37 commits into
u/timj/phase4-spectralfrom
u/timj/phase5-mappings

Conversation

@timj

@timj timj commented Nov 18, 2026

Copy link
Copy Markdown
Member

No description provided.

@timj
timj added this pull request to stack #4 November 18, 2026 05:16
timj and others added 29 commits November 18, 2026 08:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Add LutMap with jniast's constructor and LutInterp and LutEpsilon through
the generic attribute methods: C's forward and inverse transformations,
including the last value kept for each direction, GetLinear and MapMerge,
the dump and loader. Register it with the native loader.

A FITS-WCS read of a -TAB axis with TabOK set now goes on to C's
GetNamedTable, which fails as in C (AST__NOFTS without PSi_0, AST__NOTAB
when the FitsChan holds no table). IsMapTab1D uses a LutMap it finds in
series, which needs FitsTable.

Translate test_lutmap.rs, test_lutmap_inverse.rs and testlutmap.c, convert
the lutmap_forward and lutmap_inverse oracles, and add a C probe for
simplification, dumps, attributes, the kept value and -TAB reads. The
deferred lists lose their LutMap entries; brad now fails only on C's
CmpMap Equal quirk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The entry now says the shared component is left with the first list's
value, and that C's brad.map and brad.simp transform alike (a CmpMap
applies its recorded Invert values), Java's WcsMap Invert of 1 being the
right one. TabMapping's loop bound and LutMap's bad-value test gain
comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Add MathMap with C's compilation of its functions (the symbol table,
ExtractVariables, ExtractExpressions, CompileExpression, ValidateSymbol,
ParseConstant and EvaluationSort), its stack evaluator, its per-MathMap
random-number context (Rand, Gauss, Poisson, DefaultSeed), the Seed, SimpFI
and SimpIF attributes, the dump and the loader. Simplification is left to
the Mapping defaults.

Expected values come from the C probe probes/mathmap_probe.c. Translate the
test_mathmap.rs tests that need no simplification and the MathMap tests of
other Rust files that now run, enable the MathMap cases of the oracle tests,
and rewrite the deferred lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port mathmap.c MapMerge (a MathMap cancels with its inverse after it as
SimpFI and SimpIF allow) and Equal (compiled functions compared as C
does, including its skipped last opcode), and build unit.c MakeMapping's
MathMap for conversions that are not a scaling, replacing the label-only
path used while MathMap was absent. Add the probe
mathmap_simplify_probe.c with its output, translate the remaining
test_mathmap.rs, test_cmpmap.rs and units tests, and narrow the
simplify-regression AlSimp exemption to lines that disappear.

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
Drop the stale -LOG throws clause of FitsWcsRead.read, give the measured
evidence for alt_axes_alt_offset and the -LOG pixel tolerance, record
the narrow-range Hz to GHz quirk of SpectralAxes, and check the log(Hz)
FrameSet against a C probe case of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
TranMap holds the Mappings it is given, as C's clones them, records
their Invert values, and copies them in copy(). It ports tranmap.c's
Transform, Rate, Decompose, MapSplit, Equal, MapMerge (normalising an
inverted TranMap, simplifying its components, collapsing equal
components, merging with a following TranMap) and dump, and is
registered with the loader.

The C probe probes/tranmap_probe.c pins dumps with inverted
components, LutMap and MathMap components, simplifications, rates,
equality, decomposition, splits and constructor errors. The TranMap
simplify fixtures, the map split and object ID oracles and the Rust
tests that waited for TranMap now run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
fixup! Plan phase 5: the remaining jniast Mappings
Port C's astEqual (object.c astEqual_) as the package-private
AstObject.astEqual, dispatching to each class's C Equal: the Object
base (class identity), Mapping (internal error), UnitMap, ZoomMap,
ShiftMap, WinMap, MatrixMap, PermMap, PolyMap, SphMap, WcsMap, SlaMap,
TimeMap, SpecMap, CmpMap (with its expanded lists and the Invert
restore order that changes a shared component), LutMap, MathMap,
TranMap, Frame (conversion simplifying to a UnitMap) and FrameSet.
The existing equalTo methods become these overrides, the simplifier's
recursion guard compares with astEqual as cmpmap.c Simplify does, and
TranMap, ShiftMap, PolyMap, LutMap and SpecFluxFrame call astEqual where
C does.

Translate tests/test_equal.rs, test_equal_oracle.rs and the other Rust
tests deferred as needing astEqual, with a C probe (equal_probe.c)
giving C's answer for each comparison and for cases where Equal and a
text comparison disagree, and a probe of what simplifying brad.map does
to its input. Extend the TranMap probe with a point where the inverted
LutMap case shows the change of direction and with C's Nin message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
…quirks

SimplifyRegressionTest compares a row's input after simplification with
C's dump of it where simplify_input_probe records one, so the brad row,
whose WcsMap C's CmpMap comparison changes, leaves simplify-cases.txt.
The base Object Equal compares AST class names, as C does. Record that
MatrixMap Equal compresses its arguments, that CmpMap Equal restores
Invert set or unset, and narrow the ZoomMap entry's astEQUAL wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
RateMap holds the Mapping it is given, as C clones it, records its
Invert value and its two axis indices, and copies it in copy(). It
ports ratemap.c's Transform (astRate of the encapsulated Mapping, in
its recorded orientation, at every point, bad ones included), MapSplit,
Equal, MapMerge (a RateMap of the simplified Mapping; cancellation with
a neighbouring RateMap applied the other way) and dump, and is
registered with the loader.

The C probe probes/ratemap_probe.c pins dumps of RateMaps of ZoomMaps,
a LutMap, a MathMap and a TranMap, each read back; simplifications of
a RateMap alone and of cancelling pairs; rates; equality; splits; and
the constructor's errors. The RateMap simplify fixtures, the map split,
object ID and rate oracles and the Rust tests that waited for RateMap
now run; the tests that stood in a one-way Mapping for a RateMap use
one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port C's MakeSFMapping in full (specfluxframe.c): the PermMap that copies
the spectral value, MakeMap2's conversions to and from the standardised
Frames, and MakeMap3's TranMap of MakeMapF and MakeMapI, which scale the
flux value by a RateMap of the spectral conversion through MathMaps, the
RateMap of MakeMapI sharing the conversion that is then inverted, as C
does. Conversions between SpecFluxFrames, and between a SpecFluxFrame and
a FluxFrame or SpecFrame that C casts into one, now give C's Mapping.

SpecFluxFrameTest checks every conversion that threw against a new C
probe (specflux_probe.c): the class and dump of the simplified Mapping,
and a point transformed both ways, byte for byte, including Jy to mJy,
FLXDN to FLXDNW across units, logarithmic units, and spectra in FrameSets
converting between frequency/Jy, wavelength/mJy, radio velocity and
wavelength/W/m^2/nm in both directions; testspecflux.c Errors 30-32 call
astEqual. FrameSetIntegrityTest runs its two SpecFluxFrame cases, and
FrameClassAttrsTest and FrameAxisAttrsTest their SpecFluxFrame cases.
MapSplitOracleTest translates issimp_component_exclusions_still_differ
with an empty exclusion list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
… not convert

Add the C/Rust/Java entry to docs/rust-c-differences.md, and build the
astEqual results of testspecflux.c Errors 30-32 from Java's calls before
comparing them with the probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
GrismMap ports grismmap.c: the eight attributes stored as C stores
them (unset as AST__BAD, or INT_MAX for GrismM), tested, cleared and
set through the generic attribute methods and jniast's getters and
setters, immutable once shared; the derived constants, Transform,
Equal (attributes as stored), MapMerge (CanMerge with a ZoomMap
neighbour, or a GrismMap of another order applied the other way),
dump and loader, registered with the loader.

FITS-WCS reads -GRI and -GRA axes with C's GrismSpecWcs, and
SpectralAxes describes an axis whose simplified pixel to wavelength
Mapping ends in a GrismMap with the grism algorithm, extracting it with
C's ExtractGrismMap.

The C probe probes/grismmap_probe.c pins attributes, dumps with each
attribute set and unset, transformations, rates, equality and
simplifications (including C's merge with a ZoomMap whose own Invert
attribute is set, which does not transform as the pair did), and grism
headers read and written with each encoding. The Rust tests that waited
for GrismMap are translated, and the grism entries leave the deferred
lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
fixup! Port GrismMap and read and write grism axes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The grism FITS probe comparisons allow the rate tolerance only on the
lines holding rate-derived values (pixel lines, the WinMap's scale and
shift, CDELT), and libm rounding elsewhere. The GrismMap setter and NaN
protocol tests use in-range attributes and compare against C's probe
values. The grism write branch assigns the reference wavelength to
CRVAL before converting it, in C's order, and its test compares CRVAL
exactly with C's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
PcdMap ports pcdmap.c: Disco and PcdCen(1), PcdCen(2) stored as C
stores them (unset as AST__BAD), set, tested and cleared through the
generic attribute methods (PcdCen without an axis sets and clears both
and gets and tests axis 1, an axis out of range is AST__AXIIN) and
jniast's getters and setters, immutable once shared; Transform with
the sla_UNPCD inverse, Equal (attributes as stored), dump and loader,
registered with the loader.

MapMerge is C's: a PcdMap whose coefficient is zero by pcdmap.c's own
EQUAL (floor DBL_MIN) becomes a UnitMap, in series or parallel; in
series it merges with a UnitMap or its own inverse (CanMerge), and
otherwise swaps past a ZoomMap (PcdZoom, with the factor the list
applies) or an axis-swapping PermMap (PcdPerm, CanSwap with PermGet)
towards the nearest PcdMap or UnitMap and merges at once, or swaps
speculatively when a swapped Mapping then simplifies.

The C probe probes/pcdmap_probe.c pins attributes and their errors,
dumps with each attribute set and unset, transformations, rates, a
split, equality and simplifications (inverted ZoomMaps and PcdMaps on
either side included, which the pinned C transforms correctly). The
Rust tests that waited for PcdMap are translated, and the pcd entries
leave the deferred lists.

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
C writes ISInv only when it is set and reads its absence as FSInv, so a
SwitchMap whose forward selector alone was inverted reloads changed; the
probe case is now a plain round trip. The selector conversion entry rests
on C's documented contract rather than on saturation.

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
Read and write IntraMaps by function name only, with a weak process-wide registry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Give an IntraMap another function name when its identity hash is taken

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Keep one function name per Transformer across a name chain, and tidy IntraMap wording

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
DssMap ports dssmap.c. It has no public constructor, as C's astDssMap is
protected: a DssMap is read from a dump (astLoadDssMap: the plate
parameters, PPO3, PPO6 and the first 13 coefficients on each axis are
required, AST__RDERR otherwise, the rest default to zero) or made by
MapMerge, through a package-private constructor from DSS FITS cards
(BuildWcs). Transform is C's port of SAOimage's platepos and platepix,
with C's own constants (two pi is 6.28318530717959); Equal and Dump are
C's.

MapMerge is C's: in series, a WinMap on the pixel side (before the DssMap
applied forward, after it applied inverted) with good, non-zero terms
folds into CNPIX and the pixel sizes when the new offsets are whole to
within 0.01; the merged DssMap is rebuilt from the cards DssFits writes,
so the plate centre passes through its sexagesimal cards as in C
(oracle dss_merge). The WinMap's Invert attribute is restored, where C
leaves it changed after a merge.

The C probe probes/dssmap_probe.c pins transformations (inverted, with
bad points and an RA wrap), rates, equality, loads with an item missing
and simplifications. The DssMap entries leave the deferred lists, and
the Rust test a_dssmap_dump_needs_its_plate_solution is translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
timj and others added 8 commits November 18, 2026 08:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
List the Rust tests of UnitNormMap, the Region oracles and transform memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Translates the three nested-series tests of Rust tests/test_transform_memory.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
…rness does

Test that the astEqual check rejects a wrong simplification

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
@timj
timj force-pushed the u/timj/phase5-mappings branch from 507ac29 to 7f1919d Compare November 18, 2026 15:08
@timj

timj commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

@mbtaylor I've started chipping away at this. The initial goal is JNIAST compatibility so it's not including the newer mappings like SplineMap yet. Hopefully this is what you had in mind. Plot will have to wait a little bit for me to add it to the Rust (I have to allocate my tokens with preference to Rubin priorities).

@mbtaylor

Copy link
Copy Markdown
Member

Thanks @timj. Agreed that I don't expect to need/use post-JNIAST functionality any time soon. I can't do much in the way of application testing before Plot is done, but there's no hurry from my side. There are a few unit tests in jniast, but they're not very comprehensive (and some of those need Plot as well).

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.

2 participants