neoai-kterasawa commited on
Commit
d0f90f1
·
1 Parent(s): 0c76e7a

numberとnameを合体

Browse files
Files changed (3) hide show
  1. app.py +3 -3
  2. src/model/odds.py +5 -16
  3. tests/test_func.py +22 -0
app.py CHANGED
@@ -35,9 +35,9 @@ with gr.Blocks(
35
  df_output = gr.Dataframe(
36
  value=[],
37
  label=None,
38
- headers=["", "", "オッズ", "賭け額", "払戻"],
39
- datatype=["str", "str", "number", "number", "number"],
40
- col_count=(5, "fixed"),
41
  )
42
 
43
  # click ------------------------------
 
35
  df_output = gr.Dataframe(
36
  value=[],
37
  label=None,
38
+ headers=["買い目", "オッズ", "賭け額", "払戻"],
39
+ datatype=["str", "number", "number", "number"],
40
+ col_count=(4, "fixed"),
41
  )
42
 
43
  # click ------------------------------
src/model/odds.py CHANGED
@@ -1,22 +1,14 @@
1
  import re
2
  from typing import Final
3
 
4
- from pydantic import (
5
- BaseModel,
6
- RootModel,
7
- StrictFloat,
8
- StrictInt,
9
- StrictStr,
10
- computed_field,
11
- field_validator,
12
- )
13
 
14
  NUMBER_JOINER: Final[str] = "-"
15
 
16
 
17
  class Choice(BaseModel):
18
- number: StrictStr
19
- name: StrictStr = ""
20
  odds: StrictFloat
21
 
22
 
@@ -52,7 +44,6 @@ class Choices(RootModel[list[Choice]]):
52
  weight = (1 / chice.odds) / inverse_ratios_sum
53
  choice_with_bet_list.append(
54
  ChoiceWithBet(
55
- number=chice.number,
56
  name=chice.name,
57
  odds=chice.odds,
58
  bet_amount=max(int(weight * budget / 100) * 100, 100),
@@ -98,7 +89,7 @@ class Choices(RootModel[list[Choice]]):
98
  if is_odds:
99
  choices_list.append(
100
  Choice(
101
- number=NUMBER_JOINER.join(tmp_numbers),
102
  odds=float(line),
103
  )
104
  )
@@ -122,8 +113,7 @@ class Choices(RootModel[list[Choice]]):
122
 
123
  choice_list.append(
124
  Choice(
125
- number=NUMBER_JOINER.join(lines[idx_number].split()),
126
- name=NUMBER_JOINER.join(lines[idx_name].split()),
127
  odds=float(lines[idx_odds]),
128
  )
129
  )
@@ -143,7 +133,6 @@ class ChoicesWithBet(RootModel[list[ChoiceWithBet]]):
143
  def to_table(self) -> list[list]:
144
  return [
145
  [
146
- choice.number,
147
  choice.name,
148
  choice.odds,
149
  choice.bet_amount,
 
1
  import re
2
  from typing import Final
3
 
4
+ from pydantic import (BaseModel, RootModel, StrictFloat, StrictInt, StrictStr,
5
+ computed_field, field_validator)
 
 
 
 
 
 
 
6
 
7
  NUMBER_JOINER: Final[str] = "-"
8
 
9
 
10
  class Choice(BaseModel):
11
+ name: StrictStr
 
12
  odds: StrictFloat
13
 
14
 
 
44
  weight = (1 / chice.odds) / inverse_ratios_sum
45
  choice_with_bet_list.append(
46
  ChoiceWithBet(
 
47
  name=chice.name,
48
  odds=chice.odds,
49
  bet_amount=max(int(weight * budget / 100) * 100, 100),
 
89
  if is_odds:
90
  choices_list.append(
91
  Choice(
92
+ name=NUMBER_JOINER.join(tmp_numbers),
93
  odds=float(line),
94
  )
95
  )
 
113
 
114
  choice_list.append(
115
  Choice(
116
+ name=f"{NUMBER_JOINER.join(lines[idx_number].split())} {NUMBER_JOINER.join(lines[idx_name].split())}",
 
117
  odds=float(lines[idx_odds]),
118
  )
119
  )
 
133
  def to_table(self) -> list[list]:
134
  return [
135
  [
 
136
  choice.name,
137
  choice.odds,
138
  choice.bet_amount,
tests/test_func.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from src.func import calculate
2
+
3
+
4
+ def test_calculate():
5
+ assert (
6
+ calculate(
7
+ 10000,
8
+ (
9
+ "オッズを見て個別に選択全選択全解除\n"
10
+ "選択\n"
11
+ "1\n"
12
+ " \n"
13
+ "1\n"
14
+ "675.5\n"
15
+ "1\n"
16
+ "\n"
17
+ "2\n"
18
+ "93.7"
19
+ ),
20
+ )
21
+ == []
22
+ )