AstarVienna / ScopeSim_Templates

GNU General Public License v3.0
2 stars 4 forks source link

Use isinstance(x, t) instead of type(x)==t #54

Closed hugobuddel closed 1 year ago

hugobuddel commented 1 year ago

These checks were broken anyway, because they only checked for float, while the values where actually numpy.float64. As a result, many functions returned an an array with a single element. This array then got silently converted to a float anyway, but this will change, as this warning is emitted:

DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

isintance will return True for both float and numpy.float64, so now everything will work as intended.

Also removing a mutable array from a function definition.

hugobuddel commented 1 year ago

Oh, the new test is not directly related, but was an attempt to reproduce the problem (which didn't work). But well, it probably adds a little bit of coverage.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 66.66% and project coverage change: +0.29% :tada:

Comparison is base (3e0a825) 78.50% compared to head (889bb1c) 78.80%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev_master #54 +/- ## ============================================== + Coverage 78.50% 78.80% +0.29% ============================================== Files 42 43 +1 Lines 1945 1958 +13 ============================================== + Hits 1527 1543 +16 + Misses 418 415 -3 ``` | [Files Changed](https://app.codecov.io/gh/AstarVienna/ScopeSim_Templates/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AstarVienna) | Coverage Δ | | |---|---|---| | [scopesim\_templates/stellar/imf.py](https://app.codecov.io/gh/AstarVienna/ScopeSim_Templates/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AstarVienna#diff-c2NvcGVzaW1fdGVtcGxhdGVzL3N0ZWxsYXIvaW1mLnB5) | `48.15% <47.36%> (+0.44%)` | :arrow_up: | | [...opesim\_templates/tests/test\_micado/test\_cluster.py](https://app.codecov.io/gh/AstarVienna/ScopeSim_Templates/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AstarVienna#diff-c2NvcGVzaW1fdGVtcGxhdGVzL3Rlc3RzL3Rlc3RfbWljYWRvL3Rlc3RfY2x1c3Rlci5weQ==) | `100.00% <100.00%> (ø)` | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/AstarVienna/ScopeSim_Templates/pull/54/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AstarVienna)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.