def addRow(self, row_vals, rowdata_key='main', index=None, **kwargs): """Adds a new row to the spill unit. Ensures that certain requirements of the data rows, such as the chainage needing to increase for each row down are met, then call the addNewRow() method in the row_collection. Args: row_vals(Dict): keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included. index=None(int): the row to insert into. The existing row at the given index will be moved up by one. Returns: False if the addNewRow() method is unsuccessful. Raises: IndexError: If the index does not exist. ValueError: If the given value is not accepted by the DataObjects. See Also: ADataObject and subclasses for information on the parameters. """ keys = row_vals.keys() if not rdt.CHAINAGE in keys or not rdt.ELEVATION in keys: raise AttributeError( 'row_vals must include CHAINAGE and ELEVATION.') # Call superclass method to add the new row AUnit.addRow(self, row_vals, index=index, **kwargs)
def addRow(self, row_vals, rowdata_key='main', index=None, **kwargs): """Adds a new row to the spill unit. Ensures that certain requirements of the data rows, such as the chainage needing to increase for each row down are met, then call the addNewRow() method in the row_collection. Args: row_vals(Dict): keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included. index=None(int): the row to insert into. The existing row at the given index will be moved up by one. Returns: False if the addNewRow() method is unsuccessful. Raises: IndexError: If the index does not exist. ValueError: If the given value is not accepted by the DataObjects. See Also: ADataObject and subclasses for information on the parameters. """ keys = row_vals.keys() if not rdt.CHAINAGE in keys or not rdt.ELEVATION in keys: raise AttributeError('row_vals must include CHAINAGE and ELEVATION.') # Call superclass method to add the new row AUnit.addRow(self, row_vals, index=index, **kwargs)
def addRow(self, row_vals, unit_type, **kwargs): """Adds a new row to the InitialCondition units row_collection. The new row will be added at the given index. If no index is given it will be appended to the end of the collection. If no LABEL value is given a AttributeError will be raised as it cannot have a default value. All other values can be ommitted. If they are they will be given defaults. Examples: >>> import ship.fmp.datunits.ROW_DATA_TYPES as rdt >>> ics.addRow({rdt.LABEL:UNITNAME, rdt.STAGE:10.2}, index=4) Args: row_vals(Dict): keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included. Raises: AttributeError: If LABEL is not given. IndexError: If the index does not exist. ValueError: If the given value is not accepted by the DataObject's. See Also: ADataObject and subclasses for information on the parameters. """ if not rdt.LABEL in row_vals.keys(): logger.error('Required values of LABEL not given') raise AttributeError ("Required value 'LABEL' not given") # Keep a record of multiple unit types under the same name if row_vals[rdt.LABEL] in self._name_types.keys(): if not unit_type in self._name_types[row_vals[rdt.LABEL]]: self._name_types[row_vals[rdt.LABEL]].append(unit_type) else: self._name_types[row_vals[rdt.LABEL]] = [unit_type] # Don't add the same ic's in twice labels = self.row_data['main'].dataObjectAsList(rdt.LABEL) if row_vals[rdt.LABEL] in labels: return self._node_count # Call superclass method to add the new row AUnit.addRow(self, row_vals=row_vals, index=None, **kwargs) self._node_count += 1 return self._node_count
def addRow(self, row_vals, rowdata_key='main', index=None, **kwargs): """Adds a new row to one of this bridge units row_collection's. The new row will be added at the given index. If no index is given it will be appended to the end of the collection. If no chainage or elevation values are given an AttributeError will be raised as they cannot have default values. All other values can be ommitted. If they are they will be given defaults. Examples: >>> import ship.fmp.datunits.rdt as rdt >>> unit.addRow({rdt.CHAINAGE:5.0, rdt.ELEVATION:36.2}, index=4) Args: row_vals(Dict): keys must be datunits.rdt with a legal value assigned for the DataType. Chainage and Elevation MUST be included. index=None(int): the row to insert into. The existing row at the given index will be moved up by one. collection_name=None(str): If None the self.row_collection with the bridges geometry data will be updated. If a string it will be looked for in the self.additional_row_collections dictionary or raise an AttributeError if it doesn't exist. Raises: AttributeError: If required values are not given for the rowdata_key collection. See _checkRowKeys(). KeyError: if the collection_name does not exist. ValueError: If the given value is not accepted by the DataObject's. See Also: ADataObject and subclasses for information on the parameters. """ self._checkRowKeys(row_vals, rowdata_key) AUnit.addRow(self, row_vals=row_vals, rowdata_key=rowdata_key, index=index, **kwargs)
def addRow(self, row_vals, index=None, **kwargs): """Adds a new row to the river units row_data. The new row will be added at the given index. If no index is given it will be appended to the end of the collection. If no chainage or elevation values are given a AttributeError will be raised as they cannot have default values. All other values can be ommitted. If they are they will be given defaults. Examples: >>> import ship.fmp.datunits.ROW_DATA_TYPES as rdt >>> river_unit.addDataRow({rdt.CHAINAGE:5.0, rdt.ELEVATION:36.2}, index=4) Args: row_vals(Dict): keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included. index=None(int): the row to insert into. The existing row at the given index will be moved up by one. Raises: AttributeError: If CHAINAGE or ELEVATION are not given. IndexError: If the index does not exist. ValueError: If the given value is not accepted by the DataObject's. See Also: ADataObject and subclasses for information on the parameters. """ keys = row_vals.keys() if not rdt.CHAINAGE in keys or not rdt.ELEVATION in keys: raise AttributeError('row_vals must include CHAINAGE and ELEVATION.') # Call superclass method to add the new row AUnit.addRow(self, row_vals, index=index, **kwargs)