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.select raises TypeError when an integer is entered #436

Open
ahmadtourei opened this issue Sep 24, 2024 · 0 comments
Open

Spool.select raises TypeError when an integer is entered #436

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

Comments

@ahmadtourei
Copy link
Collaborator

Description

Spool.select function does not expect integers for coordinates as it calculates the argument's length.

Example

import dascore as dc

spool = dc.get_example_spool()
sub_spool = spool.select(distance=-1, samples=True)

raises:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[56], [line 4](vscode-notebook-cell:?execution_count=56&line=4)
      [1](vscode-notebook-cell:?execution_count=56&line=1) import dascore as dc
      [3](vscode-notebook-cell:?execution_count=56&line=3) spool = dc.get_example_spool()
----> [4](vscode-notebook-cell:?execution_count=56&line=4) sub_spool = spool.select(distance=-1, samples=True)
      [5](vscode-notebook-cell:?execution_count=56&line=5) sub_spool

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\core\spool.py:527, in DataFrameSpool.select(self, **kwargs)
    [524](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:524) @compose_docstring(doc=BaseSpool.select.__doc__)
    [525](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:525) def select(self, **kwargs) -> Self:
    [526](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:526)     """{doc}."""
--> [527](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:527)     _, _, extra_kwargs = split_df_query(kwargs, self._df, ignore_bad_kwargs=True)
    [528](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:528)     filtered_df = adjust_segments(self._df, ignore_bad_kwargs=True, **kwargs)
    [529](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:529)     inst = adjust_segments(
    [530](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:530)         self._instruction_df,
    [531](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:531)         ignore_bad_kwargs=True,
    [532](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:532)         **kwargs,
    [533](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:533)     ).loc[lambda x: x["current_index"].isin(filtered_df.index)]

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\utils\pd.py:86, in split_df_query(kwargs, df, ignore_bad_kwargs)
     [84](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:84) val = kwargs[key]
     [85](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:85) subset = {min_key, max_key}.issubset(col_set)
---> [86](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:86) if subset and val is not None and len(val) == 2:
     [87](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:87)     # handles ... as None.
     [88](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:88)     new_val = [None if x is ... else x for x in val]
     [89](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/utils/pd.py:89)     range_query[key] = tuple(new_val)

TypeError: object of type 'int' has no len()

Expected behavior

Versions

  • OS [e.g. Ubuntu 20.04]:
  • DasCore Version [e.g. 0.0.5]:
  • Python Version [e.g. 3.10]:
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

1 participant