Skip to content

Instantly share code, notes, and snippets.

@Narrat
Created February 4, 2015 10:19
Show Gist options
  • Save Narrat/dc3ab7099d024a41f268 to your computer and use it in GitHub Desktop.
Save Narrat/dc3ab7099d024a41f268 to your computer and use it in GitHub Desktop.
eispice3
FAIL: Variable (calc)
Doctest: calc.Variable
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 2193, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for calc.Variable
File "eispice3/module/calc.py", line 64, in Variable
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 79, in calc.Variable
Failed example:
z = x**x + cos(20*y + x) - (x / (y+50)) # z is of type _Result
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[3]>", line 1, in <module>
z = x**x + cos(20*y + x) - (x / (y+50)) # z is of type _Result
TypeError: unsupported operand type(s) for /: 'Variable' and '_Result'
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 82, in calc.Variable
Failed example:
print(round(z,6)) # z's value
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[4]>", line 1, in <module>
print(round(z,6)) # z's value
NameError: name 'z' is not defined
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 84, in calc.Variable
Failed example:
print(round(z[x],6)) # dz/dx
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[5]>", line 1, in <module>
print(round(z[x],6)) # dz/dx
NameError: name 'z' is not defined
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 86, in calc.Variable
Failed example:
print(round(z[y],6)) # dz/dx
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[6]>", line 1, in <module>
print(round(z[y],6)) # dz/dx
NameError: name 'z' is not defined
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 93, in calc.Variable
Failed example:
z = x**x + cos(20*y + x) - (x / (y+50))
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[8]>", line 1, in <module>
z = x**x + cos(20*y + x) - (x / (y+50))
TypeError: unsupported operand type(s) for /: 'Variable' and '_Result'
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 96, in calc.Variable
Failed example:
print(round(z,6)) # z's value
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[9]>", line 1, in <module>
print(round(z,6)) # z's value
NameError: name 'z' is not defined
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 98, in calc.Variable
Failed example:
print(round(z[x],6)) # dz/dx
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[10]>", line 1, in <module>
print(round(z[x],6)) # dz/dx
NameError: name 'z' is not defined
----------------------------------------------------------------------
File "eispice3/module/calc.py", line 100, in calc.Variable
Failed example:
print(round(z[y],6)) # dz/dx
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.4/doctest.py", line 1324, in __run
compileflags, 1), test.globs)
File "<doctest calc.Variable[11]>", line 1, in <module>
print(round(z[y],6)) # dz/dx
NameError: name 'z' is not defined
$ python testibis.py
Traceback (most recent call last):
File "testibis.py", line 3, in <module>
ibs = eispice.Ibis('test')
File "eispice3/module/ibis.py", line 95, in __init__
Ibis_Parser.__init__(self, filename, device)
File "eispice3/module/ibis_parser.py", line 562, in __init__
self.process()
File "eispice3/module/ibis_parser.py", line 101, in process
if self._process(line) is Done:
File "eispice3/module/ibis_parser.py", line 94, in _process
return handler(**match.groupdict())
File "eispice3/module/ibis_parser.py", line 116, in handleBlock
self.fdin.seek(-len(line),1)
OSError: Can't do nonzero cur-relative seeks
Entweder IOStream (in case of name 'test') or specific file that is opened
def process(self):
for line in iter(self.fdin.readline, ''):
if self._process(line) is Done:
self.fdin.seek(-len(line),1)
break
def handleBlock(self, key, name):
name = name.strip()
for line in iter(self.fdin.readline, ''):
if (line[0] != '['):
name = name + '\n'
name = name + line.strip()
else:
self.fdin.seek(-len(line),1)
break
key = key.replace(" ","_").lower()
setattr(self, key, name)
Py2 allows negative seeks. What is the purpose?
Apparently from the end - x, but the second value (that is needed. Without it fails. And not every value is accepted. 1 and 2 was working. Everything else failed)
fsock = open(filename, "rb", 0)
try:
fsock.seek(−128, 2)
tagdata = fsock.read(128)
finally:
fsock.close()
if tagdata[:3] == "TAG":
for tag, (start, end, parseFunc) in
A file object maintains state about the file it has open. The tell method of a file object tells you your
current position in the open file. Since you haven't done anything with this file yet, the current position is
0, which is the beginning of the file.
The seek method of a file object moves to another position in the open file. The second parameter
specifies what the first one means; 0 means move to an absolute position (counting from the start of the
file), 1 means move to a relative position (counting from the current position), and 2 means move to a
position relative to the end of the file. Since the MP3 tags you're looking for are stored at the end of the
file, you use 2 and tell the file object to move to a position 128 bytes from the end of the file.
---> Also von der aktuellen Position - der line Länge
Also vom Ende der Line wieder zum Anfang
Python3
TextIOBase:
seek(offset, whence=SEEK_SET)
Change the stream position to the given offset. Behaviour depends on the whence parameter:
SEEK_SET or 0: seek from the start of the stream (the default); offset must either be a number returned by TextIOBase.tell(), or zero. Any other offset value produces undefined behaviour.
SEEK_CUR or 1: “seek” to the current position; offset must be zero, which is a no-operation (all other values are unsupported).
SEEK_END or 2: seek to the end of the stream; offset must be zero (all other values are unsupported).
Return the new absolute position as an opaque number.
IOBase:
seek(offset, whence=SEEK_SET)
Change the stream position to the given byte offset. offset is interpreted relative to the position indicated by whence. Values for whence are:
SEEK_SET or 0 – start of the stream (the default); offset should be zero or positive
SEEK_CUR or 1 – current stream position; offset may be negative
SEEK_END or 2 – end of the stream; offset is usually negative
Return the new absolute position.
New in version 3.1: The SEEK_* constants.
New in version 3.3: Some operating systems could support additional values, like os.SEEK_HOLE or os.SEEK_DATA. The valid values for a file could depend on it being open in text or binary mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment