Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Apr 11, 2022

Copy link
Copy Markdown

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

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

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from jumploop April 11, 2022 15:12
class RL_QG_agent:
def __init__(self):
self.model_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Reversi")
pass # 删掉这句话,并填写相应代码

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 RL_QG_agent.__init__ refactored with the following changes:

This removes the following comments ( why? ):

# 删掉这句话,并填写相应代码

Comment on lines -18 to +17
# 这个函数 主要用于测试, 返回的 action是 0-63 之间的一个数值,
# action 表示的是 要下的位置。
action = 123456789 # 删掉这句话,并填写相应代码

return action
return 123456789

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 RL_QG_agent.place refactored with the following changes:

This removes the following comments ( why? ):

# 删掉这句话,并填写相应代码
# 这个函数 主要用于测试, 返回的 action是 0-63 之间的一个数值,
# action 表示的是 要下的位置。

name = ''.join([g.capitalize() for g in game.split('_')])
if obs_type == 'ram':
name = '{}-ram'.format(name)
name = f'{name}-ram'

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 311-491 refactored with the following changes:

This removes the following comments ( why? ):

# somewhat harder because of higher variance:
# probably the hardest because you only get a constant number of rewards in total:
# probably the easiest:
# semi_supervised envs
# A frameskip of 1 means we get every frame

max_epochs = 100

for i_episode in range(max_epochs):
for _ in range(max_epochs):

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 15-47 refactored with the following changes:

This removes the following comments ( why? ):

# pass
# 调用自己训练的模型

Comment on lines -40 to +43
assert isinstance(board_size, int) and board_size >= 1, 'Invalid board size: {}'.format(board_size)
assert (
isinstance(board_size, int) and board_size >= 1
), f'Invalid board size: {board_size}'

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 ReversiEnv.__init__ refactored with the following changes:

Comment on lines -21 to +20
std = np.sqrt(np.mean(np.abs(ys - ys_pred) ** 2))
return std
return np.sqrt(np.mean(np.abs(ys - ys_pred) ** 2))

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 evaluate refactored with the following changes:

Comment on lines -38 to +48
pass
# 按诗的字数排序
poems = sorted(poems, key=lambda line: len(line))
# print(poems)
# 统计每个字出现次数
all_words = []
for poem in poems:
all_words += [word for word in poem]
all_words += list(poem)
counter = collections.Counter(all_words) # 统计词和词频。
count_pairs = sorted(counter.items(), key=lambda x: -x[1]) # 排序
words, _ = zip(*count_pairs)
words = words[:len(words)] + (' ',)
words = words[:] + (' ',)

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 process_poems1 refactored with the following changes:

Comment on lines -66 to +65
line = line.strip()
if line:
if line := line.strip():

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 process_poems2 refactored with the following changes:

Comment on lines -185 to +188
if w == start_token or w == end_token:
if w in [start_token, end_token]:
break
shige.append(w)
poem_sentences = poem.split('。')
for s in poem_sentences:
if s != '' and len(s) > 10:
print(s + '。')
print(f'{s}。')

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 pretty_print_poem refactored with the following changes:

"""
sen_embed = self.word_embedding(input_sentence)
return sen_embed
return self.word_embedding(input_sentence)

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 word_embedding.forward refactored with the following changes:

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.

0 participants