Skip to content

Chk/downsampling: do_cic() with fixedpoint intern, update downsampling_test.py#21

Open
ohrenschmaus wants to merge 21 commits into
mainfrom
chk/downsampling
Open

Chk/downsampling: do_cic() with fixedpoint intern, update downsampling_test.py#21
ohrenschmaus wants to merge 21 commits into
mainfrom
chk/downsampling

Conversation

@ohrenschmaus

Copy link
Copy Markdown
Collaborator

Um Rundungsfehler klein zu halten habe ich die den internen cic-Algorithmus auf fixedpoint-Typen umgestellt. Das ist kein Problem, da dort nur addiert und subtrahiert wird. Am Ende werden die Werte wieder auf np.floats umgewandelt und ausgegeben. Die Rundungsfehler sind mit np.float nicht extrem groß, fallen aber bei der Umsetzung auf C-floats(32bit) stark ins Gewicht.
Da ein CIC-Filter mit 'num_stages' Stufen und Dezimationsfaktor 'dsr' mathematisch identisch mit einem FIR-Filter mit einem Rechteckimpuls der Länge 'dsr', der 'num_stages' mit sich selbst gefaltet wird, ist, wird do_cic() nicht mehr gegen einen Goldwert sondern gegen einen fir-referenz-Array.

Neue Testfunktionen:

  • test_cic_first_value()
  • test_cic_all_values()
  • test_cic_size()
  • test_cic_size()
  • test_polyphase_two_size()
  • test_polyphase_two_type()
  • test_polyphase_dsr2_matches_order_two()
  • test_polyphase_dsr2_matches_order_one()
  • test_polyphase_dsr4_size()
  • test_polyphase_invalid_dsr_raises

der Test test_cic() fällt raus.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1587 1517 96% 0% 🟢

New Files

File Coverage Status
elasticai/creator_plugins/downsampling/src/c_compile/simple.py 40% 🟢
TOTAL 40% 🟢

Modified Files

File Coverage Status
elasticai/preprocessor/downsampling/downsampling.py 99% 🟢
TOTAL 99% 🟢

updated for commit: f256210 by action🐍

ohrenschmaus and others added 18 commits June 25, 2026 11:14
Keep chk/downsampling version: analytical tests with _fir_cic_ref
instead of golden-data arrays from main.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- downsampling.c: use last_even_prev/last_even (even-indexed samples)
  instead of last_ls/last_hs to correctly compute FIR [1,2,1]
  output[k] = uin[2k+1] + 2*uin[2k] + uin[2k-2]
- downsampling_test.py: replace 20000-entry golden data in
  test_polyphase_two with analytical first-value check; fix setUp
  to use sampling_rate=40e3 and freq=[4,400] after merge regression

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add c/downsampling_simple_template.h
- change src/c_compile/__init__.py
- add src/c_compile/simple.py
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