class_docstr: Module level tests for all sktime transformers.
class_docstr_tok: ["Module","level","tests","for","all","sktime","transformers","."]
docstr: Test that inverse_transform is indeed inverse to transform.
docstr_tok: ["Test","that","inverse_transform","is","indeed","inverse","to","transform","."]
code: def test_transform_inverse_transform_equivalent(
      self, estimator_instance, scenario
  ):
      """Test that inverse_transform is indeed inverse to transform."""
      # skip this test if the estimator does not have inverse_transform
      if not estimator_instance.get_class_tag(
          "capability:inverse_transform", False
      ):
          return None
  
      # skip this test if the estimator skips inverse_transform
      if estimator_instance.get_tag("skip-inverse-transform", False):
          return None
  
      # skip this test if inverse_transform is not assumed an exact inverse
      if not estimator_instance.get_tag(
          "capability:inverse_transform:exact", True
      ):
          return None
  
      X = scenario.args["transform"]["X"]
      Xt = scenario.run(
          estimator_instance, method_sequence=["fit", "transform"]
      )
      Xit = estimator_instance.inverse_transform(Xt)
  
      # if inversion produces more indices, we subset to the original X indices
      if not estimator_instance.get_tag(
          "transform-returns-same-time-index"
      ):
          if isinstance(X, pd.DataFrame):
              X = X.loc[Xit.index]
  
      # check that the inverse transform is indeed the inverse
      # we check this only on entries within range of invertibility, if specified
      inv_range = estimator_instance.get_tag(
          "capability:inverse_transform:range"
      )
      if inv_range is None:
          _assert_array_almost_equal(X, Xit)
      else:
          # convert to pd.DataFrame so that we can use masks
          df_types = [
              "pd.DataFrame",
              "pd-multiindex",
              "pd_multiindex_hier",
          ]
          X = convert_to(X, df_types)
          Xit = convert_to(Xit, df_types)
  
          # mask entries of X outside range of invertibility
          # then compare for identity
          inside_mask = (X >= inv_range[0]) * (X <= inv_range[1])
          _assert_array_almost_equal(X[inside_mask], Xit[inside_mask])
  
file_path: sktime/sktime/transformations/tests/test_all_transformers.py
imports: import pandas
  from sktime.datatypes import check_is_scitype, convert_to
  from sktime.tests.test_all_estimators import BaseFixtureGenerator, QuickTester
  from sktime.utils._testing.estimator_checks import _assert_array_almost_equal
label_desc: Use image node_id 5 for calling the TestAllTransformers obj's underlying member method code with example usage: obj.test_transform_inverse_transform_equivalent(estimator_instance, scenario) and returns: None, None, None