コード例 #1
0
    def test_store_item(self):
        pm = PandasMemory()
        pm.new(["observation", "actions"])

        pm.store({"observation": 1})

        self.assertEqual(pm.df['observation'][0], 1)
コード例 #2
0
    def test_count_no_name(self):
        pm = PandasMemory()
        pm.new(["observation", "action"])
        pm.store([{
            "observation": 1,
            "action": 1
        }, {
            "observation": 2,
            "action": 0
        }])
        mem = pm.count()

        self.assertEqual(mem, 2)
コード例 #3
0
    def test_fetch_last_name_pandas(self):
        pm = PandasMemory()
        pm.new(["observation", "action"])
        pm.store([{
            "observation": 1,
            "action": 1
        }, {
            "observation": 2,
            "action": 0
        }])

        fetch = pm.fetch_last(2, 'observation')

        self.assertEqual(fetch[0], 1)
        self.assertEqual(fetch[1], 2)
コード例 #4
0
    def test_store_list_items(self):
        pm = PandasMemory()
        pm.new(["observation", "action"])

        pm.store([{
            "observation": 1,
            "action": 1
        }, {
            "observation": 2,
            "action": 0
        }])

        self.assertEqual(pm.df['observation'][0], 1)
        self.assertEqual(pm.df['action'][0], 1)
        self.assertEqual(pm.df['observation'][1], 2)
        self.assertEqual(pm.df['action'][1], 0)
コード例 #5
0
    def test_new_list(self):
        pm = PandasMemory()
        pm.new(["observation", "actions"])

        self.assertTrue("observation" in pm.df.columns.values)
        self.assertTrue("actions" in pm.df.columns.values)
コード例 #6
0
    def test_new_string(self):
        pm = PandasMemory()
        pm.new("observation")

        self.assertTrue("observation" in pm.df.columns.values)
コード例 #7
0
    def test_count_name_empty(self):
        pm = PandasMemory()
        pm.new(["observation", "action"])
        mem = pm.count('observation')

        self.assertEqual(mem, 0)