Esempio n. 1
0
 def to_dynamic_productlevelexportsystem(self, verbose=True):
     """
     Method to construct a Product Level Export System from the dataset
     """
     #-Prepare Names-#
     data = self.data.copy(deep=True)                                            #Don't Alter Dataset, Should this be the default behaviour of the data attribute?
     data = data.reset_index()
     data.rename(columns={'eiso3c' : 'country', 'value' : 'export'}, inplace=True)
     data.set_index(['year'], inplace=True)
     #-Construct Object-#
     from pyeconlab.trade.systems import DynamicProductLevelExportSystem
     system = DynamicProductLevelExportSystem()
     system.from_df(df=data)
     return system
Esempio n. 2
0
    def test_simple_data(self):
        """
		Test Simple Networks
		"""
        A = DynamicProductLevelExportSystem()
        A.from_csv(self.fn,
                   dtypes=['DataFrame', 'BiPartiteGraph'],
                   verbose=True)  # - Funtions Tested: from_csv, from_df
        for year in [2000, 2001]:
            assert_frame_equal(self.odata_yeardict[year],
                               A[year].data.reset_index())

        # print "Object A[2000] Network Nodes:" 		# These features will be migrated to DynamicProductLevelExportNetwork Class
        # print A[2000].network.nodes()
        # print "Object A[2000] Network Edges:"
        # print A[2000].network.edges()

    #-WORKING HERE-#
    #-Itegrate these into the test-#

    # ################
    # #Test Functions#
    # ################

    # print "Test .data property"
    # print A.data
    # print "Test get_data() Extended method"
    # print "Default Settings"
    # print A.get_data()
    # print "Specific Year Data"
    # print A.get_data(year=2000)
    # print "Long Panel of Data"
    # print A.get_data(rtype='long')
    # print "Wide Panel of Data"
    # print A.get_data(rtype='wide')
    # print "Panel of Data"
    # print A.get_data(rtype='panel')

    # print "Test as_cp_matrices()"
    # A.as_cp_matrices(verbose=True)
    # print A[2000].cp_matrix
    # print A[2001].cp_matrix

    # print "Testing .cp_matrix Property"
    # print A.cp_matrix

    # print "Testing rca_matrices()"
    # A.complete_trade_network = True
    # A.rca_matrices(verbose=True)
    # print A[2000].rca
    # print A[2001].rca
    # print "Testing .rca Property"
    # print A.rca

    # print "Testing Mcp_matrices()"
    # A.mcp_matrices(fillna=True, verbose=True)
    # print A[2000].mcp
    # print A[2001].mcp
    # print "Testing .mcp Property"
    # print A.mcp

    # print "Testing proximity_matrices()"
    # A.proximity_matrices(verbose=True)
    # print A[2000].proximity
    # print A[2001].proximity
    # print "Testing .proximity Property"
    # print A.proximity

    # print "Testing proximity_matrices(matrix_type='asymmetric')"
    # A.proximity_matrices(matrix_type='asymmetric', verbose=True)
    # print A[2000].proximity
    # print A[2001].proximity
    # print "Testing .proximity Property"
    # print A.proximity

    # print "Testing Product Ubiquity Method"
    # A.compute_ubiquity(verbose=True)
    # print A[2000].ubiquity
    # print A[2001].ubiquity
    # print "Testing .ubiquity Property"
    # print A.ubiquity

    # print "Testing Country Diversity Method"
    # A.compute_diversity(verbose=True)
    # print A[2000].diversity
    # print A[2001].diversity
    # print "Testing .diversity Property"
    # print A.diversity

    # print "--------"
    # print "TESTING COMPLETED SUCCESFULLY!"
    # print "--------"

    # sys.exit()

    # #################################################
    # ## Alternative Ways of Working with the Object ##
    # #################################################

    # print "\nObject B:"
    # B = DynProductLevelExportSystem()
    # # - Import Test Data - #
    # B.from_csv(data, dtypes=['DataFrame'], verbose=True)
    # B.construct_bipartite(verbose=True)
    # print B[2000].network.nodes()

    # if graphics: B[2000].draw_network()

    # ####################################
    # ### --- Test Object Networks --- ###
    # ####################################
    # # - Country Data from WDI - #
    # W = wdi.WDI('WDI_Data.csv',source_ds='d1352f394ef8e7519797214f52ccd7cc', hash_file_sep=r' ', verbose=True)
    # C = Countries() 																								#Investigate a Pickle Here
    # C.build_from_wdi(W)

    # A = DynProductLevelExportSystem()
    # # - Import Test Data - #
    # # - Funtions Tested: from_csv, from_df
    # A.from_csv(data, cntry_obj=C, dtypes=['DataFrame', 'BiPartiteGraph'], verbose=True)
    # print "Object A:"
    # print A
    # print "Object A.data => Should be the Same due to __repr__"
    # print A.ples
    # print "Object A[2000] Data:"
    # print A[2000].data
    # print "Object A[2000] Network Nodes:"
    # print A[2000].network.nodes()
    # print "Object A[2000] Network Edges:"
    # print A[2000].network.edges()

    # ################
    # #Test Functions#
    # ################

    # if graphics:
    # 	print "\nDrawing Network"
    # 	A[2000].draw_network()

    # print "\nTest to_cp_matrices()"
    # A.as_cp_matrices(verbose=True)
    # print A[2000].cp_matrix
    # print A[2001].cp_matrix

    # print "\nTesting cp_matrices() Getter Method"
    # print A.cp_matrices()