= pd.to_datetime(datetime.now())
ts = ts + pd.to_timedelta(np.arange(0, 4 * 20, 20), "ms").astype("timedelta64[us]")
ts_ind1 = ts_ind1.astype('datetime64[us]')
ts_ind ts_ind.unit
utils
utility module for data_io, numerics, etc.
Generate state
generate_state
generate_state (tz:zoneinfo.ZoneInfo)
generate a pandas DataFrame for testing purpose
Generate action
generate_action
generate_action (tz:zoneinfo.ZoneInfo)
generate a pandas DataFrame for testing purpose
'timestep'].dtype action[
Generate reward
generate_reward
generate_reward (tz:zoneinfo.ZoneInfo)
generate a pandas DataFrame for testing purpose
Generate nstate
generate_nstate
generate_nstate (tz:zoneinfo.ZoneInfo)
generate a pandas DataFrame for testing purpose
Generate observation
generate_observation
generate_observation (tz:zoneinfo.ZoneInfo)
generate a list of pandas Series for testing purpose
Generate MultiIndex DataFrame
generate_df_multiindex
generate_df_multiindex (tz:zoneinfo.ZoneInfo)
prepend two levels of index “vehicle” and “driver” to the DataFrame object
generate_eos_df
generate_eos_df (tz:zoneinfo.ZoneInfo)
generate a pandas DataFrame for testing purpose
generate_eos_df(tz)
assert isinstance(generate_eos_df(tz).index, pd.MultiIndex), f"dfs_episode.index is not a MultiIndex"
from fastcore.test import *
isinstance(generate_eos_df(tz).index, pd.MultiIndex), True) test_eq(
Generate Recipe for local pool storage
= trucks_by_id["VB7"]
truck = ObservationMetaECU(
meta =StateSpecsECU(),
state_specs=ActionSpecs(
action_specs="nm",
action_unit_code=truck.torque_table_row_num_flash,
action_row_number=truck.torque_table_col_num,
action_column_number
),=RewardSpecs(reward_unit_code="wh", reward_number=1),
reward_specs=locations_by_abbr[truck.site.abbr],
site )
meta
= "data"
data_folder = "RECORD"
coll_type = trucks_by_id["default"]
truck = locations_by_abbr[truck.site.abbr] truck.site
= meta.get_number_of_states_actions()
number_states, number_actions = ConfigParser()
recipe_default: ConfigParser
recipe_default.read_dict(
{"DEFAULT": { # should go into parquet tabel meta info
"data_folder": data_folder, # '.',
"recipe_file_name": "recipe.ini", # 'recipe.ini',
"coll_type": coll_type,
},"array_specs": { # should go into parquet columns meta info
"states": str(number_states), # 50*4*3
"actions": str(number_actions), # 17*4
"rewards": "1",
"next_states": str(number_states), # 50*4*3
},
} )
= get_filemeta_config(data_folder="data",config_file="recipe.ini",meta=meta, coll_type="RECORD") recipe_generated
configparser_as_dict(recipe_generated)
test_eq(configparser_as_dict(recipe_default), configparser_as_dict(recipe_generated))