SetReplace icon indicating copy to clipboard operation
SetReplace copied to clipboard

Improve evolution object corruption checking

Open maxitg opened this issue 4 years ago • 1 comments

The problem

Currently we assume evolution objects are guaranteed to have correct format as long as they have correct keys in the Association. Of course, it is not correct, as the user can manually modify them, which yields cryptic internal messages:

In[] := WolframModelEvolutionObject[<|"CreatorEvents" -> 0, 
   "DestroyerEvents" -> 0, "Generations" -> 0, "AtomLists" -> 0, 
   "Rules" -> 0, "MaxCompleteGeneration" -> 0, 
   "TerminationReason" -> 0, "EventRuleIDs" -> 0|>]["CausalGraph"]
image

Expected behavior

We should not assume the evolution object is correct when evaluating properties, and should produce WolframModelEvolutionObject::corrupt if we detect something is wrong.

Note, complete checking should not happen preemptively, because that could be very slow.

Version

In[] := SystemInformation["Small"]
image
In[] := $SetReplaceGitSHA

9620568bf18c009a472399a27f0bc546dfeb8fe0

maxitg avatar Jun 09 '20 21:06 maxitg

Should be useful (from #wolfram-language discord channel):

getFooData[Foo[_,_,assoc_]] := assoc;

Foo[assoc_Association] ? System`Private`HoldNoEntryQ := (
    (* check that assoc is valid *)
    System`Private`ConstructNoEntry[Foo, assoc]
)

myAPIFunction[foo_Foo ? System`Private`NoEntryQ] := 
    getFooData[foo]

Also: https://mathematica.stackexchange.com/questions/198378/custom-atomic-expressions-modern-tutorial

daneelsan avatar Nov 02 '20 17:11 daneelsan