code: def test_series_from_series(
      dtype, using_copy_on_write, warn_copy_on_write
  ):
      # Case: constructing a Series from another Series object follows CoW rules:
      # a new object is returned and thus mutations are not propagated
      ser = Series([1, 2, 3], name="name")
  
      # default is copy=False -> new Series is a shallow copy / view of original
      result = Series(ser, dtype=dtype)
  
      # the shallow copy still shares memory
      assert np.shares_memory(get_array(ser), get_array(result))
  
      if using_copy_on_write:
          assert result._mgr.blocks[0].refs.has_reference()
  
      if using_copy_on_write:
          # mutating new series copy doesn't mutate original
          result.iloc[0] = 0
          assert ser.iloc[0] == 1
          # mutating triggered a copy-on-write -> no longer shares memory
          assert not np.shares_memory(get_array(ser), get_array(result))
      else:
          # mutating shallow copy does mutate original
          with tm.assert_cow_warning(warn_copy_on_write):
              result.iloc[0] = 0
          assert ser.iloc[0] == 0
          # and still shares memory
          assert np.shares_memory(get_array(ser), get_array(result))
  
      # the same when modifying the parent
      result = Series(ser, dtype=dtype)
  
      if using_copy_on_write:
          # mutating original doesn't mutate new series
          ser.iloc[0] = 0
          assert result.iloc[0] == 1
      else:
          # mutating original does mutate shallow copy
          with tm.assert_cow_warning(warn_copy_on_write):
              ser.iloc[0] = 0
          assert result.iloc[0] == 0
  
imports: import numpy
  import pytest
  import pandas
  from pandas import DataFrame, DatetimeIndex, Index, Period, PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp
  import pandas._testing
  from pandas.tests.copy_view.util import get_array
label_desc: Use image node_id 1 for calling a global function with example usage: test_series_from_series(dtype, using_copy_on_write, warn_copy_on_write) without return types