Пример #1
0
 def run(args):
     Views.wait()
     try:
         s = Schwa(args.repository)
         analytics = s.analyze(max_commits=args.commits, parallel=not args.single)
         Views.results(analytics)
     except (RepositoryExtractionException, SchwaConfigurationException) as e:
         Views.failed(e)
         sys.exit(1)
Пример #2
0
 def learn(args):
     Views.wait()
     try:
         s = Schwa(args.repository)
         solution = s.learn(max_commits=args.commits, parallel=not args.single, bits=args.bits,
                            generations=args.generations)
         Views.learn(solution, args.repository, args.commits)
     except (RepositoryExtractionException, SchwaConfigurationException) as e:
         Views.failed(e)
         sys.exit(1)
Пример #3
0
    def test_wrong_weights(self):
        s = Schwa(".")
        configs = {
            "commits": 100,
            "features_weights": {
                "revisions": 0.4,
                "fixes": 0.3,
                "authors": 0.5
            }
        }
        self.reset_weights()
        max_commits = None

        with self.assertRaises(SchwaConfigurationException):
            max_commits = s.configure_yaml(configs, max_commits)
Пример #4
0
    def test_valid_configuration(self):
        s = Schwa(".")
        configs = {
            "commits": 100,
            "features_weights": {
                "revisions": 0.2,
                "fixes": 0.3,
                "authors": 0.5
            }
        }
        max_commits = None
        max_commits = s.configure_yaml(configs, max_commits)
        self.assertEqual(max_commits, 100)
        self.assertEqual(Metrics.REVISIONS_WEIGHT, 0.2)
        self.assertEqual(Metrics.FIXES_WEIGHT, 0.3)
        self.assertEqual(Metrics.AUTHORS_WEIGHT, 0.5)

        max_commits = 2
        max_commits = s.configure_yaml(configs, max_commits)
        self.assertEqual(max_commits, 2)

        del configs["features_weights"]
        self.reset_weights()
        s.configure_yaml(configs, max_commits)
        self.assertEqual(Metrics.REVISIONS_WEIGHT, self.r_w)
        self.assertEqual(Metrics.FIXES_WEIGHT, self.f_w)
        self.assertEqual(Metrics.AUTHORS_WEIGHT, self.a_w)
Пример #5
0
 def run_json(args):
     s = Schwa(args.repository)
     analytics = s.analyze(max_commits=args.commits, parallel=not args.single)
     Views.results_json(analytics)