@@ -352,6 +352,39 @@ def test_save_load_node_mapping_unstructured(function_tmpdir):
352352 np .testing .assert_allclose (new_heads , original_heads , err_msg = err_msg )
353353
354354
355+ @requires_pkg ("h5py" )
356+ def test_save_node_mapping_with_boundnames (function_tmpdir ):
357+ # regression test for https://github.com/modflowpy/flopy/issues/2735
358+ # boundnames in stress packages were being inserted into _node_map,
359+ # causing save_node_mapping to fail with ValueError on int() conversion
360+ sim = flopy .mf6 .MFSimulation (sim_name = "test" , sim_ws = str (function_tmpdir ))
361+ flopy .mf6 .ModflowTdis (sim )
362+ flopy .mf6 .ModflowIms (sim )
363+ gwf = flopy .mf6 .ModflowGwf (sim , modelname = "test" )
364+ flopy .mf6 .ModflowGwfdis (gwf , nlay = 1 , nrow = 10 , ncol = 10 , top = 10 , botm = 0 )
365+ flopy .mf6 .ModflowGwfic (gwf , strt = 10 )
366+ flopy .mf6 .ModflowGwfnpf (gwf )
367+ flopy .mf6 .ModflowGwfwel (
368+ gwf ,
369+ stress_period_data = {0 : [((0 , 2 , 2 ), - 1.0 , "my_well" )]},
370+ boundnames = True ,
371+ )
372+
373+ array = np .zeros ((10 , 10 ), dtype = int )
374+ array [:, 5 :] = 1
375+ mfsplit = Mf6Splitter (sim )
376+ mfsplit .split_model (array )
377+
378+ non_int_keys = [
379+ k for k in mfsplit ._node_map if not isinstance (k , (int , np .integer ))
380+ ]
381+ assert not non_int_keys , f"boundnames leaked into _node_map: { non_int_keys } "
382+
383+ hdf_file = function_tmpdir / "node_map.hdf5"
384+ mfsplit .save_node_mapping (hdf_file )
385+ assert hdf_file .exists ()
386+
387+
355388def test_control_records (function_tmpdir ):
356389 nrow = 10
357390 ncol = 10
0 commit comments