[Subversion] / PEAK-Rules / test_rules.py |
No default branch
Bookmark a link to HEAD:
(view)
(download)
(as text)
3.3 and 3.4 should now have identical test output to 3.1 and 3.2
Remove unittest deprecation warnings
Change preferred syntax matching to ~~x instead of `x`
Unify exception reprs across 2.x and 3.x so tests work
Fix tests that fail on 3.x because of Py3-removed features
PEAK-Rules tests now run (but don't pass) on Python 3
Workaround for PyPy issue #1292 affecting doctests that display classes
Decompile calls, dictionaries, and tweak some slice formatting
Fix exponentiation operator precedence in decompiler
Deprecate use of 'in' syntax for class/type checking
Rough starting draft of expression decompiler. All it does right now is basic Python expressions, but the idea is to eventually decompile criteria, predicates, etc. so that error messages (and other debugging displays) can show them in a compact, user-friendly form, without needing to save the original strings they came from (since in many cases, they won't actually come from strings!)
Tweak test to cover dotted function name case
Allow registering methods for generic functions that aren't imported yet
Fix a problem with ambiguity between (aType,) and (istype(aType),) in TypeEngine functions, and add an error message when you define circular method precedence rules.
Drop superfluous Conjunction subclasses in favor of just using Conjunction in the first place. Classes and NotObjects were a holdover from when I thought the right side of a Test would determine what kind of operation would be performed and how it would be indexed.
Fix broken indexing for "is not" conditions (especially "and"-ed ones)
Simplified class indexing strategy so that ABCs and other 2.6+ classes using __subclasscheck__/__subclasshook__ should work correctly without any special treatment. (The tradeoff is worse worst-case performance when not-yet-indexed classes are added to rules or seen during dispatching.)
Fix same-priority method problem
Simplify CriteriaBuilder by moving the actual criterial logic to exprssionSignature(), leaving just the binding-management and meta-function support in the class. This simplifies some things for meta-function compilers, since they only have to deal with one kind of builder now, and they can use expressionSignature to convert their arguments into conditions instead of expressions, if needed. (This should also make it easier to implement an @expand_as decorator for even simpler, compiler-free meta-functions!)
Begin separating API from core, so that peak.rules main module contains only stuff you need for *using* GF's, not extending/customizing, and core only contains stuff that's mutually interdependent w/other core stuff. Change imports in doctests to reflect intended usage.
Fix TypeEngine based GF's not handling kwargs correctly when the type cache misses. (Reported by Tim Parkin.)
Add a RuleSet.clear() method, and make RuleSet.__iter__ thread-safe, as described in: http://www.eby-sarna.com/pipermail/peak/2008-July/003004.html
Temporary fix for issubclass() problem reported by Alberto Valverde, as described here: http://www.eby-sarna.com/pipermail/peak/2008-July/003003.html This is just a temporary fix; the always_testable() function needs to be refactored with some other sort of ordering check. Or it might be that only isinstance() and identity tests should be considered re-orderable. More thought is required here.
Refactor condition negation by adding negate() GF, dropping truth mode from builders, and adding an OrElse sequential-or operator. This also changed how Truth tests are coded, to use Value(True, T/F) objects in place of bools (to get rid of the ambiguity that previously existed). Value(x, False) objects no longer have disjuncts, since that was another ambiguity. These ambiguities meant that you couldn't cleanly take the disjuncts() of a Test(), which meant you also couldn't negate a test safely. We also no longer force Signature() objects to expand Test disjunctions, as this isn't necessary for DNF handling. (Because we're going to grab the disjuncts() at rule-add time anyway -- eager expansion was an unnecessary holdover from the way RuleDispatch did things.) See also: http://www.eby-sarna.com/pipermail/peak/2008-July/003000.html for more background on the reasoning behind these changes.
Implement AST pattern -> predicate algorithm
Add more test coverage for "not" type criteria
Fix "not isinstance" criteria, broken by last refactoring due to inadequate test coverage. :(
Fix incorrect matching of istype() rules in inheritance
Fix botched index refactoring; single inheritance wasn't working correctly for types that weren't referenced by any rules.
Massive overhaul of the indexing system, to simplify custom indexing and fully support istype() criteria in instance/subclass nodes.
Move recursion-error test to test_rules
Determine sequence (and therefore definition precedence) at rule *parsing* time, rather than rule *addition* time. This ensures that lexical order holds within class bodies, and also prevents confusion when a ruleset is populated using data from other rulesets. (i.e. rulesets no longer generate sequence numbers.) Also, created a ParseContext struct to simplify the signature of the unwieldy parse_rule() function.
Consolidate Rule and ActionDef types, making it easier to link rulesets.
When a method is defined in a class body, defer its registration until the class is finished, and add the class to the method's criteria.
Fix missing rule for implies(istype,type)
Begin implementation of RuleDispatch emulation API To use it, use "from peak.rules import dispatch" in place of importing the dispatch module. Once you've imported the module once, other imports from dispatch.* should work correctly... unless the API in question isn't emulated. Right now, there is no PyProtocols support (i.e. interfaces don't work), and single- dispatch functions can't be cloned.
Fix selectivity problems with Truth and == comparisons that were ending up with branches==1, leading to incorrect dispatch trees. (The number of branches should never be 1 in a correct index.)
Add function argument names to engine objects (for parsing, etc.)
Fix an ambiguity in intersection rules for conjunctions and disjunctions, and a problem comparing IsObject pointers and non-integers. Add an 'engine' argument to tests_for, so that predicate engines will be able to turn type tuples into signatures using their argument info.
Predicate parsing! Still a lot of loose ends to tie up before we have full predicate functions, but this is probably the last major piece; the rest should mostly be integration and cleanup.
Predicate dispatching, at last! We don't compile strings yet, and range dispatching is worse than half the speed of RuleDispatch with C speedups. However, most other types of dispatch should be a good bit faster, and it should be possible to inline more of the range lookup.
Index reseeding, classic MROs, enhanced "abstract", and smart engine recreation (w/unsubscribe).
Ensure that subscribing or unsubscribing an engine from a ruleset during a notification will not interefere with the original list of notifications. Rename ``.func`` attribute of engines to ``.function``.
Switch to using peak.util.extremes
Prepare for switch from Aspects to AddOns
PEAK-Rules is now as "smart" as RuleDispatch, in that it now "knows" as much as RuleDispatch does about logical conditions regarding Python objects, and how to index them efficiently. The machinery is also better documented (and probably better tested) than the equivalent bits of RuleDispatch. Alas, this does not mean that you can actually use Python expressions for generic function criteria yet, as the actual tree builder/interpreter hasn't been written. So we can evaluate and index expressions, but not build them from an AST or build/run a dispatch tree from the indexes. Still, it's getting *really* close now!
Implement indexing for is/not and </>/==/!= conditions, and general bitmap-based index facility. (Still needs class indexing to achieve parity with the comparable parts of RuleDispatch, but it's getting close.)
Added Aspects (ala PEP 3124) and refactor to use them in place of special methods. Refactor indexes to be aspects of an engine. Improved handling for the self-referential bootstrapping of the implies() generic function.
Implement bytecode generation for expressions; this is basically equivalent to porting a little more than half of ``dispatch.predicates`` from RuleDispatch (specifically, the ``ExprBuilder`` class and related node types).
Ported ast_builder module from RuleDispatch, with some API changes that should make it easier to generate bytecode-based expression objects. Also, converted tests to doctests so that the code is more reusable.
Added a generic version of the Chambers & Chen algorithm, with tests. Unlike the RuleDispatch implementation, this one doesn't care how indexes or criteria or expressions actually work, and it has a much simpler way of dealing with inter-expression constraints. The tree building algorithm can also be easily revised to produce any kind of dispatch tree, either eagerly or lazily, and whether in the form of bytecode, source code, or an actual object tree. (RuleDispatch only supports lazy creation of an object tree; it can't do anything else.) Of course, this core algorithm is useless without some concrete types to represent expressions, criteria, and indexes -- not to mention some actual tree-generating code to go along with it. But this algorithm for generating decision trees will be at the heart of the main rule engine for predicate dispatching. At this point, about 2/3rds of the code in the ``dispatch.functions`` module of RuleDispatch has been mapped to ``peak.rules.core`` and ``peak.rules.indexing``. About 1/6th of ``dispatch.strategy`` has also been translated. ``dispatch.ast_builder`` will not require any code changes, but it will probably get some new tests. The remaining modules, however, (including ``strategy``, ``combiners``, and ``predicates``) will be changed substantially. The good news is that these changes should mostly be simplifications, since most of the ``predicates`` module will become calls to BytecodeAssembler APIs. But the remaining parts of ``strategy`` and ``functions`` will likely become more complex, because they will need to know how to generate decision-making bytecode, deal with rule removals, and a few other odds and ends. Some additional code will also be needed to ensure that the core implementation is sufficiently extensible to allow new features (like predicate abstractions and classifiers) to be implemented.
Shuffle some docs/tests around, add quickstart info
Support retroactively changing existing functions into generic functions using the standard decorators.
Code generation support (requires dev trunk of BytecodeAssembler). This completes the core (multiple dispatch) framework features. Next up: cleanup and doc expansion, before moving on to predicate dispatch and advanced features.
Extensible method combination has landed! around(), before(), after(), and when() all work now, and new method types and decorators can be created without needing to subclass any ruleset or engine classes. All that's left for the core to be complete is for TypeEngine objects to generate wrapper code for the functions they're attached to.
Rename DefaultEngine to TypeEngine and add support for caching, intra-signature combination (e.g. Around+Method for same types), and removing rules.
Zero-functionality setup for PEAK-Rules: mostly design docs in README plus an outline of the functionality for the core framework in framework.txt.
cvs-admin@eby-sarna.com Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |