<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _update_weights(self, margins, parameters = {}):
 """ Run calmar, stores new weights and returns adjusted margins """

        data = self._build_calmar_data()
        assert self.initial_weight_name is not None
        parameters['initial_weight'] = self.initial_weight_name
        val_pondfin, lambdasol, updated_margins = calmar(
            data, margins, **parameters)
        # Updating only afetr filtering weights
        self.weight = val_pondfin * self.filter_by + self.weight * (logical_not(self.filter_by))
        return updated_margins