当前位置: 首页>>代码示例>>Python>>正文


Python Bank.identifier方法代码示例

本文整理汇总了Python中src.bank.Bank.identifier方法的典型用法代码示例。如果您正苦于以下问题:Python Bank.identifier方法的具体用法?Python Bank.identifier怎么用?Python Bank.identifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.bank.Bank的用法示例。


在下文中一共展示了Bank.identifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: firm__get_parameters_from_file

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def firm__get_parameters_from_file(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks firm.get_parameters_from_file \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test firm__get_parameters_from_file in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct firm filename
        environment = Environment(environment_directory,  identifier)

        # get the firm_directory from the environment
        firm_directory = environment.firm_directory
        # and loop over all firms in the directory
        listing = os.listdir(firm_directory)
        firmFilename = firm_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        environment.firms.append(firm)
        helper = Helper()
        helper.initialize_standard_firm(firm, environment)
        firm.get_parameters_from_file(firmFilename, environment)

        #
        # TESTING
        #

        # test whether the parameters are read properly
        text = "Identifier has been read as follows: \n"
        text = text + "Identifier: "
        text = text + firm.identifier
        text = text + "\n"
        text = text + "Productivity: "
        text = text + str(firm.parameters["productivity"])
        self.print_info(text)
开发者ID:cogeorg,项目名称:black_rhino,代码行数:62,代码来源:tests_firm.py

示例2: central_bank__getattr

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def central_bank__getattr(self, args):
        import os
        from src.bank import Bank
        from src.central_bank import CentralBank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks central_bank.getattr \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test central_bank__getattr in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct bank filename
        environment = Environment(environment_directory,  identifier)

        # get the bank_directory from the environment
        bank_directory = environment.bank_directory
        # and loop over all banks in the directory
        listing = os.listdir(bank_directory)
        bank_filename = bank_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a central bank
        cb = CentralBank()
        cb.identifier = "test_central_bank"
        environment.central_bank.append(cb)

        #
        # TESTING
        #

        print('Accessing rates through bank.parameters["interest_rate_cb_loans"] :')
        print(cb.parameters["interest_rate_cb_loans"])
        print("Accessing rates through bank.interest_rate_cb_loans:")
        print(cb.interest_rate_cb_loans)
开发者ID:cogeorg,项目名称:black_rhino,代码行数:62,代码来源:tests_central_bank.py

示例3: measurement__set_csv_writer

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def measurement__set_csv_writer(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market
        from src.runner import Runner
        from src.measurement import Measurement

        text = "This test checks measurement.set_csv_writer \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test measurement__set_csv_writer in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # Construct a runner
        runner = Runner(environment)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        import csv
        file_new = open("__init__.py", "r")
        csv_writer = csv.writer(file_new, lineterminator='\n')
        measurement = Measurement(environment, runner)
        print("Measurement's csv_writer:")
        print(measurement.get_csv_writer())
        measurement.set_csv_writer(csv_writer)
        print("Measurement's csv_writer:")
        print(measurement.get_csv_writer())
开发者ID:cogeorg,项目名称:abm_template,代码行数:61,代码来源:tests_measurement.py

示例4: firm__set_state_variables

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def firm__set_state_variables(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks firm.set_state_variables \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test firm__set_state_variables in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct firm filename
        environment = Environment(environment_directory,  identifier)

        # get the firm_directory from the environment
        firm_directory = environment.firm_directory
        # and loop over all firms in the directory
        listing = os.listdir(firm_directory)
        firmFilename = firm_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        #
        # TESTING
        #

        # generate a firm
        firm = Firm()
        environment.firms.append(firm)
        helper = Helper()
        helper.initialize_standard_firm(firm, environment)

        text = "Original state variables:"
        print(text)
        print(firm.get_state_variables())
        text = "New state variables:"
        print(text)
        firm.set_state_variables({'test': 0.66})
        print(firm.get_state_variables())
开发者ID:cogeorg,项目名称:black_rhino,代码行数:60,代码来源:tests_firm.py

示例5: transaction__add_transaction

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def transaction__add_transaction(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction

        text = "This test checks transaction.add_transaction \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test transaction__add_transaction in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #

        print("Creating a transaction")
        transaction = Transaction()
        print("Assigning values")
        transaction.this_transaction("type", "asset", "test_household", "test_firm", 1,  2,  3, 4)
        print("Adding the transaction to the books")
        transaction.add_transaction(environment)
        print("The transaction:")
        print(transaction)
        print("The firm:")
        print(environment.get_agent_by_id("test_firm"))
        print("The household:")
        print(environment.get_agent_by_id("test_household"))
开发者ID:cogeorg,项目名称:black_rhino,代码行数:59,代码来源:tests_transaction.py

示例6: market__tatonnement

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def market__tatonnement(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market

        text = "This test checks market.tatonnement \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test market__tatonnement in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        sellers = []
        for agent in environment.households:
            sellers.append([agent, agent.supply_of_labour])
        buyers = []
        for agent in environment.firms:
            buyers.append([agent, agent.demand_for_labour])
        starting_price = 0.0
        price = 0.0
        market = Market("market")
        price = market.tatonnement(sellers, buyers, starting_price, 0.00000001, 0.01, 1.1)
        print("Price found through tatonnement:")
        print(price)
开发者ID:cogeorg,项目名称:abm_template,代码行数:59,代码来源:tests_market.py

示例7: firm__get_transactions_from_file

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def firm__get_transactions_from_file(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks firm.get_transactions_from_file \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test firm__get_transactions_from_file in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct firm filename
        environment = Environment(environment_directory,  identifier)

        # get the firm_directory from the environment
        firm_directory = environment.firm_directory
        # and loop over all firms in the directory
        listing = os.listdir(firm_directory)
        firmFilename = firm_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        environment.firms.append(firm)

        #
        # TESTING
        #

        environment.firms[0].clear_accounts()
        print("Printing firm:\n")
        print(environment.firms[0])
        print("Reading transactions from the config file.\n")
        print("Printing firm: \n")
        firm.get_transactions_from_file(firm_directory + listing[0], environment)
        print(environment.firms[0])
开发者ID:cogeorg,项目名称:black_rhino,代码行数:58,代码来源:tests_firm.py

示例8: updater__accrue_interests

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def updater__accrue_interests(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market
        from src.updater import Updater

        text = "This test checks updater.accrue_interests \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test updater__accrue_interests in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        bank.interest_rate_deposits = 0.05
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        model = Updater(environment)
        model.__init__(environment)
        environment.new_transaction("deposits", "",  environment.get_agent_by_id("test_household").identifier, environment.get_agent_by_id("test_bank"),
                                    10.0, environment.get_agent_by_id("test_bank").interest_rate_deposits,  0, -1)
        print(environment.get_agent_by_id("test_household"))
        print("Accruing interests\n")
        model.accrue_interests(environment, 0)
        print(environment.get_agent_by_id("test_household"))
开发者ID:cogeorg,项目名称:abm_template,代码行数:57,代码来源:tests_updater.py

示例9: updater__set_model_parameters

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def updater__set_model_parameters(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market
        from src.updater import Updater

        text = "This test checks updater.set_model_parameters \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test updater__set_model_parameters in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        model = Updater(environment)
        model.model_parameters = {"test": "model parameters"}
        print("Model's parameters:")
        print(model.get_model_parameters())
        print("Changing model's parameters:...")
        model.model_parameters = {"new": "model parameters"}
        print("Model's parameters:")
        print(model.get_model_parameters())
开发者ID:cogeorg,项目名称:abm_template,代码行数:56,代码来源:tests_updater.py

示例10: market__set_amplification

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def market__set_amplification(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market

        text = "This test checks market.set_amplification \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test market__set_amplification in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        market = Market("market_id")
        print("Market's amplification:")
        print(market.get_amplification())
        print("Changing amplification")
        market.set_amplification(0.55)
        print("Market's amplification:")
        print(market.get_amplification())
开发者ID:cogeorg,项目名称:abm_template,代码行数:54,代码来源:tests_market.py

示例11: helper__initialize_standard_household

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def helper__initialize_standard_household(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.helper import Helper

        text = "This test checks helper.initialize_standard_household \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test helper__initialize_standard_household in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        # household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #

        helper = Helper()
        helper.initialize_standard_household(household, environment)
        print("Initialized standard household")
        print(household)
开发者ID:cogeorg,项目名称:black_rhino,代码行数:52,代码来源:tests_helper.py

示例12: market__rationing_proportional

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def market__rationing_proportional(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment
        from src.transaction import Transaction
        from src.market import Market

        text = "This test checks market.rationing_proportional \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test market__rationing_proportional in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        #
        # TESTING
        #
        market = Market("market")
        rationed = market.rationing_proportional([["agent1", 5], ["agent2", 7], ["agent3", -3], ["agent4", -4]])
        print("Pairs found through proportional rationing:")
        print(rationed)
开发者ID:cogeorg,项目名称:abm_template,代码行数:51,代码来源:tests_market.py

示例13: environment__check_agent_homogeneity

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def environment__check_agent_homogeneity(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment

        text = "This test checks environment.check_agent_homogeneity \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test environment__check_agent_homogeneity in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct household filename
        environment = Environment(environment_directory,  identifier)

        #
        # TESTING
        #
        bank = Bank()
        bank.identifier = "new bank"
        environment.banks.append(bank)
        environment.agents = [environment.banks, environment.firms, environment.households]

        print("Are banks homogeneous?")
        print(environment.check_agent_homogeneity("banks"))
        print("Changing one of the banks...")
        environment.get_agent_by_id("new bank").parameters["active"] = 4
        print("Are banks homogeneous?")
        print(environment.check_agent_homogeneity("banks"))
开发者ID:cogeorg,项目名称:black_rhino,代码行数:41,代码来源:tests_environment.py

示例14: central_bank__clear_accounts

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def central_bank__clear_accounts(self, args):
        import os
        from src.bank import Bank
        from src.central_bank import CentralBank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks central_bank.clear_accounts \n"
        text = text + "  Checking if after the clear_accounts the total amount    \n"
        text = text + "  of transactions in zero.  \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test central_bank__clear_accounts in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct bank filename
        environment = Environment(environment_directory,  identifier)

        # get the bank_directory from the environment
        bank_directory = environment.bank_directory
        # and loop over all banks in the directory
        listing = os.listdir(bank_directory)
        bank_filename = bank_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a firm
        firm = Firm()
        firm.identifier = "test_firm"
        environment.firms.append(firm)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a central bank
        cb = CentralBank()
        cb.identifier = "test_central_bank"
        environment.central_bank.append(cb)

        #
        # TESTING
        #

        account = 0.0
        tranx = 0

        for transaction in cb.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)

        cb.add_transaction("deposits", "", "test_household",
                           cb.identifier, 0.0,  0.09,  0, -1, environment)
        cb.add_transaction("deposits", "", "test_household",
                           cb.identifier, 20.0,  0.09,  0, -1, environment)

        account = 0.0
        tranx = 0

        for transaction in cb.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)

        cb.clear_accounts()

        account = 0.0
        tranx = 0

        for transaction in cb.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)
开发者ID:cogeorg,项目名称:black_rhino,代码行数:96,代码来源:tests_central_bank.py

示例15: firm__purge_accounts

# 需要导入模块: from src.bank import Bank [as 别名]
# 或者: from src.bank.Bank import identifier [as 别名]
    def firm__purge_accounts(self, args):
        import os
        from src.bank import Bank
        from src.household import Household
        from src.firm import Firm
        from src.environment import Environment  # needed for the bankDirectory

        text = "This test checks firm.purge_accounts \n"
        text = text + "  Checking if after the purge_accounts the total amount    \n"
        text = text + "  of transactions in the firm stays the same.  \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test firm__purge_accounts in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct firm filename
        environment = Environment(environment_directory,  identifier)

        # get the firm_directory from the environment
        firm_directory = environment.firm_directory
        # and loop over all firms in the directory
        listing = os.listdir(firm_directory)
        firmFilename = firm_directory + listing[0]

        # generate a household
        household = Household()
        household.identifier = "test_household"
        environment.households.append(household)

        # generate a bank
        bank = Bank()
        bank.identifier = "test_bank"
        environment.banks.append(bank)

        # generate a firm
        firm = Firm()
        environment.firms.append(firm)
        helper = Helper()
        helper.initialize_standard_firm(firm, environment)

        #
        # TESTING
        #

        account = 0.0
        tranx = 0

        for transaction in firm.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)

        firm.add_transaction("deposits", "", environment.households[0:1][0],
                             firm.identifier, 0.0,  0.09,  0, -1, environment)
        # environment.households[0:1][0] is only for testing purposes DO NOT USE IN PRODUCTION
        # what it does is is takes the first household in environment, but if there are no
        # households (which happens in testing) it doesn't break down

        account = 0.0
        tranx = 0

        for transaction in firm.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)

        firm.accounts[0].purge_accounts(environment)

        account = 0.0
        tranx = 0

        for transaction in firm.accounts:
            account = account + transaction.amount
            tranx = tranx + 1

        print(tranx)
        print(account)
开发者ID:cogeorg,项目名称:black_rhino,代码行数:92,代码来源:tests_firm.py


注:本文中的src.bank.Bank.identifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。