Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer reader #48

Merged
merged 2 commits into from
Dec 6, 2017
Merged

Infer reader #48

merged 2 commits into from
Dec 6, 2017

Conversation

drewejohnson
Copy link
Collaborator

Added a function to automatically read the requested file and return the read object. The motivation behind this is to quickly provide access to the data inside a file, with as minimal importing and hoop jumping as possible.

The function serpentTools.read, points to serpentTools.parsers.read, and is capable of

  1. Reading the file given a reader class
  2. Reading the file given it's type
  3. Reading the file by inferring the type

Example

import serpentTools
from serpentTools.parsers import DepletionReader
fileP = 'demo_dep.m'

r0 = DepletionReader(fileP)
r0.read()

r1 = serpentTools.read(fileP, DepletionReader)
r2 = serpentTools.read(fileP, 'dep')
r3 = serpentTools.read(fileP)

These four cases are all functionally equivalent.

The function serpentTools.read / serpentTools.parsers.read will automatically read the
requested file, either with the reader passed in or by inferring the file type form the path.

Unit tests were added to verify that the appropriate readers were obtained and errors raised
if files could not be inferred.

Signed-off-by: Andrew Johnson <drewej@protonmail.com>
Signed-off-by: Andrew Johnson <drewej@protonmail.com>
@drewejohnson drewejohnson merged commit 1b61bba into develop Dec 6, 2017
@drewejohnson drewejohnson deleted the infer-reader branch December 6, 2017 17:07
drewejohnson added a commit that referenced this pull request Dec 13, 2017
* Updated gitignore to exclude pycharm project settings
* Skeleton files for each reader class; Basic directory setup
* Depletion reader and project settings (#1)
* Quick: DepletedMaterial returns time vector if not given as input (#2)
* Quick fix: DepletedMaterial getXY only returns time if no time is given as input
* Fixes #3; Cleaned up reader subclasses (#4)
* Fixes #3; Cleaned up reader subclasses
* Added versioneer (#18)
* Fix get xy (#21)
* Fixes #19: Material doesn't return days if given as input
* Fixed unit tests
* Versioneer (#23)
* Messages, logging, and exception (#24)
* Expand variable groups; XSReader base; Temporary settings  (#27)
* Branching testing; Temporary settings modification
* Initial documentation - sphinx (#28)
* Added variables.yaml to data_files in setup (#32)
* Added depreciation and future warning decorators; More debug statements (#34)
* Depletion reader now correctly adds data from TOT; Updated defaults (#39)
* Better support (#40)
* Added python 2.7 support (#41)
* Homogenized Universe (#35)
* Read depmtx (#44)
* Return A matrix from depmtx as csc matrix not csr (#46)
* Remove settings package; Cleaned up messages file (#47)
* Implemented a module level read function (#48)
* Examples (#49)
* depmtx reader now parses using regular expressions (#52)
* Updated documentation - developer guide, api, and examples (#59)
* Updated setup.py to begrudgingly support distutils (#61)
* Use warnings.catch_warnings to record warnings in test_settings (#55)
* Native drewtils (#62)
* Branching Reader (#65)
* Release 0.1.0
drewejohnson added a commit that referenced this pull request Dec 13, 2017
* Release 0.1.0 (#66)

* Updated gitignore to exclude pycharm project settings
* Skeleton files for each reader class; Basic directory setup
* Depletion reader and project settings (#1)
* Quick: DepletedMaterial returns time vector if not given as input (#2)
* Quick fix: DepletedMaterial getXY only returns time if no time is given as input
* Fixes #3; Cleaned up reader subclasses (#4)
* Fixes #3; Cleaned up reader subclasses
* Added versioneer (#18)
* Fix get xy (#21)
* Fixes #19: Material doesn't return days if given as input
* Fixed unit tests
* Versioneer (#23)
* Messages, logging, and exception (#24)
* Expand variable groups; XSReader base; Temporary settings  (#27)
* Branching testing; Temporary settings modification
* Initial documentation - sphinx (#28)
* Added variables.yaml to data_files in setup (#32)
* Added depreciation and future warning decorators; More debug statements (#34)
* Depletion reader now correctly adds data from TOT; Updated defaults (#39)
* Better support (#40)
* Added python 2.7 support (#41)
* Homogenized Universe (#35)
* Read depmtx (#44)
* Return A matrix from depmtx as csc matrix not csr (#46)
* Remove settings package; Cleaned up messages file (#47)
* Implemented a module level read function (#48)
* Examples (#49)
* depmtx reader now parses using regular expressions (#52)
* Updated documentation - developer guide, api, and examples (#59)
* Updated setup.py to begrudgingly support distutils (#61)
* Use warnings.catch_warnings to record warnings in test_settings (#55)
* Native drewtils (#62)
* Branching Reader (#65)
* Release 0.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants