机を配置しようぜ☆(^~^)?<その2> からの続き。
「 わたしたちが 何をやっているかは 説明するのが めんどくさいので 省略する☆」
Git hub: event-placement-ai
test_evaluation.py
from evaluation import evaluate
high_pos = None
low_pos = None
high_value = evaluate(high_pos)
low_value = evaluate(low_pos)
if (low_value < high_value):
print("ok.")
else:
print("BAD.")
print("Info : Finished.")
floor_map_csv_file = "./event-placement-ai/auto-generated/floor-map.csv"
participant_csv_file = "./event-placement-ai/input-data/participant.csv"
mappings_csv_file = "./event-placement-ai/auto-generated/mappings.csv"
pos_df = new_position(floor_map_csv_file,
participant_csv_file, mappings_csv_file)
「 position を作るには3つのファイルを指定するんだが、 floor-map.csv
を作るには2つのファイルが要る☆」
「 ファイル名を指定するんじゃなくて、 pandas の DataFrame を引数に渡せないの?」
import pandas as pd
from evaluation import evaluate
from my_lib.position import new_position
from my_lib.build_floor_map import convert_floor_map
# Location.
block1_file = "./event-placement-ai/test/block-1.txt"
table1_file = "./event-placement-ai/test/table-1.txt"
floor1_file = "./event-placement-ai/test/floor-1.csv"
participant1_file = "./event-placement-ai/test/participant-1.csv"
mappings1_file = "./event-placement-ai/test/mappings-1.csv"
block2_file = "./event-placement-ai/test/block-2.txt"
table2_file = "./event-placement-ai/test/table-2.txt"
floor2_file = "./event-placement-ai/test/floor-2.csv"
participant2_file = "./event-placement-ai/test/participant-2.csv"
mappings2_file = "./event-placement-ai/test/mappings-2.csv"
# Read a floor.
floor1_df = convert_floor_map(block1_file, table1_file)
floor1_df.to_csv(floor1_file, index=False)
floor2_df = convert_floor_map(block2_file, table2_file)
floor2_df.to_csv(floor2_file, index=False)
participant1_df = pd.read_csv(participant1_file)
participant2_df = pd.read_csv(participant2_file)
mappings1_df = pd.read_csv(mappings1_file,
sep=',', engine='python')
mappings2_df = pd.read_csv(mappings2_file,
sep=',', engine='python')
low_pos = new_position(floor1_df, participant1_df, mappings1_df)
high_pos = new_position(floor2_df, participant2_df, mappings2_df)
low_value = evaluate(low_pos)
high_value = evaluate(high_pos)
if (low_value < high_value):
print("ok.")
else:
print("BAD.")
print("Info : Finished.")
「 外側は こんな感じになるかだぜ☆ 分けわからんな……☆」
import pandas as pd
from evaluation import evaluate
from my_lib.position import new_position
from my_lib.build_floor_map import convert_floor_map
def make_position(test_number):
# Location.
block_file = "./event-placement-ai/test/block-{}.txt".format(test_number)
table_file = "./event-placement-ai/test/table-{}.txt".format(test_number)
# floor_file = "./event-placement-ai/test/floor-{}.csv".format(test_number)
participant_file = "./event-placement-ai/test/participant-{}.csv".format(
test_number)
mappings_file = "./event-placement-ai/test/mappings-{}.csv".format(
test_number)
# Read a floor.
floor_df = convert_floor_map(block_file, table_file)
# floor_df.to_csv(floor_file, index=False)
participant_df = pd.read_csv(participant_file)
mappings_df = pd.read_csv(mappings_file,
sep=',', engine='python')
return new_position(floor_df, participant_df, mappings_df)
low_value = evaluate(make_position(1))
high_value = evaluate(make_position(2))
if (low_value < high_value):
print("ok.")
else:
print("BAD.")
print("Info : Finished.")
「 テスト番号と バリエーション番号の2つを付けた方が あとで カバレッジ・テストをしたいときに便利じゃないか☆?」
block-1-1.txt
AA..BB
AA..BB
block-1-2.txt
AA..BB
AA..BB
table-1-1.txt
2, 1, 0, 0, 6, 5
3, 4, 0, 0, 7, 8
table-1-2.txt
2, 1, 0, 0, 6, 5
3, 4, 0, 0, 7, 8
participant-1-1.csv
ID,GENRE_CODE
1,Red
2,Red
3,Blue
4,Blue
5,Green
6,Blue
7,Red
8,Blue
participant-1-2.csv
ID,GENRE_CODE
1,Red
2,Red
3,Blue
4,Blue
5,Green
6,Blue
7,Red
8,Blue
mappings-1-1.csv
TABLE,PARTICIPANT
1,1
2,2
3,3
4,4
5,5
6,6
7,7
8,8
mappings-1-2.csv
TABLE,PARTICIPANT
1,1
2,2
3,5
4,6
5,3
6,4
7,7
8,8
「 同じファイルを何個も作ることになるのは なぜなのか……☆?」
「 バリエーション番号を付けるのは マッピング だけでいいのよ」
ok.
Info : Finished.
「 なにかが OK のようだが、どんなテストだったか分からない……☆」
「 製品版と テスト版で わけるの めんどくさいから、
HTMLと CSSのファイル名には テスト番号と バリエーション番号を必ずつけることにするかだぜ☆
製品版は 0 でも入れておけばいいだろ☆」
「 1通りだけでなく もっとテストした方がいいんだが、誰かがやってくれるだろ☆
さっさと先に進もうぜ☆」
机を配置しようぜ☆(^~^)?<その2> へ戻る。
Crieitは誰でも投稿できるサービスです。 是非記事の投稿をお願いします。どんな軽い内容でも投稿できます。
また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!
こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください。
ボードとは?
コメント