question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled exception thrown in AveragedCrossspectrum constructor

See original GitHub issue

If we create two lightcurves and then create an AveragedCrossspectrum without specifying the segment size. The following exception gets thrown: TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘float’.

The full traceback:

  File "\<stdin\>", line 1, in <module>
  File "\~/stingray/crossspectrum.py", line 541, in __init__
    Crossspectrum.__init__(self, lc1, lc2, norm, gti=gti)
  File "\~/stingray/crossspectrum.py", line 137, in __init__
    self._make_crossspectrum(lc1, lc2)
  File "\~/stingray/crossspectrum.py", line 606, in _make_crossspectrum
    self._make_segment_spectrum(lc1, lc2, self.segment_size)
  File "\~/stingray/crossspectrum.py", line 573, in _make_segment_spectrum
    dt=lc1.dt)
  File "\~/stingray/gti.py", line 597, in bin_intervals_from_gtis
    nbin = np.long(chunk_length / dt)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float' 

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
haroonrashid235commented, Jul 25, 2017

@matteobachetti So for now, best solution is to make segment_size a non-optional parameter. That way user will at least have an interpretable error message.

0reactions
matteobachetticommented, Jul 25, 2017

@haroonrashid235 @omargamal8 I would rather force the user to specify it. I think that this is a parameter that users should choose explicitly and carefully. Also, it should not be separated from the bin time! We might easily create memory overflows or useless results. We might set a default value based on a certain number of bins, and check that we don’t go further than the GTIs in the observation… In summary, it’s more complicated than it seems, and for now I would just tell the user to act responsibly 😄

(@dhuppenkothen: what do you think about this?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Eclipse says "unhandled exception" in a constructor method ...
You are throwing an exception inside constructor, but didn't specify throws clause in method signature, which is compile time error, ...
Read more >
Can Constructors Throw Exceptions in Java - Rollbar
The short answer is yes! Of course, properly implementing exceptions in your constructors is essential to getting the best results.
Read more >
Function try block handlers (C++ only) - IBM
A function try block on main() does not catch exceptions thrown in destructors of objects with static storage duration, or constructors of namespace...
Read more >
Throwing Exceptions in Constructors - Baeldung
It's not uncommon to throw an exception during the instantiation of an object. In this article, we'll examine all the details about throwing...
Read more >
AWS Lambda function errors in C# - AWS Lambda
Syntax. In the initialization phase, exceptions can be thrown for invalid handler strings, a rule-breaking type or method (see Lambda function handler ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found