Skip to content

Pr 62#65

Merged
danielnovais-tech merged 8 commits intomainfrom
pr-62
Feb 9, 2026
Merged

Pr 62#65
danielnovais-tech merged 8 commits intomainfrom
pr-62

Conversation

@danielnovais-tech
Copy link
Copy Markdown
Owner

@danielnovais-tech danielnovais-tech commented Feb 9, 2026

Description

Impact

User Benefit

Business Value

Roadmap Alignment

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test coverage improvement
  • Dependency update

Testing

  • I have run existing tests (pytest tests/ -v)
  • I have added new tests for my changes
  • All tests pass locally

Checklist

  • My code follows the PEP 8 style guidelines
  • I have added docstrings (Google-style) to new functions/classes
  • I have updated the documentation (README, API.md, etc.)
  • My changes generate no new warnings or errors
  • I have checked my code for potential security vulnerabilities
  • I have verified that my changes work as expected

Related Issues

Closes #

Screenshots (if applicable)

Additional Context

Copilot AI review requested due to automatic review settings February 9, 2026 11:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes small style/behavior adjustments across the simulation modules and scripts, including updates to test formatting, a change to GR801 fault injection scaling, UTC timestamp generation updates, and an FFT Nyquist-handling change in the toy simulation pipeline.

Changes:

  • Reformats GR801 simulation tests and config dict literals (quotes/whitespace).
  • Updates simulation_pipeline_gr801.inject_faults() chip area scaling to make faults more likely in short tests.
  • Adjusts FFT wavenumber grid generation to zero Nyquist modes (and updates scripts to use timezone-aware UTC timestamps).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_simulation_pipeline_gr801.py Test formatting updates; still contains probabilistic behavior that can be flaky without seeding.
simulation_pipeline_gr801.py Style tweaks + changes fault injection scaling; still uses print() for logging in changed regions.
simulation_pipeline.py Alters _k_grids() Nyquist handling; currently impacts k2 used beyond first-derivative operators.
scripts/run_simulation.py Uses timezone-aware UTC timestamp for run IDs.
scripts/anatel_api_diagnose.py Uses timezone-aware UTC timestamp in generated report.
Comments suppressed due to low confidence (1)

simulation_pipeline_gr801.py:178

  • safety_violation_detected emits a print() on threshold breach; this makes library use noisy and hard to test. Prefer LOGGER.warning(...) (or return the condition and let the caller decide how to report) to follow the repo’s logging convention.
        'performance': state.soc.performance,
        'total_faults_injected': state.faults_injected,
        'total_faults_corrected': state.faults_corrected,
        'application_accuracy': state.app.accuracy,
    }
    return metrics


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 65 to 78
def test_inject_faults():
"""Test fault injection mechanism with deterministic seeding."""
# Seed the random number generator for reproducibility
np.random.seed(42)

soc = sim.SoC(num_cores=4, memory_size=1024, accelerator_present=True)
radiation = sim.RadiationModel(particle_flux=10.0, upset_rate=0.1)

radiation = sim.RadiationModel(particle_flux=100.0, upset_rate=0.5)

# Run multiple times to ensure some faults are injected
# With high flux and upset rate, we should consistently see faults
total_faults = 0
for _ in range(10):
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_inject_faults is probabilistic (asserts total_faults > 0) but the test suite does not seed NumPy’s RNG, so it can be flaky (rarely producing 0 faults). Seed deterministically (e.g., np.random.seed(...)) or switch to a local np.random.default_rng(...) generator so CI runs are stable and reproducible.

Copilot uses AI. Check for mistakes.
Comment thread simulation_pipeline_gr801.py Outdated
Comment on lines 167 to 170
"faults_injected": state.faults_injected,
"faults_corrected": state.faults_corrected,
"application_accuracy": state.app.accuracy,
'time': state.time,
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module uses print() for runtime logging. Elsewhere in the repo (e.g., simulation_pipeline.py) logging goes through a module-level LOGGER = logging.getLogger(__name__). Please switch log_state to use a logger instead of print() so output can be controlled via log levels/handlers.

Copilot uses AI. Check for mistakes.
Comment on lines 182 to 185
LOGGER.info(
"Time: %.2fs, Errors: %d, Performance: %.2f",
metrics['time'], metrics['errors'], metrics['performance']
)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trigger_safe_shutdown prints directly. Prefer routing this through the module logger (and/or returning a structured shutdown reason) to keep CLI output and library behavior separate and consistent with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Comment thread simulation_pipeline.py
Comment on lines 60 to +71

# For even-sized real grids, the Nyquist mode is self-conjugate and must have
# a purely real FFT coefficient. Multiplying it by i*k to form a first
# derivative would yield a purely imaginary coefficient, which cannot
# correspond to a real-valued field on the grid. The discrete sampled
# derivative of the Nyquist cosine mode is identically zero at grid points,
# so we zero the Nyquist wavenumber for *first-derivative* operators.
if nx % 2 == 0:
kx_1d[nx // 2] = 0.0
if ny % 2 == 0:
ky_1d[ny // 2] = 0.0
if nz % 2 == 0:
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _k_grids, zeroing the Nyquist entries of kx_1d/ky_1d/kz_1d changes k2 as well, but k2 is used for non-first-derivative operators (e.g., propagate_wavefunction’s kinetic term and Gauss constraint projection). This makes the Laplacian/Poisson operator incorrect for Nyquist modes on even grids. Consider leaving the raw FFT frequencies intact here and instead handling the Nyquist special-case only inside the specific first-derivative routines (e.g., _divergence_spectral), or add a separate helper/flag so callers can request “first-derivative-safe” k-grids without affecting k2.

Copilot uses AI. Check for mistakes.
@danielnovais-tech danielnovais-tech merged commit 092bc2d into main Feb 9, 2026
4 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.

2 participants