docstr: Test whether centroid definition remains unchanged when scaling uniformly.
code: def test_k_prototypes_sample_weight_unchanged(self):
      """Test whether centroid definition remains unchanged when scaling uniformly."""
      categorical = [1, 2]
      kproto_baseline = kprototypes.KPrototypes(
          n_clusters=3, init="Cao", random_state=42
      )
      model_baseline = kproto_baseline.fit(
          STOCKS, categorical=categorical
      )
      expected = set(
          tuple(row) for row in model_baseline.cluster_centroids_
      )
      # The exact value of a weight shouldn't matter if equal for all samples.
      for weight in [0.5, 0.1, 1, 1.0, 2]:
          sample_weight = [weight] * STOCKS.shape[0]
          kproto_weighted = kprototypes.KPrototypes(
              n_clusters=3, init="Cao", random_state=42
          )
          model_weighted = kproto_weighted.fit(
              STOCKS,
              categorical=categorical,
              sample_weight=sample_weight,
          )
          factual = set(
              tuple(row) for row in model_weighted.cluster_centroids_
          )
          # Centroids might be ordered differently. To compare the centroids, we first
          # sort them.
          tuple_pairs = zip(sorted(expected), sorted(factual))
          for tuple_expected, tuple_factual in tuple_pairs:
              # Test numerical features for almost equality, categorical features for
              # actual equality.
              self.assertAlmostEqual(
                  float(tuple_expected[0]), float(tuple_factual[0])
              )
              for index in categorical:
                  self.assertTrue(
                      tuple_expected[index] == tuple_factual[index]
                  )
  
imports: import pickle
  import unittest
  import numpy
  import pandas
  from kmodes import kprototypes
  from kmodes.tests.test_kmodes import assert_cluster_splits_equal
  from kmodes.util.dissim import ng_dissim
label_desc: Use image node_id 27 for calling the TestKProtoTypes obj's underlying member method code with example usage: obj.test_k_prototypes_sample_weight_unchanged() without return types