def add(self, data): from dynts import tsname if isinstance(data,xyserie): self._series.append(data) elif isinstance(data,self.__class__): for serie in data.series(): self.name = tsname(self.name,serie.name) self._series.append(serie)
def add(self, data): from dynts import tsname if isinstance(data, xyserie): self._series.append(data) elif isinstance(data, self.__class__): for serie in data.series(): self.name = tsname(self.name, serie.name) self._series.append(serie)
def load_data(self, result): loads = self.pickler.loads vloads = self.value_pickler.loads dt, va = result if result[0] and va: dates = ny.array([loads(t) for t in dt]) fields = [] vals = [] if not isinstance(va, Mapping): va = dict(va) for f in sorted(va): fields.append(f) data = va[f] vals.append((vloads(v) for v in data)) values = ny.array(list(zip(*vals))) name = tsname(*fields) else: name = None dates = None values = None return timeseries(name=name, date=dates, data=values)
def testDataNameFull(self): names = dynts.tsname("test", "ciao", "ping") ts = randomts(100, 3, name=names) self.assertEqual(ts.name, names) self.assertEqual(ts.names(), ["test", "ciao", "ping"])
def testSquare(self): ts = self.getts(2, name=tsname('a', 'b')) rs = ts.square() self.assertEqual(rs.names(), ['square(a)', 'square(b)']) self._testscalar(np.square, rs, ts)
def testLog(self): ts = self.getts(2, name=tsname('a', 'b')) rs = ts.log() self.assertEqual(rs.names(), ['log(a)', 'log(b)']) self._testscalar(np.log, rs, ts)
def testgetFieldInOrder(self): ts1 = self.create() ts = ts1.irange(fields = ('a','b','c')) self.assertEqual(ts.count(), 3) self.assertEqual(ts.name, tsname('a','b','c'))
def testtsname(self): name = dynts.tsname('test') self.assertEqual(name, 'test') name = dynts.tsname('test', 'ping', 'pong') self.assertEqual(name, 'test__ping__pong')
def testDataNameFull(self): names = dynts.tsname('test', 'ciao', 'ping') ts = randomts(100, 3, name=names) self.assertEqual(ts.name, names) self.assertEqual(ts.names(), ['test', 'ciao', 'ping'])
def testDataName(self): ts = randomts(100, 3, name='test') self.assertEqual(ts.name, 'test') self.assertEqual(ts.names(), ['test', 'unnamed1', 'unnamed2']) ts.name = dynts.tsname('test', 'ping') self.assertEqual(ts.names(), ['test', 'ping', 'unnamed1'])
def testtsname(self): name = dynts.tsname("test") self.assertEqual(name, "test") name = dynts.tsname("test", "ping", "pong") self.assertEqual(name, "test__ping__pong")
def testDataName(self): ts = randomts(100, 3, name="test") self.assertEqual(ts.name, "test") self.assertEqual(ts.names(), ["test", "unnamed1", "unnamed2"]) ts.name = dynts.tsname("test", "ping") self.assertEqual(ts.names(), ["test", "ping", "unnamed1"])
def testLog(self): ts = self.getts(2, name = tsname('a', 'b')) rs = ts.log() self.assertEqual(rs.names(), ['log(a)', 'log(b)']) self._testscalar(np.log, rs, ts)