Skip to content

Commit

Permalink
rarray: bound spacings to greater than 0 (#454)
Browse files Browse the repository at this point in the history
* rarray: bound spacings to greater than 0
This addresses Issue 451

* Fix a typo. (#452)

* Fix a typo.

* Pin black version in travis

Co-authored-by: Adam Urbańczyk <adam-urbanczyk@users.noreply.github.com>

* rarray: bound spacings to greater than 0
This addresses Issue 451

* Added test for rarray error handling

Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
Co-authored-by: Adam Urbańczyk <adam-urbanczyk@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 27, 2020
1 parent c819dfc commit 32f25f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ def rarray(
false, the lower left corner will be at the center of the work plane
"""

if xSpacing < 1 or ySpacing < 1 or xCount < 1 or yCount < 1:
if xSpacing <= 0 or ySpacing <= 0 or xCount < 1 or yCount < 1:
raise ValueError("Spacing and count must be > 0 ")

lpoints = [] # coordinates relative to bottom left point
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from random import random
from random import randrange

from pytest import approx
from pytest import approx, raises

# my modules

Expand Down Expand Up @@ -960,6 +960,9 @@ def testRectArray(self):
# 6 faces for the box, 2 faces for each cylinder
self.assertEqual(6 + NUMX * NUMY * 2, s.faces().size())

with raises(ValueError):
Workplane().rarray(0, 0, NUMX, NUMY, True)

def testPolarArray(self):
radius = 10

Expand Down

0 comments on commit 32f25f7

Please sign in to comment.