Skip to content

Commit 7a33b90

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

3 files changed

Lines changed: 59 additions & 129 deletions

File tree

python_nbdev_starter/_modidx.py

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

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-
}
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')}}}

python_nbdev_starter/card.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,29 @@
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"]
14-
12+
suits = ["♣️","♦️","❤️","♠️"]
13+
ranks = [None, "A"] + [str(x) for x in range(2,11)] + ["J", "Q", "K"]
1514

1615
# %% ../nbs/00_card.ipynb #5bc9ec46
1716
class Card:
1817
"A playing card"
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-
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]}"
3023
__repr__ = __str__
3124

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

python_nbdev_starter/deck.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,45 @@
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-
import random
10-
11-
from fastcore.utils import *
12-
139
from .card import *
14-
10+
from fastcore.utils import *
11+
import random
1512

1613
# %% ../nbs/01_deck.ipynb #9f01cdee
1714
class Deck:
1815
"A deck of 52 cards, not including jokers"
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__
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__
3321

3422
def shuffle(self):
3523
"Shuffles the cards in this deck"
3624
random.shuffle(self.cards)
3725

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

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

52-
5340
# %% ../nbs/01_deck.ipynb #c06f233e
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`"
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`"
5944
d = Deck()
6045
d.shuffle()
61-
if replace:
62-
return [d.cards[random.choice(range(len(d.cards)))] for _ in range(n)]
63-
else:
64-
return d.cards[:n]
46+
if replace: return [d.cards[random.choice(range(len(d.cards)))] for _ in range(n)]
47+
else: return d.cards[:n]

0 commit comments

Comments
 (0)