Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brsr committed May 4, 2017
1 parent f4633d3 commit daa5bb4
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
26 changes: 15 additions & 11 deletions antitile/off.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ def load_off(file):
faces.append(vx)
facecolors.append(colorspec)

edges = np.array(edges, dtype=int)
verts = np.array(verts, dtype=int)
facecolors = np.array(facecolors)
edgecolors = np.array(edgecolors)
vertexcolors = np.array(vertexcolors)
edges = None if len(edges) == 0 else np.array(edges, dtype=int)
verts = None if len(verts) == 0 else np.array(verts, dtype=int)
facecolors = None if len(facecolors) == 0 else np.array(facecolors)
edgecolors = None if len(edgecolors) == 0 else np.array(edgecolors)
vertexcolors = None if len(vertexcolors) == 0 else np.array(vertexcolors)

return (vertices, faces, facecolors, edges, edgecolors,
verts, vertexcolors)
Expand All @@ -107,21 +107,25 @@ def write_off(vertices, faces, facecolors=None, edges=None, edgecolors=None,
vertexcolors: List of colors corresponding to each vertex
"""
#align the "faces" into a single list
if facecolors is None and faces is not None:
if (facecolors is None or len(facecolors) == 0) and faces is not None:
facecolors = ['']*len(faces)
if edgecolors is None and edges is not None:
if (edgecolors is None or len(edgecolors) == 0) and edges is not None:
edgecolors = ['']*len(edges)
if vertexcolors is None and verts is not None:
if (vertexcolors is None or len(vertexcolors) == 0) and verts is not None:
print('woo')
vertexcolors = ['']*len(verts)
elif vertexcolors is not None and verts is None:
verts = list(range(len(vertices)))

if len(faces) != len(facecolors):
raise ValueError("Different number of face colors than faces")
msg = "Different number of face colors than faces: {}, {}"
raise ValueError(msg.format(len(faces), len(facecolors)))
elif edgecolors is not None and len(edges) != len(edgecolors):
raise ValueError("Different number of edge colors than edges")
msg ="Different number of edge colors than edges: {}, {}"
raise ValueError(msg.format(len(edges), len(edgecolors)))
elif vertexcolors is not None and len(verts) != len(vertexcolors):
raise ValueError("Different number of vertex colors than vertices")
msg = "Different number of vertex colors than vertices: {}, {}"
raise ValueError(msg.format(len(verts), len(vertexcolors)))

flist = list(faces)
if edges is not None:
Expand Down
1 change: 1 addition & 0 deletions bin/breakdown.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Demonstrative figures of the different breakdowns and methods.
Expand Down
19 changes: 9 additions & 10 deletions bin/cellular.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 14 15:01:28 2017
@author: Bstone
"""
Cellular automata on the faces (or vertices) of polyhedra"""

import argparse
from sys import stdin
Expand Down Expand Up @@ -46,7 +44,7 @@ def main():
parser.add_argument("-v", help=NEIGHBOR, action='store_true')
parser.add_argument("-d", action='store_true', help="Color the vertices "
"as if the cellular automata were operating on "
"the dual polyhedron/tiling")
"the dual polyhedron/tiling")
parser.add_argument("-o", help="Output prefix.", default="cellular")
args = parser.parse_args()
file = open(args.filename) if args.filename else stdin
Expand All @@ -55,8 +53,9 @@ def main():
init = vc if args.d else fc
if init is None:
init = np.random.randint(2, size=len(faces))
elif len(init.shape) > 1:
raise ValueError("Need color indexes, not color values")
init = np.asarray(init)
if len(init.shape) > 1:
raise ValueError("Need color indexes, not color values")
poly = tiling.Tiling(vertices, faces)
if args.d:
adj = poly.vertex_f_adjacency if args.v else poly.vertex_adjacency
Expand All @@ -74,10 +73,10 @@ def main():
result = this_state.astype(int)
if args.d:
string = off.write_off(vertices, faces, facecolors=fc, edges=e,
edgecolors=ec, vertexcolors=result)
edgecolors=ec, vertexcolors=result)
else:
string = off.write_off(vertices, faces, facecolors=result, edges=e,
edgecolors=ec, vertexcolors=vc)
string = off.write_off(vertices, faces, facecolors=result,
edges=e, edgecolors=ec, vertexcolors=vc)
fn = file_template.format(i + 1)
with open(fn, 'w') as f:
f.write(string)
Expand Down
1 change: 0 additions & 1 deletion bin/factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import argparse
from collections import Counter

#norm, mod, natural prime mod class
DOMAINS = {"i": factor.Integer,
"g": factor.Gaussian,
"e": factor.Eisenstein,
Expand Down
4 changes: 3 additions & 1 deletion bin/sgsstats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Statistics of polyhedra, with a focus on using similar grid subdivision
polyhedra to approximate the sphere
"""
import argparse
import csv
Expand Down
1 change: 1 addition & 0 deletions bin/svg_subdiv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Creates SVG files for each subdivision square
Expand Down
2 changes: 1 addition & 1 deletion bin/view_off.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Visualizes OFF files using matplotlib, which allows for export to png, svg,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup

setup(name='antitile',
version='20170427',
version='20170503',
description='Tiling subdivision scripts, for use with Antiprism',
url='http://github.com/brsr/antitile',
author='B R S Recht',
Expand Down

0 comments on commit daa5bb4

Please sign in to comment.