Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gstlal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duncan Macleod
gstlal
Commits
f510a54d
Commit
f510a54d
authored
5 years ago
by
Daichi Tsuna
Browse files
Options
Downloads
Patches
Plain Diff
snglbursttable.c: cmp override for coinc analysis
__lt__() and friends
parent
0016c9b3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gstlal-burst/python/snglbursttable.c
+91
-0
91 additions, 0 deletions
gstlal-burst/python/snglbursttable.c
with
91 additions
and
0 deletions
gstlal-burst/python/snglbursttable.c
+
91
−
0
View file @
f510a54d
...
...
@@ -31,11 +31,15 @@
#define PY_SSIZE_T_CLEAN
#include
<Python.h>
#include
<structmember.h>
#include
<lal/Date.h>
#include
<snglburstrowtype.h>
static
PyObject
*
LIGOTimeGPSType
=
NULL
;
/*
* ============================================================================
*
...
...
@@ -199,6 +203,77 @@ static struct PyMethodDef methods[] = {
};
/*
* comparison is defined specifically for the coincidence code, allowing a
* bisection search of a sorted trigger list to be used to identify the
* subset of triggers that fall within a time interval
*/
static
PyObject
*
richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op_id
)
{
PyObject
*
converted
=
PyObject_CallFunctionObjArgs
(
LIGOTimeGPSType
,
other
,
NULL
);
PyObject
*
attr
;
PyObject
*
result
;
LIGOTimeGPS
t_other
;
int
cmp
;
if
(
!
converted
)
return
NULL
;
attr
=
PyObject_GetAttrString
(
converted
,
"gpsSeconds"
);
if
(
!
attr
)
{
Py_DECREF
(
converted
);
return
NULL
;
}
t_other
.
gpsSeconds
=
PyInt_AsLong
(
attr
);
Py_DECREF
(
attr
);
attr
=
PyObject_GetAttrString
(
converted
,
"gpsNanoSeconds"
);
if
(
!
attr
)
{
Py_DECREF
(
converted
);
return
NULL
;
}
t_other
.
gpsNanoSeconds
=
PyInt_AsLong
(
attr
);
Py_DECREF
(
attr
);
Py_DECREF
(
converted
);
cmp
=
XLALGPSCmp
(
&
((
gstlal_GSTLALSnglBurst
*
)
self
)
->
row
.
peak_time
,
&
t_other
);
switch
(
op_id
)
{
case
Py_LT
:
result
=
(
cmp
<
0
)
?
Py_True
:
Py_False
;
break
;
case
Py_LE
:
result
=
(
cmp
<=
0
)
?
Py_True
:
Py_False
;
break
;
case
Py_EQ
:
result
=
(
cmp
==
0
)
?
Py_True
:
Py_False
;
break
;
case
Py_NE
:
result
=
(
cmp
!=
0
)
?
Py_True
:
Py_False
;
break
;
case
Py_GE
:
result
=
(
cmp
>=
0
)
?
Py_True
:
Py_False
;
break
;
case
Py_GT
:
result
=
(
cmp
>
0
)
?
Py_True
:
Py_False
;
break
;
default:
PyErr_BadInternalCall
();
return
NULL
;
}
Py_INCREF
(
result
);
return
result
;
}
/*
* Type
*/
...
...
@@ -215,6 +290,7 @@ static PyTypeObject gstlal_GSTLALSnglBurst_Type = {
.
tp_name
=
MODULE_NAME
".GSTLALSnglBurst"
,
.
tp_new
=
__new__
,
.
tp_dealloc
=
__del__
,
.
tp_richcompare
=
richcompare
,
};
...
...
@@ -231,6 +307,21 @@ PyMODINIT_FUNC init_snglbursttable(void)
{
PyObject
*
module
=
Py_InitModule3
(
MODULE_NAME
,
NULL
,
"Low-level wrapper for GSTLALSnglBurst type."
);
/* LIGOTimeGPS */
{
PyObject
*
lal
=
PyImport_ImportModule
(
"lal"
);
if
(
!
lal
)
return
;
LIGOTimeGPSType
=
PyDict_GetItemString
(
PyModule_GetDict
(
lal
),
"LIGOTimeGPS"
);
if
(
!
LIGOTimeGPSType
)
{
Py_DECREF
(
lal
);
return
;
}
Py_INCREF
(
LIGOTimeGPSType
);
Py_DECREF
(
lal
);
}
/* SnglBurst */
if
(
PyType_Ready
(
&
gstlal_GSTLALSnglBurst_Type
)
<
0
)
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment