def test_property_type_ndstype(self): new = Channel('') self.assertIsNone(new.ndstype) new.type = 'm-trend' self.assertEqual(new.ndstype, 16) self.assertEqual(new.type, 'm-trend') new.ndstype = 's-trend' self.assertEqual(new.ndstype, 8) self.assertEqual(new.type, 's-trend')
def test_property_type_ndstype(self): new = Channel('') self.assertIsNone(new.ndstype) new.type = 'm-trend' self.assertEqual(new.ndstype, 16) self.assertEqual(new.type, 'm-trend') new.ndstype = 's-trend' self.assertEqual(new.ndstype, 8) self.assertEqual(new.type, 's-trend')
def _new(channel, find_parent=True): """Create a new `~gwpy.detector.Channel` in the globalv cache. """ # convert to Channel if isinstance(channel, Channel): new = channel else: new = Channel(channel) name = str(channel) type_ = new.type # work out what kind of channel it is parts = re_channel.findall(name) # match single raw channel for LIGO if (len(parts) == 1 and new.ifo in ('H1', 'L1') and not re.search(r'\.[a-z]+\Z', name)): new.url = '%s/channel/byname/%s' % (CIS_URL, str(new)) # match single trend elif len(parts) == 1: # set default trend type based on mode if type_ is None and ':DMT-' in name: # DMT is always m-trend new.type = 'm-trend' # match parameters from 'raw' version of this channel # match composite channel else: new.subchannels = parts new._ifo = "".join(set(p.ifo for p in map(Channel, parts) if p.ifo)) if find_parent: _update_dependent(new) # store new channel and return globalv.CHANNELS.append(new) try: return get_channel(new) except RuntimeError as e: if 'maximum recursion depth' in str(e): raise RuntimeError("Recursion error while accessing channel " "information for %s" % str(channel)) raise