code: def test_fill_na():
      df_raw = pd.DataFrame(
          np.nan, index=range(0, 20), columns=list("ABCDEFGHIJ")
      )
      for _ in range(20):
          df_raw.iloc[
              random.randint(0, 19), random.randint(0, 9)
          ] = random.randint(0, 99)
      value_df_raw = pd.DataFrame(
          np.random.randint(0, 100, (10, 7)).astype(np.float32),
          columns=list("ABCDEFG"),
      )
      series_raw = pd.Series(np.nan, index=range(20))
      for _ in range(3):
          series_raw.iloc[random.randint(0, 19)] = random.randint(0, 99)
      value_series_raw = pd.Series(
          np.random.randint(0, 100, (10,)).astype(np.float32),
          index=list("ABCDEFGHIJ"),
      )
  
      df = md.DataFrame(df_raw)
      series = md.Series(series_raw)
  
      # when nothing supplied, raise
      with pytest.raises(ValueError):
          df.fillna()
      # when both values and methods supplied, raises
      with pytest.raises(ValueError):
          df.fillna(value=1, method="ffill")
      # when call on series, cannot supply DataFrames
      with pytest.raises(ValueError):
          series.fillna(value=df)
      with pytest.raises(ValueError):
          series.fillna(value=df_raw)
      with pytest.raises(NotImplementedError):
          series.fillna(value=series_raw, downcast="infer")
      with pytest.raises(NotImplementedError):
          series.ffill(limit=1)
  
      df2 = tile(df.fillna(value_series_raw))
      assert len(df2.chunks) == 1
      assert df2.chunks[0].shape == df2.shape
      assert df2.chunks[0].op.stage is None
  
      series2 = tile(series.fillna(value_series_raw))
      assert len(series2.chunks) == 1
      assert series2.chunks[0].shape == series2.shape
      assert series2.chunks[0].op.stage is None
  
      df = md.DataFrame(df_raw, chunk_size=5)
      df2 = tile(df.fillna(value_series_raw))
      assert len(df2.chunks) == 8
      assert df2.chunks[0].shape == (5, 5)
      assert df2.chunks[0].op.stage is None
  
      series = md.Series(series_raw, chunk_size=5)
      series2 = tile(series.fillna(value_series_raw))
      assert len(series2.chunks) == 4
      assert series2.chunks[0].shape == (5,)
      assert series2.chunks[0].op.stage is None
  
      df2 = tile(df.ffill(axis="columns"))
      assert len(df2.chunks) == 8
      assert df2.chunks[0].shape == (5, 5)
      assert df2.chunks[0].op.axis == 1
      assert df2.chunks[0].op.stage == OperandStage.combine
      assert df2.chunks[0].op.method == "ffill"
      assert df2.chunks[0].op.limit is None
  
      series2 = tile(series.bfill())
      assert len(series2.chunks) == 4
      assert series2.chunks[0].shape == (5,)
      assert series2.chunks[0].op.stage == OperandStage.combine
      assert series2.chunks[0].op.method == "bfill"
      assert series2.chunks[0].op.limit is None
  
      value_df = md.DataFrame(value_df_raw, chunk_size=7)
      value_series = md.Series(value_series_raw, chunk_size=7)
  
      df2 = tile(df.fillna(value_df))
      assert df2.shape == df.shape
      assert df2.chunks[0].op.stage is None
  
      df2 = tile(df.fillna(value_series))
      assert df2.shape == df.shape
      assert df2.chunks[0].op.stage is None
  
      value_series_raw.index = list(range(10))
      value_series = md.Series(value_series_raw)
      series2 = tile(series.fillna(value_series))
      assert series2.shape == series.shape
      assert series2.chunks[0].op.stage is None
  
file_path: mars/mars/dataframe/missing/tests/test_missing.py
imports: import random
  import numpy
  import pandas
  import pytest
  from ....None import dataframe
  from ....None import tensor
  from ....core import tile
  from ....core.operand import OperandStage
  from ....utils import pd_release_version
  from ...core import MultiIndex
label_desc: Use image node_id 1 for calling a global function with example usage: test_fill_na() without return types