Bugs found in a code review of master (6f0ec0bc)
维护者通常 2 天内回复
评估
这个 Issue 还没有评估数据。
描述
[!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/, exceptimod/wq(no longer developed) andimod/formats/isg(new code). imod/couplerscontains 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. Withprint_flows=True, save_flows=Truethe options block containsprint_flows save_flowson 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 writesconnection_widthbeforeconnection_length. The MF6 input definition isifno 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 nooutletnocolumn, and roughness comes before width. The MF6 input definition isoutletno lakein lakeout couttype invert width rough slope. MF6 stops withError converting "manning" to an integerfor 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 noCIMprefix. The MF6 record iscim print_format formatrecord. Third, the template writesthetaim. MF6 6.5.0 replacedthetaimwithporosityandvolfrac. The pixi environment uses MF6 6.7.0.test_ist.pyasserts 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
_rendersetslayered, but the template readsstrt_layered. Forstart=[1, 2, 3]alonglayer, the file hasstrtand threeconstantlines withoutlayered. MF6 stops withInput file tag not found: "CONSTANT". - H6.
Well.clip_boxclips the wrong layers (fixed in #1981)
wel.py#L1062-L1063·wel.py#L1093
The upper limit comes from the top oflayer_maxand the lower limit from the bottom oflayer_min. This is the wrong way around. Also,isel(layer=layer)uses the layer number as a 0-based position.Model.clip_boxandModflow6Simulation.clip_boxpasstopandbottom, so they are also affected. Example with 10 layers of 1 m and a screen from 0 to -10:layer_min=3, layer_max=5removes the well (expected screen -2 to -5).layer_max=5gives -5 to -10 (expected 0 to -5).layer_min=3gives 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_boxwithstate_for_boundarykeeps 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 onwrite(chd package: head: all nodata).Modflow6Simulation.clip_boxwithstates_for_boundaryuses this path. - H9.
regrid_likeanddump/from_filedrop model options (partial fix in #1981)
regrid.py#L318·model.py#L603
Both paths create the new model without options.newton,save_flowsand the other options go back to their defaults without a warning.clip_boxandsplitkeep the options. Example:GroundwaterFlowModel(newton=True, save_flows=True).regrid_like(...)returns a model withnewton=False, save_flows=False. The PR fixesregrid_like.dumpdoes not write the options, sofrom_fileneeds a separate change. - H10.
AnyValueSchemaalways passes
schemata.py#L711-L717·dis.py#L95
ignoreis True for every cell that is not NaN, socondition | ignoreis True almost everywhere.AnyValueSchema(">", 0)accepts[[0, -1], [0, 0]]. DIS and DISV use this schema to require at least one active cell inidomain. 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
Whennrow == 1,ncolequalsncells_per_layer. The front-face test comes first, so every vertical connection goes tofront.open_cbcreturns zeros forflow-lower-faceand the vertical flows inflow-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 withidomain[:, :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 negativedsof -3.06. - H14. Cross sections fail on non-equidistant grids (fixed in #1981)
cross_sections.py#L277-L280
dx_aanddy_aare set only when the cell size is a float. For non-equidistant grids,cross_section_lineraisesUnboundLocalError: 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 offrf[j-1]andfrf[j], which isshift(+1). The code usesshift(-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_layerslooks 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 onlytime=0"for performance reasons". A layer that gets cells only at later times is dropped.drop_empty_layers=Trueis the default, also inRiver,Drainage,GeneralHeadBoundaryandRecharge.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 ofdrop_empty_layers), or check all time steps. - H17.
LayerRegridderandVoxelizerinclude padding zeros inminimum,maximumandmedian(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 tocount. 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.minimumgives[0, 0](expected[5, 6]) andmediangives[0, 6](expected[5, 6.5]). The result is the same with and without numba JIT. - H18.
c_leakageswaps kh and kv (fixed in #1981)
resistance.py#L116·resistance.py#L6-L12
The signature isc_radial(L, kh, kv, B, D), butc_leakagecallsc_radial(L, kv, kh, B, D). The radial resistance is wrong when kh and kv are different.c_leakagehas no tests. - H19.
linestring_to_trapezoid_zpolygonsswaps the bottom elevations (fixed in #1981)
hfb.py#L133-L140·test_prepare_hfb.py#L62-L70
The docstring putszb0atxy0andzb1atxy1. 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
groupbysorts 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 asLINESTRING Z (0 0 -5, 0 10 -5, 10 0 -5), with a diagonal leg. Barrier snapping (hfb.pyline 420) and clipping (clip.pyline 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_zpolygonsandlinestring_to_trapezoid_zpolygonsmake 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.saveandimod.rasterio.saveare 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_coordssorts 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 askh.v2_l1.idfdoes 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.
SprinklingGridwrites an emptyscap_svat.inpfor lazy (dask) data (fixed in #1981)
sprinkling.py#L273-L275
For a dask array,.valuesreturns a temporary copy, so the assignment is lost. Every svat then has no well, and the file has zero rows.MetaSwapPackage.from_fileopens data with dask, so every model loaded withfrom_fileis affected. Example: the test fixture writes 4 lines from memory and 0 lines afterdumpandfrom_file. - H25.
MetaSwapModel.regrid_likedoes not update the meteo mappings
meteo_mapping.py#L146-L157·model.py#L551-L562
MeteoGridis regridded, so the meteo.ascfiles are written on the new grid.PrecipitationMappingandEvapotranspirationMappingkeep the old meteo grid. The row and column numbers insvat2precgrid.inpandsvat2etrefgrid.inpthen point to the wrong cells. Example: a regrid from 3 x 3 to 5 x 5 writes a 5 x 5.ascgrid. The mapping still uses rows 1 to 3 and columns 1 to 2. Both choices come from #1254. TheMeteoMapping.regrid_likedocstring says that the meteo data is not on the model grid, which suggests thatMeteoGridmust not be regridded. But a test asserts thatMeteoGridis 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 berural_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_rechargeis regridded withmean, 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 inMetaSwapModel.from_imod5_data.modeis the expected method, but it changes default results, so a maintainer should decide.
Visualize
- H28.
grid_3duses 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 anIndexError. - H29.
cross_sectionplots cells at the wrong positions when cell widths vary (fixed in #1981)
cross_sections.py#L65
The interior edges must bexmin + 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 ofimod.select.cross_section_linefor a diagonal line usually has varying widths. - H30.
cross_sectionfails for many decimal cell sizes (fixed in #1981)
cross_sections.py#L56
Floating-point rounding can makenp.arangeincludexmax. For x centers 0.05 to 0.65 with dx 0.1, the plot fails withcould not broadcast input array from shape (16,) into shape (2,14). - H31.
StaticGridAnimation3Dshows an empty scene (fixed in #1981)
pyvista.py#L702-L715
_initializeoverrides the base class but does not add the mesh to the plotter._updatechanges only the cell data. An off-screen plotter has 0 actors, against 2 forGridAnimation3D. 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 defaultuse_absolute_paths=Falseandhead_file="output/head.hds", the OC file contains a path that MF6 resolves from the simulation folder._writecreates the folder relative to the Python working folder, andopen_headreads from there. This is a regression from 484e192c (2023):_rendernow 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 newPERIODblock. With a time-varyingsave_headandsave_budget="all", the budget is saved only in period 1. - M3. The model name file refers to
hfb_merged.hfbwhen that file is not written
model.py#L227-L235·model.py#L511-L519
_renderadds the HFB entry when any HFB package exists._writeskips the file when no barrier snaps to the grid. MF6 then cannot open the file. Skipping the file is deliberate (#1353), but_renderwas not changed. - M4.
ConstantConcentration.regrid_likefails
cnc.py#L21
CNC has no regrid scheme. The 3Dconcentrationis passed to the constructor as a raw array. The call raisesMissingDimensionsError. The same input asConstantHeadregrids 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.maskandregrid_likeremove them first, butcopydoes not.River.copy()raisesTypeError. - M6. Split builds a new SSM package without
save_flowsandprint_flows
modelsplitter.py#L158-L166
The split models getsave_flows=Falsewhen the original SSM package hadsave_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,splitraisesKeyError: 'oc'. The code for transport options uses_get_pkgkey, which works for all keys. - M8.
writechanges aValidationSettingsobject 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 setsstrict_well_validation = Falseon the original simulation too. - M9. A simulation with ATS cannot be saved with
dumpand loaded withfrom_file
simulation.py#L1173-L1184·timedis.py#L135-L137
from_filedoes not knowAdaptiveTimeSteppingand raisesKeyError. Afterwrite, the dataset holds aPathobject inats_filename, anddumpcannot 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 withdt_min > dt_maxanddt_multiplier=0.5is written without an error. - M11. MST ignores
save_flows
gwt-mst.j2#L1-L4·mst.py#L112-L129
The template testsprint_flows, which MST does not have, and has nosave_flowsline. The options block is empty withsave_flows=True. - M12. SRC writes its first option on the
begin optionsline
gwt-src.j2#L1-L2
The file containsbegin options save_flows, and MF6 ignores the option. The budget file has no SRC term. - M13. Non-equidistant
delranddelcare written withstr(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 gets1.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 requireslakeout > 0. The docstring andcreate_outlet_datause 0 for an outlet that leaves the model. - M15.
OutletSpecifieddrops a scalarrate
lak.py#L222-L232·lak.py#L360-L364
rateis 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.
HorizontalFlowBarrierMultiplierscales 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.
reallocatedrops concentration andrepeat_stress
topsystem.py#L129-L132
The reallocated River, Drainage, GHB or Recharge package has no concentration variables. - M18.
LayeredWellacceptsminimum_kandminimum_thicknessbut ignores them
wel.py#L1246-L1251·wel.py#L1458-L1466
The docstring says that wells are not placed in cells below these limits. Withminimum_k=100and 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_filenamehas no template line.ts6_filenameis written only whents_filerecordis set, and no code sets it. - M20. IST rejects an initial immobile concentration of 0
ist.py#L164
The schema requiresinitial_immobile_concentration > 0.0. 0 is a common starting value.
Output, evaluate and select
- M21.
stability_constraint_advectionreturns NaN where a velocity component is 0
constraints.py#L134-L140
Zero velocities become NaN before the terms are added, so one NaN term makesdtNaN. The bottom layer and all single-layer models getdt = 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 theconnectivityarray, which has no time. DIS and DISV raiseValueError. - M23.
read_grbfails on all DISU grid files
disu.py#L13-L19
The text header parsing does not match the MF6 layout (LENTXT 100). Both test files raiseIndexError. - M24.
open_cbcgives a UZF entry that fails on compute
common.py#L25-L32·cbc.py#L305-L310
The id2 mapping of thegwf_*record is applied to all imeth=6 records.flow-ja-face_uzfhas a different length and raisesValueErroron 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_valuesthen fails, andpoints_set_valueswrites values into the wrong cells. - M26. Points exactly on
xmaxorymaxselect the wrong cell
points.py#L120·points.py#L173-L179
The bounds test includes the upper bound, butsearchsortedputs it outside the grid. With descending y,y == ymaxselects the bottom row.x == xmaxraisesIndexError. The inclusive bound is deliberate (#1189). The fix is to put points on the upper bound in the last cell.test_get_indices__nonequidistantexpects the column index 4 for 4 columns, which is out of range. - M27. The
layerargument 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, andlayer=2on layers 1, 3, 5 selects layer 3.stability_constraint_welfails 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 aslayer, or document the limit and fix the callers such asstability_constraint_wel. - M28. The
facebudgetdocstring gives the wrong sign forlower
budget.py#L163-L165·constraints.py#L85-L87
The code uses the MF6 convention (positive is upward flow). The existing testtest_flowlower_upexpects this convention. Only the docstring must change. - M29.
facebudgetfails 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_boundariesfails with a 3Dzand a scalardz
boundaries.py#L151-L164
The scalardzis broadcast to the 3D shape ofz. The dispatch then tests the dimensions ofz.dz(0), not of the broadcast array, and calls the numba function for a 1Ddz. numba raises aTypingError. - M31.
velocity_fieldswaps x and y for a 3Dzand changes the inputz(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_exaggerationmultiplies 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_botandat_elevationignoreactive
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_interpolatefills empty slices with 0
laplace.py#L43-L69
A layer or time step without data becomes 0.0.fillleaves it NaN. - M35.
gdal_rasterizereturns an empty raster for ascending y
spatial.py#L429
With dy > 0, the raster origin is above the grid.rasterizeraises 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.
celltablecounts can overflow
spatial.py#L620-L621
The counts use the column dtype. Withint16, a cell with more than 32767 fine cells gets a negative area. - M38.
imod.util.replacefails on chunked dask arrays
structured.py#L94
The chunk function uses the full arraydainstead of the chunk. - M39.
to_datetime_internalwraps dates out of range and ignoresuse_cftime(second part: design question)
time.py#L76-L97
datetime(3000, 1, 1)becomes 1830-11-23. Annp.datetime64input staysdatetime64withuse_cftime=True. The first part is a mistake:_check_yearruns only forstranddatetime64input. The second part is older behavior, and the docstring does not say what must happen. - M40.
Voxelizer.voxelizechanges the inputlike
voxelize.py#L176-L184
The function adds adzcoordinate to the input. The argumentuse_relative_weightsis not used. - M41. Allocation fails when
tophas a layer dimension of size 1
allocation.py#L376-L384·layer.py#L23
_is_layeredneeds more than one layer, so a single-layertopis handled as a top without layers. The call raisesIndexError.
Formats
- M42.
savesilently overwrites files for dimensions other than time, layer and species
path.py#L171-L188
The file name does not include other dimensions. Withscenario=["a", "b"], both slices go tokh.idf. The docstring says that only these dimensions are supported, and thepatternargument can handle other dimensions. But withoutpattern,savedoes not raise an error. - M43. Wildcards in folder names no longer work in
idf.openandrasterio.open
reading.py#L434-L438
Path.parent.glob(name)does not expand wildcards in the folder part.run*/head_l*.idfraisesFileNotFoundError. Commit 2f8950be changed this fromglob.glob. - M44. Species files written by
savecannot be read back (design question)
path.py#L58-L60·path.py#L183-L188
savewrites_c{n}for any name. The reader recognizes species only for the nameconcfollowed by a time. The strict reader is deliberate (1e169c8a, for the iMOD-SEAWAT conventionconc_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 andchunk_layout="per_timestep"fail on names such ashead_steady-state_l1.idf. - M46.
idf.writewrites a corrupt file when the grid is uneven in one direction only
idf.py#L788-L791·idf.py#L816-L818
With onedxand per-rowdy, only onedxvalue is written instead ofncol. Withoutdxordycoordinates, the call raisesKeyError. - M47. PRJ: a constant
artificial_recharge_layerfails in the CAP block
prj.py#L1190-L1194·prj.py#L1262-L1265
The code readsblock_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]androw[5]are read also when a layer is given. An IPF with onlyx, y, idraisesIndexError. - M49. PRJ: "active" flags are read but not used
prj.py#L272·prj.py#L563-L564
read_projectfilereads the flags, butopen_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, ortimeis constant for each ID, the requiredtimecolumn also moves.write_assocthen raisesValueError. A workaround is theassoc_columnsargument. - M51.
ipf.saveneeds anidcolumn when there is alayercolumn
ipf.py#L759-L766
A frame withx, y, rate, layerand no associated files raisesKeyError: '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 ,-999returns -999 instead of NaN. - M53. IPF: rows with a trailing comma shift by one column
ipf.py#L52-L76
pd.read_csvwithoutindex_col=Falseuses the first field as the index.1.0,2.0,3.0,becomesx=2, y=3, rate=NaN. - M54.
gen.writeaccepts a rotated rectangle and writes a different box
gen.py#L244-L249
GEN rectangles are axis-aligned, so the code must compare withenvelope. 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_fwfskips 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. AUnicodeDecodeErrorbecomesTypeError: function takes exactly 5 arguments. The same pattern is inipf.pyline 388 andprj.pylines 219, 558, 1177 and 1292. - M57.
ipf.readwith 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 callspath.parenton astr.
MetaSWAP
- M58. Packages from
from_imod5_datacannot be regridded
meteo_grid.py#L231·regrid_schemes.py#L127·sprinkling.py#L478
TheMeteoGridCopypath becomes the text of a DataArray.FileCopierraises.SprinklingPointsusesart_gridin the scheme andid_sprinklingin the dataset. - M59.
MetaSwapModel.regrid_likeloses settings and fails with defaults
model.py#L544-L566
The new model gets defaultsimulation_settingsand nostarttime. The defaultregrid_cache=Noneraises. ACouplerMappingas first package raisesUnboundLocalError. - M60.
starttimeis lost byclip_boxanddump/from_file
model.py#L687·model.py#L444·dump_model.py#L83-L84
The start date changes to the first package time.dumpalso fails whenunsaturated_databaseis aPath. - M61.
mask_all_packagesmasks variables that are not grids
model.py#L612-L619
The scalarnodataofIdfMappingbecomes a 2D array, and the point arrays ofSprinklingPointsget x and y dimensions. - M62. The landuse validation includes inactive cells
model.py#L212
Masking fills inactive cells with landuse 0. Aftermask_all_packages,writewith validation always fails. - M63.
TimeOutputControl.clip_boxwrites a time before the new start
output_control.py#L129
The file uses thetimesvariable, but clipping changes only thetimecoordinate. - 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.
InitialConditionsSavedStateloses its path indump/from_file
initial_conditions.py#L106
The path is a plain attribute, not a dataset variable.writeafter a round trip raisesAttributeError. - M66.
SprinklingPointsuses 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]raiseIndexError. AllSprinklingPointscode usessubunit=[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_topviewdraws ascending-y data upside down
spatial.py#L413-L414
The array is not flipped for ascending y.plot_mapflips it. - M69.
cross_sectionflips 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]at6f0ec0bc, 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=...)raisesIndexError: 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 getfillna. NaN cast to bool is True.msw.GridData["active"]is affected. - M73.
clip_layer_slicefails on a scalar layer outside the range
clip.py#L334-L337
Rechargewith a scalarlayer=1andclip_box(layer_min=2)raisesIndexError. - M74. Plot functions change their inputs
spatial.py#L199·cross_sections.py#L263-L264
plot_mapchanges the over and under colors of a user colormap. The docstring says it does not. Keys are popped fromkwargs_colorbarand similar dicts, so the second call behaves differently. - M75.
plot_mapandcross_sectionhandlefigandaxincorrectly
spatial.py#L228-L229·cross_sections.py#L272-L273
plot_map(fig=myfig)draws on the current figure.cross_section(ax=ax)withoutfigcreates a new figure.
Low
- L1.
_get_grb_pathbuilds the flow model path with the transport model's discretization key.simulation.py#L1031-L1033 - L2. (design question)
use_absolute_paths=Truekeeps relativetdisandimspaths inmfsim.nam. The docstring says "all paths", buttest_mf6_absolute_paths.pyasserts 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 thets6/obs6file 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, andAdvectionnow has init schemata. Skip by type, or remove the skip.model.py#L323 - L5. (deliberate)
SourceSinkMixing.from_flow_modelraises 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_conductancehas no docstring, because a statement comes before the string.conductance.py#L278-L279 - L8.
modereturns NaN when NaN sources have the largest overlap.common.py#L330-L350 - L9. The
empty_*helpers fail on NumPy scalar cell sizes such asnp.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.writeandsavefail 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.saveandipf.write_assocchange the column names of the input DataFrame.ipf.py#L758·ipf.py#L479 - L13. (design question)
gen.writedrops polygon holes without a warning. GEN polygons cannot hold holes. Warn, or raise an error.gen.py#L252-L254 - L14.
logger.logreports a line inilogger.py(94 or 96, depending on the log level) as the source line.ilogger.py#L86-L100 - L15.
LanduseOptionsdefaultsinterception_intercepttoNone, but the value is required.landuse.py#L157·landuse.py#L195 - L16.
MetaSwapModel.splitgives all submodels the same settings dict.model.py#L740-L757 - L17. Schemata details:
CoordsSchema(require_all_keys=False)has no effect,DimsSchemadoes not acceptNoneas a wildcard, and theShapeSchemamessage 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
encodingargument from the user.netcdfserializer.py#L26 - L20.
lhm_clip_triangular_gridis documented to return anxr.Dataset, but returns anxu.Ugrid2d.sample_data.py#L184-L193 - L21.
out_of_bounds="ignore"with list inputs fails inpoints_indicesandpoints_set_values.points.py#L137 - L22.
open_hds_likedoes 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_gridclips points by bounding box, but unstructured clips by active cells.writeremoves 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_slicegives wrong bounds or fails for grids withoutdx/dycoordinates.grid.py#L17-L21 - L25.
test_precipitation_from_imod5[no_paths]andtest_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_lakestest fixture storesSpecificStorageunder the key"chd", so it replaces theConstantHeadpackage. 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_discretizationdocstring usestimes=. The argument isadditional_times.simulation.py#L230 - D2.
ValidationSettingsexample usesvalidation_context=. The argument isvalidation_settings, andnameis 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
icelltyperegrid method is documented asmean. The code usesmode.regrid_schemes.py#L289 - D5. Dispersion regrid docstring says
transversal_horizontal. The field istransversal_horizontal1.regrid_schemes.py#L89 - D6. IMS docstring mentions a
csv_outputargument that does not exist.ims.py#L22-L24 - D7.
Welldocstrin
- 主要语言
- Python
- 星标
- 41
- 派生
- 12
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Deltares/imod-python 的其他 Issue
-
backwards_compatibility enhancement
难度 2/5 1-3 小时 新手友好度 69/100
Deltares/imod-python#1963 · 2 条评论 ·
维护者通常 2 天内回复
-
bug Deltares
难度 2/5 1-3 小时 新手友好度 72/100
Deltares/imod-python#1950 ·
维护者通常 2 天内回复
-
Deltares enhancement good first issue
难度 2/5 1-3 小时 新手友好度 74/100
Deltares/imod-python#1843 ·
维护者通常 2 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 68/100
Deltares/imod-python#1684 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 57/100
Deltares/imod-python#1979 · 1 个 reaction ·
维护者通常 2 天内回复
查看 Deltares/imod-python 的全部 Issue
相似的 Issue
-
docs(contributing): the two things that silently block a PR可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭available documentation good first issue
难度 1/5 1-3 小时 新手友好度 95/100
Nixitov/Riptide-Native#944 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
JTHCode/secretguard#24 ·
维护者通常 1 天内回复
-
area: middleware documentation good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
omarelshamy25x/shamy-hijri#63 ·
维护者通常 1 天内回复