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: improve readability #419

Merged
merged 3 commits into from
Mar 24, 2023
Merged

refactor: improve readability #419

merged 3 commits into from
Mar 24, 2023

Conversation

RogerHYang
Copy link
Contributor

@RogerHYang RogerHYang commented Mar 22, 2023

  • more imperative and fewer indents; taller and skinnier
  • avoid list/dict comprehension when for-loop works
  • minimize functional style

end=time_range.end,
time_index=dataframe.index,
time_start=time_range.start,
time_stop=time_range.end,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
time_stop=time_range.end,
time_end=time_range.end,

Copy link
Contributor Author

@RogerHYang RogerHYang Mar 24, 2023

Choose a reason for hiding this comment

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

stop was intended to emphasize its end exclusive-ness, matching the terminology in the range built-in

class range(start, stop, step=1)

Copy link
Contributor

Choose a reason for hiding this comment

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

My 2 cents: I think end is more clear even with the note about exclusivity

Copy link
Contributor Author

@RogerHYang RogerHYang Mar 24, 2023

Choose a reason for hiding this comment

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

will stay with stop, given the ambiguity with end. see JavaScript below.

const result = endOfHour(new Date(2014, 8, 2, 11, 55))
//=> Tue Sep 02 2014 11:59:59.999

Comment on lines +195 to +196
time_start=time_range.start,
time_stop=time_range.end,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
time_start=time_range.start,
time_stop=time_range.end,
start_time=time_range.start,
end_time=time_range.end,

to match _results in timeseries?

Comment on lines +101 to +102
StartTime: TypeAlias = datetime
EndTime: TypeAlias = datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefit of this? Honest question. The way I see it: It forces me to have more information and reference this type, vs knowing in code that the type is datetime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably tenuous but mostly intended to give names to the return signature (like how you can name return variables in go)

Iterator[Tuple[StartTime, EndTime, pd.Grouper]]

vs

Iterator[Tuple[datetime, datetime, pd.Grouper]]

end=time_range.end,
time_index=dataframe.index,
time_start=time_range.start,
time_stop=time_range.end,
Copy link
Contributor

Choose a reason for hiding this comment

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

My 2 cents: I think end is more clear even with the note about exclusivity

@RogerHYang RogerHYang merged commit e3d332a into main Mar 24, 2023
@RogerHYang RogerHYang deleted the improve-readability branch March 24, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants