コード例 #1
0
    def test_to_dict_from_dict(self):
        time = datetime(2018, 1, 1)
        s = CompetitionSpec(
            title="",
            type=CompetitionType.CLASSIFY,
            expiration=time,
            prize=1.0,
            num_classes=2,
            dataset="http://test.com",
            metric=CompetitionMetric.LOGLOSS,
            answer="http://test.com",
        )

        print(str(s))
        d = s.to_dict()

        d["expiration"] = time.strftime("%Y-%m-%d %H:%M:%S")

        j = s.to_json()

        s2 = CompetitionSpec.from_dict(d)
        s3 = CompetitionSpec.from_json(j)

        for item in ["type", "expiration", "prize", "num_classes", "metric"]:
            assert getattr(s, item) == getattr(s2, item) == getattr(s3, item)
コード例 #2
0
    def test_to_dict_from_dict(self):
        time = datetime(2018, 1, 1)
        s = CompetitionSpec(title='',
                            type=CompetitionType.CLASSIFY,
                            expiration=time,
                            prize=1.0,
                            num_classes=2,
                            dataset='http://test.com',
                            metric=CompetitionMetric.LOGLOSS,
                            answer='http://test.com')

        print(str(s))
        d = s.to_dict()

        d['expiration'] = time.strftime("%Y-%m-%d %H:%M:%S")

        j = s.to_json()

        s2 = CompetitionSpec.from_dict(d)
        s3 = CompetitionSpec.from_json(j)

        for item in ['type', 'expiration', 'prize', 'num_classes', 'metric']:
            assert getattr(s, item) == getattr(s2, item) == getattr(s3, item)