colinsheppard / time

A NetLogo extension that brings date/time utilities and discrete event scheduling to NetLogo
12 stars 13 forks source link

error (NullPointerException) with time:ts-get-range #26

Closed nellReduan closed 10 years ago

nellReduan commented 10 years ago

When I use the primitive "time:ts-get-range" as follows : let ts time:ts-load "File.csv" let tslist time:ts-get-range ts time:create "2013/08/01" time:create "2013/11/01" "all"

I obtain the following error message : error (NullPointerException) while observer running _asm_proceduretest_setprocedurevariable_2 called by procedure TEST called by Button 'test'

Here is an insight of my loaded file "File.csv" in Netlogo : {{time:LogoTimeSeries TIMESTAMP,Date-2 2010-08-01 05:37:00.000,2010-08-01 18:21 2010-08-02 05:39:00.000,2010-08-02 18:19 2010-08-03 05:40:00.000,2010-08-03 18:18 2010-08-04 05:41:00.000,2010-08-04 18:17

My file .csv contains 93 rows and 2 columns.

Thank you very much for your help.

colinsheppard commented 10 years ago

Thank you for submitting this bug, I believe I have corrected the issue. Please install the latest release and let me know if the problem persists:

https://github.com/colinsheppard/time/releases/tag/v1.1.2

nellReduan commented 10 years ago

Thank you Colin for your answer. The error message "error (NullPointerException)" disappeared but is it normal that I obtain a list with two empty sub-lists [ [] [] ] ?

Code : let ts time:ts-load "File.csv" let cycle-date time:ts-get-range cycle time:create "2013/08/01 00:00" time:create "2013/11/01 00:00" "all" print cycle-date

Output : "keyset: 2010-08-01 05:37:00.000 --- 2010-08-02 05:39:00.000 --- 2010-08-03 05:40:00.000 --- 2010-08-04 05:41:00.000 --- ............. --- 2010-10-31 07:31:00.000 --- "" "testing lowerKey: 2013-08-01 00:00:00.000 then timeLow 2013-08-01 00:00:00.000" "is null?: yes" "is lowerKey null now?: yes" "testing higherKey: 2013-11-01 00:00:00.000 then timeHigh 2013-11-01 00:00:00.000" "is null?: yes" "is higherKey null now?: no" [[] []]

Thank you very much for your help.

colinsheppard commented 10 years ago

Thanks for following up, I see that I forgot to turn off debugging statements in the version I released. But in a way it's nice I didn't because I can confidently answer your question.

Your data range from August 2010 through October 2010, but your query: "time:ts-get-range ....." is looking for data between August and November of 2013. So the extension is returning empty lists which is the default behavior for that primitive if no rows are found.

You can download the latest version with debug statements turned off here:

https://github.com/colinsheppard/time/releases/tag/v1.1.2

nellReduan commented 10 years ago

Hello Colin,

Thank you very much for your answer. I don't understand why the last date in the first column of the file .csv (2010-10-31 07:31) appears in "keyset" but doesn't appear in the first sub-list of "cycle-date" ? There isn't this problem with the second sub-list of "cycle-date".

Code : let ts time:ts-load "File.csv" let cycle-date time:ts-get-range cycle time:create "2013/08/01 00:00" time:create "2013/11/01 00:00" "all" print cycle-date

Output : "keyset: 2010-08-01 05:37:00.000 --- 2010-08-02 05:39:00.000 --- 2010-08-03 05:40:00.000 --- 2010-08-04 05:41:00.000 --- .... --- 2010-10-30 07:29:00.000 --- 2010-10-31 07:31:00.000 --- " "testing lowerKey: 2010-08-01 00:00:00.000 then timeLow 2010-08-01 00:00:00.000" "is null?: yes" "is lowerKey null now?: no" "testing higherKey: 2010-11-01 00:00:00.000 then timeHigh 2010-11-01 00:00:00.000" "is null?: yes" "is higherKey null now?: no" [[{{time:logotime 2010-08-01 05:37:00.000}} {{time:logotime 2010-08-02 05:39:00.000}} {{time:logotime 2010-08-03 05:40:00.000}} {{time:logotime 2010-08-04 05:41:00.000}} .... {{time:logotime 2010-10-29 07:28:00.000}} {{time:logotime 2010-10-30 07:29:00.000}}]

Thank you very much for your help. Have a nice day Best regards Nelly Reduan

Date: Mon, 6 Jan 2014 15:15:00 -0800 From: notifications@github.com To: time@noreply.github.com CC: nell.redu@hotmail.fr Subject: Re: [time] error (NullPointerException) with time:ts-get-range (#26)

Thanks for following up, I see that I forgot to turn off debugging statements in the version I released. But in a way it's nice I didn't because I can confidently answer your question.

Your data range from August 2010 through October 2010, but your query: "time:ts-get-range ....." is looking for data between August and November of 2013. So the extension is returning empty lists which is the default behavior for that primitive if no rows are found.

You can download the latest version with debug statements turned off here:

https://github.com/colinsheppard/time/releases/tag/v1.1.2

— Reply to this email directly or view it on GitHub.

colinsheppard commented 10 years ago

Nelly, can you please paste the contents of your csv file into this issue thread? It'll be helpful for me to be able to recreate the issue.

I'm confused that you are getting any results at all since you are asking for rows between Aug and Nov of 2013 but the key set only contains values for the year 2010, so you should be getting back empty lists....

Thanks.

nellReduan commented 10 years ago

Thank you very much Colin for your answer. Sorry, I forgot to modify the year in the code but the output is the same than in my previous message :

Code : let ts time:ts-load "File.csv" let cycle-date time:ts-get-range ts time:create "2010/08/01 00:00" time:create "2010/11/01 00:00" "all" print cycle-date

Here is the content of my csv file : Date-1 Date-2 8/1/2010 5:37 8/1/2010 18:21 8/2/2010 5:39 8/2/2010 18:19 8/3/2010 5:40 8/3/2010 18:18 8/4/2010 5:41 8/4/2010 18:17 8/5/2010 5:42 8/5/2010 18:15 8/6/2010 5:43 8/6/2010 18:14 8/7/2010 5:44 8/7/2010 18:13 8/8/2010 5:46 8/8/2010 18:11 8/9/2010 5:47 8/9/2010 18:10 8/10/2010 5:48 8/10/2010 18:08 8/11/2010 5:49 8/11/2010 18:07 8/12/2010 5:50 8/12/2010 18:05 8/13/2010 5:52 8/13/2010 18:03 8/14/2010 5:53 8/14/2010 18:02 8/15/2010 5:54 8/15/2010 18:00 8/16/2010 5:55 8/16/2010 17:59 8/17/2010 5:56 8/17/2010 17:57 8/18/2010 5:58 8/18/2010 17:55 8/19/2010 5:59 8/19/2010 17:54 8/20/2010 6:00 8/20/2010 17:52 8/21/2010 6:01 8/21/2010 17:50 8/22/2010 6:02 8/22/2010 17:49 8/23/2010 6:04 8/23/2010 17:47 8/24/2010 6:05 8/24/2010 17:45 8/25/2010 6:06 8/25/2010 17:43 8/26/2010 6:07 8/26/2010 17:42 8/27/2010 6:08 8/27/2010 17:40 8/28/2010 6:10 8/28/2010 17:38 8/29/2010 6:11 8/29/2010 17:36 8/30/2010 6:12 8/30/2010 17:34 8/31/2010 6:13 8/31/2010 17:33 9/1/2010 6:14 9/1/2010 17:31 9/2/2010 6:16 9/2/2010 17:29 9/3/2010 6:17 9/3/2010 17:27 9/4/2010 6:18 9/4/2010 17:25 9/5/2010 6:19 9/5/2010 17:23 9/6/2010 6:21 9/6/2010 17:21 9/7/2010 6:22 9/7/2010 17:20 9/8/2010 6:23 9/8/2010 17:18 9/9/2010 6:24 9/9/2010 17:16 9/10/2010 6:25 9/10/2010 17:14 9/11/2010 6:27 9/11/2010 17:12 9/12/2010 6:28 9/12/2010 17:10 9/13/2010 6:29 9/13/2010 17:08 9/14/2010 6:30 9/14/2010 17:06 9/15/2010 6:31 9/15/2010 17:04 9/16/2010 6:33 9/16/2010 17:02 9/17/2010 6:34 9/17/2010 17:00 9/18/2010 6:35 9/18/2010 16:59 9/19/2010 6:36 9/19/2010 16:57 9/20/2010 6:37 9/20/2010 16:55 9/21/2010 6:39 9/21/2010 16:53 9/22/2010 6:40 9/22/2010 16:51 9/23/2010 6:41 9/23/2010 16:49 9/24/2010 6:42 9/24/2010 16:47 9/25/2010 6:44 9/25/2010 16:45 9/26/2010 6:45 9/26/2010 16:43 9/27/2010 6:46 9/27/2010 16:41 9/28/2010 6:47 9/28/2010 16:39 9/29/2010 6:49 9/29/2010 16:37 9/30/2010 6:50 9/30/2010 16:36 10/1/2010 6:51 10/1/2010 16:34 10/2/2010 6:52 10/2/2010 16:32 10/3/2010 6:54 10/3/2010 16:30 10/4/2010 6:55 10/4/2010 16:28 10/5/2010 6:56 10/5/2010 16:26 10/6/2010 6:57 10/6/2010 16:24 10/7/2010 6:59 10/7/2010 16:22 10/8/2010 7:00 10/8/2010 16:21 10/9/2010 7:01 10/9/2010 16:19 10/10/2010 7:03 10/10/2010 16:17 10/11/2010 7:04 10/11/2010 16:15 10/12/2010 7:05 10/12/2010 16:13 10/13/2010 7:06 10/13/2010 16:12 10/14/2010 7:08 10/14/2010 16:10 10/15/2010 7:09 10/15/2010 16:08 10/16/2010 7:10 10/16/2010 16:06 10/17/2010 7:12 10/17/2010 16:05 10/18/2010 7:13 10/18/2010 16:03 10/19/2010 7:14 10/19/2010 16:01 10/20/2010 7:16 10/20/2010 15:59 10/21/2010 7:17 10/21/2010 15:58 10/22/2010 7:18 10/22/2010 15:56 10/23/2010 7:20 10/23/2010 15:54 10/24/2010 7:21 10/24/2010 15:53 10/25/2010 7:23 10/25/2010 15:51 10/26/2010 7:24 10/26/2010 15:50 10/27/2010 7:25 10/27/2010 15:48 10/28/2010 7:27 10/28/2010 15:47 10/29/2010 7:28 10/29/2010 15:45 10/30/2010 7:29 10/30/2010 15:44 10/31/2010 7:31 10/31/2010 15:42

Thank you very much for your help.

colinsheppard commented 10 years ago

Thanks, looks like this is another bug (or a new one). I'll fix this week.

nellReduan commented 10 years ago

Did you manage to fix the bug ?

Thank you for your help. Have a nice day Nelly

Date: Tue, 14 Jan 2014 13:38:30 -0800 From: notifications@github.com To: time@noreply.github.com CC: nell.redu@hotmail.fr Subject: Re: [time] error (NullPointerException) with time:ts-get-range (#26)

Thanks, looks like this is another bug (or a new one). I'll fix this week.

— Reply to this email directly or view it on GitHub.

colinsheppard commented 10 years ago

Thanks for the reminder, sorry it took so long. Turned out to be a subtle assumption I made about the java TreeMap class that was wrong.