code: def test_nan_encoding(self):
      # Generate some numbers
      data = list(range(-50, 50, 2))
  
      # Add invalid values to the data
      invalid_data = _pollute(data)
  
      # Prepare with the correct data and decode invalid data
      encoder = NumericEncoder()
      encoder.prepare(pd.Series(data))
      for array in invalid_data:
          # Make sure the encoding has no nans or infs
          encoded_repr = encoder.encode(pd.Series(array))
          assert not torch.isnan(encoded_repr).any()
          assert not torch.isinf(encoded_repr).any()
  
          # Make sure the invalid value is decoded as `None` and the rest as numbers
          decoded_repr = encoder.decode(encoded_repr)
          for x in decoded_repr[:-1]:
              assert not is_none(x)
          assert decoded_repr[-1] is None
  
      # Prepare with the invalid data and decode the valid data
      for array in invalid_data:
          encoder = NumericEncoder()
          encoder.prepare(pd.Series(array))
  
          # Make sure the encoding has no nans or infs
          encoded_repr = encoder.encode(pd.Series(array))
          assert not torch.isnan(encoded_repr).any()
          assert not torch.isinf(encoded_repr).any()
  
          # Make sure the invalid value is decoded as `None` and the rest as numbers
          decoded_repr = encoder.decode(encoded_repr)
          for dec, real in zip(decoded_repr, array):
              if is_none(real):
                  assert is_none(dec)
              else:
                  assert not is_none(x) or x != 0.0
  
file_path: lightwood/tests/unit_tests/encoder/numeric/test_numeric.py
imports: import unittest
  import numpy
  import pandas
  import torch
  from lightwood.encoder.numeric import NumericEncoder
  from lightwood.encoder.numeric import TsNumericEncoder
  from lightwood.helpers.general import is_none
label_desc: Use image node_id 4 for calling the TestNumericEncoder obj's underlying member method code with example usage: obj.test_nan_encoding() without return types