Open ajsmale opened 6 years ago
Merging #21 into master will decrease coverage by
0.44%
. The diff coverage is22.22%
.
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
- Coverage 76.53% 76.08% -0.45%
==========================================
Files 9 9
Lines 1189 1196 +7
Branches 248 250 +2
==========================================
Hits 910 910
- Misses 168 174 +6
- Partials 111 112 +1
Impacted Files | Coverage Δ | |
---|---|---|
oceanwaves/swan.py | 72.7% <22.22%> (-1.06%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update d71a3da...cf1ee14. Read the comment docs.
Hi Alfons,
Thanks for the improvement. The fix seems appropriate, but seems to work only up to 400 bins. I think it is trivial to make the fix work for an unlimited number of bins. Untested example code:
n = len(self.frequencies)
m = int(np.ceil(len(self.directions)/MAX_BINS_PER_LINE))
q_splitted = self.lines.read_blockbody(n*m)
q_concatenated =[]
for i in range(len(self.frequencies)):
q_concatenated.append(sum(q_splitted[m*i:m*(i+1)]))
q = np.asarray(q_concatenated, dtype=np.float64) * f
Further, I have some minor requests regarding readability and testing (see also the code snippet above).
temp
? You can use subscripting, for example q_splitted
and q_concatenated
.i
as counter variable rather than ii
? For readability I prefer the use of different characters, for example j
, but here there is no need to use anything else than i
.data/swan
that has more than 200 directional bins?tests/test_swan.py
that tries to read this file?Finally, can you add a line to docs/whatsnew.rst
either under Bug fixes or Improvements under the unreleased section describing your fix and acknowledging yourself?
Bas
Updated parse_data to deal with more than 200 directional bins as well as spectra with all zeros
Apparently a maximum of 200 directional bins is written by SWAN to one line (this is hardcoded somewhere, not part of a swan input/use settings. With more than 200 bins, the data is written in multiple lines. Code changes allows for this.
Furthermore, if for some reason all data is zero (or more specifically all integer), the np.asarray makes and integer array, which does not allow multiplication with the floating value of factor f. Changed np.asarray to also hardcode float64.