Skip to content

Consider using DataFrame index to flag problematic trials in warnings #128

@raeedcho

Description

@raeedcho

In interval.py, trial_data.trial_id is used in warnings to flag trials where things have gone wrong. I suggest changing this to trial_data.index instead, for two reasons:

  1. With index returned, a user can quickly pull up the problematic trial using trial_data.loc[index_val,:] rather than using more cumbersome selection code like trial_data.loc[trial_data['trial_id']==trial_id_val,:] (I admit I may be unaware of a really simple way to do this)
  2. Unlike trial_id, trial_data.index has to exist in the DataFrame, and entries in it have to be unique, which adds a bit of robustness to the framework.

For some context, in my workflow, I end up setting trial_id as the DataFrame index and make sure to set reset_index=False whenever using PyalData functions with the option (another thing I think should be default, but perhaps that's another issue). This gets rid of the column from the DataFrame, but gives me handles for each row of the DataFrame as I would normally use the trial_id. However, I get errors when a PyalData function refers to trial_data.trial_id, and I think in at least most cases, it would be better to use trial_data.index anyway. I doubt that this change would break anyone's code, but I've certainly been wrong about what breaks code before 😄

If others agree, I can open up a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions