Skip to content

Commit

Permalink
replace deprecated numpy in1d() with isin() (#1081)
Browse files Browse the repository at this point in the history
Co-authored-by: swryan <swryan@users.noreply.github.com>
  • Loading branch information
swryan and swryan authored Jun 27, 2024
1 parent 5037718 commit e8f1af6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dymos/transcriptions/pseudospectral/birkhoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def _get_timeseries_var_source(self, var, output_name, phase):
# Repeat nodes that are on segment bounds (but not the first or last nodes in the phase)
nodes_to_repeat = list(set(state_input_idxs).intersection(set(segment_end_idxs)))
# Now find these nodes in the state input indices
idxs_of_ntr_in_state_inputs = np.where(np.in1d(state_input_idxs, nodes_to_repeat))[0]
idxs_of_ntr_in_state_inputs = np.where(np.isin(state_input_idxs, nodes_to_repeat))[0]
# All state input nodes are used once, but nodes_to_repeat are used twice
repeat_idxs[idxs_of_ntr_in_state_inputs] = 2
# Now we have a way of mapping the state input indices to all nodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _get_rate_source_path(self, state_name, nodes, phase):
# Repeat nodes that are on segment bounds (but not the first or last nodes in the phase)
nodes_to_repeat = list(set(state_input_idxs).intersection(segment_end_idxs))
# Now find these nodes in the state input indices
idxs_of_ntr_in_state_inputs = np.where(np.in1d(state_input_idxs, nodes_to_repeat))[0]
idxs_of_ntr_in_state_inputs = np.where(np.isin(state_input_idxs, nodes_to_repeat))[0]
# All state input nodes are used once, but nodes_to_repeat are used twice
repeat_idxs[idxs_of_ntr_in_state_inputs] = 2
# Now we have a way of mapping the state input indices to all nodes
Expand Down
2 changes: 1 addition & 1 deletion dymos/transcriptions/pseudospectral/pseudospectral_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def configure_defects(self, phase):
state_disc_idxs = grid_data.subset_node_indices['state_disc']

if any_state_cnty:
state_input_subidxs = np.where(np.in1d(state_disc_idxs, segment_end_idxs))[0]
state_input_subidxs = np.where(np.isin(state_disc_idxs, segment_end_idxs))[0]

for name, options in phase.state_options.items():
shape = options['shape']
Expand Down
4 changes: 2 additions & 2 deletions dymos/transcriptions/pseudospectral/radau_pseudospectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _get_rate_source_path(self, state_name, nodes, phase):
# Repeat nodes that are on segment bounds (but not the first or last nodes in the phase)
nodes_to_repeat = list(set(state_input_idxs).intersection(segment_end_idxs))
# Now find these nodes in the state input indices
idxs_of_ntr_in_state_inputs = np.where(np.in1d(state_input_idxs, nodes_to_repeat))[0]
idxs_of_ntr_in_state_inputs = np.where(np.isin(state_input_idxs, nodes_to_repeat))[0]
# All state input nodes are used once, but nodes_to_repeat are used twice
repeat_idxs[idxs_of_ntr_in_state_inputs] = 2
# Now we have a way of mapping the state input indices to all nodes
Expand Down Expand Up @@ -349,7 +349,7 @@ def _get_timeseries_var_source(self, var, output_name, phase):
# Repeat nodes that are on segment bounds (but not the first or last nodes in the phase)
nodes_to_repeat = list(set(state_input_idxs).intersection(set(segment_end_idxs)))
# Now find these nodes in the state input indices
idxs_of_ntr_in_state_inputs = np.where(np.in1d(state_input_idxs, nodes_to_repeat))[0]
idxs_of_ntr_in_state_inputs = np.where(np.isin(state_input_idxs, nodes_to_repeat))[0]
# All state input nodes are used once, but nodes_to_repeat are used twice
repeat_idxs[idxs_of_ntr_in_state_inputs] = 2
# Now we have a way of mapping the state input indices to all nodes
Expand Down

0 comments on commit e8f1af6

Please sign in to comment.