Independent test of grid factoring methods.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu bằng cách xác định phần triển khai multiplicative-partition hiện tại và kiểm tra xem các helper create_factors đã bị deprecated có còn tồn tại sau đợt refactor grid_shape hay không. So sánh hai cách tiếp cận được mô tả trong issue, sau đó xác định xem có thể dùng một test độc lập để bao phủ phương thức còn lại hay không, bao gồm cả các dạng grid chứa các giá trị 1; được xem là hoàn thành khi test hữu ích và pass đối với các trường hợp được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
To address #258, we are making changes to allow 1 values in grid_shape. Previously, we had two methods for computing the factors, I think one slow but simpler, and one fast and more subtle. Only the second one of these is surviving the refactor for this, as the first is effectively unused code. But, the deprecated method being removed might be useful as an independent test of the factorization method that we do use. This deprecated method proved difficult to adapt to allowing the 1 values, which also argued for its removal.
But in case this alternate method is later useful for testing, I note the code used here, so it is not lost track of.
def test_both_methods(self):
"""
Do the two methods of computing the multiplicative partitions agree?
"""
for s in [2, 3]:
for n in range(2, 512):
self.assertEqual(utils.mult_partitions(n, s),
utils.create_factors(n, s))
def divisors(n):
i = 2
while i<n:
if n % i == 0:
yield i
i += 1
def multi_for(iterables):
if not iterables:
yield ()
else:
for item in iterables[0]:
for rest_tuple in multi_for(iterables[1:]):
yield (item,) + rest_tuple
def create_factors(n, size=2):
divs = list(divisors(n))
factors = []
for indices in multi_for( [range(p) for p in size*[len(divs)]] ):
total = 1
for i in indices:
total = total*divs[i]
if n == total:
factor = [divs[i] for i in indices]
factor.sort()
factor = tuple(factor)
if factor not in factors:
factors.append(factor)
return factors
def divisors_minmax(n, dmin, dmax):
"""Find the divisors of n in the interval (dmin,dmax]."""
i = dmin+1
while i<=dmax:
if n % i == 0:
yield i
i += 1
def mult_partitions(n, s):
"""Compute the multiplicative partitions of n of size s
>>> mult_partitions(52,3)
[(2, 2, 13)]
>>> mult_partitions(52,2)
[(2, 26), (4, 13)]
"""
return [tuple(flatten(p)) for p in mult_partitions_recurs(n,s)]
def mult_partitions_recurs(n, s, pd=1):
if s == 1:
return [n]
divs = divisors_minmax(n, pd, int(sqrt(n)))
fs = []
for d in divs:
fs.extend([(d,f) for f in mult_partitions_recurs(n/d, s-1, pd)])
pd = d
return fs
- Ngôn ngữ chính
- Python
- Star
- 5
- Fork
- 1
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của enthought/distarray
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
TypeErrors with numpy 1.10 Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Tất cả issue của enthought/distarray
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100