Skip to content

Commit 88334d7

Browse files
authored
Small change in the internals of basins_of_attraction (#180)
* small changes in basins_of_attraction. * add show_progress kw
1 parent c487c7f commit 88334d7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/mapping/recurrences/attractor_mapping_recurrences.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ conditions to map to attractors, the method can further utilize found exit and a
200200
basins, making the computation faster as the grid is processed more and more.
201201
"""
202202
function basins_of_attraction(mapper::AttractorsViaRecurrences; show_progress = true)
203-
basins = mapper.bsn_nfo.basins
204-
if basins isa SparseArray;
203+
if mapper.bsn_nfo.basins isa SparseArray;
205204
throw(ArgumentError("""
206205
Sparse version of AttractorsViaRecurrences is incompatible with
207206
`basins_of_attraction(mapper)`."""
@@ -214,6 +213,8 @@ function basins_of_attraction(mapper::AttractorsViaRecurrences; show_progress =
214213
grid = mapper.grid.grid
215214
end
216215

216+
basins = zero(mapper.bsn_nfo.basins)
217+
217218
I = CartesianIndices(basins)
218219
progress = ProgressMeter.Progress(
219220
length(basins); desc = "Basins of attraction: ", dt = 1.0
@@ -227,18 +228,11 @@ function basins_of_attraction(mapper::AttractorsViaRecurrences; show_progress =
227228
if basins[ind] == 0
228229
show_progress && ProgressMeter.update!(progress, k)
229230
y0 = generate_ic_on_grid(grid, ind)
230-
basins[ind] = recurrences_map_to_label!(
231-
mapper.bsn_nfo, mapper.ds, y0; show_progress, mapper.kwargs...
232-
)
231+
basins[ind] = mapper(y0; show_progress)
233232
end
234233
end
235234

236-
# remove attractors and rescale from 1 to max number of attractors
237-
bas_tmp = copy(basins)
238-
ind = iseven.(basins)
239-
bas_tmp[ind] .+= 1
240-
bas_tmp .= (bas_tmp .- 1) 2
241-
return bas_tmp, mapper.bsn_nfo.attractors
235+
return basins, extract_attractors(mapper)
242236
end
243237

244238
#####################################################################################

0 commit comments

Comments
 (0)