Bug #3541
csspec aborts if there is an energy bin with 0 observed/predicted events
Status: | Closed | Start date: | 02/17/2021 | |
---|---|---|---|---|
Priority: | Urgent | Due date: | ||
Assigned To: | Knödlseder Jürgen | % Done: | 100% | |
Category: | - | |||
Target version: | 2.0.0 | |||
Duration: |
Description
This issue was reported by Marianne, here’s an extract from the debug output
2021-02-16T16:27:33: +===================+ 2021-02-16T16:27:33: | Input observation | 2021-02-16T16:27:33: +===================+ 2021-02-16T16:27:33: === GObservations === 2021-02-16T16:27:33: Number of observations ....: 1 2021-02-16T16:27:33: Number of models ..........: 2 2021-02-16T16:27:33: Number of observed events .: 0 2021-02-16T16:27:33: Number of predicted events : 0 2021-02-16T16:27:33: 2021-02-16T16:27:33: +=================================+ 2021-02-16T16:27:33: | Maximum likelihood optimisation | 2021-02-16T16:27:33: +=================================+ terminate called after throwing an instance of 'GException::empty' what(): *** ERROR in GMatrixSparse::GMatrixSparse(int&, int&, int&): Zero-size allocation. Aborted
A likelihood fit can certainly not work with 0 observed and predicted events, we should add a check and skip bins for which this situation occurs.
Recurrence
No recurrence.
History
#1 Updated by Knödlseder Jürgen over 3 years ago
- Priority changed from Normal to High
- Target version set to 2.0.0
I have this same error recently quite often, not sure why it did not show up before.
#2 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from New to In Progress
- Assigned To set to Knödlseder Jürgen
- % Done changed from 0 to 10
I modified the
GMatrixSparse::GMatrixSparse(const int& rows, const int& columns, const int& elements)
constructor so that it allows also zero number of rows or columns. This was a todo
that was identified. Nevertheless, I need to check that the sparse matrix class allows to operate on empty matrices. I did the same in the GMatrix
and GMatrixSymmetric
class.#3 Updated by Knödlseder Jürgen over 3 years ago
It seems that the sparse matrix class is not yet working properly on empty matrices:
0 libgamma.8.dylib 0x0000000107e9e6b9 cs_transpose(GMatrixSparse const&, int) + 121 (GMatrixSparse.cpp:3810) 1 libgamma.8.dylib 0x0000000107e9e5d0 GMatrixSparse::transpose() const + 224
#4 Updated by Knödlseder Jürgen over 3 years ago
- Project changed from ctools to GammaLib
- Target version deleted (
2.0.0) - % Done changed from 10 to 30
I added unit tests to verify that all methods and operators of GMatrixSparse
work seamlessly on empty matrices. This needed a few code adaptions.
I still need to do the same for the other two storage classes.
#5 Updated by Knödlseder Jürgen over 3 years ago
- Target version set to 2.0.0
#6 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from In Progress to Pull request
- % Done changed from 30 to 90
I implement unit tests also for all other storage classes. Things seem to work well now.
In addition, I modified the code in GObservation
and GResponse
so that no issues occur in case that there are no events. I tested the code on cssens
where I had the same error before and now it works fine.
#7 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from Pull request to Closed
- % Done changed from 90 to 100
The code was merged into devel
.
#8 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from Closed to In Progress
- Priority changed from High to Urgent
- % Done changed from 100 to 50
There seems still to be a problem when passing an observation without any event. Such a problem occurs in the csphasecrv
unit test.
#9 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from In Progress to Pull request
- % Done changed from 50 to 90
Found it. It was an exception in GMatrixSparse::stack_push_column()
that I moved and that I shouldn’t. I fixed the issue.
#10 Updated by Knödlseder Jürgen over 3 years ago
- Status changed from Pull request to Closed
- % Done changed from 90 to 100
The code was merged into devel
.