From bf39a08a569317292f60fbae23241fa32a9fc871 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 24 Jun 2020 15:17:30 +0200 Subject: [PATCH] Add equality and non-equality operators to GSkyRegionCircle class --- ChangeLog | 1 + NEWS | 6 ++++++ doc/source/admin/release_history/1.7.rst | 1 + include/GSkyRegionCircle.hpp | 8 ++++++-- pyext/GSkyRegionCircle.i | 8 +++++++- src/sky/GSkyRegionCircle.cpp | 32 +++++++++++++++++++++++++++++++- test/test_GSky.cpp | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------ test/test_GSky.hpp | 10 ++++------ test/test_GSky.py | 29 +++++++++++++++++++++++++++-- 9 files changed, 203 insertions(+), 162 deletions(-) diff --git a/ChangeLog b/ChangeLog index 242e7ac..3d4211c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Version 1.7.0 released ======================== + Add equality and non-equality operators to GSkyRegionCircle class Add GModelSpatialRadialRing class (#3253) Fix ambiguity problem in GSkyDir::posang() and posang_deg() (#3199) Avoid rounding errors in GSkyMap operators (#3126) diff --git a/NEWS b/NEWS index ca7beb3..9aea676 100644 --- a/NEWS +++ b/NEWS @@ -44,7 +44,10 @@ The following methods have been added: - GSkyDir::rotate() - Rotate sky direction (radians variant) - GSkyDir::GSkyDir(GVector&) - Sky direction vector constructor - GSkyMap::extract() - Extract section of sky map +- GSkyRegionCircle::operator==() - Equality operator +- GSkyRegionCircle::operator!=() - Non-equality operator - GModelSpatial::flux() - Extract flux from sky region +- GModelSpatialDiffuseCube::mc_cone() - Return MC simulation cone - GCTAObservation::remove_response_cache(string&) - Remove response cache for model - GCTAResponse::remove_response_cache(string&) - Remove response cache for model - GCTAResponseCache::remove(string&) - Remove response cache for model @@ -58,6 +61,7 @@ The following methods have been removed: - none The following methods have been renamed: +- GModelSpatialDiffuseCube::set_mc_cone() to GModelSpatialDiffuseCube::mc_cone() - GResponse::irf(GEvent&, GSource&, GObservation&) to GResponse::irf_spatial() - GLATResponse::irf(GLATEventAtom&, GSource&, GObservation&) to GLATResponse::irf_spatial_atom() - GLATResponse::irf(GLATEventBin&, GSource&, GObservation&) to GLATResponse::irf_spatial_bin() @@ -161,6 +165,8 @@ None 12. Sky module -------------- +Added equality and non-equality operators to the GSkyRegionCircle class. + The position angle is now computed by GSkyDir::posang() and GSkyDir::posang_deg() for the coordinate system that is specified by the coordsys argument. By default this argument is set to "CEL", hence by default the methods return the position diff --git a/doc/source/admin/release_history/1.7.rst b/doc/source/admin/release_history/1.7.rst index 276d16e..78c1c32 100644 --- a/doc/source/admin/release_history/1.7.rst +++ b/doc/source/admin/release_history/1.7.rst @@ -30,6 +30,7 @@ Bug fixes Improvements ------------ +* Add equality and non-equality operators to ``GSkyRegionCircle`` class. * [`3202 `_] - Replace ``GCTAResponseCache`` class by ``GResponseCache`` class. * [`3062 `_] - diff --git a/include/GSkyRegionCircle.hpp b/include/GSkyRegionCircle.hpp index e024273..e8b5e95 100644 --- a/include/GSkyRegionCircle.hpp +++ b/include/GSkyRegionCircle.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GSkyRegionCircle.hpp - circular sky region class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2015 by Michael Mayer * + * copyright (C) 2013-2020 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -57,6 +57,10 @@ ***************************************************************************/ class GSkyRegionCircle : public GSkyRegion { + // Operator friends + friend bool operator==(const GSkyRegionCircle &a, const GSkyRegionCircle &b); + friend bool operator!=(const GSkyRegionCircle &a, const GSkyRegionCircle &b); + public: // Constructors and destructors GSkyRegionCircle(void); @@ -96,7 +100,7 @@ protected: // Protected members GSkyDir m_centre; //!< Centre or reference point of the region - double m_radius; //!< Radius of circular the region [deg] + double m_radius; //!< Radius of circular the region (degrees) }; diff --git a/pyext/GSkyRegionCircle.i b/pyext/GSkyRegionCircle.i index 6f76780..8b79289 100644 --- a/pyext/GSkyRegionCircle.i +++ b/pyext/GSkyRegionCircle.i @@ -1,7 +1,7 @@ /*************************************************************************** * GSkyRegionCircle.i - Sky region class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2019 by Michael Mayer * + * copyright (C) 2013-2020 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -67,6 +67,12 @@ public: * @brief GSkyRegionCircle class extension ***************************************************************************/ %extend GSkyRegionCircle { + bool __eq__(const GSkyRegionCircle& region) const { + return ((*self) == region); + } + bool __ne__(const GSkyRegionCircle& region) const { + return ((*self) != region); + } GSkyRegionCircle copy() { return (*self); } diff --git a/src/sky/GSkyRegionCircle.cpp b/src/sky/GSkyRegionCircle.cpp index 00c5f73..40e32ba 100644 --- a/src/sky/GSkyRegionCircle.cpp +++ b/src/sky/GSkyRegionCircle.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GSkyRegionCircle.cpp - Circular sky region class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Michael Mayer * + * copyright (C) 2013-2020 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -609,3 +609,33 @@ void GSkyRegionCircle::compute_solid_angle(void) // Return return; } + + +/***********************************************************************//** + * @brief Equality operator + * + * @param[in] a First sky region circle. + * @param[in] b Second sky region circle. + * @return True if both sky region circles are identical. + * + * Returns true if two sky region circles and identical. + ***************************************************************************/ +bool operator==(const GSkyRegionCircle &a, const GSkyRegionCircle &b) +{ + // Return equality + return ((a.m_centre == b.m_centre) && (a.m_radius == b.m_radius)); +} + + +/***********************************************************************//** + * @brief Non equality operator + * + * @param[in] a First sky region circle. + * @param[in] b Second sky region circle. + * @return True if both sky region circles are different. + ***************************************************************************/ +bool operator!=(const GSkyRegionCircle &a, const GSkyRegionCircle &b) +{ + // Return non equality + return ((a.m_centre != b.m_centre) || (a.m_radius != b.m_radius)); +} diff --git a/test/test_GSky.cpp b/test/test_GSky.cpp index ef30abd..ced3ab3 100644 --- a/test/test_GSky.cpp +++ b/test/test_GSky.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GSky.cpp - Test sky module * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2019 by Juergen Knoedlseder * + * copyright (C) 2010-2020 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -54,10 +54,10 @@ const std::string sky_map = datadir + "/cena_lobes_parkes.fits"; * @brief Set parameters and tests ***************************************************************************/ void TestGSky::set(void){ - + // Test name name("GSky"); - + // Append tests append(static_cast(&TestGSky::test_GWcs), "Test GWcs"); @@ -77,16 +77,12 @@ void TestGSky::set(void){ "Test GSkyMap"); append(static_cast(&TestGSky::test_GSkyMap_io), "Test GSkyMap I/O"); - append(static_cast(&TestGSky::test_GSkyRegions_io), + append(static_cast(&TestGSky::test_GSkyRegions), "Test GSkyRegions"); - append(static_cast(&TestGSky::test_GSkyRegionCircle_construct), - "Test GSkyRegionCircle constructors"); - append(static_cast(&TestGSky::test_GSkyRegionCircle_logic), - "Test GSkyRegionCircle logic"); - append(static_cast(&TestGSky::test_GSkyRegionMap_construct), - "Test GSkyRegionMap constructors"); - append(static_cast(&TestGSky::test_GSkyRegionMap_logic), - "Test GSkyRegionMap logic"); + append(static_cast(&TestGSky::test_GSkyRegionCircle), + "Test GSkyRegionCircle"); + append(static_cast(&TestGSky::test_GSkyRegionMap), + "Test GSkyRegionMap"); append(static_cast(&TestGSky::test_GHorizDir), "Test GHorizDir"); @@ -124,10 +120,10 @@ double TestGSky::wcs_forth_back_pixel(GWcs* wcs, { // Initialise maximal distance double dist_max = 0.0; - + // Loop over x pixels for (int ix = -nx; ix <= nx; ++ix) { - + // Set x value double x = double(ix) + crpix1; @@ -357,7 +353,7 @@ void TestGSky::test_GSkyDir(void) // Return return; -} +} /***********************************************************************//** @@ -913,7 +909,7 @@ void TestGSky::test_GSkyMap(void) // Define empty sky map GSkyMap empty_map; - + // Test that empty map is indeed empty test_assert(empty_map.is_empty(), "Check for empty sky map"); test_value(empty_map.nmaps(), 0, "Check for no sky maps"); @@ -922,13 +918,13 @@ void TestGSky::test_GSkyMap(void) test_value(empty_map.ny(), 0, "Check number of empty sky map X pixels"); test_value(empty_map.ndim(), 0, "Check empty sky map dimension"); test_value(empty_map.shape().size(), 0, "Check empty sky map shape"); - + // Test that writing, publishing and printing of empty sky map does not // lead to a segmentation fault empty_map.save("test_empty_map.fits", true); empty_map.publish("Empty sky map"); empty_map.print(); - + // Define several maps for comparison GSkyMap map_src("CAR", "GAL", 0.0, 0.0, -1.0, 1.0, 10, 10, 2); GSkyMap map_dst("CAR", "GAL", 0.0, 0.0, -0.1, 0.1, 100, 100, 2); @@ -1230,7 +1226,7 @@ void TestGSky::test_GSkyMap(void) // Load map for smoothing GSkyMap map_smooth(sky_map); - + // Compute sum of sky map for reference double ref_smooth = 0.0; for (int pix = 0; pix < map_smooth.npix(); ++pix) { @@ -1296,7 +1292,7 @@ void TestGSky::test_GSkyMap(void) test_map = map_src.extract(inclusions); test_value(test_map.npix(), 36, "Check trimmed map pixel count (region)"); test_value(test_map.nmaps(), map_src.nmaps(), "Check total maps in trimmed map (region)"); - + // Check the pixel values total_test = 0.0; total_src = 0.0; @@ -1408,7 +1404,7 @@ void TestGSky::test_GSkyMap_io(void) wcs3.shape(2,2,3); wcs3.write(fits, "WCS3"); fits.save(true); - + // Load HEALPix map and check content GSkyMap map1(filename+"[HEALPIX1]"); test_value(map1.npix(), healpix1.npix(), "Check number of HEALPix pixels"); @@ -1452,12 +1448,69 @@ void TestGSky::test_GSkyMap_io(void) /*************************************************************************** - * @brief GSkyRegionCircle_construct + * @brief Test GSkyRegions class + ***************************************************************************/ + void TestGSky::test_GSkyRegions(void) +{ + // Allocate regions + GSkyRegions regions; + + // Test regions loading + test_try("Test regions loading"); + try { + regions.load(sky_region); + test_try_success(); + } + catch (std::exception &e) { + test_try_failure(e); + } + + // Check if region was loaded correctly + GSkyRegionCircle* circle = dynamic_cast(regions[0]); + test_assert(circle->type() == "Circle", "Region is not a circle"); + test_value(circle->radius(), 10.0, 1.0e-10); + test_value(circle->ra(), 0.1, 1.0e-10); + test_value(circle->dec(), -35.6, 1.0e-10); + + // Test regions saving + test_try("Test regions saving"); + try { + regions.save("region.reg"); + test_try_success(); + } + catch (std::exception &e) { + test_try_failure(e); + } + + // Test regions reloading + test_try("Test regions reloading"); + try { + regions.load("region.reg"); + test_try_success(); + } + catch (std::exception &e) { + test_try_failure(e); + } + + // Check if region was loaded correctly + circle = dynamic_cast(regions[0]); + test_assert(circle->type() == "Circle", "Region is not a circle"); + test_value(circle->radius(), 10.0, 1.0e-10); + test_value(circle->ra(), 0.1, 1.0e-10); + test_value(circle->dec(), -35.6, 1.0e-10); + + // Exit test + return; +} + + +/*************************************************************************** + * @brief Test GSkyRegionCircle ***************************************************************************/ -void TestGSky::test_GSkyRegionCircle_construct(void) +void TestGSky::test_GSkyRegionCircle(void) { // Define region for comparison - GSkyDir refdir_radeczerozero = GSkyDir(); + GSkyDir refdir_radeczerozero; refdir_radeczerozero.radec_deg(0,0); double refradius = 10.; @@ -1471,7 +1524,7 @@ void TestGSky::test_GSkyRegionCircle_construct(void) test_try_failure(e); } - // Test constructing with radius 0 + // Test constructing with radius -1 test_try("Test constructor2"); try { GSkyRegionCircle circle(refdir_radeczerozero,-1); @@ -1508,70 +1561,55 @@ void TestGSky::test_GSkyRegionCircle_construct(void) double solidangle = 2*gammalib::pi*(1- std::cos(refradius /180 * gammalib::pi)); test_value(solidangle_check,solidangle,1.0e-10, "Test solid angle assignment"); - //exit test - return; -} - -/*************************************************************************** - * @brief GSkyRegions_logic - ***************************************************************************/ -void TestGSky::test_GSkyRegionCircle_logic(void) -{ - - // set input files /filenames -// const std::string file1 = "test_GSkyRegionCircle1.reg"; -// const std::string file2 = "test_GSkyRegionCircle2.reg"; - - //set reference values - - GSkyDir refdir_radeczerozero = GSkyDir(); + // Set reference sky directions + //GSkyDir refdir_radeczerozero; + GSkyDir refdir_lbzerozero; + GSkyDir refdir_outside_refregion; + GSkyDir refdir_raoffset; + GSkyDir refdir_decpole; + GSkyDir refdir_ndecpole; + GSkyDir refdir_rapole; refdir_radeczerozero.radec_deg(0,0); - - GSkyDir refdir_lbzerozero = GSkyDir(); refdir_lbzerozero.lb_deg(0,0); - - GSkyDir refdir_outside_refregion = GSkyDir(); refdir_outside_refregion.radec_deg(100,80); - - GSkyDir refdir_raoffset = GSkyDir(); refdir_raoffset.radec_deg(5,0); - - GSkyDir refdir_decpole = GSkyDir(); refdir_decpole.radec_deg(0,89); - - GSkyDir refdir_ndecpole = GSkyDir(); refdir_ndecpole.radec_deg(100,89); - - GSkyDir refdir_rapole = GSkyDir(); refdir_rapole.radec_deg(359,0); - GSkyRegionCircle refregion(refdir_radeczerozero,10); - GSkyDir centre = refregion.centre(); - - GSkyRegionCircle refregion_smaller(refdir_radeczerozero,5); - GSkyRegionCircle refregion_larger(refdir_radeczerozero,20); - GSkyRegionCircle refregion_raoffset(refdir_raoffset,10); - GSkyRegionCircle refregion_rapole(refdir_rapole,3); - GSkyRegionCircle refregion_decpole(refdir_decpole,3); + // Set reference sky regions + refregion = GSkyRegionCircle(refdir_radeczerozero, 10.0); + GSkyDir centre = refregion.centre(); + GSkyRegionCircle refregion_smaller(refdir_radeczerozero, 5.0); + GSkyRegionCircle refregion_larger(refdir_radeczerozero, 20.0); + GSkyRegionCircle refregion_raoffset(refdir_raoffset, 10.0); + GSkyRegionCircle refregion_rapole(refdir_rapole, 3.0); + GSkyRegionCircle refregion_decpole(refdir_decpole, 3.0); // Test contain dirs - test_assert(refregion.contains(refdir_radeczerozero),"test for containment"); - test_assert(refregion.contains(centre), "test if centre in circle"); - test_assert(!refregion.contains(refdir_outside_refregion), "test2 for containment"); + test_assert(refregion.contains(refdir_radeczerozero),"Test for containment"); + test_assert(refregion.contains(centre), "Test if centre in circle"); + test_assert(!refregion.contains(refdir_outside_refregion), "Test2 for containment"); // Test contain regions - test_assert(refregion.contains(refregion_smaller),"test for containment region"); - test_assert(!refregion.contains(refregion_larger), "test for containment region2 "); - test_assert(refregion.contains(refregion), "test3 for containment region"); + test_assert(refregion.contains(refregion_smaller),"Test for containment region"); + test_assert(!refregion.contains(refregion_larger), "Test for containment region2 "); + test_assert(refregion.contains(refregion), "Test3 for containment region"); - test_assert(refregion.contains(refdir_rapole), "rapole for containment region"); - test_assert(refregion_decpole.contains(refdir_ndecpole), "rapole for containment region"); + test_assert(refregion.contains(refdir_rapole), "Test rapole for containment region"); + test_assert(refregion_decpole.contains(refdir_ndecpole), "Test rapole for containment region"); // Test overlaps - test_assert(refregion.overlaps(refregion_smaller),"test for overlap"); - test_assert(refregion.overlaps(refregion_larger),"test2 for overlap"); - test_assert(refregion.overlaps(refregion_raoffset),"test3 for overlap"); - test_assert(!refregion.overlaps(refregion_decpole),"test4 for overlap"); + test_assert(refregion.overlaps(refregion_smaller),"Test for overlap"); + test_assert(refregion.overlaps(refregion_larger),"Test2 for overlap"); + test_assert(refregion.overlaps(refregion_raoffset),"Test3 for overlap"); + test_assert(!refregion.overlaps(refregion_decpole),"Test4 for overlap"); + + // Test equality and non-equality operators + test_assert(refregion_smaller == refregion_smaller,"Test for equality"); + test_assert(!(refregion_smaller == refregion_larger),"Test for equality"); + test_assert(!(refregion_smaller != refregion_smaller),"Test for non-equality"); + test_assert(refregion_smaller != refregion_larger,"Test for non-equality"); // Exit test return; @@ -1579,9 +1617,9 @@ void TestGSky::test_GSkyRegionCircle_logic(void) /*************************************************************************** - * @brief GSkyRegionMap_construct + * @brief Test GSkyRegionMap ***************************************************************************/ -void TestGSky::test_GSkyRegionMap_construct(void) +void TestGSky::test_GSkyRegionMap(void) { // Test file constructor: test_try("Test file constructor"); @@ -1603,26 +1641,16 @@ void TestGSky::test_GSkyRegionMap_construct(void) catch (std::exception &e) { test_try_failure(e); } - - // Exit test - return; -} - -/*************************************************************************** - * @brief GSkyRegionMap_logic - ***************************************************************************/ -void TestGSky::test_GSkyRegionMap_logic(void) -{ // Load reference region map (a mask centred on (RA,Dec)=(0,0) with radius 0.3deg) GSkyRegionMap regmap(sky_region_map); // Set reference directions and regions GSkyDir refdir_radeczerozero = GSkyDir(); - refdir_radeczerozero.radec_deg(0.0,0.0); GSkyDir refdir_radeclargeshift = GSkyDir(); - refdir_radeclargeshift.radec_deg(2.0,0.0); GSkyDir refdir_radecsmallshift = GSkyDir(); + refdir_radeczerozero.radec_deg(0.0,0.0); + refdir_radeclargeshift.radec_deg(2.0,0.0); refdir_radecsmallshift.radec_deg(0.3,0.0); GSkyRegionCircle inregion(refdir_radeczerozero,0.2); GSkyRegionCircle outregion(refdir_radeclargeshift,0.2); @@ -1646,64 +1674,6 @@ void TestGSky::test_GSkyRegionMap_logic(void) /*************************************************************************** - * @brief Test GSkyRegions input and output - ***************************************************************************/ - void TestGSky::test_GSkyRegions_io(void) -{ - // Allocate regions - GSkyRegions regions; - - // Test regions loading - test_try("Test regions loading"); - try { - regions.load(sky_region); - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); - } - - // Check if region was loaded correctly - GSkyRegionCircle* circle = dynamic_cast(regions[0]); - test_assert(circle->type() == "Circle", "Region is not a circle"); - test_value(circle->radius(), 10.0, 1.0e-10); - test_value(circle->ra(), 0.1, 1.0e-10); - test_value(circle->dec(), -35.6, 1.0e-10); - - // Test regions saving - test_try("Test regions saving"); - try { - regions.save("region.reg"); - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); - } - - // Test regions reloading - test_try("Test regions reloading"); - try { - regions.load("region.reg"); - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); - } - - // Check if region was loaded correctly - circle = dynamic_cast(regions[0]); - test_assert(circle->type() == "Circle", "Region is not a circle"); - test_value(circle->radius(), 10.0, 1.0e-10); - test_value(circle->ra(), 0.1, 1.0e-10); - test_value(circle->dec(), -35.6, 1.0e-10); - - // Exit test - return; - -} - - -/*************************************************************************** * @brief Test GHorizDir class ***************************************************************************/ void TestGSky::test_GHorizDir(void) @@ -1729,7 +1699,7 @@ void TestGSky::test_GHorizDir(void) // Return return; -} +} /*************************************************************************** @@ -1738,12 +1708,12 @@ void TestGSky::test_GHorizDir(void) int main(void) { GTestSuites testsuites("GSky"); - + bool was_successful = true; - + // Create a test suite TestGSky test; - + // Append to the container testsuites.append(test); diff --git a/test/test_GSky.hpp b/test/test_GSky.hpp index 32ce786..7e107ee 100644 --- a/test/test_GSky.hpp +++ b/test/test_GSky.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GSky.hpp - Test sky module * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2019 by Jean-Baptiste Cayrou * + * copyright (C) 2012-2020 by Jean-Baptiste Cayrou * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -50,11 +50,9 @@ public: void test_GSkyMap_wcs_io(void); void test_GSkyMap(void); void test_GSkyMap_io(void); - void test_GSkyRegions_io(void); - void test_GSkyRegionCircle_construct(void); - void test_GSkyRegionCircle_logic(void); - void test_GSkyRegionMap_construct(void); - void test_GSkyRegionMap_logic(void); + void test_GSkyRegions(void); + void test_GSkyRegionCircle(void); + void test_GSkyRegionMap(void); void test_GHorizDir(void); // Private methods diff --git a/test/test_GSky.py b/test/test_GSky.py index f2664e3..c4cb5c8 100755 --- a/test/test_GSky.py +++ b/test/test_GSky.py @@ -1,7 +1,7 @@ # ========================================================================== # This module performs unit tests for the GammaLib sky module. # -# Copyright (C) 2012-2018 Juergen Knoedlseder +# Copyright (C) 2012-2020 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -164,7 +164,7 @@ class Test(gammalib.GPythonTestSuite): map[2] = 3.0 map[3] = 4.0 map_b = map.copy() - + # Addition operator map += map_b self.test_value(map[0], 2.0) @@ -561,6 +561,30 @@ class Test(gammalib.GPythonTestSuite): # Return return + # Test GSkyRegionCircle class + def _test_region_circle(self): + """ + Test GSkyRegionCircle class + """ + # Setup sky region circles + circle1 = gammalib.GSkyRegionCircle(0.0, 0.0, 180.0) + circle2 = gammalib.GSkyRegionCircle(0.0, 0.0, 90.0) + circle3 = gammalib.GSkyRegionCircle(10.0, 10.0, 180.0) + circle4 = gammalib.GSkyRegionCircle(10.0, 10.0, 180.0) + + # Test equality and non-equality operators + self.test_assert(circle1 == circle1, 'Test equality operator (1)') + self.test_assert(not(circle1 == circle2), 'Test equality operator (2)') + self.test_assert(not(circle1 == circle3), 'Test equality operator (3)') + self.test_assert(not(circle1 == circle4), 'Test equality operator (4)') + self.test_assert(not(circle1 != circle1), 'Test non-equality operator (1)') + self.test_assert(circle1 != circle2, 'Test non-equality operator (2)') + self.test_assert(circle1 != circle3, 'Test non-equality operator (3)') + self.test_assert(circle1 != circle4, 'Test non-equality operator (4)') + + # Return + return + # Test class pickeling def _test_pickeling(self): """ @@ -651,6 +675,7 @@ class Test(gammalib.GPythonTestSuite): self.append(self._test_skymap_tan, 'Test TAN projection map') self.append(self._test_regions_access, 'Test GSkyRegions region access') self.append(self._test_regions_slicing, 'Test GSkyRegions slicing') + self.append(self._test_region_circle, 'Test GSkyRegionCircle class') self.append(self._test_pickeling, 'Test sky class pickeling') # Return -- libgit2 0.21.4