-
Notifications
You must be signed in to change notification settings - Fork 3
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
IO - Object-oriented API? #24
Comments
The second part of this would be the library of registered file formats and their relevant import/export functions (likely to/from import sys, inspect
class PewIOSpecification(object):
extension = None
def __init__(self, *args, **kwargs):
pass
class PewCSV(PewIOSpecification):
extension = '.csv'
def read(self, filepath):
...
df = pd.read_csv(filepath, ...)
return df
def write(self, df, filepath):
...
df.to_csv(filepath.with_suffix(self.extension))
class PewSCANCSV(PewIOSpecification):
extension = '.scancsv'
def read(self, filepath):
...
df = read_scancsv(filepath)
return df
def write(self, df, filepath):
...
to_scancsv(filepath.with_suffix(self.extension))
def registered_extensions():
"""
Get a dictionary of registered extensions mapping the relevant IO specifications.
"""
specs = inspect.getmembers(
sys.modules[__name__],
lambda cls: issubclass(cls, PewIOSpecification) if inspect.isclass(cls) else False,
)
return {cls.extension: cls for (name, cls) in specs} |
This in practice would look like: map = Pew()
map.calibrate('source_calibration_coords.csv', 'dest_calibration_coords.scancsv')
map.load('sample_coords.csv')
map.export('laserfile.scancsv') |
Another thing that we'll need for this is a specification for how we store intermediate information (e.g. principally sample coordinates, but also things like sample names, comments and other analytical metadata). One logical way to do this is with dataframes, as in most cases sample analysis involves tabular data. This would require:
And optionally include things like:
|
This issue has largely been addressed, so will now be closed. The |
One option for developing an API for calibration, transformation and export of points/images would be a class-based interface which allows import and export of 'known/registered' formats
The first part of this might look something along the lines of:
The text was updated successfully, but these errors were encountered: