Repository navigation
Make the Working for Families helpers exact on unusual inputs - #31
Conversation
Fix the helper items in issue #27, none of which today's formulas reach except a 32-bit reform value: - cents_by_family bounds the sum after widening, so the smallest int64 takes the exact path, and add_cents adds narrow integers and mixed signed and unsigned integers as int64 when no sum can reach 2**63. - stored keeps the integers of a sequence, divides a whole number held as a finite float exactly, and repairs a tie for a float numerator. - finite_parts reads NumPy floats and keeps the input's shape. - whole rounds the nearest whole number of steps to the value's own NumPy float type, so the 16- or 32-bit value nearest a cent passes. - credit_sums and best_start_sums raise a named error when a row of daily counts of children could sum to 2**53. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- stored holds the denominator exactly as a Fraction and raises a ValueError for a zero, infinite or NaN denominator or a numerator that is not a number. Its 64-bit fast path runs only for an array that is not an object array, whose values lie below 2**53, and a denominator that a 64-bit float holds exactly. An integer over a whole denominator divides as Python integers, as on main, which round the exact quotient once; every other value divides exactly through Fraction. A matrix divides like an array, and zeros and infinities take the sign of the quotient. - cents_by_family and add_cents add booleans and unsigned integers as 64-bit integers, and split any other array into exact finite parts and infinities, so a huge integer beside an infinity stays exact. Cents that are not whole numbers raise a ValueError. - finite_parts turns a sequence into an object array and gives Python numbers. - exact_counts replaces check_counts. It needs a day axis, requires whole numbers, bounds each row's own sum of absolute counts, and returns int32 or int64 counts, which the two sums now use. - whole's docstring names the steps it supports, a cent and 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the first review, which requested changes at 9d6fe64. 70fde42 addresses each finding; the description's Tests section has the checks behind these answers. P1, P1, narrow arrays. The 64-bit path widens the numerators to 64-bit floats before it divides, and runs only when they lie below 2**53 and a 64-bit float holds the denominator exactly. A float16 P1, unsigned and float cents. Integer and boolean cents add as 64-bit integers; every other array takes an exact path. P1, booleans. Booleans count as integers in both sums, and P1, a huge integer beside an infinity. Both cent sums split each value into a finite Python integer, an infinity or NaN before they add. P1, P1, sparse rows. P1, unsigned and float counts. P2, P2, the four missing P2, the count and month assertions. P2, credit to #27. The description now credits #27's comment with the 32-bit cent and calls the 16-bit cent the extension, and the test module's opening comment covers both row types. New errors. Finding 1 objected to inputs main handled and the fix rejected. This version rejects four kinds of input that main accepted, each now a Speed. Holding the denominator as a Round 2 can start from 70fde42. |
- stored's 64-bit division runs on the normalized values when each is a float or an integer below 2**53 and a 64-bit float holds the denominator exactly, inside np.errstate(all="ignore"), so underflow and overflow round without raising. The tie repair also settles a quotient that rounds to the signed 32-bit overflow midpoint in 64 bits, so an exact quotient just inside it gives the largest 32-bit float on every path; the clamps that did that for the integer and Fraction paths had no effect left and are gone. NaN keeps its bits. - _python_number holds a finite Decimal, and a NumPy float wider than 64 bits that no 64-bit float holds, as the exact int or Fraction they hold; a Decimal zero, infinity or NaN becomes that float. It raises for a NumPy duration. - The helpers accept arrays of booleans, integers, floats and objects only, so dates, durations and text raise a ValueError, and finite_parts raises for a value that is not a number. - add_cents returns a zero-dimensional array for zero-dimensional input on both paths. Integer cents still add in 64 bits only while no sum can reach 2**63 in size, and cents_by_family's only while the absolute sum stays below 2**62; other sums are Python integers. - whole compares an integer exactly, and its docstring names CENT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the second review, which requested changes at 70fde42. 27c679e addresses each finding. Each result below comes from a run at 27c679e, on this Mac's 64-bit long double and on an x86-64 interpreter whose long double has 80 bits. Correction first. My first answer said P1, the overflow midpoint in arrays. P1, strict floating-point errors. The 64-bit division runs on the normalized values inside P1, zero-dimensional sums. The exact path turns the total into an object array before it sets the infinities, and the integer path returns an array too, so a zero-dimensional sum is a zero-dimensional array on both paths. P1, Decimals. P1, wider floats. I took your fix: P1, dates and durations. The helpers check an array's kind before they read any value, and accept only booleans, integers, floats and objects. P1, P2, the five P2, the six cent and count mutations. P2, wording. The description now calls the child-sum battery a check that other count types give the int64 results, gives the grid's filter (it ignores rises up to 1e-6 and skips the Family Tax Credit and In-Work Tax Credit comparisons for an Mutations. I ran 87 changes to Other checks. A battery of 886 cases, now with Decimals, dates, durations, text, zero-dimensional arrays, exponent extremes and the overflow midpoint with both signs, matches an exact reference in every case with NumPy set to raise on floating-point errors, and every error this version raises there is a Round 3 can start from 27c679e. |
- stored divides only built-in floats and ints on its 64-bit path, so a subclass with its own __float__ divides as the number it holds. - A sequence's nested arrays of dates, durations or text raise an error in stored, the cent sums, finite_parts and exact_counts, before NumPy turns their values into integers. - whole holds a step other than an int or Fraction exactly, so a step of 1.0 compares a large integer exactly. - exact_counts gives its 2**53 error for a row sum too large to print. Tests pin each case, the integer and Fraction paths just below the 32-bit overflow midpoint, and the NaN bits on the exact path. The test helper _nearest_float32 now works up to the largest 32-bit float. Correction to 27c679e's message: NaN keeps all its bits only in _quotient. stored keeps a NaN's sign on every path, and its 32-bit result drops the payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the third review, which requested changes at 27c679e. 1a405f8 addresses each finding. Each result below comes from a run at 1a405f8 merged with main, on this Mac and, where it says so, on the x86-64 interpreter whose long double has 80 bits. P1, a subclass on the 64-bit path. P1, dates and durations inside a sequence. The cent sums, P1, P1, the P1, NaN bits. You were right: P1, the strict battery comparison. You were right that the reference raised in 12 of its own conversions under P1, the row-sum error. P2, Mutations. The table now covers 95 changes: the last round's 87, with four re-anchored to the moved code, and eight for this round's fixes. Ninety-two fail at least one test, one of them only on the x86-64 interpreter, and the same three as before change nothing a test can see. Other checks. Round two's witnesses give 0 failures under both interpreters. The new test file has 98 cases: on this Mac 97 pass and the long-double one skips, and on the x86-64 interpreter all 96 that need no Core simulation pass. The suite passes, 1,722 tests. Round 4 can start from 1a405f8. |
- _python_number turns a subclass of float or int into the built-in number it holds, so its own __float__, division or as_integer_ratio cannot change a result, its zeros, infinities and NaNs included. - The check for dates, durations and text reads every sequence and array-like value NumPy would read, and checks an array subclass as the plain array it holds. The cent sums keep an array held in an object array's slot as one value, which they reject. - A Decimal NaN keeps its sign. - _python_number returns built-in floats and ints at once, so plain numbers skip the subclass checks. Tests pin each case, and exact_counts' error for rows of text. The test helper _nearest_float32 raises no floating-point error at either end of the 32-bit range. Correction to 1a405f8's message: stored's 32-bit result keeps a NaN's sign and the payload bits that 32 bits hold, and drops the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the fourth review, which requested changes at 1a405f8. Round 4 was the last scoped round, so the review rules leave its open findings with this hub: I fixed each one in 606e9b2 and checked it here, as below. Each result comes from a run at 606e9b2 merged with main at d8ee910, on this Mac and, where it says so, on the x86-64 interpreter whose long double has 80 bits. I reproduced every witness in the review at 1a405f8 first. P1, a subclass's special values and its own arithmetic. P1, dates and durations past the sequence check. P1, NaN. You were right on both counts. A Decimal NaN, quiet or signalling, now keeps its sign. The description, P2, Speed. The subclass checks slowed Checks. The mutation table now covers 104 changes: round 3's 95, with two re-anchored to the moved Decimal lines, and nine for this round's fixes. One hundred fail at least one test, one of them only on the x86-64 interpreter. The other four change nothing a test can see: round 3's three, and the 64-bit path's type check above. The battery gives the same 886 outputs as at 1a405f8 and as the guarded reference, under strict errors and with errors ignored. Round two's witnesses give 0 failures under both interpreters. The new file has 169 cases: on this Mac 168 pass and the long-double one skips, and on the x86-64 interpreter all 167 that need no Core simulation pass. On main with the stub No P0 or P1 stays open. I'll mark this ready and merge it once CI passes at 606e9b2. |
Agent-written for Max, by Claude Code for Max Ghenis.
Fixes #27.
What this fixes
The helper items in #27. #27's comment also asked that the checks on a reform's amounts accept the 32-bit float nearest a cent and reject the next one; the 16-bit float nearest a cent follows the same path and now passes too. A reform reaches these values when it sets a parameter row's value directly, since Core 3.20.0's
Parameter.updaterejects a 32-bit value. #27 found that none of its helper items changes a result the formulas produce today, and the model grid below agrees. #27's test items landed in #30.#27's last helper item, the
OverflowErrorin_dollars_over, no longer occurs on main, and #30 added the test that pins it.Changes
In
policyengine_nz/working_for_families.py:cents_by_familyadds integer and boolean cents as 64-bit integers when their absolute sum stays below 2**62, after it widens them to 64-bit floats to bound that sum. Every other array, Decimals included, takes an exact path that splits each value into a finite Python integer, an infinity or NaN, adds the finite parts, and gives NaN where a family has NaN or both infinities. On main, one family's −2**63 and −1 sum to 2**63 − 1, unsigned 2**53 + 1 and 1 sum to 2**53, and an object-held 10**350 beside an infinity raisesOverflowError.add_centsfollows the same rule: integer and boolean arrays add as 64-bit integers when no sum can reach 2**63, and as Python integers otherwise. Zero-dimensional arrays give a zero-dimensional array on both paths. On main, 8-bit 127 and 1 sum to −128, a signed −1 and an unsigned 2**53 + 3 sum to the 64-bit float 2**53 + 4, and 8-bit 127 andTruesum to −128.storedholds each numerator exactly, as a Python integer, float orFraction, and the denominator as aFraction. It divides in 64 bits only when every numerator is a built-in float or a built-in integer below 2**53 and a 64-bit float holds the denominator exactly, so the one division rounds once. That division ignores NumPy's floating-point error settings, since an underflow or overflow in it rounds correctly. An integer over a whole denominator divides as Python integers, as on main, which also round the exact quotient once. Every other numerator divides exactly throughFraction. Where a 64-bit quotient lies halfway between two 32-bit floats, or equals the 32-bit overflow midpoint, the exact quotient settles the rounding. A sequence that is not an array keeps its integers, a matrix divides like an array, zeros and infinities take the sign that the division gives them, and NaN stays NaN with its sign and the payload bits that a 32-bit float holds; like any conversion to 32 bits, the result drops the rest of the payload. On main, an infinity over −100 stays positive,stored([2**54 + 2**30 + 1, inf], 1)raisesTypeError, and a float16[1]divided by 3 gives 0.333251953125, the float16 quotient, where the nearest 32-bit float is 0.3333333432674408._python_number, which every helper uses, turns NumPy booleans and integers into Python ones, a NumPy float into the float it holds, and a subclass offloat, or ofintother thanbool, into the built-in number it holds, so a subclass divides as that number whatever its own__float__,__truediv__oras_integer_ratiogives. A NumPy float wider than 64 bits that no 64-bit float holds, and a finite Decimal, become the exact int orFractionthey hold; a Decimal zero, infinity or NaN, a signalling NaN included, becomes that float with its sign. A built-in float or integer returns at once._python_numberrejects an object-held NumPy duration. On main,add_centsadds nanosecond dates and durations as integers,storeddivides durations, andfinite_partspasses dates, durations and text through.finite_partsturns a sequence into an object array, reads NumPy booleans, integers and floats as the Python numbers they hold, keeps a finite count's exact value, and returns all three outputs in the input's shape. On main, an object-held float32 infinity or NaN sets neither mask, a(1, 5)input gives(1,)masks, and a count of 2.5 gives 0 and counts as infinite.wholetakes the value's type and rounds the nearest whole number of steps to that NumPy float type before it compares, and_checkedpasses the type. It compares an integer exactly and holds the step exactly, so a step of 1.0 works as 1 does; on main, whosewholetakes no type,whole(2**53 + 1, 1)is false. Its docstring names the steps it supports,CENTand 1, the steps the formulas use.exact_countschecks the daily counts of children thatcredit_sumsandbest_start_sumsadd, and returns them for the sums to use. Counts need a day axis and must be whole numbers. When the largest count times the number of days reaches 2**53, it sums each row's absolute counts exactly and raises aValueErrorif a row reaches 2**53, giving a sum too large to print as a power of 2. It keeps 32- and 64-bit signed counts and converts every other type to 64-bit integers, so unsigned and float counts give the same sums as signed ones. Core's counts are 32-bit integers far below the bound.policyengine_nz/tests/test_working_for_families_helpers.pyholds the new tests, andchangelog.d/wff-helper-edge-cases.fixed.mdthe changelog fragment.Inputs that now raise an error
This version raises a
ValueErrorthat names the problem for each of these:stored(main gives[inf],[0.0]and[nan]for a numerator of 1), and a numerator or denominator that is not a number (main raisesTypeError);add_centsorcents_by_family(main'scents_by_familyturns 1.5 cents into 1);finite_parts(main's results for arrays of dates, durations and text are in the bullet on accepted arrays above).Tests
The new file has 58 tests, 169 with their parametrized cases. One runs only where NumPy's long double is wider than 64 bits, as on CI's Linux runners, and skips on this Mac. An x86-64 interpreter whose long double has 80 bits runs it along with every other test that needs no Core simulation, 167 in all, and all pass there. On main at d8ee910, with a stub
exact_countsthat returns its input so the file imports, 126 fail. The other 42 pin results main already gives: the sequence and array cases that agree on main, main's results for other denominators, the −0.0 numerator, the matrix, the overflow midpoint, the boundary denominators and the separate cent operands and families that the second review's mutations broke, the error for the next 32-bit float above a cent and for a 32-bit month value that is not whole, a sparse row of counts, which the stub accepts, the NaN bits that main's_quotientkeeps, a positive integer quotient just below the overflow midpoint, anintsubclass's quotient, the sign and the payload bits that main'sstoredkeeps for a NaN, in 16 cases, and the check that the tests' own reference rounding raises no floating-point error.I made 104 changes to
working_for_families.py, one at a time, and ran the new file after each on this Mac; the one that needs a long double wider than 64 bits also ran on the x86-64 interpreter. They include my versions of the changes the reviews tried. One hundred fail at least one new test, as the table shows; one of them, rounding a NumPy float wider than 64 bits first, fails only on the x86-64 interpreter, since this Mac's long double has 64 bits. The other four change nothing a test can see. Sending boolean cents incents_by_familyto the exact path gives the same exact sums. Rounding to infinity only above the overflow midpoint, on the integer or theFractionpath, still gives infinity at the midpoint itself, where the 32-bit rounding gives infinity and the tie repair keeps it. The 64-bit path's own type check now sees no subclass other thanbool, since_python_numberhas already turned each other subclass into the built-in number it holds, and abooldivides the same on either path.The 104 changes and a new test each fails
test_a_matrix_divides_like_an_arraynp.asarraytest_a_sequence_keeps_an_integer_above_2_to_the_53cents_by_familytest_unsigned_and_float_cents_sum_exactly_beside_an_empty_familycents_by_familyto the exact pathtest_unsigned_and_float_cents_sum_exactly_beside_an_empty_familytest_cents_must_be_whole_numbers[float]test_decimals_are_held_exactlytest_decimals_are_held_exactlytest_a_zero_dimensional_sum_is_an_arraytest_a_zero_dimensional_sum_is_an_arrayadd_centsto the exact pathtest_booleans_add_as_integersadd_centstest_narrow_and_mixed_sign_integers_add_exactlyadd_centstest_a_zero_dimensional_sum_is_an_arraytest_a_denominator_must_be_a_finite_number_other_than_zerotest_a_denominator_must_be_a_finite_number_other_than_zerotest_a_numerator_must_be_a_numbertest_a_finite_float_numerator_divides_exactlytest_zeros_and_infinities_take_the_sign_of_the_quotienttest_zeros_and_infinities_take_the_sign_of_the_quotientFractions in_quotienttest_a_finite_float_numerator_divides_exactly_python_numbertest_booleans_add_as_integersfinite_parts' sequence withnp.asarraytest_dates_and_durations_are_not_numbers[dates]test_only_a_rows_own_counts_add_togethertest_only_a_rows_own_counts_add_togethertest_counts_must_be_whole_numbers[2.5]test_core_counts_stay_as_they_are_and_others_become_64_bittest_core_counts_stay_as_they_are_and_others_become_64_bittest_counts_keep_their_shape_and_need_a_day_axiscredit_sums' counts but sum the originalstest_unsigned_counts_give_the_signed_resultsbest_start_sums' counts but sum the originalstest_whole_float_counts_sum_exactlytest_counts_must_sum_below_2_to_the_53cents_by_family's sum before wideningtest_the_smallest_int64_sums_exactly_beside_an_empty_familystored's sequence withnp.asarraytest_a_sequence_keeps_an_integer_above_2_to_the_53Fraction(value, denominator)test_a_float_numerator_halfway_between_32_bit_floats_rounds_to_even_python_numbertest_finite_parts_keeps_the_shape_and_reads_numpy_floatsfinite_parts' inputtest_finite_parts_keeps_the_shape_and_reads_numpy_floatsfinite_partstest_finite_parts_keeps_a_finite_float_countwholetest_the_32_bit_float_nearest_a_cent_pays_one_centwholewithout the value's type in_checkedtest_the_32_bit_float_nearest_a_cent_pays_one_centcredit_sumstest_each_sum_of_children_checks_both_counts[1-_credit_sums]credit_sumstest_each_sum_of_children_checks_both_counts[0-_credit_sums]best_start_sumstest_each_sum_of_children_checks_both_counts[1-_best_start_sums]best_start_sumstest_each_sum_of_children_checks_both_counts[0-_best_start_sums]test_counts_must_sum_below_2_to_the_53test_counts_must_sum_below_2_to_the_53test_counts_must_sum_below_2_to_the_53test_a_quotient_just_below_a_32_bit_midpoint_rounds_down_python_numbertest_dates_and_durations_are_not_numbers[held durations]test_counts_must_sum_below_2_to_the_53test_counts_keep_their_shape_and_need_a_day_axistest_counts_must_sum_below_2_to_the_53test_a_32_bit_value_with_a_step_of_1_must_be_wholetest_counts_keep_their_shape_and_need_a_day_axistest_integers_near_the_32_bit_overflow_midpoint_take_the_quotients_signtest_a_value_that_is_not_a_64_bit_float_divides_exactlytest_a_value_that_is_not_a_64_bit_float_divides_exactlytest_more_exact_denominators_and_boundariestest_a_value_that_is_not_a_64_bit_float_divides_exactlytest_a_quotient_that_underflows_or_overflows_raises_no_floating_point_errortest_integers_near_the_32_bit_overflow_midpoint_take_the_quotients_signtest_integers_near_the_32_bit_overflow_midpoint_take_the_quotients_signtest_dates_and_durations_are_not_numbers[held durations]test_a_wider_float_is_held_exactlyon the x86-64 interpretertest_finite_parts_keeps_the_shape_and_reads_numpy_floatstest_a_decimal_nan_keeps_its_sign[NaN-100-64-bit]test_decimals_are_held_exactlytest_counts_must_sum_below_2_to_the_53test_counts_must_sum_below_2_to_the_53test_dates_and_durations_are_not_numbers[dates]storedandfinite_partstest_dates_and_durations_are_not_numbers[dates]exact_countstest_rows_of_text_are_not_counts[text]test_a_zero_dimensional_sum_is_an_arrayfinite_partstest_dates_and_durations_are_not_numbers[held dates]wholethrough a 64-bit floattest_an_integer_is_whole_exactlytest_a_zero_dimensional_sum_is_an_arraytest_zeros_and_infinities_take_the_sign_of_the_quotientFractiondenominatortest_zeros_and_infinities_take_the_sign_of_the_quotienttest_more_exact_denominators_and_boundariestest_more_exact_denominators_and_boundariestest_cents_keep_each_operand_and_family_apartadd_centstest_cents_keep_each_operand_and_family_apartadd_centstest_cents_keep_each_operand_and_family_apartadd_cents' masks with exclusive ortest_cents_keep_each_operand_and_family_aparttest_cents_keep_each_operand_and_family_aparttest_core_counts_stay_as_they_are_and_others_become_64_bit__float___python_numberhas already turned every subclass butboolinto the built-in number it holds, and abooldivides the same on either pathstoredandfinite_partstest_dates_and_durations_inside_a_sequence_are_not_numbersexact_countstest_dates_and_durations_inside_a_sequence_are_not_numberswholewithout holding it exactlytest_an_integer_is_whole_exactlyFractionpath's quotient against the overflow midpoint in 64 bitstest_the_exact_paths_keep_a_quotient_below_the_midpoint_finitetest_integers_near_the_32_bit_overflow_midpoint_take_the_quotients_signtest_the_exact_quotient_keeps_a_nans_bitsexact_counts' errortest_counts_must_sum_below_2_to_the_53floatsubclass unconverted in_python_numbertest_a_subclass_with_its_own_arithmetic_divides_as_the_number_it_holdsintsubclass unconverted in_python_numbertest_a_subclass_with_its_own_arithmetic_divides_as_the_number_it_holdstest_dates_and_durations_inside_a_sequence_are_not_numbersdtypetest_an_array_subclass_is_checked_as_the_array_it_holds__array__or an array interfacetest_dates_and_durations_inside_a_sequence_are_not_numbersnp.arraytest_an_array_held_in_one_slot_is_not_a_numbertest_a_decimal_nan_keeps_its_sign[-NaN-100-64-bit]test_a_numerator_must_be_a_numberTrueandFalseinto 1 and 0 in_python_numbertest_finite_parts_gives_python_numbersOther checks, each run at this version merged with main at d8ee910:
stored,add_cents,cents_by_family,finite_partsand the two sums of children, across numerator types, Decimals, dates, durations and text, zero-dimensional arrays, exponent extremes, the overflow midpoint with both signs, integer, float,Fractionand Decimal denominators, many kinds of cents, and sequence, object and array inputs, gives the same output as an exact reference, built fromFractions and Python integers, in all 886, with NumPy set to raise on any floating-point error in both. The reference guards its own 32-bit conversions against those errors; before it did, 12 of its own conversions raised, as the third review found, and it matched 874. It gives the same output with those errors ignored, and every error it raises is one of theValueErrors listed above. For the two sums of children, the reference converts the counts to int64 and calls this version's own sums, so that part checks that other count types give the int64 results. Main differs from this version in 555 cases: main returns a value other than the exact one in 290, raises where this version returns the exact value in 92, raises a different error in 28, and returns a value where this version raises one of the errors listed above in 145.wholeagrees with an exact nearest-value check, built fromFractions, at steps of a cent and 1, on 387,488 checks: each step with every finite non-negative float16, and with 162,000 float32 values.Fractions and Core's 32-bit storage, gives the same stored credits, abatement and net credits as the model for 18,823 random families across nine reform schedules. Every family keeps its results beside an extreme family and with the families and their members in reverse order, and no credit is negative. No net Family Tax Credit, In-Work Tax Credit or Best Start payment rises by more than 1e-6 when income goes up by $1 or $1,000; the Family Tax Credit and In-Work Tax Credit checks skip families whose first parent hasAUTOMATICstatus and no wages, where a first dollar of wages can start the In-Work Tax Credit.storedtakes 4.0 to 4.1 milliseconds at this version, 5.6 to 5.8 at 1a405f8 and 3.2 to 3.3 on main, across three alternating runs that each take the best of five.working_for_families.pyas on main, finds none in the new test file, and leaves both files' formatting as it is.git merge-treefinds no conflicts with main at d8ee910, which changes no file this PR touches.The first review reproduced its findings 2 to 5 on main as well as at the first version, and my own runs on main agree.
Revisions
storedholds the denominator exactly, divides an integer over a whole denominator as Python integers and any other value that a 64-bit float does not hold throughFraction, and keeps main's results for negative and NumPy denominators and for matrices; the cent sums add booleans, unsigned integers and whole floats exactly and keep a huge integer exact beside an infinity;finite_partskeeps a sequence's integers and gives Python numbers;exact_countsreplacescheck_counts, bounds each row's own counts, and converts unsigned and float counts;whole's docstring names its steps; the description credits Working for Families helpers: int64, mixed-sequence and shape edge cases, and three missed mutations #27's comment with the 32-bit cent. Zero, infinite or NaN denominators and cents or counts that are not whole numbers now raise aValueError.storedsettles a 64-bit quotient at the overflow midpoint with the exact quotient (and drops two clamps that had no effect left), divides in 64 bits on normalized values with NumPy's floating-point errors ignored, and keeps NaN's bits in_quotient;_python_numberholds Decimals and NumPy floats wider than 64 bits exactly; the helpers reject date, duration and text arrays and object-held durations, andfinite_partsrejects values that are not numbers; zero-dimensional sums return arrays;wholecompares integers exactly; the description's parity, battery and grid wording is narrower; tests cover each witness.storeddivides only built-in floats and integers in 64 bits, so a subclass with its own__float__divides as the number it holds; the helpers reject arrays of dates, durations or text inside a sequence;wholeholds its step exactly;exact_countsgives its 2**53 error for a row sum too large to print; new tests cover the integer andFractionpaths just below the overflow midpoint and_quotient's NaN bits, and the test helper_nearest_float32works up to the largest 32-bit float. The description now saysstoredkeeps a NaN's sign, where the third version's entry said its bits, gives main's two-argumentwholecall, and gives the battery's strict comparison with the guarded reference._python_numberturns a subclass offloatorintinto the built-in number it holds before anything converts or divides it; the helpers check every sequence and array-like value that NumPy reads, check an array subclass as the plain array it holds, and keep an array held in a slot of an object array as one value; a Decimal NaN keeps its sign; the test helper_nearest_float32raises no floating-point error; a built-in float or integer leaves_python_numberat once, sostoredruns faster than at the fourth version; a new test pinsexact_counts' error for rows of text. The description andstored's docstring now say that a NaN keeps its sign and the payload bits that a 32-bit float holds, and drops the rest; the fourth version's commit message saidstoredkeeps NaN's bits.axiom: no RuleSpec change (helper code, tests and changelog)
🤖 Generated with Claude Code