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

Spool.chunk raises NotImplementedError when units are applied #437

Open
ahmadtourei opened this issue Sep 24, 2024 · 1 comment
Open

Spool.chunk raises NotImplementedError when units are applied #437

ahmadtourei opened this issue Sep 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ahmadtourei
Copy link
Collaborator

Description

Not a super important issue, but we get a NotImplementedError when applying units (which are not necessary for the chunk function).

Example

import dascore as dc
from dascore.units import s

spool = dc.get_example_spool()
sub_spool = spool.chunk(time=1*s)

raises:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[18], [line 5](vscode-notebook-cell:?execution_count=18&line=5)
      [2](vscode-notebook-cell:?execution_count=18&line=2) from dascore.units import s
      [4](vscode-notebook-cell:?execution_count=18&line=4) spool = dc.get_example_spool()
----> [5](vscode-notebook-cell:?execution_count=18&line=5) sub_spool = spool.chunk(time=1*s)

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\core\spool.py:492, in DataFrameSpool.chunk(self, overlap, keep_partial, snap_coords, tolerance, conflict, **kwargs)
    [482](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:482) df = self._df.drop(columns=list(self._drop_columns), errors="ignore")
    [483](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:483) chunker = ChunkManager(
    [484](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:484)     overlap=overlap,
    [485](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:485)     keep_partial=keep_partial,
   (...)
    [490](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:490)     **kwargs,
    [491](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:491) )
--> [492](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:492) in_df, out_df = chunker.chunk(df)
    [493](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:493) if df.empty:
    [494](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:494)     instructions = None

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\utils\chunk.py:449, in ChunkManager.chunk(self, df)
    [447](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/chunk.py:447) group_maxs = stop.groupby(group).max()
    [448](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/chunk.py:448) # split/group dataframe into new chunks by iterating over each group.
--> [449](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/chunk.py:449) out = self._get_group_dfs(group, dur, overlap, group_mins, group_maxs, df, step)
    [450](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/chunk.py:450) if not len(out):
    [451](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/chunk.py:451)     msg = "Could not chunk. No segments with sufficient length found."
...
    [171](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/time.py:171)     return np.timedelta64("NaT")
    [172](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/time.py:172) msg = f"type {type(obj)} is not supported"
--> [173](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/time.py:173) raise NotImplementedError(msg)

NotImplementedError: type <class 'pint.Quantity'> is not supported

Expected behavior

Versions

  • OS [e.g. Ubuntu 20.04]:
  • DasCore Version [e.g. 0.0.5]:
  • Python Version [e.g. 3.10]:
@ahmadtourei ahmadtourei added the bug Something isn't working label Sep 24, 2024
@d-chambers
Copy link
Contributor

Agreed, we should make this work. We would need to include units in the pytables index, which we don't current do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants