Skip to content

Commit

Permalink
Merge pull request #3 from billy-price/module_refactor
Browse files Browse the repository at this point in the history
organised the file structure better for a python module
blinkybool authored Jan 29, 2020
2 parents 89d47aa + 5609e9a commit 9207880
Showing 26 changed files with 687 additions and 404 deletions.
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
magmaenv
*.cache
*__pycache__
*.vscode
.pytest_cache


# latex
*.aux
*.fdb_latexmk
*.fls
*.log
*.synctex.gz

# python
*__pycache__
*.pytest_cache
*.pyc
329 changes: 0 additions & 329 deletions magma.py

This file was deleted.

18 changes: 18 additions & 0 deletions magma/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
TEX_TEMPLATES_PATH = 'tex_templates'
from .tikz import *
from .catalan import *
from .asciiDrawing import *
from .catalan_families.brackets import *
from .catalan_families.trees import *
from .catalan_families.tableaux import *
from .catalan_families.dyckPaths import *
from .catalan_families.productStrings import *
from .catalan_families.triangulations import *
from .catalan_families.mountainsAscii import *
from .catalan_families.nestedMatchings import *
from .catalan_families.staircasePolygons import *
from .catalan_families.friezePatterns import *


for Catalan_Family in Catalan.all_catalan_families():
Catalan_Family.init_norm_cache()
File renamed without changes.
18 changes: 18 additions & 0 deletions magma/asciiDrawing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class AsciiDrawing:
def __init__(self, width, height):
self.width = width
self.height = height
self.charmap = dict()

def write(self, char, x, y):
self.charmap[(x,y)] = char

def __str__(self):
return self.get_str()

def get_str(self, trim_rows=False):
rows = [''.join(self.charmap.get((x, self.height-y-1), ' ') for x in range(self.width)) for y in range(self.height)]
if trim_rows:
return '\n'.join(row for row in rows if not row.isspace())
else:
return '\n'.join(rows)
Loading
Oops, something went wrong.

0 comments on commit 9207880

Please sign in to comment.