예제 #1
0
 def __add__(self, other):
     import composite
     if isinstance(other, Agent):
         return composite.Composite(self.name + other.name,
                                    members=[self, other])
     else:
         return None
    def create_composite(self, name, *,
                         field,
                         dates,
                         round_dates=False,
                         skip_if_exists=False):

        if skip_if_exists and name in self.composites:
            return self.composites[name]

        assert name not in self.composites
        assert field in self.field_dict

        composite_shape = self.field_dict[field].shape[1:] # the first index is for the dates, the rest gives the actual field shape

        comp = cp.Composite(field_name=field, shape=composite_shape, info=name)

        for date in dates:
            if not isinstance(date, dt.date):
                date = dt.datetime.strptime(date, "%Y-%m-%d").date()
            date_index = np.searchsorted(self.timeseries.index, date)
            if (not round_dates) and (self.timeseries.index[date_index] != date):
                raise KeyError("no data for {}".format(date))
            comp += self.field_dict[field][date_index]

        self.composites[name] = comp

        return comp
예제 #3
0
    def __init__(self):
        self.model = morph.morph.Morph()
        ''' root of modeling tree of user's objects'''

        self.bounding_box = gui.boundingbox.BoundingBox()
        ''' Singleton controls.  Ghosts, not directly controllable by user '''
        # TODO this is being appended to transformed_c...

        # TODO this is obsolete? and should be a morph?
        self.transformed_controls = composite.Composite()
        ''' Semi-permanent GUI controls widgets e.g. text selections that are attached to transformed morphs, thus also need to be transformed.
    '''

        self.widgets = []
        ''' Untransformed. Ephemeral GUI controls widgets '''

        # TODO move this to transformer
        # !!! Set the topmost transform to scale by PENSOOL.SCALE
        translation = vector.Vector(0.0, 0.0)
        scale = vector.Vector(config.PENSOOL_UNIT, config.PENSOOL_UNIT)
        self.model.set_transform(translation, scale, 0.0)