Skip to content

Manual format binding#45

Merged
mx-moth merged 2 commits intomainfrom
bind-format
Jan 4, 2023
Merged

Manual format binding#45
mx-moth merged 2 commits intomainfrom
bind-format

Conversation

@mx-moth
Copy link
Contributor

@mx-moth mx-moth commented Jan 4, 2023

Adds a mechanism to bypass automatic format detection.

xarray accessors like dataset.ems are read only and cached. They can not be manually set. Simply doing dataset.ems = SomeFormat(dataset) does not work, and once set a format can not be swapped out. As such, an alternate mechanism to bind formats to datasets was required. The emsarray.state.State class represents this. This has attributes that are modifiable. A new Format instance can be constructed and bound to a dataset - this will set the state.format attribute. When dataset.ems is then accessed, the accessor will first check to see if a custom format has already been bound. If one has been, this will be used, else a new format will be constructed using the usual autodetection method.

This allows for greater flexibility and for overriding the format if autodetection fails.

It was only used for UGrid in the past, and is no longer required.
Nothing else seems likely to use it in the future.
@mx-moth mx-moth self-assigned this Jan 4, 2023
@mx-moth mx-moth merged commit e626559 into main Jan 4, 2023
@mx-moth mx-moth deleted the bind-format branch January 4, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant