<s> import copy <EOL> import pandas as pd <EOL> import numpy as np <EOL> import numpy . testing as npt <EOL> from skbio . util . _testing import assert_data_frame_almost_equal <EOL> class MetadataMixinTests : <EOL> def test_constructor_invalid_type ( self ) : <EOL> for md in ( <NUM_LIT:0> , '<STR_LIT:a>' , ( '<STR_LIT:f>' , '<STR_LIT:o>' , '<STR_LIT:o>' ) , np . array ( [ ] ) , pd . DataFrame ( ) ) : <EOL> with self . assertRaisesRegex ( TypeError , '<STR_LIT>' ) : <EOL> self . _metadata_constructor_ ( metadata = md ) <EOL> def test_constructor_no_metadata ( self ) : <EOL> for md in None , { } : <EOL> obj = self . _metadata_constructor_ ( metadata = md ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> def test_constructor_with_metadata ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> obj = self . _metadata_constructor_ ( <EOL> metadata = { '<STR_LIT>' : '<STR_LIT>' , <NUM_LIT> : { '<STR_LIT:a>' : '<STR_LIT:b>' , '<STR_LIT:c>' : '<STR_LIT:d>' } } ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT>' : '<STR_LIT>' , <NUM_LIT> : { '<STR_LIT:a>' : '<STR_LIT:b>' , '<STR_LIT:c>' : '<STR_LIT:d>' } } ) <EOL> def test_constructor_makes_shallow_copy_of_metadata ( self ) : <EOL> md = { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ ] } <EOL> obj = self . _metadata_constructor_ ( metadata = md ) <EOL> self . assertEqual ( obj . metadata , md ) <EOL> self . assertIsNot ( obj . metadata , md ) <EOL> md [ '<STR_LIT:foo>' ] = '<STR_LIT>' <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ ] } ) <EOL> md [ <NUM_LIT> ] . append ( True ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ True ] } ) <EOL> def test_eq ( self ) : <EOL> self . assertReallyEqual ( <EOL> self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : <NUM_LIT> } ) , <EOL> self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : <NUM_LIT> } ) ) <EOL> self . assertReallyEqual ( <EOL> self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : <NUM_LIT> , <NUM_LIT> : { } } ) , <EOL> self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : <NUM_LIT> , <NUM_LIT> : { } } ) ) <EOL> def test_eq_missing_metadata ( self ) : <EOL> self . assertReallyEqual ( self . _metadata_constructor_ ( ) , <EOL> self . _metadata_constructor_ ( ) ) <EOL> self . assertReallyEqual ( self . _metadata_constructor_ ( ) , <EOL> self . _metadata_constructor_ ( metadata = { } ) ) <EOL> self . assertReallyEqual ( self . _metadata_constructor_ ( metadata = { } ) , <EOL> self . _metadata_constructor_ ( metadata = { } ) ) <EOL> def test_ne ( self ) : <EOL> obj1 = self . _metadata_constructor_ ( metadata = { '<STR_LIT:id>' : '<STR_LIT:foo>' } ) <EOL> obj2 = self . _metadata_constructor_ ( metadata = { '<STR_LIT:id>' : '<STR_LIT:bar>' } ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> obj1 = self . _metadata_constructor_ ( metadata = { '<STR_LIT:id>' : '<STR_LIT:foo>' } ) <EOL> obj2 = self . _metadata_constructor_ ( ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> def test_copy_metadata_none ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> self . assertEqual ( obj_copy . metadata , { } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> def test_copy_metadata_empty ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { } ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> self . assertEqual ( obj_copy . metadata , { } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> def test_copy_with_metadata ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> self . assertEqual ( obj_copy . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> self . assertIs ( obj . metadata [ '<STR_LIT:foo>' ] , obj_copy . metadata [ '<STR_LIT:foo>' ] ) <EOL> obj_copy . metadata [ '<STR_LIT:foo>' ] . append ( <NUM_LIT:2> ) <EOL> obj_copy . metadata [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( obj_copy . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] } ) <EOL> def test_deepcopy_metadata_none ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> self . assertEqual ( obj_copy . metadata , { } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> def test_deepcopy_metadata_empty ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { } ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> self . assertEqual ( obj_copy . metadata , { } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> def test_deepcopy_with_metadata ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> self . assertEqual ( obj_copy . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> self . assertIsNot ( obj . metadata , obj_copy . metadata ) <EOL> self . assertIsNot ( obj . metadata [ '<STR_LIT:foo>' ] , obj_copy . metadata [ '<STR_LIT:foo>' ] ) <EOL> obj_copy . metadata [ '<STR_LIT:foo>' ] . append ( <NUM_LIT:2> ) <EOL> obj_copy . metadata [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( obj_copy . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : [ <NUM_LIT:1> ] } ) <EOL> def test_deepcopy_memo_is_respected ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> memo = { } <EOL> copy . deepcopy ( obj , memo ) <EOL> self . assertGreater ( len ( memo ) , <NUM_LIT:2> ) <EOL> def test_metadata_getter ( self ) : <EOL> obj = self . _metadata_constructor_ ( <EOL> metadata = { <NUM_LIT> : '<STR_LIT:foo>' , ( '<STR_LIT:hello>' , '<STR_LIT>' ) : <NUM_LIT> } ) <EOL> self . assertIsInstance ( obj . metadata , dict ) <EOL> self . assertEqual ( obj . metadata , { <NUM_LIT> : '<STR_LIT:foo>' , ( '<STR_LIT:hello>' , '<STR_LIT>' ) : <NUM_LIT> } ) <EOL> obj . metadata [ <NUM_LIT> ] = '<STR_LIT:bar>' <EOL> self . assertEqual ( obj . metadata , { <NUM_LIT> : '<STR_LIT:bar>' , ( '<STR_LIT:hello>' , '<STR_LIT>' ) : <NUM_LIT> } ) <EOL> def test_metadata_getter_no_metadata ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> self . assertIsInstance ( obj . metadata , dict ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> def test_metadata_setter ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> obj . metadata = { '<STR_LIT:hello>' : '<STR_LIT>' } <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:hello>' : '<STR_LIT>' } ) <EOL> obj . metadata = { } <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> def test_metadata_setter_makes_shallow_copy ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> md = { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ ] } <EOL> obj . metadata = md <EOL> self . assertEqual ( obj . metadata , md ) <EOL> self . assertIsNot ( obj . metadata , md ) <EOL> md [ '<STR_LIT:foo>' ] = '<STR_LIT>' <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ ] } ) <EOL> md [ <NUM_LIT> ] . append ( True ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' , <NUM_LIT> : [ True ] } ) <EOL> def test_metadata_setter_invalid_type ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { <NUM_LIT> : <NUM_LIT> } ) <EOL> for md in ( None , <NUM_LIT:0> , '<STR_LIT:a>' , ( '<STR_LIT:f>' , '<STR_LIT:o>' , '<STR_LIT:o>' ) , np . array ( [ ] ) , <EOL> pd . DataFrame ( ) ) : <EOL> with self . assertRaisesRegex ( TypeError , '<STR_LIT>' ) : <EOL> obj . metadata = md <EOL> self . assertEqual ( obj . metadata , { <NUM_LIT> : <NUM_LIT> } ) <EOL> def test_metadata_deleter ( self ) : <EOL> obj = self . _metadata_constructor_ ( metadata = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertEqual ( obj . metadata , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> del obj . metadata <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> del obj . metadata <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> obj = self . _metadata_constructor_ ( ) <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> del obj . metadata <EOL> self . assertEqual ( obj . metadata , { } ) <EOL> def test_has_metadata ( self ) : <EOL> obj = self . _metadata_constructor_ ( ) <EOL> self . assertFalse ( obj . has_metadata ( ) ) <EOL> self . assertFalse ( <EOL> self . _metadata_constructor_ ( metadata = { } ) . has_metadata ( ) ) <EOL> self . assertTrue ( <EOL> self . _metadata_constructor_ ( metadata = { '<STR_LIT>' : '<STR_LIT>' } ) . has_metadata ( ) ) <EOL> self . assertTrue ( <EOL> self . _metadata_constructor_ ( <EOL> metadata = { '<STR_LIT:foo>' : <NUM_LIT> } ) . has_metadata ( ) ) <EOL> class PositionalMetadataMixinTests : <EOL> def test_constructor_invalid_positional_metadata_type ( self ) : <EOL> with self . assertRaisesRegex ( TypeError , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <NUM_LIT:0> , positional_metadata = <NUM_LIT:2> ) <EOL> def test_constructor_positional_metadata_len_mismatch ( self ) : <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <NUM_LIT:4> , positional_metadata = [ ] ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . Series ( range ( <NUM_LIT:3> ) ) ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . Series ( range ( <NUM_LIT:5> ) ) ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . DataFrame ( { '<STR_LIT>' : range ( <NUM_LIT:3> ) } ) ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . DataFrame ( { '<STR_LIT>' : range ( <NUM_LIT:5> ) } ) ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = pd . DataFrame ( index = range ( <NUM_LIT:2> ) ) ) <EOL> def test_constructor_no_positional_metadata ( self ) : <EOL> for empty in None , { } , pd . DataFrame ( ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = empty ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:0> ) ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = None ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> def test_constructor_with_positional_metadata_len_zero ( self ) : <EOL> for data in [ ] , ( ) , np . array ( [ ] ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : data } ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : data } , index = np . arange ( <NUM_LIT:0> ) ) ) <EOL> def test_constructor_with_positional_metadata_len_one ( self ) : <EOL> for data in [ <NUM_LIT:2> ] , ( <NUM_LIT:2> , ) , np . array ( [ <NUM_LIT:2> ] ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:1> , positional_metadata = { '<STR_LIT:foo>' : data } ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : data } , index = np . arange ( <NUM_LIT:1> ) ) ) <EOL> def test_constructor_with_positional_metadata_len_greater_than_one ( self ) : <EOL> for data in ( [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:100> , <NUM_LIT:0> , <NUM_LIT:0> ] , <EOL> ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:100> , <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> np . array ( [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:100> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:9> , positional_metadata = { '<STR_LIT:foo>' : data } ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : data } , index = np . arange ( <NUM_LIT:9> ) ) ) <EOL> def test_constructor_with_positional_metadata_multiple_columns ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:5> , positional_metadata = { '<STR_LIT:foo>' : np . arange ( <NUM_LIT:5> ) , <EOL> '<STR_LIT:bar>' : np . arange ( <NUM_LIT:5> ) [ : : - <NUM_LIT:1> ] } ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : np . arange ( <NUM_LIT:5> ) , <EOL> '<STR_LIT:bar>' : np . arange ( <NUM_LIT:5> ) [ : : - <NUM_LIT:1> ] } , index = np . arange ( <NUM_LIT:5> ) ) ) <EOL> def test_constructor_with_positional_metadata_custom_index ( self ) : <EOL> df = pd . DataFrame ( { '<STR_LIT:foo>' : np . arange ( <NUM_LIT:5> ) , '<STR_LIT:bar>' : np . arange ( <NUM_LIT:5> ) [ : : - <NUM_LIT:1> ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' , '<STR_LIT:e>' ] ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:5> , positional_metadata = df ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : np . arange ( <NUM_LIT:5> ) , <EOL> '<STR_LIT:bar>' : np . arange ( <NUM_LIT:5> ) [ : : - <NUM_LIT:1> ] } , index = np . arange ( <NUM_LIT:5> ) ) ) <EOL> def test_constructor_makes_shallow_copy_of_positional_metadata ( self ) : <EOL> df = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = df ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , df ) <EOL> orig_df = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> assert_data_frame_almost_equal ( df , orig_df ) <EOL> df [ '<STR_LIT:foo>' ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> df . values [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT:10> <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> df [ '<STR_LIT:bar>' ] [ <NUM_LIT:0> ] . append ( <NUM_LIT> ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ <NUM_LIT> ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> def test_eq_basic ( self ) : <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> self . assertReallyEqual ( obj1 , obj2 ) <EOL> def test_eq_from_different_source ( self ) : <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : np . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } , <EOL> index = [ '<STR_LIT:foo>' , '<STR_LIT:bar>' , '<STR_LIT>' ] ) ) <EOL> self . assertReallyEqual ( obj1 , obj2 ) <EOL> def test_eq_missing_positional_metadata ( self ) : <EOL> for empty in None , { } , pd . DataFrame ( ) , pd . DataFrame ( index = [ ] ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = empty ) <EOL> self . assertReallyEqual ( <EOL> obj , <EOL> self . _positional_metadata_constructor_ ( <NUM_LIT:0> ) ) <EOL> self . assertReallyEqual ( <EOL> obj , <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = empty ) ) <EOL> for empty in None , pd . DataFrame ( index = [ '<STR_LIT:a>' , '<STR_LIT:b>' ] ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:2> , positional_metadata = empty ) <EOL> self . assertReallyEqual ( <EOL> obj , <EOL> self . _positional_metadata_constructor_ ( <NUM_LIT:2> ) ) <EOL> self . assertReallyEqual ( <EOL> obj , <EOL> self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:2> , positional_metadata = empty ) ) <EOL> def test_ne_len_zero ( self ) : <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : [ ] } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : [ ] , '<STR_LIT:bar>' : [ ] } ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : [ ] } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <NUM_LIT:0> ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> def test_ne_len_greater_than_zero ( self ) : <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ] } ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> def test_ne_len_mismatch ( self ) : <EOL> obj1 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj2 = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:2> , positional_metadata = pd . DataFrame ( index = range ( <NUM_LIT:2> ) ) ) <EOL> self . assertReallyNotEqual ( obj1 , obj2 ) <EOL> def test_copy_positional_metadata_none ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> assert_data_frame_almost_equal ( obj_copy . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , obj_copy . positional_metadata ) <EOL> def test_copy_positional_metadata_empty ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> assert_data_frame_almost_equal ( obj_copy . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , obj_copy . positional_metadata ) <EOL> def test_copy_with_positional_metadata ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) <EOL> obj_copy = copy . copy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , index = range ( <NUM_LIT:4> ) ) ) <EOL> assert_data_frame_almost_equal ( <EOL> obj_copy . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , index = range ( <NUM_LIT:4> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , <EOL> obj_copy . positional_metadata ) <EOL> self . assertIsNot ( obj . positional_metadata . values , <EOL> obj_copy . positional_metadata . values ) <EOL> self . assertIs ( obj . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] , <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] ) <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] . append ( <NUM_LIT:1> ) <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT>' ] = <NUM_LIT> <EOL> assert_data_frame_almost_equal ( <EOL> obj_copy . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ <NUM_LIT:1> ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ <NUM_LIT:1> ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) ) <EOL> def test_deepcopy_positional_metadata_none ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> assert_data_frame_almost_equal ( obj_copy . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , obj_copy . positional_metadata ) <EOL> def test_deepcopy_positional_metadata_empty ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> assert_data_frame_almost_equal ( obj_copy . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , obj_copy . positional_metadata ) <EOL> def test_deepcopy_with_positional_metadata ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) <EOL> obj_copy = copy . deepcopy ( obj ) <EOL> self . assertEqual ( obj , obj_copy ) <EOL> self . assertIsNot ( obj , obj_copy ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , index = range ( <NUM_LIT:4> ) ) ) <EOL> assert_data_frame_almost_equal ( <EOL> obj_copy . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } , index = range ( <NUM_LIT:4> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , obj_copy . positional_metadata ) <EOL> self . assertIsNot ( obj . positional_metadata . values , <EOL> obj_copy . positional_metadata . values ) <EOL> self . assertIsNot ( obj . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] , <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] ) <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT:bar>' ] . append ( <NUM_LIT:1> ) <EOL> obj_copy . positional_metadata . loc [ <NUM_LIT:0> , '<STR_LIT>' ] = <NUM_LIT> <EOL> assert_data_frame_almost_equal ( <EOL> obj_copy . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ <NUM_LIT:1> ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] , [ ] ] , <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) ) <EOL> def test_deepcopy_memo_is_respected ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> memo = { } <EOL> copy . deepcopy ( obj , memo ) <EOL> self . assertGreater ( len ( memo ) , <NUM_LIT:2> ) <EOL> def test_positional_metadata_getter ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] } ) <EOL> self . assertIsInstance ( obj . positional_metadata , pd . DataFrame ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] } ) ) <EOL> obj . positional_metadata [ '<STR_LIT:foo>' ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } ) ) <EOL> obj . positional_metadata [ '<STR_LIT>' ] = [ True , False , True ] <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ True , False , True ] } ) ) <EOL> def test_positional_metadata_getter_no_positional_metadata ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:4> ) <EOL> self . assertIsInstance ( obj . positional_metadata , pd . DataFrame ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:4> ) ) ) <EOL> def test_positional_metadata_getter_set_column_series ( self ) : <EOL> length = <NUM_LIT:8> <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> length , positional_metadata = { '<STR_LIT:foo>' : range ( length ) } ) <EOL> obj . positional_metadata [ '<STR_LIT:bar>' ] = pd . Series ( range ( length - <NUM_LIT:3> ) ) <EOL> npt . assert_equal ( obj . positional_metadata [ '<STR_LIT:bar>' ] , <EOL> np . array ( list ( range ( length - <NUM_LIT:3> ) ) + [ np . nan ] * <NUM_LIT:3> ) ) <EOL> obj . positional_metadata [ '<STR_LIT>' ] = pd . Series ( range ( length + <NUM_LIT:3> ) ) <EOL> npt . assert_equal ( obj . positional_metadata [ '<STR_LIT>' ] , <EOL> np . array ( range ( length ) ) ) <EOL> def test_positional_metadata_getter_set_column_array ( self ) : <EOL> length = <NUM_LIT:8> <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> length , positional_metadata = { '<STR_LIT:foo>' : range ( length ) } ) <EOL> for array_like in ( np . array ( range ( length - <NUM_LIT:1> ) ) , range ( length - <NUM_LIT:1> ) , <EOL> np . array ( range ( length + <NUM_LIT:1> ) ) , range ( length + <NUM_LIT:1> ) ) : <EOL> with self . assertRaisesRegex ( ValueError , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) : <EOL> obj . positional_metadata [ '<STR_LIT:bar>' ] = array_like <EOL> def test_positional_metadata_setter_pandas_consumable ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj . positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] } <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] } ) ) <EOL> obj . positional_metadata = pd . DataFrame ( index = np . arange ( <NUM_LIT:3> ) ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> def test_positional_metadata_setter_data_frame ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj . positional_metadata = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] } ) ) <EOL> obj . positional_metadata = pd . DataFrame ( index = np . arange ( <NUM_LIT:3> ) ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> def test_positional_metadata_setter_none ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : [ ] } ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ ] } ) ) <EOL> obj . positional_metadata = None <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = np . arange ( <NUM_LIT:0> ) ) ) <EOL> def test_positional_metadata_setter_makes_shallow_copy ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> df = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> obj . positional_metadata = df <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> self . assertIsNot ( obj . positional_metadata , df ) <EOL> orig_df = pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> assert_data_frame_almost_equal ( df , orig_df ) <EOL> df [ '<STR_LIT:foo>' ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> df . values [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT:10> <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> df [ '<STR_LIT:bar>' ] [ <NUM_LIT:0> ] . append ( <NUM_LIT> ) <EOL> assert_data_frame_almost_equal ( <EOL> obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ] , '<STR_LIT:bar>' : [ [ <NUM_LIT> ] , [ ] , [ ] ] } , <EOL> index = np . arange ( <NUM_LIT:3> ) ) ) <EOL> def test_positional_metadata_setter_invalid_type ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ] } ) <EOL> with self . assertRaisesRegex ( TypeError , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) : <EOL> obj . positional_metadata = <NUM_LIT:2> <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ] } ) ) <EOL> def test_positional_metadata_setter_len_mismatch ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ] } ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> obj . positional_metadata = None <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ] } ) ) <EOL> with self . assertRaisesRegex ( ValueError , '<STR_LIT>' ) : <EOL> obj . positional_metadata = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT> ] } ) ) <EOL> def test_positional_metadata_deleter ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:3> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) ) <EOL> del obj . positional_metadata <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> del obj . positional_metadata <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:3> ) <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> del obj . positional_metadata <EOL> assert_data_frame_almost_equal ( obj . positional_metadata , <EOL> pd . DataFrame ( index = range ( <NUM_LIT:3> ) ) ) <EOL> def test_has_positional_metadata ( self ) : <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:4> ) <EOL> self . assertFalse ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <NUM_LIT:0> , positional_metadata = { } ) <EOL> self . assertFalse ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . DataFrame ( index = np . arange ( <NUM_LIT:4> ) ) ) <EOL> self . assertFalse ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = pd . DataFrame ( index = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' ] ) ) <EOL> self . assertFalse ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:0> , positional_metadata = { '<STR_LIT:foo>' : [ ] } ) <EOL> self . assertTrue ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:4> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] } ) <EOL> self . assertTrue ( obj . has_positional_metadata ( ) ) <EOL> obj = self . _positional_metadata_constructor_ ( <EOL> <NUM_LIT:2> , positional_metadata = { '<STR_LIT:foo>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT:bar>' : [ '<STR_LIT:abc>' , '<STR_LIT>' ] } ) <EOL> self . assertTrue ( obj . has_positional_metadata ( ) ) </s>
