Skip to content

Commit 0c0af0b

Browse files
committed
add warning for pending default behavoir change for TreeMesh
1 parent 5c47411 commit 0c0af0b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

discretize/tree_mesh.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Module containing the TreeMesh implementation."""
22

3+
import warnings
4+
35
# ___ ___ ___ ___ ___ ___
46
# /\ \ /\ \ /\ \ /\ \ /\ \ /\ \
57
# /::\ \ /::\ \ \:\ \ /::\ \ /::\ \ /::\ \
@@ -169,7 +171,7 @@ class TreeMesh(
169171
170172
diagonal_balance : bool, optional
171173
Whether to balance cells along the diagonal of the tree during construction.
172-
This will effect all calls to refine the tree.
174+
This will affect all calls to refine the tree.
173175
174176
Examples
175177
--------
@@ -233,9 +235,20 @@ class TreeMesh(
233235
_items = {"h", "origin", "cell_state"}
234236

235237
# inheriting stuff from BaseTensorMesh that isn't defined in _QuadTree
236-
def __init__(self, h=None, origin=None, diagonal_balance=False, **kwargs):
238+
def __init__(self, h=None, origin=None, diagonal_balance=None, **kwargs):
237239
if "x0" in kwargs:
238240
origin = kwargs.pop("x0")
241+
242+
if diagonal_balance is None:
243+
diagonal_balance = False
244+
warnings.warn(
245+
"In discretize v1.0 the TreeMesh will change the default value of "
246+
"diagonal_balance to True, which will likely slightly change meshes you have"
247+
"previously created. If you need to keep the current behavoir, explicitly set "
248+
"diagonal_balance=False.",
249+
FutureWarning,
250+
stacklevel=2,
251+
)
239252
super().__init__(h=h, origin=origin, diagonal_balance=diagonal_balance)
240253

241254
cell_state = kwargs.pop("cell_state", None)

0 commit comments

Comments
 (0)