Comment #12 on issue 2014 by smichr: sympy.solvers.solvers.solve should
also allow frozenset to hold equations
http://code.google.com/p/sympy/issues/detail?id=2014
I'm +1/2 with comments below. I have often thought that listing all
iterable types was kind of a clunky way to test for iterability. The
proposed change seems sound. Sometimes type of arguments are used to
trigger different types of handling in a routine but I don't think those
kinds of changes are being made here.
I notice that
stride = kwargs.pop('stride', 0.25)
try: stride = eval(stride)
except: pass
- if isinstance(stride, (list, tuple)):
+ if hasattr(stride, '__len__'):
assert len(stride) == 3
self._stride = stride
else:
Is similar to the change made in dot with the difference that here it has
not been confirmed that stride is an iterable so it is conceivable that
stride could be anything that has a length e.g. a dictionary or a string.
So to maintain the same strictness a test that it be an iterable should be
made.
This raises the more general issue: dictionaries support iteration, too,
but replacing a list, set or tuple with a dictionary will give unintended
results when it is iterated. To maintain the same strictness a double test,
hasattr(obj, '__iter__') and hasattr(obj, '__len__'), otherwise we are
introducing a new "feature." Does anyone else see implications for allowing
the iterable to be the keys of a dictionary?
Checking tow attributes is still faster, too, than testing for a type in a
list of length greater than 1.
timeit('hasattr([], "__iter__") and hasattr([],"__len__")')
1.1612908903226611
timeit('type([]) in [list, tuple]')
1.18388733763652
timeit('type([]) in [tuple, list]')
1.2167714053043142
timeit('type([]) in [set, tuple, list]')
1.3359323601184201
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-iss...@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.