示例#1
0
 def test_get_outcomes_with_age(self):
     analyze = Analyze()
     result = analyze.readfile()
     lines = analyze.get_lines(result)
     objects = analyze.get_objects(lines)
     result = analyze.get_outcomes_with_age(objects)
     self.assertEqual(28, len(result))
示例#2
0
 def test_get_age_groups(self):
     analyze = Analyze()
     result = analyze.readfile()
     lines = analyze.get_lines(result)
     objects = analyze.get_objects(lines)
     result = analyze.get_age_groups(objects)
     self.assertEqual(10, len(result))
示例#3
0
 def run(self):
     for i in range(self.runs):
         S = Simulation(self.timesteps, self.pf_number, self.con_number,
                        self.con_share, self.rest_number)
         S.iterate()
         an = Analyze(S)
         sorted_results = an.sort_pf_by_survival()
         for pf_n in range(self.pf_number):
             self.trans_distrib[pf_n, i] = sorted_results['trans'][pf_n]
             self.rest_distrib[pf_n, i] = sorted_results['rest'][pf_n]
             self.mult_distrib[pf_n, i] = sorted_results['mult'][pf_n]
     self.calc_av(self.trans_distrib, self.trans_av)
     self.calc_av(self.rest_distrib, self.rest_av)
示例#4
0
def main(is_print=False):
    params = {'root_path': root_path}
    processing_ = Processing(params)
    stats = Analyze(processing_.dict_, columns=['title',
                                                'paper_id', 'abstract', 'body_text'])

    if is_print is True:
        print(stats.df_covid.describe(include='all'))

    count = 0
    for x in processing_.dict_['title']:
        if x is "":
            count += 1

    print("\n\n\n\nQuantity of title is empty: {}".format(count))

    return stats
示例#5
0
def analyze(source_path, api):

    # config.txt is used to ignore certain permissions
    print("Looking in root for a config.txt...")
    ignore = {'groups': set(), 'individual': set()}
    try:
        with open("./config.txt") as config:
            for index, line in enumerate(config):

                # ignore commented lines
                if not line.startswith("//"):
                    if line.startswith("#"):
                        # groups -- remove '# ' and add to set
                        sanitized = line[2:].rstrip()
                        ignore['groups'].add(sanitized)
                    elif line != '\n':
                        # specific permissions
                        sanitized = line.rstrip()
                        ignore['individual'].add(sanitized)
        print("Config found. Analysis will ignore the stated permissions.")

    except FileNotFoundError:
        print("Couldn't find a config.txt. Proceeding with analysis")

    # Create reports directory if it doesn't exist
    if not os.path.exists('./reports'):
        os.mkdir('./reports')

    # Parse manifest and validate API
    manifest_tree = get_manifest_tree(source_path)
    validate_minimum_sdk(manifest_tree)

    # Collect permissions
    package_name = get_package_name(manifest_tree)
    permissions = get_requested_permissions(manifest_tree)
    third_party_permissions = get_third_party_permissions(manifest_tree)

    # Scrape the source
    analyzer = Analyze(source_path, package_name, permissions, ignore,
                       str(api))
    source_report = analyzer.search_project_root()

    # Analyze and print results
    report = Report(package_name, permissions, third_party_permissions)
    report.print_analysis(permissions, source_report)
示例#6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 31 12:05:29 2019

@author: clara
"""
from Simulation import Simulation
from Plot import Plot
from Analyze import Analyze
"""test Simulation"""
S = Simulation(20, 3)
results = S.iterate()

an = Analyze(S)
sorted_results = an.sort_pf_by_survival()

p = Plot()
""" Plot transaction distribution """
p.simple_hist_plot(sorted_results['trans'], 'Transactions per platform')
""" Plot restaurant distribution """
p.simple_hist_plot(sorted_results['rest'], 'Restaurants per platform')

p.cum_hist_plot(sorted_results['trans'], 'Transactions, ')
示例#7
0
def run():
    analyze = Analyze()
    print(analyze.print())
示例#8
0
 def test_getlines(self):
     analyze = Analyze()
     result = analyze.readfile()
     lines = analyze.get_lines(result)
     self.assertEqual(360, len(lines))
示例#9
0
 def test_plot(self):
     analyze = Analyze()
     result = analyze.readfile()
     lines = analyze.get_lines(result)
     objects = analyze.get_objects(lines)
     result = analyze.plot_subs(objects)
示例#10
0
 def test_getobjects(self):
     analyze = Analyze()
     result = analyze.readfile()
     lines = analyze.get_lines(result)
     objects = analyze.get_objects(lines)
     self.assertEqual(20, len(objects))