@@ -806,71 +806,3 @@ def new_module(*args, **kwargs):
806806 return new_module
807807
808808 return deprecator
809-
810-
811- def check_data_input_order (deprecate_version , remove_version ):
812- """
813- Decorator to raise a FutureWarning if the order of data input parameters
814- changes and positional arguments are passed.
815-
816- The decorator is temporary and should be removed in v0.7.0.
817-
818- Parameters
819- ----------
820- deprecate_version : str
821- The PyGMT version when the order of data input parameters is changed.
822- remove_version : str
823- The PyGMT version when the deprecation warning should be removed.
824-
825- Examples
826- --------
827- >>> @check_data_input_order("v0.0.0", "v9.9.9")
828- ... def module(data=None, x=None, y=None, z=None, **kwargs):
829- ... "A module that prints the arguments it received"
830- ... print(f"data={data}, x={x}, y={y}, z={z}")
831- >>> module(data="table.txt")
832- data=table.txt, x=None, y=None, z=None
833- >>> module(x=0, y=1, z=2)
834- data=None, x=0, y=1, z=2
835- >>> with warnings.catch_warnings(record=True) as w:
836- ... module(0, 1, 2)
837- ... assert len(w) == 1
838- ... assert issubclass(w[0].category, FutureWarning)
839- ...
840- data=0, x=1, y=2, z=None
841- """
842-
843- def data_input_order_checker (module_func ):
844- """
845- The decorator that creates the new function to check if positional
846- arguments are passed.
847- """
848-
849- @functools .wraps (module_func )
850- def new_module (* args , ** kwargs ):
851- """
852- New module instance that raises a warning if positional arguments
853- are passed.
854- """
855- # Plotting functions always have a "self" parameter
856- # which is a pygmt.Figure instance that has a "savefig" method
857- if len (args ) > 1 and hasattr (args [0 ], "savefig" ):
858- plotting_func = 1
859- else :
860- plotting_func = 0
861-
862- if len (args ) > 1 + plotting_func :
863- # more than one positional arguments are used
864- msg = (
865- "The function parameters has been re-ordered as 'data, x, y, [z]' "
866- f"since { deprecate_version } but you're passing positional arguments. "
867- "You can silence the warning by passing keyword arguments "
868- "like 'x=x, y=y, z=z'. Otherwise, the warning will be removed "
869- f"in { remove_version } ."
870- )
871- warnings .warn (msg , category = FutureWarning , stacklevel = 2 )
872- return module_func (* args , ** kwargs )
873-
874- return new_module
875-
876- return data_input_order_checker
0 commit comments