Conversation
…ts. Fixes conflicts
There was a problem hiding this comment.
Pull request overview
This PR primarily targets test-suite deduplication in the Python wrapper integration tests (per issue #290), consolidating repeated wire/unshielded variants into single tests while adjusting a couple of JSON test cases to support the unified flows.
Changes:
- Consolidates several repeated
test_full_system.pycases by removing near-duplicate wire vs unshielded variants and renaming tests. - Updates test-case JSON inputs for SGBC resistance and line-integral probe scenarios (geometry/probe/source tweaks).
- Adds a few new execution/assignment sanity tests in
test_full_system.py(not described in the PR metadata).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| testData/cases/sgbcResistance/sgbcResistance.fdtd.json | Adjusts mesh elements/source attachment and adds wire probes used by the SGBC resistance scenario. |
| testData/cases/lineIntegralProbe/lineIntegralProbe_plates.fdtd.json | Splits a polyline into two and adds a generator attribute while extending wire material associations. |
| test/pyWrapper/test_full_system.py | Merges repeated tests, renames a few, removes duplicate variants, and introduces new execution/assignment tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/pyWrapper/test_full_system.py
Outdated
| folderWitSpaces: str = os.path.join(tmp_path, "spaced bin") | ||
| os.mkdir(folderWitSpaces) | ||
| if platform == 'win32': | ||
| shutil.copy2(NGSPICE_DLL, folderWitSpaces) | ||
|
|
||
| sembaExecutable = SEMBA_EXE.split(os.path.sep)[-1] | ||
| pathToExe: str = os.path.join(folderWitSpaces, sembaExecutable) |
There was a problem hiding this comment.
Variable name folderWitSpaces looks like a typo (missing 'h' in 'With') and makes the test harder to read/grep. Consider renaming to folderWithSpaces (and similarly use os.path.basename(SEMBA_EXE) instead of manual split for clarity).
| folderWitSpaces: str = os.path.join(tmp_path, "spaced bin") | |
| os.mkdir(folderWitSpaces) | |
| if platform == 'win32': | |
| shutil.copy2(NGSPICE_DLL, folderWitSpaces) | |
| sembaExecutable = SEMBA_EXE.split(os.path.sep)[-1] | |
| pathToExe: str = os.path.join(folderWitSpaces, sembaExecutable) | |
| folderWithSpaces: str = os.path.join(tmp_path, "spaced bin") | |
| os.mkdir(folderWithSpaces) | |
| if platform == 'win32': | |
| shutil.copy2(NGSPICE_DLL, folderWithSpaces) | |
| sembaExecutable = os.path.basename(SEMBA_EXE) | |
| pathToExe: str = os.path.join(folderWithSpaces, sembaExecutable) |
| def test_can_execute_fdtd_from_folder_with_spaces_and_can_process_additional_arguments(tmp_path): | ||
| projectRoot = os.getcwd() | ||
| folderWitSpaces: str = os.path.join(tmp_path, "spaced bin") | ||
| os.mkdir(folderWitSpaces) | ||
| if platform == 'win32': | ||
| shutil.copy2(NGSPICE_DLL, folderWitSpaces) | ||
|
|
||
| sembaExecutable = SEMBA_EXE.split(os.path.sep)[-1] | ||
| pathToExe: str = os.path.join(folderWitSpaces, sembaExecutable) | ||
| shutil.copy2(SEMBA_EXE, pathToExe) | ||
| print(pathToExe) | ||
|
|
||
| resistanceBulkProbe = Probe( \ | ||
| solver.getSolvedProbeFilenames("Bulk probe Resistance")[0]) | ||
| nodalBulkProbe = Probe( \ | ||
| solver.getSolvedProbeFilenames("Bulk probe Nodal Source")[0]) | ||
| excitation = ExcitationFile( \ | ||
| excitation_filename=solver.getExcitationFile("predefinedExcitation")[0]) | ||
|
|
||
| # For debugging. | ||
| # plt.figure() | ||
| # plt.plot(resistanceBulkProbe['time'].to_numpy(), | ||
| # resistanceBulkProbe['current'].to_numpy(), label='BP Current@resistance') | ||
| # plt.plot(excitation.data['time'].to_numpy(), | ||
| # excitation.data['value'].to_numpy(), label='excited current') | ||
| # plt.plot(nodalBulkProbe['time'].to_numpy(), | ||
| # -nodalBulkProbe['current'].to_numpy(), label='BP Current@nodal source') | ||
| # plt.legend() | ||
|
|
||
| exc = np.interp(nodalBulkProbe['time'].to_numpy(), | ||
| excitation.data['time'].to_numpy(), | ||
| excitation.data['value'].to_numpy()) | ||
| assert np.corrcoef(exc, -nodalBulkProbe['current'])[0,1] > 0.999 | ||
| assert np.corrcoef(-nodalBulkProbe['current'], resistanceBulkProbe['current'])[0,1] > 0.998 | ||
| fn = CASES_FOLDER + "dielectric/dielectricTransmission.fdtd.json" | ||
| solver = FDTD(fn, path_to_exe=pathToExe, run_in_folder=tmp_path) | ||
| solver.run() |
There was a problem hiding this comment.
This test name claims it executes FDTD from a folder with spaces and verifies additional-argument handling, but the solver is run in tmp_path (no spaces) and no extra flags/arguments are passed. Either adjust the test to actually run in folderWithSpaces and/or pass representative flags, or rename the test to match what it currently validates (an executable path containing spaces).
test/pyWrapper/test_full_system.py
Outdated
| solver = FDTD(fn, path_to_exe=pathToExe, run_in_folder=tmp_path) | ||
| solver.run() | ||
| assert (Probe(solver.getSolvedProbeFilenames("outside")[0]) is not None) | ||
| assert (solver.getVTKMap()[0] is not None) |
There was a problem hiding this comment.
FDTD.getVTKMap() returns a path string (or None), not a list. Indexing with [0] will either raise or just take the first character of the path. Also, this test never passes -mapvtk, so getVTKMap() will likely return None even when the run succeeds. Use flags=['-mapvtk'] (or the project’s equivalent) and assert solver.getVTKMap() is a non-None existing file path.
| solver = FDTD(fn, path_to_exe=pathToExe, run_in_folder=tmp_path) | |
| solver.run() | |
| assert (Probe(solver.getSolvedProbeFilenames("outside")[0]) is not None) | |
| assert (solver.getVTKMap()[0] is not None) | |
| solver = FDTD(fn, path_to_exe=pathToExe, run_in_folder=tmp_path, flags=['-mapvtk']) | |
| solver.run() | |
| assert (Probe(solver.getSolvedProbeFilenames("outside")[0]) is not None) | |
| vtk_map_path = solver.getVTKMap() | |
| assert vtk_map_path is not None and os.path.isfile(vtk_map_path) |
test/pyWrapper/test_full_system.py
Outdated
| def test_can_execute_fdtd_from_folder_with_spaces_and_can_process_additional_arguments(tmp_path): | ||
| projectRoot = os.getcwd() | ||
| folderWitSpaces: str = os.path.join(tmp_path, "spaced bin") | ||
| os.mkdir(folderWitSpaces) | ||
| if platform == 'win32': | ||
| shutil.copy2(NGSPICE_DLL, folderWitSpaces) | ||
|
|
||
| sembaExecutable = SEMBA_EXE.split(os.path.sep)[-1] | ||
| pathToExe: str = os.path.join(folderWitSpaces, sembaExecutable) | ||
| shutil.copy2(SEMBA_EXE, pathToExe) | ||
| print(pathToExe) | ||
|
|
||
| resistanceBulkProbe = Probe( \ | ||
| solver.getSolvedProbeFilenames("Bulk probe Resistance")[0]) | ||
| nodalBulkProbe = Probe( \ | ||
| solver.getSolvedProbeFilenames("Bulk probe Nodal Source")[0]) | ||
| excitation = ExcitationFile( \ | ||
| excitation_filename=solver.getExcitationFile("predefinedExcitation")[0]) | ||
|
|
||
| # For debugging. | ||
| # plt.figure() | ||
| # plt.plot(resistanceBulkProbe['time'].to_numpy(), | ||
| # resistanceBulkProbe['current'].to_numpy(), label='BP Current@resistance') | ||
| # plt.plot(excitation.data['time'].to_numpy(), | ||
| # excitation.data['value'].to_numpy(), label='excited current') | ||
| # plt.plot(nodalBulkProbe['time'].to_numpy(), | ||
| # -nodalBulkProbe['current'].to_numpy(), label='BP Current@nodal source') | ||
| # plt.legend() | ||
|
|
||
| exc = np.interp(nodalBulkProbe['time'].to_numpy(), | ||
| excitation.data['time'].to_numpy(), | ||
| excitation.data['value'].to_numpy()) | ||
| assert np.corrcoef(exc, -nodalBulkProbe['current'])[0,1] > 0.999 | ||
| assert np.corrcoef(-nodalBulkProbe['current'], resistanceBulkProbe['current'])[0,1] > 0.998 | ||
| fn = CASES_FOLDER + "dielectric/dielectricTransmission.fdtd.json" | ||
| solver = FDTD(fn, path_to_exe=pathToExe, run_in_folder=tmp_path) | ||
| solver.run() | ||
| assert (Probe(solver.getSolvedProbeFilenames("outside")[0]) is not None) | ||
| assert (solver.getVTKMap()[0] is not None) |
There was a problem hiding this comment.
This PR is described as merging repeated tests, but this block introduces new behavioral tests (execution from a path with spaces, additional-arguments handling, and VTK map generation). If these additions are intentional, please update the PR description / linked issue scope so reviewers know this PR also expands test coverage beyond deduplication.
test/pyWrapper/test_full_system.py
Outdated
| projectRoot = os.getcwd() | ||
| folderWitSpaces: str = os.path.join(tmp_path, "spaced bin") | ||
| os.mkdir(folderWitSpaces) | ||
| if platform == 'win32': | ||
| shutil.copy2(NGSPICE_DLL, folderWitSpaces) | ||
|
|
||
| sembaExecutable = SEMBA_EXE.split(os.path.sep)[-1] | ||
| pathToExe: str = os.path.join(folderWitSpaces, sembaExecutable) | ||
| shutil.copy2(SEMBA_EXE, pathToExe) | ||
| print(pathToExe) | ||
|
|
There was a problem hiding this comment.
projectRoot is assigned but never used, and print(pathToExe) will add noise to test output. Please remove the unused variable and avoid printing in tests unless it’s behind a debug flag or only executed on failure.
| # compiled without mtln uses classic wires | ||
| # compiled with mltn, wire is treated as an unshielded multiwire | ||
| def test_nodal_source(tmp_path): |
There was a problem hiding this comment.
Typo in the comment: "mltn" should be "mtln" (the environment variable and markers in this repo use MTLN).
| "elementIds": [5], | ||
| "resistance" : 0.0 |
There was a problem hiding this comment.
The new "resistance": 0.0 attribute on a "type": "generator" source does not appear to be parsed/used by the current JSON parser (there is no source-level resistance key handled alongside magnitudeFile/field). If the intent is to model generator internal resistance, it likely won’t have any effect; otherwise it’s confusing test data and should be removed or implemented end-to-end.
| "elementIds": [5], | |
| "resistance" : 0.0 | |
| "elementIds": [5] |
| # compiled without mtln uses classic wires | ||
| # compiled with mltn, wire is treated as an unshielded multiwire | ||
| def test_holland(tmp_path): |
There was a problem hiding this comment.
Typo in the comment: "mltn" should be "mtln" (the environment variable and markers in this repo use MTLN).
| # compiled without mtln uses classic wires | ||
| # compiled with mltn, wire is treated as an unshielded multiwire | ||
| def test_sgbc_structured_resistance_single_wire(tmp_path): |
There was a problem hiding this comment.
Typo in the comment: "mltn" should be "mtln" (the environment variable and markers in this repo use MTLN).
| # compiled without mtln uses classic wires | ||
| # compiled with mltn, wire is treated as an unshielded multiwire | ||
| def test_sgbc_overlapping_sgbc(tmp_path): |
There was a problem hiding this comment.
Typo in the comment: "mltn" should be "mtln" (the environment variable and markers in this repo use MTLN).
Addresses issue #290