This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
228 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from .fileio import * | ||
from .spectra import * | ||
from .reshape import * | ||
|
||
# TODO: Get rid of it. | ||
del fileio | ||
del spectra | ||
del spectra | ||
del reshape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""TODO: Docstring""" | ||
|
||
import numpy as np | ||
import pandas as pd | ||
from .spectra import Spectra | ||
|
||
__all__ = ["rbind"] | ||
|
||
|
||
def rbind(*objs, join="strict", data_join=None, spc_join=None): | ||
"""TODO: Docstring""" | ||
if data_join is None: | ||
data_join = join | ||
if spc_join is None: | ||
spc_join = join | ||
|
||
allowed_joins = ("strict", "outer", "inner") | ||
if (spc_join not in allowed_joins) or (data_join not in allowed_joins): | ||
raise ValueError("Incorrect join strategy") | ||
if len(objs) <= 1: | ||
raise ValueError("No data to bind.") | ||
|
||
if spc_join == "strict": | ||
for obj in objs: | ||
if not np.array_equal(obj.wl, objs[0].wl): | ||
raise ValueError( | ||
"Strict join is not possible: Spectra have different wavelenghts." | ||
) | ||
spc_join = "outer" | ||
|
||
if data_join == "strict": | ||
for obj in objs: | ||
if not np.array_equal(obj.data.columns, objs[0].data.columns): | ||
raise ValueError( | ||
"Strict join is not possible: Data have different columns." | ||
) | ||
data_join = "outer" | ||
|
||
return Spectra( | ||
spc=pd.concat([obj.spc for obj in objs], join=spc_join), | ||
data=pd.concat([obj.data for obj in objs], join=data_join), | ||
) |
Oops, something went wrong.