Skip to content

Commit

Permalink
init version
Browse files Browse the repository at this point in the history
  • Loading branch information
Deufel committed Aug 18, 2024
1 parent 189fb93 commit a1dbb8b
Show file tree
Hide file tree
Showing 53 changed files with 8,218 additions and 156 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ipynb merge=nbdev-merge
11 changes: 11 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generated by nbdev_install_hooks
#
# If you need to disable this instrumentation do:
# git config --local --unset include.path
#
# To restore:
# git config --local include.path ../.gitconfig
#
[merge "nbdev-merge"]
name = resolve conflicts with nbdev_fix
driver = nbdev_merge %O %A %B %P
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# nbdev_demo
demo of setting up a nbdev enviorment


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

This file will become your README and also the index of your
documentation.

## Install

``` sh
pip install nbdev-demo
```

## How to use

This library provides a
`` [`Card`](https://Deufel.github.io/nbdev_demo/card.html#card) `` class
you can use to display, and compare playing cards:

``` python
Card(suit=1,rank=4)
```

4♦️

Suits are numbered according to this list:

``` python
suits
```

['♣️', '♦️', '♥️', '♠️']
1 change: 1 addition & 0 deletions _proc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
237 changes: 237 additions & 0 deletions _proc/00_card.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"description: A simple API for creating and using playing cards\n",
"output-file: card.html\n",
"title: card\n",
"\n",
"---\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"['♣️', '♦️', '♥️', '♠️']"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"suits"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"for example the suit ar index ```0```:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"'♣️'"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"suits[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"[None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ranks"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"for exampel the rank at index ```1``` (note no rank at index 1 so that 2 - 10 match)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"'A'"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ranks[1]"
]
},
{
"cell_type": "code",
"execution_count": 1,
"has_sd": true,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/Deufel/nbdev_demo/blob/master/nbdev_demo/card.py#L11){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### Card\n",
"\n",
"> Card (suit:int, rank:int)\n",
"\n",
"*A playing card*\n",
"\n",
"| | **Type** | **Details** |\n",
"| -- | -------- | ----------- |\n",
"| suit | int | An index into `suits` |\n",
"| rank | int | an index into `ranks` |"
],
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/Deufel/nbdev_demo/blob/master/nbdev_demo/card.py#L11){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### Card\n",
"\n",
"> Card (suit:int, rank:int)\n",
"\n",
"*A playing card*\n",
"\n",
"| | **Type** | **Details** |\n",
"| -- | -------- | ----------- |\n",
"| suit | int | An index into `suits` |\n",
"| rank | int | an index into `ranks` |"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#| echo: false\n",
"#| output: asis\n",
"show_doc(Card)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"3♦️"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = Card(suit=1, rank=3)\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Comparison opperators\n",
"\n",
"equality, less than, and greater than should work on rank and suit indicies"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [],
"source": [
"test_eq(Card(suit=1, rank=3), Card(suit=1, rank=3))\n",
"test_ne(Card(suit=1, rank=12), Card(suit=3, rank=12))\n",
"test_ne(Card(suit=1, rank=3), Card(suit=3, rank=3))\n",
"\n",
"assert Card(suit=1, rank=3) < Card(suit=2, rank=3)\n",
"\n",
"assert Card(suit=3, rank=3) > Card(suit=2, rank=3)\n",
"assert not Card(suit=1, rank=3) > Card(suit=2, rank=3)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
67 changes: 0 additions & 67 deletions _proc/00_core.ipynb

This file was deleted.

Loading

0 comments on commit a1dbb8b

Please sign in to comment.