示例#1
0
class TestCompleteAggregation():
    """ Import example data & aggregate.
    - check correct sizes.
    """
    def setup(self):
        print('Setup Interface class, load data files and aggreatate.')
        self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
        self.hosp.load_dataIP('./flosp/test/data/simpleday/SimpleIP.csv')
        self.hosp.make_new_tables()

    def test_aggregation_shape(self):
        "check length of dataframe. NOTE: width will change in future as add new aggregations (columns) to analysis."
        assert self.hosp.data.HOURLY.shape[0] == 96

    def test_HOURLY_column_sums(self):
        " check sums of columns for HOURLY aggregation dataframe."
        columns = {
            'ED_arrivals': 24,
            'ED_departures': 24,
            'IP_admissions_total': 24,
            'IP_discharges_total': 24,
            'EDocc_total': 23,
            'IPocc_total': 132,
            'IPocc_nonelec': 66,
            'IP_admissions_nonelec': 12,
            'IP_discharges_elec': 12,
            'IPadm_minus_dis_elec_nonelec': 0,
        }

        for column in columns.keys():
            assert self.hosp.data.HOURLY[column].sum() == columns[column]
示例#2
0
 def setup(self):
     print("setup             class:TestStuff")
     from flosp.interface import Interface
     self.hosp = Interface('./example/setup.py')
     self.hosp.load_dataED(
         './example/example_data_ED.csv'
     )  # note this path makes it important which dir pytest is run
示例#3
0
class TestInterfaceIP():
    """ import example data
    - check correct sizes
    - columns in df
    """
    def setup(self):
        print("setup Interface and load data files.")
        self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
        self.hosp.load_dataIP(
            './flosp/test/data/simpleday/SimpleIP.csv'
        )  # note this path makes it important which dir run from

    def test_dataIP_shape(self):
        """check size of dataframes, check all expected columns exist etc.
        Is this useful for checks module too?
        Is this all reproduced in test_io"""
        assert self.hosp.data.IP.shape == (48, 37)
示例#4
0
class TestInterfaceED():
    """ import example data
    - check correct sizes
    - columns in df
    """
    def setup(self):
        print("setup Interface and load data files.")
        self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
        self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv'
                              )  # note this path makes it important which dir

    def test_dataED_shape(self):
        """check size of dataframes, check all expected columns exist etc.
        Is this useful for checks module too?
        Is this all reproduced in test_io"""
        assert self.hosp.data.ED.shape == (24, 41)

    def test_extract_dataED(self):
        """check returns dataframe object, with valid and invalid inputs"""
        pass
示例#5
0
class TestInterfaceLoadED():
    """ import example data
    - check correct sizes
    - columns in df
    """
    def setup(self):
        print("setup             class:TestStuff")
        from flosp.interface import Interface
        self.hosp = Interface('./example/setup.py')
        self.hosp.load_dataED(
            './example/example_data_ED.csv'
        )  # note this path makes it important which dir pytest is run

    def test_load_dataED(self):
        """check size of dataframes, check all expected columns exist etc.
        Is this useful for checks module too?
        Is this all reproduced in test_io"""
        pass

    def test_extract_dataED(self):
        """check returns dataframe object, with valid and invalid inputs"""
        pass
示例#6
0
class TestAgg():
    """ 
    Testing of aggregation functions for simple day example data.
    """

    def setup(self):
        print ("Get some data.")
        self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
        self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv') # note this path makes it important which dir 
        self.hosp.make_new_tables()

    def test_hourly_IPocc_total(self):
        """
        Test occupancy calcs, flosp vs. manual check with function from this test file.
        This is really testing that the flosp aggregation of occupancy calcs is correct, rather than the calculation of occupancy itself.
        """
        #### get list of datetimes to test

        hours_list = get_datetimes_list(self.hosp.data.IPSPELL, 'ADM_DTTM')

        df_flosp = self.hosp.data.HOURLY

        for datetime_hour in hours_list:
            occ_value = get_occ_hour_athour(self.hosp.data.IPSPELL, 'ADM_DTTM', 'DIS_DTTM', datetime_hour)
            assert occ_value == df_flosp.loc[datetime_hour].IPocc_total

        return


    def test_hourly_IPocc_nonelec(self):
        """
        Test occupancy calcs, flosp vs. manual check with function from this test file.
        """
        #### get list of datetimes to 
        
        df = self.hosp.data.IPSPELL

        dff = df.query('ADM_TYPE in ["Non-Elective"]')

        hours_list = get_datetimes_list(dff, 'ADM_DTTM')

        df_flosp = self.hosp.data.HOURLY

        for datetime_hour in hours_list:
            occ_value = get_occ_hour_athour(dff, 'ADM_DTTM', 'DIS_DTTM', datetime_hour)
            assert occ_value == df_flosp.loc[datetime_hour].IPocc_nonelec

        return

    def test_hourly_EDocc_total(self):
        """
        Test occupancy calcs, flosp vs. manual check with function from this test file.
        """
        #### get list of datetimes to 
        
        df = self.hosp.data.ED

        dff = df

        # dff = df.query('ADM_TYPE in ["Non-Elective"]')

        hours_list = get_datetimes_list(dff, 'ARRIVAL_DTTM')

        df_flosp = self.hosp.data.HOURLY

        for datetime_hour in hours_list:
            # occ_value = get_occ_hour_inwindow(dff, 'ARRIVAL_DTTM', 'DEPARTURE_DTTM', datetime_hour)
            occ_value = get_occ_hour_athour(dff, 'ARRIVAL_DTTM', 'DEPARTURE_DTTM', datetime_hour)
            assert occ_value == df_flosp.loc[datetime_hour].EDocc_total

        return
        
    def test_(self):
        """check returns dataframe object, with valid and invalid inputs"""
        pass
示例#7
0
 def setup(self):
     print ("Get some data.")
     self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
     self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv') # note this path makes it important which dir 
     self.hosp.make_new_tables()
示例#8
0
 def setup(self):
     print("setup Interface and load data files.")
     self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
     self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv'
                           )  # note this path makes it important which dir
示例#9
0
 def setup(self):
     print('Setup Interface class, load data files and aggreatate.')
     self.hosp = Interface('./flosp/test/data/simpleday/setup.py')
     self.hosp.load_dataIP('./flosp/test/data/simpleday/SimpleIP.csv')
     self.hosp.make_new_tables()
示例#10
0
 def setup(self):
     print("setup             class:TestStuff")
     from flosp.interface import Interface
     hosp = Interface('./example/setup.py')
示例#11
0
 def setup(self):
     print("setup             class:TestStuff")
     from flosp.interface import Interface
     self.hosp = Interface('./dfasdf/dasf/setup.py')
示例#12
0
 def setup(self):
     print("setup             class:TestStuff")
     from flosp.interface import Interface
     self.hosp = Interface('./flosp/test/data/simpleday/setup.py')