ansys.dyna.core.lib.field_writer#
Module for writing fields to buffers.
Attributes#
Functions#
|
Check that the field type is valid. |
|
Write a single field to the buffer. |
|
Write a single field to the buffer. |
|
Method to write a DataFrame to a buffer using hollerith format. |
|
Write fields representing a line of a keyword to buf. |
|
Writes the comment line to the buffer. |
|
Write fields representing a line of a keyword to buf in comma-delimited format. |
|
Write a DataFrame to buf in comma-delimited format. |
Module Contents#
- ansys.dyna.core.lib.field_writer.check_field_type(field_type: type)[source]#
Check that the field type is valid.
- ansys.dyna.core.lib.field_writer.write_field_c(buf: IO[AnyStr], field_type: type, value: Any, width: int) None[source]#
Write a single field to the buffer.
- ansys.dyna.core.lib.field_writer.write_field(buf: IO[AnyStr], field_type: type, value: Any, width: int) None[source]#
Write a single field to the buffer.
- ansys.dyna.core.lib.field_writer.write_c_dataframe(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], table: pandas.DataFrame, format: ansys.dyna.core.lib.format_type.format_type) None[source]#
Method to write a DataFrame to a buffer using hollerith format.
- ansys.dyna.core.lib.field_writer.write_fields(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], values: List[Any] | None = None, format: ansys.dyna.core.lib.format_type.format_type | None = format_type.default) None[source]#
Write fields representing a line of a keyword to buf.
Use the fixed column offsets and width
- Parameters:
- buf: IO
buffer to write to
- fields: List
fields to write
- values: List
optional - list of values for the field. If not set, use the value property of each field. used by TableCard
- format: format_type
optional - format to write
- >>> s=io.String()
- >>> fields = [
- … Field(“a”, int, 0, 10, 1),
- … Field(“b”, str, 10, 10, “hello”)
- … ]
- >>> write_fields(s, fields)
- >>> s.getvalue()
- ‘ 1 hello’
- ansys.dyna.core.lib.field_writer.write_comment_line(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], format: ansys.dyna.core.lib.format_type.format_type | None = format_type.default) None[source]#
Writes the comment line to the buffer.
- Parameters:
- buf: IO
buffer to write to
- fields: List
fields to write
- format: format_type
format to write in
- >>> s=io.String()
- >>> fields = [
- … Field(“a”, int, 0, 10, 1),
- … Field(“b”, str, 10, 10, “hello”)
- … ]
- >>> write_comment_line(s, fields)
- >>> s.getvalue()
- ‘ a b’
- ansys.dyna.core.lib.field_writer.write_fields_csv(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], values: List[Any] | None = None) None[source]#
Write fields representing a line of a keyword to buf in comma-delimited format.
This produces LS-DYNA compatible comma-delimited (free format) output.
- Parameters:
- buf
IO Buffer to write to.
- fields
List[Field] Fields to write.
- values
List[Any],optional List of values for the fields. If not set, use the value property of each field.
- buf
Examples
>>> s = io.StringIO() >>> fields = [ ... Field("a", int, 0, 10, value=1), ... Field("b", str, 10, 10, value="hello") ... ] >>> write_fields_csv(s, fields) >>> s.getvalue() '1,hello'
- ansys.dyna.core.lib.field_writer.write_c_dataframe_csv(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], table: pandas.DataFrame) None[source]#
Write a DataFrame to buf in comma-delimited format.
- Parameters:
- buf
IO Buffer to write to.
- fields
List[Field] Field definitions for the columns.
- table
pd.DataFrame The data to write.
- buf