Beispiel #1
0
 def test_create_plot_geolife(self, get_geolife_triplegs_with_modes):
     """Check if we can run the plot function with geolife data without error"""
     modal_split = calculate_modal_split(get_geolife_triplegs_with_modes,
                                         freq='d',
                                         per_user=False)
     plot_modal_split(modal_split)
     assert True
Beispiel #2
0
    def test_check_dtype_error(self, get_geolife_triplegs_with_modes):
        """Check if error is thrown correctly when index is not datetime

        freq=None calculates the modal split over the whole period
        """
        modal_split = calculate_modal_split(get_geolife_triplegs_with_modes,
                                            freq=None,
                                            per_user=False)
        with pytest.raises(ValueError):
            plot_modal_split(modal_split)
        assert True
Beispiel #3
0
    def test_multi_user_error(self, get_test_triplegs_with_modes):
        """Create a modal split plot based on randomly generated test data"""
        modal_split = calculate_modal_split(get_test_triplegs_with_modes,
                                            freq='d',
                                            per_user=True,
                                            norm=True)
        with pytest.raises(ValueError):
            plot_modal_split(modal_split)

        # make sure that there is no error if the data was correctly created
        modal_split = calculate_modal_split(get_test_triplegs_with_modes,
                                            freq='d',
                                            per_user=False,
                                            norm=True)
        plot_modal_split(modal_split)

        assert True
Beispiel #4
0
    def test_create_plot_testdata(self, get_test_triplegs_with_modes):
        """Create a modal split plot based on randomly generated test data"""
        tmp_file = os.path.join('tests', 'data', 'modal_split_plot.png')

        modal_split = calculate_modal_split(get_test_triplegs_with_modes,
                                            freq='d',
                                            per_user=False,
                                            norm=True)

        modal_split = modal_split[['walk', 'bike', 'train', 'car', 'bus'
                                   ]]  # change order for the looks of the plot
        plot_modal_split(modal_split,
                         out_path=tmp_file,
                         date_fmt_x_axis='%d',
                         y_label='Percentage of daily count',
                         x_label='days')

        assert os.path.exists(tmp_file)
        os.remove(tmp_file)
        os.remove(tmp_file.replace('png', 'pdf'))
    def test_create_plot_testdata(self, get_test_triplegs_with_modes):
        """Create a modal split plot based on randomly generated test data"""
        tmp_file = os.path.join("tests", "data", "modal_split_plot.png")

        modal_split = calculate_modal_split(get_test_triplegs_with_modes,
                                            freq="d",
                                            per_user=False,
                                            norm=True)

        modal_split = modal_split[["walk", "bike", "train", "car", "bus"
                                   ]]  # change order for the looks of the plot
        plot_modal_split(modal_split,
                         out_path=tmp_file,
                         date_fmt_x_axis="%d",
                         y_label="Percentage of daily count",
                         x_label="days")

        assert os.path.exists(tmp_file)
        os.remove(tmp_file)
        os.remove(tmp_file.replace("png", "pdf"))