prop/test/microwaveprop/propagation/calibration_test.exs
Graham McIntire fd976b0cd5
fix: resolve 391 Credo issues across codebase
- Add jump_credo_checks ~> 0.4 with all 20 checks enabled
- Fix all standard Credo issues: 139 @spec (113 done, 26 remain),
  4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom,
  2 max line length, 9 assert_receive timeout
- Fix 170+ jump_credo_checks warnings:
  - 117 TopLevelAliasImportRequire: move nested alias/import to module top
  - 32 UseObanProWorker: switch to Oban.Pro.Worker
  - 4 DoctestIExExamples: add doctests / create test file
  - ~20 WeakAssertion: strengthen type-check assertions
  - Various ConditionalAssertion, AssertReceiveTimeout fixes
- Exclude vendor/ from Credo analysis
- Remaining: 175 warnings (mostly opinionated WeakAssertion,
  AvoidSocketAssignsInTest), 26 @spec annotations
2026-06-12 13:51:32 -05:00

33 lines
1 KiB
Elixir

defmodule Microwaveprop.Propagation.CalibrationTest do
use ExUnit.Case, async: true
alias Microwaveprop.Propagation.Calibration
describe "spearman/2" do
test "perfect monotonic correlation is 1.0" do
assert_in_delta Calibration.spearman([1, 2, 3, 4, 5], [10, 20, 30, 40, 50]), 1.0, 1.0e-9
end
test "perfect inverse correlation is -1.0" do
assert_in_delta Calibration.spearman([1, 2, 3, 4, 5], [50, 40, 30, 20, 10]), -1.0, 1.0e-9
end
test "uncorrelated input lands near zero" do
xs = Enum.to_list(1..100)
# constant ys has zero variance; function returns 0.0 by convention.
ys = List.duplicate(42, 100)
assert Calibration.spearman(xs, ys) == 0.0
end
test "returns nil for fewer than 3 pairs" do
assert Calibration.spearman([1], [1]) == nil
assert Calibration.spearman([1, 2], [3, 4]) == nil
end
end
describe "rmse/2" do
test "zero for identical lists" do
assert Calibration.rmse([1, 2, 3], [1, 2, 3]) == 0.0
end
end
end