-
Notifications
You must be signed in to change notification settings - Fork 2
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
Blob labels returned #37
Conversation
This commit provides an implementation of the blob labels as a separate variable. Blob labels are required for using 2d_propagating_blobs to create test data for supervised machine learning. This is a first quick implementation, the following features should be added in the future: - tests for blob_labels - analytically calculated max_amplitudes instead of estimated max amplitudes (current implementation with np.max()) - animation function that shows density and blob labels at the same time
this commit adds a test for writing out blob labels for both speed_up = True and speed_up = False in make_realizations()
Codecov Report
@@ Coverage Diff @@
## main #37 +/- ##
==========================================
+ Coverage 91.04% 92.88% +1.84%
==========================================
Files 6 6
Lines 201 225 +24
Branches 25 35 +10
==========================================
+ Hits 183 209 +26
+ Misses 14 13 -1
+ Partials 4 3 -1
Continue to review full report at Codecov.
|
blobmodel/model.py
Outdated
__max_amplitudes[__max_amplitudes == 0] = np.inf | ||
__tmp = np.copy(__labels_field[:, :, __start:__stop]) | ||
__tmp[__single_blob >= __max_amplitudes * label_border] = 1 | ||
__labels_field[:, :, __start:__stop] = __tmp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why create __tmp? Seems unnecessary:
__labels_field[:, :, __start:__stop][__single_blob >= __max_amplitudes * label_border] = 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find another way of implementing this since I am not aware of a simpler way of applying a condition only on a slice of the array.
i.e.
__label_field[:, :, __start:__stop && __single_blob >= __max_amplitudes * label_border]
@Sosnowsky do you know a simpler way in python? Otherwise I would keep the current implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't what I wrote work?
__labels_field[:, :, __start:__stop][__single_blob >= __max_amplitudes * label_border] = 1
Creating the tmp array is time-comsuming, so in general you would prefer to avoid doing it if it is not necessary.
__create_xr_dataset(), __sum_up_blobs() and __sum_up_blobs_speedup() are created to shorten make_realization() mehtod.
make_realization() is split into multiple private methods to increase readability |
__sum_up_blobs() and __sum_up_blobs_speedup() are replaced by _sum_up_blobs() and __compute_start_stop()
@Sosnowsky code is refactored as discussed in my office |
Implementation of blob labels as a separate variable.
Blob labels are required for using 2d_propagating_blobs to create test data for supervised machine learning.
Note that the current blob implementation returns the same label for all blobs. We can discuss together with Filippo whether it is advisable to implement different labels for different blobs in the future.
This is a first quick implementation, the following features should be added in the future:
(current implementation with np.max())