Bug persisting through 11.2.0

For example, we have

v = {10, 100};
u = {20, 2000};
t = {1, 2};

Then I construct two TemporalData


I call td2 is reversed relative to td1, and

td1 // Normal
td2 // Normal


{{{1, 10}, {2, 100}}, {{1, 20}, {2, 2000}}}
{{{-2, 100}, {-1, 10}}, {{-2, 2000}, {-1, 20}}}

Now comes the peculiar part:

first, obviously

{v, u} === td1["ValueList"]
t === td1["Times"]




TemporalData[td1["ValueList"], {td1["Times"]}] === td1
TemporalData[td1["ValueList"], -{td1["Times"]}] === td2



What?! They suppose to be both true. Why the second identity is false?

I tried to Trace, but even as simple as TemporalData[{1}, {{1}}]//Trace will produce huge bulk of result, don't know what is going on there.

By the way, I also tried

   td1["ValueList"], -{td1["Times"]}]] === td2

Also False.

So How can I create a function that serves to reverse TemporalData? The function below is not working, why?

reverseTemporalData[temporalData_] := 
 Module[{valueList = temporalData["ValueList"], 
   times = temporalData["Times"]},
  TemporalData[valueList, -{times}]]


PS. I am using Mathematica 11.2

  • $\begingroup$ Looks like a bug/feature: it seems that you need to Reverse the values when you minus the times: TemporalData[td1["ValueList"], {-td1["Times"]}]==TemporalData[Reverse/@{v, u}, {-t}] gives True. $\endgroup$ – kglr Oct 2 '17 at 9:56
  • $\begingroup$ @kglr But How to understand TemporalData[{{10, 100}, {20, 2000}}, {{-1, -2}}]===td2 give True? $\endgroup$ – matheorem Oct 2 '17 at 9:59
  • $\begingroup$ @kglr and Clear[reverseTemporalData]; reverseTemporalData[temporalData_] := Module[{valueList = temporalData["ValueList"], times = temporalData["Times"]}, TemporalData[Reverse /@ valueList, {-times}]] doesn't work $\endgroup$ – matheorem Oct 2 '17 at 10:01
  • $\begingroup$ maybe ClearAll[rubeGoldbergReverseTimesInTemporalData]; rubeGoldbergReverseTimesInTemporalData[t_TemporalData] :=TemporalData[ Reverse /@ Transpose[Reverse@Transpose@t["ValueList"]], {-t["Times"]}];rubeGoldbergReverseTimesInTemporalData[td1] ===td2?:) $\endgroup$ – kglr Oct 2 '17 at 10:56
  • 2
    $\begingroup$ This also seems to work: TemporalData[Uncompress@Compress@td1["ValueList"], -{td1["Times"]}] === td2 - for some reason, destroying the "identity" of the value list helps TemporalData to behave properly... $\endgroup$ – Lukas Lang Oct 2 '17 at 13:50

Here's what's going on

TemporalData[Developer`FromPackedArray@td1["ValueList"], -{td1["Times"]}] === td2
(* True *)

This is definitely a bug, and I have forward this to the relevant developers. My understanding is that the fact that first argument is packed is tricking the code into thinking the values are already sorted, even though they need to be re-sorted because the times have been reversed.

  • $\begingroup$ Hi, @Itai Seggev. Thank you for explanation. But I don't quite understand the "re-sorted" procedure, could you explain a little why it needs resorting? What is more, I don't understand why Normal@Activate[ Inactive[TemporalData][td1["ValueList"], -{td1["Times"]}]] is not equal to Normal@TemporalData[{{10, 100}, {20, 2000}}, {{-1, -2}}]. It seems that it is consistent with functionality of Inactive and Activate $\endgroup$ – matheorem Oct 7 '17 at 7:30
  • $\begingroup$ As for your second question, Activate[ Inactive[TemporalData][td1["ValueList"], -{td1["Times"]}]] is exactly equivalent to TemporalData[td1["ValueList"], {{-1, -2}}] and so this the same as above. Why would you expect inactivating and then activating somehow alter the behavior? $\endgroup$ – Itai Seggev Oct 7 '17 at 22:30
  • $\begingroup$ As for your first, note that td1["ValueList"] and td2["ValueList"] are different. It needs to decide whether it has been given in the form of "ValueList" or tranposed, and is making different decisions based on whether the array is packed or not. $\endgroup$ – Itai Seggev Oct 7 '17 at 22:34
  • $\begingroup$ Hi, @Itai Seggev. Thank you for explanation. But Normal@TemporalData[{{10, 100}, {20, 2000}}, {{-1, -2}}] gives different result from Normal@TemporalData[td1["ValueList"], {{-1, -2}}]. If you run Inactive[TemporalData][td1["ValueList"], -{td1["Times"]}], it is gives Inactive[TemporalData][{{10, 100}, {20, 2000}}, {{-1, -2}}]. Why you said it is equivalent to TemporalData[td1["ValueList"], {{-1, -2}}]? $\endgroup$ – matheorem Oct 8 '17 at 2:51
  • $\begingroup$ That's not what I said. If you evaluate the two expressions I entered, you'll find they product exactly the same result as I claim. You are missing the point that TemporalData[td1["ValueList"], {{-1, -2}}] === TemporalData[{{10, 100}, {20, 2000}}, {{-1, -2}}] gives False, even though td1["ValueList"] === {{10, 100}, {20, 2000}} gives True. Activate & Inactive have nothing to do with the issue at hand. This is resolved by the fact that Developer`PackedArrayQ /@ {td1["ValueList"], {{10, 100}, {20, 2000}}} gives {True,False} (still a bug, but explains what's going on). $\endgroup$ – Itai Seggev Oct 8 '17 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.