Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: response time class api #313

Merged
merged 15 commits into from
Aug 30, 2023

Conversation

rokamu623
Copy link
Contributor

@rokamu623 rokamu623 commented Aug 3, 2023

Description

Implement to_best_case_records() and to_worst_case_records() in the ResponseTime class, which are APIs in the same format as to_records() in Latency class.

Related links

Jira: https://tier4.atlassian.net/browse/RT2-886

Notes for reviewers

Pre-review checklist for the PR author

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR has been properly tested.
  • The PR has been reviewed.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • (Optional) The PR has been properly tested with CARET_report verification.
  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

@rokamu623 rokamu623 requested a review from taro-yu August 3, 2023 04:45
@rokamu623 rokamu623 self-assigned this Aug 3, 2023
@rokamu623 rokamu623 changed the title Refactor/response time api refactor: ResponseTime API Aug 3, 2023
@rokamu623 rokamu623 changed the title refactor: ResponseTime API refactor: response time class api Aug 3, 2023
@rokamu623
Copy link
Contributor Author

@taro-yu
Please review.
The pytest error will be resolved by #311 or #312 .

Signed-off-by: rokamu623 <[email protected]>
Signed-off-by: rokamu623 <[email protected]>
Signed-off-by: rokamu623 <[email protected]>
Signed-off-by: rokamu623 <[email protected]>
Signed-off-by: rokamu623 <[email protected]>
Comment on lines +764 to +765
t_in = range_records.get_column_series(input_column)
t_out = range_records.get_column_series(output_column)
Copy link
Contributor

@taro-yu taro-yu Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is also used in the function _to_timeseries(), it's better to change t_in/out to timestamps_in/out or somethings more comprehensible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will not be changed in this PR as it is written in accordance with existing code.

Comment on lines +748 to +758
def to_best_case_records(self) -> RecordsInterface:
records = self._records.to_range_records()
input_column = records.columns[1]
output_column = records.columns[-1]
return self._to_records(input_column, output_column)

def to_worst_case_records(self) -> RecordsInterface:
records = self._records.to_range_records()
input_column = records.columns[0]
output_column = records.columns[-1]
return self._to_records(input_column, output_column)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is also used in the function from line 743, I think that using to_range_records is not best way just for column name.
Although there is no way to get column names in ResponseTime class, it is better that, for example, create a new variable self._input_records = records in the ResponseTime class and then write as input_column = f'{self._input_records.columns[0]}_min or max'.
However, it is a little more complicated to write than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will not be changed in this PR as it is written in accordance with existing code.

{'start': 6, 'end': 6},
]
result = to_dict(response.to_records(all_pattern=True))
result = to_dict(response.to_best_case_stacked_bar())
assert result == expect_raw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that 'start' : 4 is not taken into account?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross_case may be different from the desired specification. (The implement may wrong.)

However, as this PR is a refactoring, this investigation and correction will not be conducted.

Comment on lines -233 to 158
result = to_dict(response.to_response_records())
assert result == expect_raw

expect_raw = [
{'start': 0, 'end': 3},
{'start': 0, 'end': 5},
{'start': 2, 'end': 3},
]

result = to_dict(response.to_records(all_pattern=True))
result = to_dict(response.to_stacked_bar())
assert result == expect_raw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test case, it seems not to consider the case: 'end' : 5 in line 238.
Is this OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross_case may be different from the desired specification. (The implement may wrong.)

However, as this PR is a refactoring, this investigation and correction will not be conducted.

@nabetetsu nabetetsu self-requested a review August 21, 2023 05:40
@rokamu623
Copy link
Contributor Author

@nabetetsu
Please check this PR.

@taro-yu taro-yu closed this Aug 22, 2023
@taro-yu taro-yu reopened this Aug 22, 2023
taro-yu
taro-yu previously approved these changes Aug 22, 2023
Copy link
Contributor

@taro-yu taro-yu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Signed-off-by: rokamu623 <[email protected]>
Copy link
Collaborator

@nabetetsu nabetetsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rt2-886_result.zip
LGTM 👍
I have confirmed that there is no difference between the visualization results of Stacked bar and Timeseries before and after this PR's modification.

@rokamu623 rokamu623 merged commit 67dab0c into tier4:main Aug 30, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants