Skip to content

Commit 7d12b1b

Browse files
committed
chore: nbdev v3
1 parent bef4868 commit 7d12b1b

6 files changed

Lines changed: 134 additions & 102 deletions

File tree

nbs/01_deck.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
"metadata": {},
224224
"outputs": [],
225225
"source": [
226-
"#|export\n",
226+
"#| export\n",
227227
"@patch\n",
228228
"def remove(self:Deck,\n",
229229
" card:Card): # Card to remove\n",
@@ -281,7 +281,7 @@
281281
"metadata": {},
282282
"outputs": [],
283283
"source": [
284-
"#|export\n",
284+
"#| export\n",
285285
"def draw_n(n:int, # number of cards to draw\n",
286286
" replace:bool=True): # whether or not draw with replacement\n",
287287
" \"Draw `n` cards, with replacement iif `replace`\"\n",
@@ -330,4 +330,4 @@
330330
},
331331
"nbformat": 4,
332332
"nbformat_minor": 5
333-
}
333+
}

nbs/index.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"metadata": {},
88
"outputs": [],
99
"source": [
10-
"#|hide\n",
10+
"#| hide\n",
1111
"from python_nbdev_starter.card import *"
1212
]
1313
},
@@ -135,4 +135,4 @@
135135
},
136136
"nbformat": 4,
137137
"nbformat_minor": 5
138-
}
138+
}

python_nbdev_starter/_modidx.py

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,71 @@
11
# Autogenerated by nbdev
22

3-
d = { 'settings': { 'branch': 'main',
4-
'doc_baseurl': '/python_nbdev_starter',
5-
'doc_host': 'https://moneebullah25.github.io',
6-
'git_url': 'https://github.com/moneebullah25/python_nbdev_starter',
7-
'lib_path': 'python_nbdev_starter'},
8-
'syms': { 'python_nbdev_starter.card': { 'python_nbdev_starter.card.Card': ('card.html#card', 'python_nbdev_starter/card.py'),
9-
'python_nbdev_starter.card.Card.__eq__': ( 'card.html#card.__eq__',
10-
'python_nbdev_starter/card.py'),
11-
'python_nbdev_starter.card.Card.__gt__': ( 'card.html#card.__gt__',
12-
'python_nbdev_starter/card.py'),
13-
'python_nbdev_starter.card.Card.__init__': ( 'card.html#card.__init__',
14-
'python_nbdev_starter/card.py'),
15-
'python_nbdev_starter.card.Card.__lt__': ( 'card.html#card.__lt__',
16-
'python_nbdev_starter/card.py'),
17-
'python_nbdev_starter.card.Card.__str__': ( 'card.html#card.__str__',
18-
'python_nbdev_starter/card.py')},
19-
'python_nbdev_starter.deck': { 'python_nbdev_starter.deck.Deck': ('deck.html#deck', 'python_nbdev_starter/deck.py'),
20-
'python_nbdev_starter.deck.Deck.__contains__': ( 'deck.html#deck.__contains__',
21-
'python_nbdev_starter/deck.py'),
22-
'python_nbdev_starter.deck.Deck.__init__': ( 'deck.html#deck.__init__',
23-
'python_nbdev_starter/deck.py'),
24-
'python_nbdev_starter.deck.Deck.__len__': ( 'deck.html#deck.__len__',
25-
'python_nbdev_starter/deck.py'),
26-
'python_nbdev_starter.deck.Deck.__str__': ( 'deck.html#deck.__str__',
27-
'python_nbdev_starter/deck.py'),
28-
'python_nbdev_starter.deck.Deck.pop': ('deck.html#deck.pop', 'python_nbdev_starter/deck.py'),
29-
'python_nbdev_starter.deck.Deck.remove': ( 'deck.html#deck.remove',
30-
'python_nbdev_starter/deck.py'),
31-
'python_nbdev_starter.deck.Deck.shuffle': ( 'deck.html#deck.shuffle',
32-
'python_nbdev_starter/deck.py'),
33-
'python_nbdev_starter.deck.draw_n': ('deck.html#draw_n', 'python_nbdev_starter/deck.py')}}}
3+
d = {
4+
"settings": {
5+
"branch": "main",
6+
"doc_baseurl": "/python_nbdev_starter",
7+
"doc_host": "https://moneebullah25.github.io",
8+
"git_url": "https://github.com/moneebullah25/python_nbdev_starter",
9+
"lib_path": "python_nbdev_starter",
10+
},
11+
"syms": {
12+
"python_nbdev_starter.card": {
13+
"python_nbdev_starter.card.Card": ("card.html#card", "python_nbdev_starter/card.py"),
14+
"python_nbdev_starter.card.Card.__eq__": (
15+
"card.html#card.__eq__",
16+
"python_nbdev_starter/card.py",
17+
),
18+
"python_nbdev_starter.card.Card.__gt__": (
19+
"card.html#card.__gt__",
20+
"python_nbdev_starter/card.py",
21+
),
22+
"python_nbdev_starter.card.Card.__init__": (
23+
"card.html#card.__init__",
24+
"python_nbdev_starter/card.py",
25+
),
26+
"python_nbdev_starter.card.Card.__lt__": (
27+
"card.html#card.__lt__",
28+
"python_nbdev_starter/card.py",
29+
),
30+
"python_nbdev_starter.card.Card.__str__": (
31+
"card.html#card.__str__",
32+
"python_nbdev_starter/card.py",
33+
),
34+
},
35+
"python_nbdev_starter.deck": {
36+
"python_nbdev_starter.deck.Deck": ("deck.html#deck", "python_nbdev_starter/deck.py"),
37+
"python_nbdev_starter.deck.Deck.__contains__": (
38+
"deck.html#deck.__contains__",
39+
"python_nbdev_starter/deck.py",
40+
),
41+
"python_nbdev_starter.deck.Deck.__init__": (
42+
"deck.html#deck.__init__",
43+
"python_nbdev_starter/deck.py",
44+
),
45+
"python_nbdev_starter.deck.Deck.__len__": (
46+
"deck.html#deck.__len__",
47+
"python_nbdev_starter/deck.py",
48+
),
49+
"python_nbdev_starter.deck.Deck.__str__": (
50+
"deck.html#deck.__str__",
51+
"python_nbdev_starter/deck.py",
52+
),
53+
"python_nbdev_starter.deck.Deck.pop": (
54+
"deck.html#deck.pop",
55+
"python_nbdev_starter/deck.py",
56+
),
57+
"python_nbdev_starter.deck.Deck.remove": (
58+
"deck.html#deck.remove",
59+
"python_nbdev_starter/deck.py",
60+
),
61+
"python_nbdev_starter.deck.Deck.shuffle": (
62+
"deck.html#deck.shuffle",
63+
"python_nbdev_starter/deck.py",
64+
),
65+
"python_nbdev_starter.deck.draw_n": (
66+
"deck.html#draw_n",
67+
"python_nbdev_starter/deck.py",
68+
),
69+
},
70+
},
71+
}

python_nbdev_starter/card.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,44 @@
33
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_card.ipynb.
44

55
# %% auto #0
6-
__all__ = ['suits', 'ranks', 'Card']
6+
__all__ = ["suits", "ranks", "Card"]
77

88
# %% ../nbs/00_card.ipynb #a04efe04
99
from fastcore.utils import *
1010

1111
# %% ../nbs/00_card.ipynb #24bd4f9b
12-
suits = ["♣️","♦️","❤️","♠️"]
13-
ranks = [None, "A"] + [str(x) for x in range(2,11)] + ["J", "Q", "K"]
12+
suits = ["♣️", "♦️", "❤️", "♠️"]
13+
ranks = [None, "A"] + [str(x) for x in range(2, 11)] + ["J", "Q", "K"]
14+
1415

1516
# %% ../nbs/00_card.ipynb #5bc9ec46
1617
class Card:
1718
"A playing card"
18-
def __init__(self,
19-
suit:int, # An index into `suits`
20-
rank:int): # An index into `ranks`
21-
self.suit,self.rank = suit,rank
22-
def __str__(self): return f"{ranks[self.rank]}{suits[self.suit]}"
19+
20+
def __init__(
21+
self,
22+
suit: int, # An index into `suits`
23+
rank: int,
24+
): # An index into `ranks`
25+
self.suit, self.rank = suit, rank
26+
27+
def __str__(self):
28+
return f"{ranks[self.rank]}{suits[self.suit]}"
29+
2330
__repr__ = __str__
2431

32+
2533
# %% ../nbs/00_card.ipynb #92f3ee33
2634
@patch
27-
def __eq__(self:Card, a:Card): return (self.suit,self.rank)==(a.suit,a.rank)
35+
def __eq__(self: Card, a: Card):
36+
return (self.suit, self.rank) == (a.suit, a.rank)
37+
38+
2839
@patch
29-
def __lt__(self:Card, a:Card): return (self.suit,self.rank)<(a.suit,a.rank)
40+
def __lt__(self: Card, a: Card):
41+
return (self.suit, self.rank) < (a.suit, a.rank)
42+
43+
3044
@patch
31-
def __gt__(self:Card, a:Card): return (self.suit,self.rank)>(a.suit,a.rank)
45+
def __gt__(self: Card, a: Card):
46+
return (self.suit, self.rank) > (a.suit, a.rank)

python_nbdev_starter/deck.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,62 @@
33
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_deck.ipynb.
44

55
# %% auto #0
6-
__all__ = ['Deck', 'draw_n']
6+
__all__ = ["Deck", "draw_n"]
77

88
# %% ../nbs/01_deck.ipynb #c82c3961
9-
from .card import *
10-
from fastcore.utils import *
119
import random
1210

11+
from fastcore.utils import *
12+
13+
from .card import *
14+
15+
1316
# %% ../nbs/01_deck.ipynb #9f01cdee
1417
class Deck:
1518
"A deck of 52 cards, not including jokers"
16-
def __init__(self): self.cards = [Card(s, r) for s in range(4) for r in range(1, 14)]
17-
def __len__(self): return len(self.cards)
18-
def __str__(self): return '; '.join(map(str, self.cards))
19-
def __contains__(self, card): return card in self.cards
20-
__repr__=__str__
19+
20+
def __init__(self):
21+
self.cards = [Card(s, r) for s in range(4) for r in range(1, 14)]
22+
23+
def __len__(self):
24+
return len(self.cards)
25+
26+
def __str__(self):
27+
return "; ".join(map(str, self.cards))
28+
29+
def __contains__(self, card):
30+
return card in self.cards
31+
32+
__repr__ = __str__
2133

2234
def shuffle(self):
2335
"Shuffles the cards in this deck"
2436
random.shuffle(self.cards)
2537

38+
2639
# %% ../nbs/01_deck.ipynb #8f2f72e1
2740
@patch
28-
def pop(self:Deck,
29-
idx:int=-1): # The index of the card to remove, defaulting to the last one
41+
def pop(self: Deck, idx: int = -1): # The index of the card to remove, defaulting to the last one
3042
"Remove one card from the deck"
3143
return self.cards.pop(idx)
3244

45+
3346
# %% ../nbs/01_deck.ipynb #b155c9a2
3447
@patch
35-
def remove(self:Deck,
36-
card:Card): # Card to remove
48+
def remove(self: Deck, card: Card): # Card to remove
3749
"Removes `card` from the deck or raises exception if it is not there"
3850
self.cards.remove(card)
3951

52+
4053
# %% ../nbs/01_deck.ipynb #c06f233e
41-
def draw_n(n:int, # number of cards to draw
42-
replace:bool=True): # whether or not draw with replacement
43-
"Draw `n` cards, with replacement iif `replace`"
54+
def draw_n(
55+
n: int, # number of cards to draw
56+
replace: bool = True,
57+
): # whether or not draw with replacement
58+
"Draw `n` cards, with replacement if `replace`"
4459
d = Deck()
4560
d.shuffle()
46-
if replace: return [d.cards[random.choice(range(len(d.cards)))] for _ in range(n)]
47-
else: return d.cards[:n]
61+
if replace:
62+
return [d.cards[random.choice(range(len(d.cards)))] for _ in range(n)]
63+
else:
64+
return d.cards[:n]

settings.ini

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)