Skip to content

code/sim_analysis.py : Error passing parameters to main function #3

@FanboZhao

Description

@FanboZhao

Source code (Line 641 code/sim_analysis.py)

data_puffs, data_wind = load_plume(
        'puff_data_switching_wind.pickle', 
        'wind_data_switching_wind.pickle')

Explanation

Function definition of load_plume

def load_plume(
    dataset='constant', 
    t_val_min=None,
    t_val_max=None,
    env_dt=0.04,
    puff_sparsity=1.00,
    radius_multiplier=1.00,
    diffusion_multiplier=1.00,
    data_dir=config.datadir,
    ):
    print(dataset)
    puff_filename = f'{data_dir}/puff_data_{dataset}.pickle' 
    wind_filename = f'{data_dir}/wind_data_{dataset}.pickle' 

    # pandas dataframe
    data_puffs = pandas.read_pickle(puff_filename)
    data_wind = pandas.read_pickle(wind_filename)

    # Load plume/wind data and truncate away upto t_val_min 
    if t_val_min is not None:
        data_wind.query("time >= {}".format(t_val_min), inplace=True)
        data_puffs.query("time >= {}".format(t_val_min), inplace=True)

...

Bug

The parameter(dataset) passed in is the dataset name instead of file name. Besides, the source code pass two parameters, which lead to the second parameter(t_val_min) is incorrectly assigned value.

As a result, t_val_min is not None, leading to a type error in the code below.

 if t_val_min is not None:
        data_wind.query("time >= {}".format(t_val_min), inplace=True)
        data_puffs.query("time >= {}".format(t_val_min), inplace=True)

Suggested revisions

data_puffs, data_wind = load_plume('constantx5b5')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions