When I try to set the fixedpoint engine to PDR, and I try to set the pdr_use_farkas option, I am getting an unknown_parameter error.
In particular, I am using the following options on the fixedpoint object:
fp.set(engine='1',pdr_use_farkas=True,unbound_compressor=False,compile_with_widening=True)
This causes the error:
z3.types.Z3Exception: "unknown parameter ':pdr-use-farkas'"
Using set_option doesn't help either. I tried
set_option(dl_engine='1')
set_option(dl_pdr_use_farkas=True)
and I'm getting "unknown option".
Where am I making the mistake?
I'm using Z3 4.3.1 64bit.
The parameter names have changed between versions as newer versions include a name-space mechanism for parameter names. The Python API has a method for listing parameter descriptions: For example:
fp = Fixedpoint()
print fp.param_descrs()
prints the set of available parameters (permalink: rise4fun.com/Z3Py/r32)
Related
Web search found links to bugs, I don't write complicated code on Python, just want to confirm I understand syntax:
https://docs.python.org/3/library/pathlib.html
Path.stat(*, follow_symlinks=True)¶
But when I write Path(filepath).stat(follow_symlinks=False) I'm getting "stat() got an unexpected keyword argument 'follow_symlinks'" error. lstat() in place of stat(follow_symlinks=False) does job done.
Python 3.8.5. TIA
You're reading it correctly. You just missed the footnote. From the page you linked
Changed in version 3.10: The follow_symlinks parameter was added.
So if you want to use that keyword argument, you need Python 3.10 or newer. Otherwise, as you've already figured out, just use lstat.
I am trying to use Python to run an external program using its COM interface. In general, everything works as expected. The only problem I’m having is that any time I try to retrieve a value from the program using their GetValue method, I get the following error (code included).
This method is supposed to overwrite the value of my Value variable. The function takes 3 arguments, and I have verified that the error is related to the first argument (Value) by using separate functions successfully that only take the last 2 arguments. The documentation for the COM interface mentions this issue for C#, and their recommended solution was to define Value as an Object type variable and set the value to null. I have it set to None below, but I’ve also tried setting it to different int/float/string with no success.
I receive this error whether or not I use the EnsureModule command before dispatch.
See the code below
Object = win32.Dispatch(“COMObject”)
Object.OpenFile(“Filename”)
Value = None
Object.GetValue(Value,0,1)
Exception has occurred:com_error
(-2147352571,’type mismatch’,None,1)
I have seen all previous questions about this, but nothing seems to be working on my end. I am trying to run a test that uses a protobuf generated file, called 'resource_pb2'. I am using Python 3.8 with grpc 1.33.2 and protobuf version 3.14.
When using a class from this protobuf generated file, my test fails with the following error:
Parameter to MergeFrom() must be instance of same class: expected RecognitionResource got RecognitionResource
I've checked the type and id's of all the "recognition resource" classes being called in that particular test, and I get the following:
<class 'resource_pb2.RecognitionResource'> 2069160783760
<class 'resource_pb2.RecognitionResource'> 2069160783760
<class 'resource_pb2.RecognitionResource'> 2069160783760
They are clearly all being called from the same source, so why is this issue occuring?
I had a similar issue and the reason was that I had made a mistake when passing parameters to the function.
The problem was solved when I realized about my bug and I invoked the function in the right way, with all required parameters properly set.
Hope it helps.
Python now supports type hinting, so... yay! It seems like a great method to avoid some of the more obscure runtime bugs.
Sadly, third-party library support remains an issue. Though partially solved by the typeshed project, which is also used by mypy, when trying to port some of my code to use type hints, I ran into issues due to missing stubs.
E.g.
# file:mypytest.py
import lxml.etree as et
tree = et.fromstring('<root><a>1</a><b>2</b><a>3</a></root>')
items = tree.xpath('/root/a')
print([i.text for i in items])
will work perfectly well, but mypy will produce the spurious error message
>>> mypy mypytest.py
mypytest.py:3: error: "_Element" has no attribute "xpath"
because the stub is currently incomplete.
For a larger project, downloading the stub from typeshed, adding the missing entries, and maybe even submitting the corresponding pull request is a no-brainer.
But is there some method to monkey-patch the missing information in quick-and-dirty scenarios?
Bad workaround
The best I was able to come up with was
items = tree.xpath('/root/a') # type: ignore
which silences the error, but also disables type-checking where the variable items is used afterwards. E.g. items[0] + 1 will not cause a warning anymore.
In order to preserve type-checking it is possible to use
items_tmp = tree.xpath('/root/a') # type: ignore
items = items_tmp # type: List[et._Element]
but this seems hackish; It also has to be repeated everywhere the .xpath method is used.
Update from 2017-09-12: Alternatively one can use the syntax
items_tmp : List[et._Element] = tree.xpath('/root/a') # type: ignore
Hopefully simple question here, I have a value that based on if its unicode, must be encoded. I use the built in string.encode class
code is simple:
if value_t is unicode:
values += (value.encode('utf-8', errors='backslashreplace'), None)
continue
However it returns "encode() takes no keyword arguments"
I am running this in python 2.6, I couldn't find any documentation saying this didn't exist in 2.6
Is there a way for me to make sure it isn't being overwritten by an encode function in a different library? or some sort of solution to it.
It seems like you are able to use string.encode in 2.6 (https://docs.python.org/2.6/howto/unicode.html) so I am not really sure why it wouldn't be working. I am working on one file in a fairly big system, so I am worried this is somehow being overwritten. Either that or some module I need isn't installed..But i am lost
The Python docs for encode explain why you're seeing this issue. Specifically: Changed in version 2.7: Support for keyword arguments added
Since method signatures tend to change from version to version, You should always read the relevant documentation to version you are working with
From str.encode documentation for python 2.6, the method signature is:
str.encode([encoding[, errors]])
There is no errors keyword argument, but the second parameter can be used for the same purpose.