Bugs found in a code review of master (6f0ec0bc)

Ouverte
#1,980 0 commentaires 1 réaction 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@JoerivanEngelen y travaille déjà.

Depuis le 27/11/2026.

  • #1981 par @evetion — ouverte

Évaluation

Cette issue n'a pas encore été évaluée.

Description

[!NOTE]
Bot notice: An AI coding agent (Claude Opus 5.5) wrote this issue for @evetion.

Summary

An AI agent reviewed the code on master at commit 6f0ec0bc. This issue lists 31 high, 75 medium and 26 low items, and 19 docstring errors. PR #1981 fixes 25 items. For 3 of them, the fix is partial.

Scope

  • The review covers all of imod/, except imod/wq (no longer developed) and imod/formats/isg (new code).
  • imod/couplers contains only a stub. The review found no problems there.
  • All links point to commit 6f0ec0bc.

Evidence

  • High: The agent reproduced each item with a script, or compared the written file with the MODFLOW 6 input definition (dfn) files. Some reproductions ran MF6 6.7.0 from the pixi environment. Each item gives the observed result and the expected result.
  • Medium and Low: A script or a reading of the code found the problem during the review. The agent did not reproduce these items a second time.
  • Intent: A second review checked each item for intent. It read the git history, the linked PRs and issues, the tests, the docstrings and the changelog, and it reproduced some items again with a script. No item was a wrong claim. Most items are mistakes: typos, copy-paste errors, regressions from refactors, or tests that were written to match the wrong output. Some items are deliberate behavior, or a side effect of a deliberate change:
    • (design question): a maintainer must decide what the correct behavior is.
    • (deliberate): the behavior is correct. Only the docs or a cleanup remain.

Severity

  • High: wrong results or a crash in normal use.
  • Medium: a crash or a wrong result in less common cases, or an API that does not do what its documentation says.
  • Low: small inconsistencies.

Status

A checked box means that #1981 fixes the item. #1981 is not merged yet. An item with a partial fix stays unchecked, and its text says what remains.

  • Fixed in #1981 (22): H1, H2, H3, H5, H6, H7, H8, H11, H12, H14, H17, H18, H19, H21, H24, H26, H28, H29, H30, H31, M31, L26
  • Partly fixed in #1981 (3): H4, H9, H23
  • Open (107 items and 19 docstring errors): all other items
  • Design questions (12, all open): H16, M27, M32, M36, M39 (second part), M44, M66, L2, L4, L11, L13, L23
  • Deliberate (2, open): L3, L5

High

MODFLOW 6 input
  • H1. EVT writes several options on one line (fixed in #1981)
    gwf-evt.j2#L4-L12
    Each {%- tag removes the newline before the next option. With print_flows=True, save_flows=True the options block contains print_flows save_flows on one line. MF6 reads only the first keyword. With MF6 6.7.0 the run ends normally, but the budget file has no EVT term. With species concentration, MF6 reads the keywords as auxiliary names and stops with an error.
  • H2. Lake connection data has length and width in the wrong order (fixed in #1981)
    lak.py#L988-L1008
    imod writes connection_width before connection_length. The MF6 input definition is ifno iconn cellid claktype bedleak belev telev connlen connwidth. The conductance of horizontal and embedded connections is wrong when length and width are different.
  • H3. Lake outlets block cannot be read by MF6 (fixed in #1981)
    lak.py#L1010-L1021
    The outlets block has no outletno column, and roughness comes before width. The MF6 input definition is outletno lakein lakeout couttype invert width rough slope. MF6 stops with Error converting "manning" to an integer for each lake with an outlet. There is a second problem. WEIR and SPECIFIED outlets have NaN for the fields that they do not use. imod writes NaN as an empty field, so the line is incomplete. MF6 6.7.0 stops with a segmentation fault on such a line. The PR fixes the column order, and writes 0.0 for the fields that the outlet type does not use. A missing value that the outlet type uses stays empty, so MF6 still reports it. Note: MF6 6.7.0 on macOS arm64 stops with SIGILL in the first solve for a MANNING or WEIR outlet from one lake to another lake, also when the invert is above the stage. A model that flopy writes, without imod, gives the same SIGILL. This is a problem in MF6, not in imod.
  • H4. IST package cannot be read by MF6 6.5 and later (partial fix in #1981)
    ist.py#L248 · gwt-ist.j2#L14-L15 · gwt-ist.j2#L21-L22
    There are three problems. First, the dataset key is "columns " with a trailing space, so {{columns}} renders empty. Second, the print-format line has no CIM prefix. The MF6 record is cim print_format formatrecord. Third, the template writes thetaim. MF6 6.5.0 replaced thetaim with porosity and volfrac. The pixi environment uses MF6 6.7.0. test_ist.py asserts the wrong print-format line. The PR fixes the first two problems. The third problem needs new arguments and a decision.
  • H5. Initial conditions with one constant per layer cannot be read by MF6 (fixed in #1981)
    ic.py#L88-L90 · gwf-ic.j2#L5
    _render sets layered, but the template reads strt_layered. For start=[1, 2, 3] along layer, the file has strt and three constant lines without layered. MF6 stops with Input file tag not found: "CONSTANT".
  • H6. Well.clip_box clips the wrong layers (fixed in #1981)
    wel.py#L1062-L1063 · wel.py#L1093
    The upper limit comes from the top of layer_max and the lower limit from the bottom of layer_min. This is the wrong way around. Also, isel(layer=layer) uses the layer number as a 0-based position. Model.clip_box and Modflow6Simulation.clip_box pass top and bottom, so they are also affected. Example with 10 layers of 1 m and a screen from 0 to -10: layer_min=3, layer_max=5 removes the well (expected screen -2 to -5). layer_max=5 gives -5 to -10 (expected 0 to -5). layer_min=3 gives 0 to -4 (expected -2 to -10).
MODFLOW 6 simulation and model
  • H7. Split skips an exchange after it removes an empty exchange (fixed in #1981)
    simulation.py#L1671-L1678
    The loop removes items from the list that it iterates over. The exchange after a removed exchange is not filtered. That exchange keeps connections to inactive cells, and imod writes them to the exchange file. Example with three partitions: one exchange has 18 connections, and 6 of them connect to inactive cells. The same model without the empty exchange gives 12 connections and none to inactive cells.
  • H8. Modflow6Model.clip_box with state_for_boundary keeps empty packages (fixed in #1981)
    model.py#L724-L738
    In the branch with a boundary state, only the top-system packages are purged. A CHD or WEL package that is empty after clipping stays in the model. The clipped simulation then fails validation on write (chd package: head: all nodata). Modflow6Simulation.clip_box with states_for_boundary uses this path.
  • H9. regrid_like and dump/from_file drop model options (partial fix in #1981)
    regrid.py#L318 · model.py#L603
    Both paths create the new model without options. newton, save_flows and the other options go back to their defaults without a warning. clip_box and split keep the options. Example: GroundwaterFlowModel(newton=True, save_flows=True).regrid_like(...) returns a model with newton=False, save_flows=False. The PR fixes regrid_like. dump does not write the options, so from_file needs a separate change.
  • H10. AnyValueSchema always passes
    schemata.py#L711-L717 · dis.py#L95
    ignore is True for every cell that is not NaN, so condition | ignore is True almost everywhere. AnyValueSchema(">", 0) accepts [[0, -1], [0, 0]]. DIS and DISV use this schema to require at least one active cell in idomain. An all-inactive domain passes validation. A fix makes validation stricter, so a maintainer should decide how to release it.
MODFLOW 6 output, evaluate and select
  • H11. Single-row DIS models: vertical flow is read as front-face flow (fixed in #1981)
    dis.py#L362-L367
    When nrow == 1, ncol equals ncells_per_layer. The front-face test comes first, so every vertical connection goes to front. open_cbc returns zeros for flow-lower-face and the vertical flows in flow-front-face. Reproduced with an MF6 6.7.0 run of a model with 2 layers, 1 row and 5 columns.
  • H12. DISV face flows go to the wrong edges when IDOMAIN is larger than 1 (fixed in #1981)
    disv.py#L25 · disv.py#L465
    A cell is active only when IDOMAIN equals 1. MF6 treats every positive value as active. Cells with IDOMAIN 2 drop out of the connection mask, and the flows shift to other edges. In an MF6 run of the TWRI DISV model with idomain[:, :10] = 2, 1257 of 1260 horizontal edges have a wrong value. With IDOMAIN 1 everywhere, all 1260 edges match the MF6 values.
  • H13. Cross sections give wrong cells when a line enters or leaves the grid near a corner
    cross_sections.py#L141-L163
    The start and end of the line inside the grid come from the first matching bound test. The code must use the latest entry and the earliest exit over x and y. On a 3 x 4 grid, the line from (-1, -10) to (2, 2) gives values [nan, 8, 9, 9, 5]. The expected values are [nan, 9, 5]. The line from (3.5, 2.5) to (-1, -20) gives a negative ds of -3.06.
  • H14. Cross sections fail on non-equidistant grids (fixed in #1981)
    cross_sections.py#L277-L280
    dx_a and dy_a are set only when the cell size is a float. For non-equidistant grids, cross_section_line raises UnboundLocalError: cannot access local variable 'dx_a'. The docstring says that non-equidistant grids are supported.
  • H15. Streamfunction and quiver use the flow of the next cell
    streamfunction.py#L79-L80 · streamfunction.py#L124-L125 · streamfunction.py#L201-L202 · streamfunction.py#L248-L249
    frf[j] is the flow through the right face of cell j. The cell-center flow of cell j is the mean of frf[j-1] and frf[j], which is shift(+1). The code uses shift(-1) and gives the center flow of cell j+1. For right-face flows [-1, -2, 0] the code gives [-1.5, -1, nan]. The expected values are [-0.5, -1.5, -1]. The NaN in the last row or column also makes the streamfunction 0 along a section in that row.
Prepare
  • H16. drop_empty_layers looks only at the first time step (design question)
    allocation.py#L647-L649 · allocation.py#L113-L121
    The docstrings say that a layer is dropped only when it is empty at all times, and that dropping does not change the values. The code uses only time=0 "for performance reasons". A layer that gets cells only at later times is dropped. drop_empty_layers=True is the default, also in River, Drainage, GeneralHeadBoundary and Recharge.from_imod5_data. Example: a stage that moves from layer 2 into layer 1 at the second time step loses 4 of 12 cells. The shortcut is deliberate: #1912 added it to avoid costly computations for transient packages. But the docstrings, and the changelog entry that says the values do not change, contradict it. A maintainer must choose: keep the shortcut and fix the docs (and maybe change the default of drop_empty_layers), or check all time steps.
  • H17. LayerRegridder and Voxelizer include padding zeros in minimum, maximum and median (fixed in #1981)
    layerregrid.py#L51-L52 · layerregrid.py#L94 · common.py#L312-L317
    The work buffers have one slot per source layer and are filled up to count. The code passes the full buffers to the method. Methods that do not use the weights also see the padding zeros. Example: source layers with values 5, 6 and 7. Target layer 1 overlaps source layer 1. Target layer 2 overlaps source layers 2 and 3. minimum gives [0, 0] (expected [5, 6]) and median gives [0, 6] (expected [5, 6.5]). The result is the same with and without numba JIT.
  • H18. c_leakage swaps kh and kv (fixed in #1981)
    resistance.py#L116 · resistance.py#L6-L12
    The signature is c_radial(L, kh, kv, B, D), but c_leakage calls c_radial(L, kv, kh, B, D). The radial resistance is wrong when kh and kv are different. c_leakage has no tests.
  • H19. linestring_to_trapezoid_zpolygons swaps the bottom elevations (fixed in #1981)
    hfb.py#L133-L140 · test_prepare_hfb.py#L62-L70
    The docstring puts zb0 at xy0 and zb1 at xy1. The code puts them the other way around. Every barrier made from these polygons gets the bottom of the other vertex, also without clipping. Example: x from 0 to 10, bottom -10 to -20. The bottom at x = 0 is -20 (expected -10). Clipping interpolates along this wrong bottom line: clipped at x = 2, the bottom is -18 (expected -12). The test asserts the swapped coordinates.
  • H20. Bent vertical barrier polygons lose their vertex order
    line_data.py#L109-L113
    groupby sorts the vertices by x and y, so the path order is lost. The schema accepts walls that bend in the xy plane. An L-shaped wall from (10, 0) to (0, 0) to (0, 10) comes back as LINESTRING Z (0 0 -5, 0 10 -5, 10 0 -5), with a diagonal leg. Barrier snapping (hfb.py line 420) and clipping (clip.py line 185) use this function. groupby(sort=False) alone is not a full fix, because a polygon ring can start in the middle of the path. Only polygons with more than one segment are affected, for example polygons that a user makes, or 3D GEN files. linestring_to_square_zpolygons and linestring_to_trapezoid_zpolygons make one polygon per segment, so their output is not affected.
Formats
  • H21. Saving an array chunked in x or y keeps only the last chunk (fixed in #1981)
    writing.py#L38-L41 · writing.py#L62-L71
    The function tests only the first dimension for x and y. For a (layer, y, x) array chunked in x, the recursion splits along x and writes each chunk to the same file. imod.idf.save and imod.rasterio.save are affected. Example: an array of shape (2, 2, 6) with x chunks of 3 reads back with shape (2, 2, 3).
  • H22. PRJ constants go to the wrong layer or period when entries are not sorted
    prj.py#L593-L598 · prj.py#L680-L689
    _merge_coords sorts the coordinates, but the values stay in file order. Example: KHV constants for layers 3, 1, 2 with values 30, 10, 20 come back as layer 1 = 30, layer 2 = 10, layer 3 = 20. An RCH block with WINTER before SUMMER also gets the values swapped. IDF paths are not affected.
  • H23. Opening several files that do not match the name pattern returns only the first file (partial fix in #1981)
    path.py#L61 · reading.py#L380-L381
    The default name pattern accepts only [\w-]. A name such as kh.v2_l1.idf does not match, so no dimensions are found. The reader then uses only the first path and ignores the others. imod.idf.open("kh.v2_l*.idf") on three files returns one 2D array with the values of the first file. The PR raises an error in this case. A better default pattern needs a decision.
MetaSWAP
  • H24. SprinklingGrid writes an empty scap_svat.inp for lazy (dask) data (fixed in #1981)
    sprinkling.py#L273-L275
    For a dask array, .values returns a temporary copy, so the assignment is lost. Every svat then has no well, and the file has zero rows. MetaSwapPackage.from_file opens data with dask, so every model loaded with from_file is affected. Example: the test fixture writes 4 lines from memory and 0 lines after dump and from_file.
  • H25. MetaSwapModel.regrid_like does not update the meteo mappings
    meteo_mapping.py#L146-L157 · model.py#L551-L562
    MeteoGrid is regridded, so the meteo .asc files are written on the new grid. PrecipitationMapping and EvapotranspirationMapping keep the old meteo grid. The row and column numbers in svat2precgrid.inp and svat2etrefgrid.inp then point to the wrong cells. Example: a regrid from 3 x 3 to 5 x 5 writes a 5 x 5 .asc grid. The mapping still uses rows 1 to 3 and columns 1 to 2. Both choices come from #1254. The MeteoMapping.regrid_like docstring says that the meteo data is not on the model grid, which suggests that MeteoGrid must not be regridded. But a test asserts that MeteoGrid is regridded. The direction of the fix is open.
  • H26. iMOD5 area conversion makes fully urban cells rural (fixed in #1981)
    imod5_converter.py#L57-L64
    The condition must be rural_area >= 0.0. Assume that one cell has more urban and wetted area than its cell area. The code then also sets the urban area to 0 in cells with a rural area of exactly 0. Those fully urban cells become fully rural. Example with a cell area of 100: cell A has urban 100. Cell B has urban 80 and wetted 50. Cell A comes back with rural 100 and urban 0.
  • H27. artificial_recharge is regridded with mean, but it holds types or IDs
    regrid_schemes.py#L56 · regrid_schemes.py#L479
    In grid mode the values are types 0, 1 and 2. In point mode they are sprinkling well IDs. Types 1 and 2 average to 1.5. The converter then treats the cell as active, but neither groundwater nor surface water. IDs 3 and 5 average to 4, which is a different well. CapDataRegridMethod() is the default in MetaSwapModel.from_imod5_data. mode is the expected method, but it changes default results, so a maintainer should decide.
Visualize
  • H28. grid_3d uses the top of the second layer as the model top (fixed in #1981)
    pyvista.py#L457
    isel(layer=1) selects the second layer. With layer tops 10 and 5 and bottoms 5 and 0, the mesh goes from 0 to 5 instead of 0 to 10. A model with one layer raises an IndexError.
  • H29. cross_section plots cells at the wrong positions when cell widths vary (fixed in #1981)
    cross_sections.py#L65
    The interior edges must be xmin + dx[:-1].cumsum(). For widths 1, 2 and 3, the edges are [0, 3, 3, 6, 6, 6]. The expected edges are [0, 1, 1, 3, 3, 6]. Output of imod.select.cross_section_line for a diagonal line usually has varying widths.
  • H30. cross_section fails for many decimal cell sizes (fixed in #1981)
    cross_sections.py#L56
    Floating-point rounding can make np.arange include xmax. For x centers 0.05 to 0.65 with dx 0.1, the plot fails with could not broadcast input array from shape (16,) into shape (2,14).
  • H31. StaticGridAnimation3D shows an empty scene (fixed in #1981)
    pyvista.py#L702-L715
    _initialize overrides the base class but does not add the mesh to the plotter. _update changes only the cell data. An off-screen plotter has 0 actors, against 2 for GridAnimation3D. The only test for this class is skipped.
Medium (75), Low (26) and docstring errors (19)

Medium

MODFLOW 6
  • M1. Relative OC output paths resolve against two different folders
    oc.py#L148-L153 · oc.py#L203-L211 · simulation.py#L979-L981
    With the default use_absolute_paths=False and head_file="output/head.hds", the OC file contains a path that MF6 resolves from the simulation folder. _write creates the folder relative to the Python working folder, and open_head reads from there. This is a regression from 484e192c (2023): _render now receives a path relative to the simulation folder, so the path conversion has no effect.
  • M2. OC writes scalar settings only in period 1 when another setting varies in time
    oc.py#L173-L187
    MF6 resets all OC settings at each new PERIOD block. With a time-varying save_head and save_budget="all", the budget is saved only in period 1.
  • M3. The model name file refers to hfb_merged.hfb when that file is not written
    model.py#L227-L235 · model.py#L511-L519
    _render adds the HFB entry when any HFB package exists. _write skips the file when no barrier snaps to the grid. MF6 then cannot open the file. Skipping the file is deliberate (#1353), but _render was not changed.
  • M4. ConstantConcentration.regrid_like fails
    cnc.py#L21
    CNC has no regrid scheme. The 3D concentration is passed to the constructor as a raw array. The call raises MissingDimensionsError. The same input as ConstantHead regrids without problems.
  • M5. Package.copy() fails for boundary conditions with species concentration
    package.py#L381-L392
    The species become extra data variables, which are not constructor arguments. mask and regrid_like remove them first, but copy does not. River.copy() raises TypeError.
  • M6. Split builds a new SSM package without save_flows and print_flows
    modelsplitter.py#L158-L166
    The split models get save_flows=False when the original SSM package had save_flows=True.
  • M7. Split requires the package keys "oc" and "npf"
    simulation.py#L1641-L1645 · simulation.py#L1665
    Package keys are chosen by the user. With other keys, split raises KeyError: 'oc'. The code for transport options uses _get_pkgkey, which works for all keys.
  • M8. write changes a ValidationSettings object that other simulations share
    simulation.py#L352-L354 · simulation.py#L1367-L1369 · simulation.py#L1533-L1535
    Clip, split and regrid pass the same settings object to the new simulation. Writing a split simulation sets strict_well_validation = False on the original simulation too.
  • M9. A simulation with ATS cannot be saved with dump and loaded with from_file
    simulation.py#L1173-L1184 · timedis.py#L135-L137
    from_file does not know AdaptiveTimeStepping and raises KeyError. After write, the dataset holds a Path object in ats_filename, and dump cannot serialize it.
  • M10. Simulation-level packages are not validated on write
    simulation.py#L397-L405
    IMS and ATS are written without validation. An ATS package with dt_min > dt_max and dt_multiplier=0.5 is written without an error.
  • M11. MST ignores save_flows
    gwt-mst.j2#L1-L4 · mst.py#L112-L129
    The template tests print_flows, which MST does not have, and has no save_flows line. The options block is empty with save_flows=True.
  • M12. SRC writes its first option on the begin options line
    gwt-src.j2#L1-L2
    The file contains begin options save_flows, and MF6 ignores the option. The budget file has no SRC term.
  • M13. Non-equidistant delr and delc are written with str(ndarray)
    dis.py#L130-L140
    NumPy shortens arrays with more than 1000 values to ... and rounds to 8 significant digits. A grid with 1001 columns gets 1.12345679 1. 2. ... 2. 1. 2. in the file.
  • M14. A lake outlet to outside the model fails validation
    lak.py#L703 · lak.py#L313-L316
    The schema requires lakeout > 0. The docstring and create_outlet_data use 0 for an outlet that leaves the model.
  • M15. OutletSpecified drops a scalar rate
    lak.py#L222-L232 · lak.py#L360-L364
    rate is not in the outlet variables, and only variables with a time coordinate are kept. A scalar rate of 5.0 does not appear in the file.
  • M16. HorizontalFlowBarrierMultiplier scales the multiplier by the overlap fraction
    hfb.py#L1485-L1488 · hfb.py#L1415
    The class docstring says that the multiplier applies to the whole layer. A barrier over 50% of a layer with multiplier 1.5 gives -0.75 instead of -1.5. The correct formula for a partial overlap is a choice: the multiplier for the whole layer, or 1 − f + f·m for an overlap fraction f.
  • M17. reallocate drops concentration and repeat_stress
    topsystem.py#L129-L132
    The reallocated River, Drainage, GHB or Recharge package has no concentration variables.
  • M18. LayeredWell accepts minimum_k and minimum_thickness but ignores them
    wel.py#L1246-L1251 · wel.py#L1458-L1466
    The docstring says that wells are not placed in cells below these limits. With minimum_k=100 and k = 1, the well is still placed. The limits were never implemented. Implement them, or remove the arguments.
  • M19. Lake options that are never written
    lak.py#L939-L954
    package_convergence_filename has no template line. ts6_filename is written only when ts_filerecord is set, and no code sets it.
  • M20. IST rejects an initial immobile concentration of 0
    ist.py#L164
    The schema requires initial_immobile_concentration > 0.0. 0 is a common starting value.
Output, evaluate and select
  • M21. stability_constraint_advection returns NaN where a velocity component is 0
    constraints.py#L134-L140
    Zero velocities become NaN before the terms are added, so one NaN term makes dt NaN. The bottom layer and all single-layer models get dt = NaN. The current test expects this result.
  • M22. open_cbc(flowja=True, simulation_start_time=...) always fails
    dis.py#L539-L543 · disv.py#L639-L643
    The time conversion also runs on the connectivity array, which has no time. DIS and DISV raise ValueError.
  • M23. read_grb fails on all DISU grid files
    disu.py#L13-L19
    The text header parsing does not match the MF6 layout (LENTXT 100). Both test files raise IndexError.
  • M24. open_cbc gives a UZF entry that fails on compute
    common.py#L25-L32 · cbc.py#L305-L310
    The id2 mapping of the gwf_* record is applied to all imeth=6 records. flow-ja-face_uzf has a different length and raises ValueError on compute.
  • M25. out_of_bounds="warn" does not drop points outside the grid
    points.py#L128-L144
    The docstrings say that "warn" warns and ignores those points. Only "ignore" drops them. points_values then fails, and points_set_values writes values into the wrong cells.
  • M26. Points exactly on xmax or ymax select the wrong cell
    points.py#L120 · points.py#L173-L179
    The bounds test includes the upper bound, but searchsorted puts it outside the grid. With descending y, y == ymax selects the bottom row. x == xmax raises IndexError. The inclusive bound is deliberate (#1189). The fix is to put points on the upper bound in the last cell. test_get_indices__nonequidistant expects the column index 4 for 4 columns, which is out of range.
  • M27. The layer argument of the point functions is treated as a spatial coordinate (design question)
    points.py#L147-L181 · constraints.py#L48-L53
    layer=[1] fails, layers 1, 2, 4 fail, and layer=2 on layers 1, 3, 5 selects layer 3. stability_constraint_wel fails on single-layer models. The point functions treat each keyword as an equidistant, cell-centered coordinate on purpose. A maintainer must choose: support label coordinates such as layer, or document the limit and fix the callers such as stability_constraint_wel.
  • M28. The facebudget docstring gives the wrong sign for lower
    budget.py#L163-L165 · constraints.py#L85-L87
    The code uses the MF6 convention (positive is upward flow). The existing test test_flowlower_up expects this convention. Only the docstring must change.
  • M29. facebudget fails without a zone and without a time dimension
    budget.py#L332-L336
    chunks = (1, *da_shape) always adds a time chunk, so 3D input fails.
  • M30. interpolate_value_boundaries fails with a 3D z and a scalar dz
    boundaries.py#L151-L164
    The scalar dz is broadcast to the 3D shape of z. The dispatch then tests the dimensions of z.dz (0), not of the broadcast array, and calls the numba function for a 1D dz. numba raises a TypingError.
  • M31. velocity_field swaps x and y for a 3D z and changes the input z (fixed in #1981)
    pyvista.py#L755-L762
    The meshgrid order is (z, x, y), but the result is unpacked as (z, y, x). zz *= vertical_exaggeration multiplies the caller's array in place. The function is not exported, but the changelog refers to it.
Prepare and util
  • M32. A stage exactly on a layer boundary puts most conductance in a layer the river does not reach (design question)
    allocation.py#L441 · conductance.py#L377-L379
    The layer above the stage (its bottom equals the stage) is allocated, and its full thickness is used as weight. Stage 0 at the bottom of layer 1 gives weights [0.667, 0.333]. A stage of 1e-6 higher gives [0, 1]. The >= test is deliberate (#1786), for the case where the stage, the river bottom and the layer bottom are equal. A maintainer must choose: keep >= and give that layer a weight of 0, or use >= only in that case.
  • M33. stage_to_riv_bot and at_elevation ignore active
    allocation.py#L136-L151 · allocation.py#L231-L232
    Both options allocate cells where IDOMAIN <= 0. The other options do not. These are the default options for rivers and drains.
  • M34. laplace_interpolate fills empty slices with 0
    laplace.py#L43-L69
    A layer or time step without data becomes 0.0. fill leaves it NaN.
  • M35. gdal_rasterize returns an empty raster for ascending y
    spatial.py#L429
    With dy > 0, the raster origin is above the grid. rasterize raises an error for the same input.
  • M36. zonal_aggregate_* give partial results for zones that cross chunks (design question)
    spatial.py#L1052-L1058 · spatial.py#L1107-L1115
    Each chunk is aggregated separately and the results are only joined. A zone that crosses a chunk boundary gets one row per chunk, each with a partial area and value. Aggregating per chunk is a deliberate trade-off for speed, and for methods such as mode and percentiles that cannot be merged. A maintainer must choose: merge the rows for methods that allow it, or document the behavior.
  • M37. celltable counts can overflow
    spatial.py#L620-L621
    The counts use the column dtype. With int16, a cell with more than 32767 fine cells gets a negative area.
  • M38. imod.util.replace fails on chunked dask arrays
    structured.py#L94
    The chunk function uses the full array da instead of the chunk.
  • M39. to_datetime_internal wraps dates out of range and ignores use_cftime (second part: design question)
    time.py#L76-L97
    datetime(3000, 1, 1) becomes 1830-11-23. An np.datetime64 input stays datetime64 with use_cftime=True. The first part is a mistake: _check_year runs only for str and datetime64 input. The second part is older behavior, and the docstring does not say what must happen.
  • M40. Voxelizer.voxelize changes the input like
    voxelize.py#L176-L184
    The function adds a dz coordinate to the input. The argument use_relative_weights is not used.
  • M41. Allocation fails when top has a layer dimension of size 1
    allocation.py#L376-L384 · layer.py#L23
    _is_layered needs more than one layer, so a single-layer top is handled as a top without layers. The call raises IndexError.
Formats
  • M42. save silently overwrites files for dimensions other than time, layer and species
    path.py#L171-L188
    The file name does not include other dimensions. With scenario=["a", "b"], both slices go to kh.idf. The docstring says that only these dimensions are supported, and the pattern argument can handle other dimensions. But without pattern, save does not raise an error.
  • M43. Wildcards in folder names no longer work in idf.open and rasterio.open
    reading.py#L434-L438
    Path.parent.glob(name) does not expand wildcards in the folder part. run*/head_l*.idf raises FileNotFoundError. Commit 2f8950be changed this from glob.glob.
  • M44. Species files written by save cannot be read back (design question)
    path.py#L58-L60 · path.py#L183-L188
    save writes _c{n} for any name. The reader recognizes species only for the name conc followed by a time. The strict reader is deliberate (1e169c8a, for the iMOD-SEAWAT convention conc_c{n}_{time}). The writer and the reader do not agree, so a maintainer must choose which one to change.
  • M45. "steady-state" file names break some read paths
    path.py#L148-L154 · idf.py#L462-L465 · idf.py#L579-L583
    open_subdomains, explicit {time} patterns and chunk_layout="per_timestep" fail on names such as head_steady-state_l1.idf.
  • M46. idf.write writes a corrupt file when the grid is uneven in one direction only
    idf.py#L788-L791 · idf.py#L816-L818
    With one dx and per-row dy, only one dx value is written instead of ncol. Without dx or dy coordinates, the call raises KeyError.
  • M47. PRJ: a constant artificial_recharge_layer fails in the CAP block
    prj.py#L1190-L1194 · prj.py#L1262-L1265
    The code reads block_item[0]["path"], which exists only for file entries.
  • M48. PRJ: WEL with linked time series needs filter columns
    prj.py#L1039-L1045
    row[4] and row[5] are read also when a layer is given. An IPF with only x, y, id raises IndexError.
  • M49. PRJ: "active" flags are read but not used
    prj.py#L272 · prj.py#L563-L564
    read_projectfile reads the flags, but open_projectfile_data (prj.py#L1197) does not use them. A package or system that is switched off is returned like an active one.
  • M50. ipf.save(itype=...) fails when each ID has one record
    ipf.py#L643-L661 · ipf.py#L481-L483
    Columns with one value per ID move into the IPF file. This is deliberate, but when each ID has one record, or time is constant for each ID, the required time column also moves. write_assoc then raises ValueError. A workaround is the assoc_columns argument.
  • M51. ipf.save needs an id column when there is a layer column
    ipf.py#L759-L766
    A frame with x, y, rate, layer and no associated files raises KeyError: 'id'.
  • M52. IPF: spaces after an associated column name stop nodata conversion
    ipf.py#L219-L224
    The nodata key keeps the space, but the column name is stripped. Head ,-999 returns -999 instead of NaN.
  • M53. IPF: rows with a trailing comma shift by one column
    ipf.py#L52-L76
    pd.read_csv without index_col=False uses the first field as the index. 1.0,2.0,3.0, becomes x=2, y=3, rate=NaN.
  • M54. gen.write accepts a rotated rectangle and writes a different box
    gen.py#L244-L249
    GEN rectangles are axis-aligned, so the code must compare with envelope. A 10 x 2 box rotated 30 degrees has area 20 when written and 31.6 when read back.
  • M55. A GEN file with an empty attribute row cannot be read back
    gen.py#L311-L320
    read_fwf skips blank lines, so the row count does not match.
  • M56. raise type(e)(msg) fails for some exception types
    gen.py#L409 · ipf.py#L120 · prj.py#L610
    The extra context in the message is deliberate, and the original error stays available as __context__. But some exception types need more than one argument. A UnicodeDecodeError becomes TypeError: function takes exactly 5 arguments. The same pattern is in ipf.py line 388 and prj.py lines 219, 558, 1177 and 1292.
  • M57. ipf.read with a list of string paths fails for associated files
    ipf.py#L367-L368 · ipf.py#L113
    The docstring shows a list of strings, but the code calls path.parent on a str.
MetaSWAP
  • M58. Packages from from_imod5_data cannot be regridded
    meteo_grid.py#L231 · regrid_schemes.py#L127 · sprinkling.py#L478
    The MeteoGridCopy path becomes the text of a DataArray. FileCopier raises. SprinklingPoints uses art_grid in the scheme and id_sprinkling in the dataset.
  • M59. MetaSwapModel.regrid_like loses settings and fails with defaults
    model.py#L544-L566
    The new model gets default simulation_settings and no starttime. The default regrid_cache=None raises. A CouplerMapping as first package raises UnboundLocalError.
  • M60. starttime is lost by clip_box and dump/from_file
    model.py#L687 · model.py#L444 · dump_model.py#L83-L84
    The start date changes to the first package time. dump also fails when unsaturated_database is a Path.
  • M61. mask_all_packages masks variables that are not grids
    model.py#L612-L619
    The scalar nodata of IdfMapping becomes a 2D array, and the point arrays of SprinklingPoints get x and y dimensions.
  • M62. The landuse validation includes inactive cells
    model.py#L212
    Masking fills inactive cells with landuse 0. After mask_all_packages, write with validation always fails.
  • M63. TimeOutputControl.clip_box writes a time before the new start
    output_control.py#L129
    The file uses the times variable, but clipping changes only the time coordinate.
  • M64. Regridding averages the -9999 "off" value into infiltration resistances
    regrid_schemes.py#L257-L258 · infiltration.py#L33
    Values -9999 and 100 give -4949.5. Validation accepts this value.
  • M65. InitialConditionsSavedState loses its path in dump/from_file
    initial_conditions.py#L106
    The path is a plain attribute, not a dataset variable. write after a round trip raises AttributeError.
  • M66. SprinklingPoints uses subunit coordinate values as positions (design question)
    sprinkling.py#L146-L150 · sprinkling.py#L53-L58
    The code works only for subunit coordinates [0, 1, ...]. Coordinates [1, 2] raise IndexError. All SprinklingPoints code uses subunit=[0, 1], but no check validates it. A maintainer must choose: validate the coordinates, or select by position.
  • M67. Fixed-width fields round or overflow values that pass validation
    fixed_format.py#L24-L26 · landuse.py#L86-L87
    Width-3 Jarvis fields lose all decimals, and values of 1000 or more overflow. Sprinkling capacities of 1e8 or more overflow width 8. An overflow moves all later columns in the line.
Common, visualize and logging
  • M68. imshow_topview draws ascending-y data upside down
    spatial.py#L413-L414
    The array is not flipped for ascending y. plot_map flips it.
  • M69. cross_section flips the data, but not the cell widths and the top and bottom, for decreasing x
    cross_sections.py#L53-L55
    Cells get the width, top and bottom of the cell at the mirrored position. With x = [4.5, 2, 0.5] and dx = [-3, -2, -1], the edges are [0, 5, 5, 6, 6, 6] at 6f0ec0bc, and [0, 3, 3, 5, 5, 6] after the H29 fix in #1981. The expected edges are [0, 1, 1, 3, 3, 6].
  • M70. The logging decorators fail when the first argument is a keyword
    logging_decorators.py#L25 · logging_decorators.py#L59
    Modflow6Simulation.from_file(toml_path=...) raises IndexError: tuple index out of range.
  • M71. Each call to configure(LoggerType.PYTHON) adds another handler
    pythonlogger.py#L40-L46
    After three calls, each message is printed three times.
  • M72. Regridding turns no-data into True for boolean variables
    regrid.py#L114-L116
    Only integer dtypes get fillna. NaN cast to bool is True. msw.GridData["active"] is affected.
  • M73. clip_layer_slice fails on a scalar layer outside the range
    clip.py#L334-L337
    Recharge with a scalar layer=1 and clip_box(layer_min=2) raises IndexError.
  • M74. Plot functions change their inputs
    spatial.py#L199 · cross_sections.py#L263-L264
    plot_map changes the over and under colors of a user colormap. The docstring says it does not. Keys are popped from kwargs_colorbar and similar dicts, so the second call behaves differently.
  • M75. plot_map and cross_section handle fig and ax incorrectly
    spatial.py#L228-L229 · cross_sections.py#L272-L273
    plot_map(fig=myfig) draws on the current figure. cross_section(ax=ax) without fig creates a new figure.

Low

  • L1. _get_grb_path builds the flow model path with the transport model's discretization key. simulation.py#L1031-L1033
  • L2. (design question) use_absolute_paths=True keeps relative tdis and ims paths in mfsim.nam. The docstring says "all paths", but test_mf6_absolute_paths.py asserts exactly one absolute path. Change the docstring or the code. simulation.py#L274 · simulation.py#L288
  • L3. (deliberate) Template variables that the code never fills: continue, nocheck, memory_print_option, mxiter, and the ts6/obs6 file records in all boundary condition templates. The templates were generated from the MF6 definitions with all options. This is a cleanup item. sim-nam.j2#L1-L10 · gwf-wel.j2#L1-L15
  • L4. (design question) Validation skips a package by its key "adv", not by its type. The skip is deliberate, but it matches on the key, and Advection now has init schemata. Skip by type, or remove the skip. model.py#L323
  • L5. (deliberate) SourceSinkMixing.from_flow_model raises for packages without concentration, but the docstring says it skips them. The error is deliberate, and a test asserts it. Change the docstring. ssm.py#L141-L143 · ssm.py#L185-L186
  • L6. The HFB init schema tests print_flows, which HFB does not store, and the init schema never runs. hfb.py#L1281-L1283 · hfb.py#L620-L627
  • L7. distribute_ghb_conductance has no docstring, because a statement comes before the string. conductance.py#L278-L279
  • L8. mode returns NaN when NaN sources have the largest overlap. common.py#L330-L350
  • L9. The empty_* helpers fail on NumPy scalar cell sizes such as np.float32. spatial.py#L58-L70
  • L10. The IDF header min and max include the nodata value. idf.py#L766-L767 · idf.py#L784-L785
  • L11. (design question) rasterio.write and save fail on integer arrays with the default nodata. The docstring makes the user responsible for a nodata value that fits the dtype. A default that depends on the dtype is an option. rasterio.py#L364 · rasterio.py#L456
  • L12. ipf.save and ipf.write_assoc change the column names of the input DataFrame. ipf.py#L758 · ipf.py#L479
  • L13. (design question) gen.write drops polygon holes without a warning. GEN polygons cannot hold holes. Warn, or raise an error. gen.py#L252-L254
  • L14. logger.log reports a line in ilogger.py (94 or 96, depending on the log level) as the source line. ilogger.py#L86-L100
  • L15. LanduseOptions defaults interception_intercept to None, but the value is required. landuse.py#L157 · landuse.py#L195
  • L16. MetaSwapModel.split gives all submodels the same settings dict. model.py#L740-L757
  • L17. Schemata details: CoordsSchema(require_all_keys=False) has no effect, DimsSchema does not accept None as a wildcard, and the ShapeSchema message swaps the counts. schemata.py#L556-L563 · schemata.py#L410-L416 · schemata.py#L498
  • L18. The basemap CRS test looks at the column names, so the overlay CRS is never used. spatial.py#L274-L277
  • L19. The netCDF serializer replaces an encoding argument from the user. netcdfserializer.py#L26
  • L20. lhm_clip_triangular_grid is documented to return an xr.Dataset, but returns an xu.Ugrid2d. sample_data.py#L184-L193
  • L21. out_of_bounds="ignore" with list inputs fails in points_indices and points_set_values. points.py#L137
  • L22. open_hds_like does not work for DIS or DISV (it is not exported). __init__.py#L353-L359 · dis.py#L548-L558 · disv.py#L647-L658
  • L23. (design question) Structured clip_by_grid clips points by bounding box, but unstructured clips by active cells. write removes wells in inactive cells, so the model output is probably the same. Make both paths the same, or accept the difference. clip.py#L53-L67 · clip.py#L82-L97
  • L24. get_active_domain_slice gives wrong bounds or fails for grids without dx/dy coordinates. grid.py#L17-L21
  • L25. test_precipitation_from_imod5[no_paths] and test_evapotranspiration_from_imod5[no_paths] fail on Linux and macOS, because the regex expects Windows path separators. test_precipitation_mapping.py#L210-L211 · test_evapotranspiration_mapping.py#L185-L186
  • L26. The rectangle_with_lakes test fixture stores SpecificStorage under the key "chd", so it replaces the ConstantHead package. The test model has no constant heads. (fixed in #1981) mf6_rectangle_with_lakes.py#L56
Docstrings that do not match the code
  • D1. create_time_discretization docstring uses times=. The argument is additional_times. simulation.py#L230
  • D2. ValidationSettings example uses validation_context=. The argument is validation_settings, and name is required. validation_settings.py#L42
  • D3. Aggregate scheme examples call riv.aggregate(aggregate_method=...), which does not exist. aggregate_schemes.py#L36-L37
  • D4. NPF icelltype regrid method is documented as mean. The code uses mode. regrid_schemes.py#L289
  • D5. Dispersion regrid docstring says transversal_horizontal. The field is transversal_horizontal1. regrid_schemes.py#L89
  • D6. IMS docstring mentions a csv_output argument that does not exist. ims.py#L22-L24
  • D7. Well docstrin
Langage dominant
Python
Étoiles
41
Forks
12
Merge moyen
2 j 8 h
PR mergées (30 j)
13

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Deltares/imod-python

Toutes les issues de Deltares/imod-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.