Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Outdated functions/methods in ParametricSummarizer #52

Open
xdonu2x opened this issue Nov 8, 2023 · 0 comments
Open

Outdated functions/methods in ParametricSummarizer #52

xdonu2x opened this issue Nov 8, 2023 · 0 comments

Comments

@xdonu2x
Copy link

xdonu2x commented Nov 8, 2023

Hi,

I encountered a couple errors in the ParametricSummarizer. I've traced it down to the xrange and iteritems methods/functions that is not supported in PythonV3.

Another error was in the SummaryStatistics class, where it throws an error if count is not divisible by two. I've also managed to fixed that using numpy to calculate the statistics instead.

Traceback (most recent call last):
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\IO.py", line 190, in parse
self.parse_records(count)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\IO.py", line 165, in parse_records
self.send((recType, fields))
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\Pipeline.py", line 25, in new_fn
action(ds, *args)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\ParametricSummarizer.py", line 54, in before_send
self.onMpr(row)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\ParametricSummarizer.py", line 63, in onMpr
for i in xrange(row[mpr.RSLT_CNT]):
NameError: name 'xrange' is not defined


		#Original code change to range for PythonV3 xdonu2x 8Nov2023
		# for i in xrange(row[mpr.RSLT_CNT]):
		for i in range(row[mpr.RSLT_CNT]):
			values = self.rawMap.setdefault((row[ptr.SITE_NUM],row[ptr.TEST_NUM],i), [])
			values.append(row[mpr.RTN_RSLT][i])

Traceback (most recent call last):
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\IO.py", line 191, in parse
self.complete()
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\Pipeline.py", line 25, in new_fn
action(ds, *args)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\ParametricSummarizer.py", line 43, in before_complete
for key, values in self.rawMap.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

	# change .iteritems to .items for PyhonV3 xdonu2x 8Nov2023
	# for key, values in self.rawMap.iteritems():
	for key, values in self.rawMap.items():
	
def getAllRows(self):
	# change .iteritems to .items for PyhonV3 Ejo 8Nov2023
	#return self.summaryMap.iteritems()
	return self.summaryMap.items()

Traceback (most recent call last):
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\IO.py", line 191, in parse
self.complete()
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\Pipeline.py", line 25, in new_fn
action(ds, *args)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\ParametricSummarizer.py", line 46, in before_complete
self.summaryMap[key] = SummaryStatistics(values)
File "C:\Users\xdonu2x\PycharmProjects\usingpySTDF\venv\lib\site-packages\pystdf\SummaryStatistics.py", line 29, in init
self.median = self.q2 = self.values[self.count / 2]
TypeError: list indices must be integers or slices, not float

import numpy as np

class SummaryStatistics:
	def __init__(self, values):
		self.values = values
		self.min = min(values)
		self.max = max(values)
		self.count = len(values)
		self.sum = sum(values)
		self.sumsqrs = sum([value*value for value in values])
		self.mean = self.sum / float(self.count)
		# self.median = self.q2 = self.values[int(self.count / 2)]
		self.median = self.q2 = np.median(self.values)
		# self.q1 = self.values[int(self.count / 4)]
		# self.q3 = self.values[3 *int(self.count / 4)]
		self.q1 = np.quantile(self.values,0.25)
		self.q3 = np.quantile(self.values,0.75)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant