Change Square_lattice to Lattice_square
This commit is contained in:
parent
36f5226107
commit
fba87c564a
@ -24,18 +24,18 @@ class Lattice():
|
|||||||
specs=spec.split(":")
|
specs=spec.split(":")
|
||||||
# check type of lattice
|
# check type of lattice
|
||||||
if specs[0]=="square":
|
if specs[0]=="square":
|
||||||
return Square_lattice.new_square(specs[1:],spec)
|
return Lattice_square.new_square(specs[1:],spec)
|
||||||
else:
|
else:
|
||||||
return(None,"error: unrecognized lattice type: '"+specs[0]+"'")
|
return(None,"error: unrecognized lattice type: '"+specs[0]+"'")
|
||||||
|
|
||||||
|
|
||||||
# square lattice
|
# square lattice
|
||||||
class Square_lattice(Lattice):
|
class Lattice_square(Lattice):
|
||||||
def __init__(self,**kwargs):
|
def __init__(self,**kwargs):
|
||||||
|
|
||||||
self.spacing=kwargs.get("spacing",1.)
|
self.spacing=kwargs.get("spacing",1.)
|
||||||
|
|
||||||
super(Square_lattice,self).__init__(**kwargs,type="square")
|
super(Lattice_square,self).__init__(**kwargs,type="square")
|
||||||
|
|
||||||
# lattice point nearest to point
|
# lattice point nearest to point
|
||||||
def nearest(self,point):
|
def nearest(self,point):
|
||||||
@ -49,12 +49,12 @@ class Square_lattice(Lattice):
|
|||||||
def new_square(specs,spec):
|
def new_square(specs,spec):
|
||||||
# no optional args
|
# no optional args
|
||||||
if len(specs)==0:
|
if len(specs)==0:
|
||||||
return (Square_lattice(),"")
|
return (Lattice_square(),"")
|
||||||
if len(specs)>1:
|
if len(specs)>1:
|
||||||
return (None,"error: '"+spec+"' is not a valid specification for the square lattice: should be 'square[:spacing]'")
|
return (None,"error: '"+spec+"' is not a valid specification for the square lattice: should be 'square[:spacing]'")
|
||||||
try:
|
try:
|
||||||
spacing=float(specs[0])
|
spacing=float(specs[0])
|
||||||
return (Square_lattice(spacing=spacing),"")
|
return (Lattice_square(spacing=spacing),"")
|
||||||
except:
|
except:
|
||||||
return (None,"error: '"+spec+"' is not a valid specification for the square lattice: should be 'square[:spacing]'")
|
return (None,"error: '"+spec+"' is not a valid specification for the square lattice: should be 'square[:spacing]'")
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ from kivy.graphics import Color,Line
|
|||||||
from point import Point
|
from point import Point
|
||||||
from polyomino import Cross
|
from polyomino import Cross
|
||||||
from polyomino import Square_element
|
from polyomino import Square_element
|
||||||
from lattice import Square_lattice
|
|
||||||
|
|
||||||
from tools import remove_fromlist
|
from tools import remove_fromlist
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user