Skip to content

Sourcery Starbot ⭐ refactored anebz/boulder - #40

Open
SourceryAI wants to merge 1 commit into
anebz:mainfrom
SourceryAI:main
Open

SourceryAI wants to merge 1 commit into
anebz:mainfrom
SourceryAI:main

Conversation

@SourceryAI

Copy link
Copy Markdown

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch https://github.com/sourcery-ai-bot/boulder main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment thread app.py
distances = [abs(current_min - _min) for _min in minutes]
closest_min = minutes[distances.index(min(distances))]
current_time = dt.replace(':'+str(current_min), ':'+str(closest_min))
current_time = dt.replace(f':{current_min}', f':{str(closest_min)}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_current_time refactored with the following changes:

Comment thread app.py
Comment on lines -121 to +124
st.markdown(f"""
Does your gym show this occupancy data? Make a PR yourself or let us know and we'll add your gym 😎\n
Created by [anebz](https://github.com/anebz) and [AnglinaBhambra](https://github.com/AnglinaBhambra).\n
Follow us! [![@anebzt](https://img.shields.io/twitter/follow/anebzt?style=social)](https://www.twitter.com/anebzt)
[![@_AnglinaB](https://img.shields.io/twitter/follow/_AnglinaB?style=social)](https://www.twitter.com/_AnglinaB)""")
st.markdown(
"""\x1f Does your gym show this occupancy data? Make a PR yourself or let us know and we'll add your gym 😎\\n\x1f Created by [anebz](https://github.com/anebz) and [AnglinaBhambra](https://github.com/AnglinaBhambra).\\n\x1f Follow us! [![@anebzt](https://img.shields.io/twitter/follow/anebzt?style=social)](https://www.twitter.com/anebzt)\x1f [![@_AnglinaB](https://img.shields.io/twitter/follow/_AnglinaB?style=social)](https://www.twitter.com/_AnglinaB)"""
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lines 121-125 refactored with the following changes:

Comment on lines -37 to +43

# admin-ajax.php not working
page = requests.get(url)
if page.status_code != 200:
return 0
try:
occupancy = int(float(re.search(r'style="margin-left:(.*?)%"', page.text).group(1)))
occupancy = int(float(re.search(r'style="margin-left:(.*?)%"', page.text)[1]))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_occupancy_boulderwelt refactored with the following changes:

Comment on lines -71 to +77
occupancy = int(re.search(r'left: (\d*)%', str(soup.find_all("div", class_="pointer-image")[0]['style'])).group(1))
occupancy = int(
re.search(
r'left: (\d*)%',
str(soup.find_all("div", class_="pointer-image")[0]['style']),
)[1]
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_occupancy_boulderado refactored with the following changes:

Comment on lines -184 to +191
frame_soup = BeautifulSoup(response.content, 'html.parser')
occupancy = re.search(r'left: (\d+)%', str(frame_soup)).group(1)
frame_soup = BeautifulSoup(response.content, 'html.parser')
occupancy = re.search(r'left: (\d+)%', str(frame_soup))[1]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_occupancy_einstein refactored with the following changes:

Comment on lines -124 to +123
for n in range(8):
for _ in range(8):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Testget_missing_aquisition_timestamps.test_fill_nan refactored with the following changes:

Comment on lines -136 to +135
for n in range(8):
for _ in range(8):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Testget_missing_aquisition_timestamps.test_drop_additional refactored with the following changes:

Comment on lines -155 to +172
for n in range(8):
for _ in range(8):
drop = df.index[random.randint(0, len(df)-1)]
dropped.append(df.loc[drop])
df = df.drop([drop])

df2 = add_missing_timestamps(df,
interval='20min',
sample_start='07:20',
sample_end='23:40')
df2 = fill_nan_values(df2)
#get the values it recovered:
recovered=[]
for n, drop in enumerate(dropped):
recovered.append(df2[(df2.gym_name == drop.gym_name)&
(df2.current_time == drop.current_time)])
recovered = [
df2[
(df2.gym_name == drop.gym_name)
& (df2.current_time == drop.current_time)
]
for drop in dropped
]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Testget_missing_aquisition_timestamps.test_correct_value_recovered refactored with the following changes:

Comment thread src/visualize_data.py
Comment on lines -121 to -126
chart = alt.Chart(df).mark_line(interpolate='basis').encode(
x=alt.X('time:N', axis=alt.Axis(grid=True)),
y=alt.Y('occupancy:Q', scale=alt.Scale(domain=[0, 100])),
color=alt.Color("name:N")
return (
alt.Chart(df)
.mark_line(interpolate='basis')
.encode(
x=alt.X('time:N', axis=alt.Axis(grid=True)),
y=alt.Y('occupancy:Q', scale=alt.Scale(domain=[0, 100])),
color=alt.Color("name:N"),
)
)
return chart

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function plot_data refactored with the following changes:

Comment thread src/visualize_data.py
Comment on lines -152 to +155
# convert to numpy array
X_today = [np.asarray(today_data)]
return X_today
return [np.asarray(today_data)]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function preprocess_current_data refactored with the following changes:

This removes the following comments ( why? ):

# convert to numpy array

This branch has not been deployed

No deployments
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.

1 participant