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

TypeError when nothing is found on in a document #8

Closed
oholter opened this issue Apr 30, 2021 · 6 comments
Closed

TypeError when nothing is found on in a document #8

oholter opened this issue Apr 30, 2021 · 6 comments

Comments

@oholter
Copy link

oholter commented Apr 30, 2021

Hi!
I'm getting an exception from fit_and_aggregate.
TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'.
The exception is from line 227 in aggregation.py, np.apply_along_axis(...)

This seems to happen when all of my labeling functions return empty on one of the docs so the DataFrame is empty.

@plison
Copy link
Collaborator

plison commented Apr 30, 2021

Are you running the latest version of the toolkit? It seems the same issue as #3 , which I thought I had fixed.

@oholter
Copy link
Author

oholter commented Apr 30, 2021

I am running v0.2.9 (installed via pip a few days ago)

@plison
Copy link
Collaborator

plison commented Apr 30, 2021

My bad, it seemed the last fix was not included in the PyPI package. It should now be fixed, just do pip install --upgrade skweak to get the latest version.

@plison plison closed this as completed Apr 30, 2021
@oholter
Copy link
Author

oholter commented May 5, 2021

Hi thanks!
It fixed the above exception. But I got another one. It seems to be related to the same issue (nothing is found).

Traceback (most recent call last):
  File "/runner.py", line 105, in <module>
    hmm.fit_and_aggregate(docs)
  File "/venv/lib/python3.8/site-packages/skweak/aggregation.py", line 304, in fit_and_aggregate
    return list(self.pipe(docs))
  File "/venv/lib/python3.8/site-packages/skweak/base.py", line 33, in pipe
    yield self(doc)
  File "/venv/lib/python3.8/site-packages/skweak/aggregation.py", line 296, in __call__
    return super(HMM, self).__call__(doc)
  File "/venv/lib/python3.8/site-packages/skweak/aggregation.py", line 64, in __call__
    agg_df = self._aggregate(df)
  File "/venv/lib/python3.8/site-packages/skweak/aggregation.py", line 326, in _aggregate
    _, forward_lattice = self._do_forward_pass(framelogprob)
  File "/venv/lib/python3.8/site-packages/hmmlearn/base.py", line 501, in _do_forward_pass
    n_samples, n_components = framelogprob.shape
ValueError: not enough values to unpack (expected 2, got 0)

plison added a commit that referenced this issue May 5, 2021
@plison
Copy link
Collaborator

plison commented May 5, 2021

OK, it should now be fixed. I had tested for the absence of "spans" in a document, but apparently not for documents with spans assigned to empty lists -- sorry about that. Let me know if you still experience problems!

@oholter
Copy link
Author

oholter commented May 6, 2021

Thanks! it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants