Skip to content

Commit e768fcc

Browse files
authored
Merge pull request #2716 from AllenInstitute/psb-172/update_dependency_compatibility
Update Dependency Compatibility
2 parents 7af2406 + 26a4665 commit e768fcc

File tree

24 files changed

+68
-72
lines changed

24 files changed

+68
-72
lines changed

.github/workflows/github-actions-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
strategy:
4545
matrix:
4646
os: ["macos-latest", "windows-latest", "ubuntu-latest"]
47-
python-version: ["3.8", "3.9", "3.10"]
47+
python-version: ["3.8", "3.9", "3.10", "3.11"]
4848
fail-fast: false
4949
defaults:
5050
run:

allensdk/brain_observatory/behavior/behavior_project_cache/tables/util/prior_exposure_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def __get_prior_exposure_count(
157157
index = df.index
158158
df = df.sort_values("date_of_acquisition")
159159
df = df[df["session_type"].notnull()]
160-
161160
# reindex "to" to df
162161
to = to.loc[df.index]
163162

@@ -171,12 +170,13 @@ def __get_prior_exposure_count(
171170
counts = df.groupby(["mouse_id", to]).cumcount()
172171
elif agg_method == "cumsum":
173172
df["to"] = to
174-
173+
df_index_name = df.index.name
175174
def cumsum(x):
176175
return x.cumsum().shift(fill_value=0).astype("int64")
177176

178177
counts = df.groupby(["mouse_id"])["to"].apply(cumsum)
179178
counts.name = None
179+
counts.index = counts.index.get_level_values(df_index_name)
180180
else:
181181
raise ValueError(f"agg method {agg_method} not supported")
182182

allensdk/brain_observatory/behavior/data_objects/cell_specimens/cell_specimens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ def _postprocess(
820820
curr_roi.width = table_row["width"]
821821
curr_roi.height = table_row["height"]
822822
curr_roi.mask = np.array(table_row["roi_mask"])
823-
roi_mask_list.append(curr_roi.get_mask_plane().astype(np.bool))
823+
roi_mask_list.append(curr_roi.get_mask_plane().astype(bool))
824824

825825
cell_specimen_table["roi_mask"] = roi_mask_list
826826
cell_specimen_table = cell_specimen_table[

allensdk/brain_observatory/behavior/data_objects/stimuli/presentations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def from_stimulus_file(
361361
stim_pres_df = stim_pres_df[
362362
stim_pres_df["image_name"].isin(limit_to_images)
363363
]
364-
stim_pres_df.index = pd.Int64Index(
364+
stim_pres_df.index = pd.Index(
365365
range(stim_pres_df.shape[0]), name=stim_pres_df.index.name
366366
)
367367

allensdk/brain_observatory/behavior/data_objects/stimuli/stimulus_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _exclude_unseen_pixels(self, arr: np.ndarray):
7676
"""After warping, some pixels are not visible on the screen.
7777
This sets those pixels to nan to make downstream analysis easier."""
7878
mask = self._monitor.get_mask()
79-
arr = arr.astype(np.float)
79+
arr = arr.astype('float')
8080
arr *= mask
8181
arr[mask == 0] = np.nan
8282
return arr

allensdk/brain_observatory/behavior/dprime.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
def get_go_responses(hit=None, miss=None, aborted=None):
1111
assert len(hit) == len(miss) == len(aborted)
12-
not_aborted = np.logical_not(np.array(aborted, dtype=np.bool))
13-
hit = np.array(hit, dtype=np.bool)[not_aborted]
14-
miss = np.array(miss, dtype=np.bool)[not_aborted]
12+
not_aborted = np.logical_not(np.array(aborted, dtype=bool))
13+
hit = np.array(hit, dtype=bool)[not_aborted]
14+
miss = np.array(miss, dtype=bool)[not_aborted]
1515

1616
# Go responses are nan when catch (aborted are masked out); 0 for miss, 1 for hit
1717
# This allows pd.Series.rolling to ignore non-go trial data
18-
go_responses = np.empty_like(hit, dtype=np.float)
18+
go_responses = np.empty_like(hit, dtype='float')
1919
go_responses.fill(float('nan'))
2020
go_responses[hit] = 1
2121
go_responses[miss] = 0
@@ -38,13 +38,13 @@ def get_trial_count_corrected_hit_rate(hit=None, miss=None, aborted=None, slidin
3838

3939
def get_catch_responses(correct_reject=None, false_alarm=None, aborted=None):
4040
assert len(correct_reject) == len(false_alarm) == len(aborted)
41-
not_aborted = np.logical_not(np.array(aborted, dtype=np.bool))
42-
correct_reject = np.array(correct_reject, dtype=np.bool)[not_aborted]
43-
false_alarm = np.array(false_alarm, dtype=np.bool)[not_aborted]
41+
not_aborted = np.logical_not(np.array(aborted, dtype=bool))
42+
correct_reject = np.array(correct_reject, dtype=bool)[not_aborted]
43+
false_alarm = np.array(false_alarm, dtype=bool)[not_aborted]
4444

4545
# Catch responses are nan when go (aborted are masked out); 0 for correct-rejection, 1 for false-alarm
4646
# This allows pd.Series.rolling to ignore non-catch trial data
47-
catch_responses = np.empty_like(correct_reject, dtype=np.float)
47+
catch_responses = np.empty_like(correct_reject, dtype='float')
4848
catch_responses.fill(float('nan'))
4949
catch_responses[false_alarm] = 1
5050
catch_responses[correct_reject] = 0

allensdk/brain_observatory/behavior/swdb/summary_figures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def plot_max_proj_and_roi_masks(session, save_dir=None):
381381
ax[2].set_title(str(session.metadata['ophys_experiment_id']))
382382

383383
tmp = session.segmentation_mask_image.data.copy()
384-
mask = np.empty(session.segmentation_mask_image.data.shape, dtype=np.float)
384+
mask = np.empty(session.segmentation_mask_image.data.shape, dtype='float')
385385
mask[:] = np.nan
386386
mask[tmp > 0] = 1
387387
cax = ax[2].imshow(mask, cmap='hsv', alpha=0.4, vmin=0, vmax=1)

allensdk/brain_observatory/chisquare_categorical.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ def stim_table_to_categories(stim_table,
8484

8585
category = 0
8686
sweep_categories = -1*np.ones((num_sweeps,))
87-
curr_combination = np.zeros((num_params,),dtype=np.int)
88-
options_per_column = np.array(options_per_column).astype(np.int)
87+
curr_combination = np.zeros((num_params,),dtype='int')
88+
options_per_column = np.array(options_per_column).astype('int')
8989
all_tried = False
9090
while not all_tried:
9191

92-
matches_combination = np.ones((num_sweeps,),dtype=np.bool)
92+
matches_combination = np.ones((num_sweeps,),dtype=bool)
9393
for i_col,column in enumerate(columns):
9494
param = unique_params[i_col][curr_combination[i_col]]
9595
matches_param = stim_table[column].values == param
@@ -140,7 +140,7 @@ def make_category_dummy(sweep_categories):
140140
categories = np.unique(sweep_categories)
141141
num_categories = len(categories)
142142

143-
sweep_category_mat = np.zeros((num_sweeps,num_categories),dtype=np.bool)
143+
sweep_category_mat = np.zeros((num_sweeps,num_categories),dtype=bool)
144144
for i_cat,category in enumerate(categories):
145145
category_idx = np.argwhere(sweep_categories==category)[:,0]
146146
sweep_category_mat[category_idx,i_cat] = True

allensdk/brain_observatory/ecephys/ecephys_project_api/ecephys_project_warehouse_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def get_unit_analysis_metrics(self, unit_ids=None, ecephys_session_ids=None, ses
288288
columns = set(output.columns.values.tolist())
289289
if "p_value_rf" in columns and "on_screen_rf" in columns:
290290

291-
pv_is_bool = np.issubdtype(output["p_value_rf"].values[0], np.bool)
291+
pv_is_bool = np.issubdtype(output["p_value_rf"].values[0], bool)
292292
on_screen_is_float = np.issubdtype(output["on_screen_rf"].values[0].dtype, np.floating)
293293

294294
# this is not a good test, but it avoids the case where we fix

allensdk/brain_observatory/ecephys/stimulus_table/naming_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def replace(match_obj):
154154

155155
movie_rows = table[stim_colname].str.contains(movie_re, na=False)
156156
table.loc[movie_rows, stim_colname] = \
157-
table.loc[movie_rows, stim_colname].str.replace(numeral_re, replace)
157+
table.loc[movie_rows, stim_colname].str.replace(numeral_re, replace, regex=True)
158158

159159
return table
160160

allensdk/brain_observatory/receptive_field_analysis/chisquarerf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ def get_peak_significance(chi_square_grid_NLL,
146146
best_p[n] = p_value_corrected_per_pixel[y,x]
147147
if best_p[n] < alpha:
148148
significant_cells[n] = True
149-
best_exclusion_region_list.append(disc_masks[y, x, :,:].astype(np.bool))
149+
best_exclusion_region_list.append(disc_masks[y, x, :,:].astype(bool))
150150
else:
151-
best_exclusion_region_list.append(np.zeros((disc_masks.shape[0], disc_masks.shape[1]), dtype=np.bool))
151+
best_exclusion_region_list.append(np.zeros((disc_masks.shape[0], disc_masks.shape[1]), dtype=bool))
152152

153153
return significant_cells, best_p, corrected_p_value_array_list, best_exclusion_region_list
154154

allensdk/brain_observatory/receptive_field_analysis/eventdetection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def detect_events(data, cell_index, stimulus, debug_plots=False):
128128

129129

130130
assert len(var_dict) == len(stimulus_table)
131-
b = np.zeros(len(stimulus_table), dtype=np.bool)
131+
b = np.zeros(len(stimulus_table), dtype=bool)
132132
for yi in yes_set:
133133
b[yi] = True
134134

allensdk/brain_observatory/receptive_field_analysis/postprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def run_postprocessing(data, rf):
106106
cell_index = rf['attrs']['cell_index']
107107
locally_sparse_noise_template = data.get_stimulus_template(stimulus)
108108

109-
event_array = np.zeros((rf['event_vector']['data'].shape[0], 1), dtype=np.bool)
109+
event_array = np.zeros((rf['event_vector']['data'].shape[0], 1), dtype=bool)
110110
event_array[:,0] = rf['event_vector']['data']
111111

112112
chi_squared_grid = chi_square_binary(event_array, locally_sparse_noise_template)

allensdk/brain_observatory/receptive_field_analysis/receptive_field.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def compute_receptive_field(data, cell_index, stimulus, **kwargs):
9393

9494
fdr_corrected_pvalues_on = fdr_corrected_pvalues[
9595
:number_of_pixels].reshape(s1, s2)
96-
_fdr_mask_on = np.zeros_like(pvalues_on, dtype=np.bool)
96+
_fdr_mask_on = np.zeros_like(pvalues_on, dtype=bool)
9797
_fdr_mask_on[fdr_corrected_pvalues_on < alpha] = True
9898
components_on, number_of_components_on = get_components(_fdr_mask_on)
9999

100100
fdr_corrected_pvalues_off = fdr_corrected_pvalues[
101101
number_of_pixels:].reshape(s1, s2)
102-
_fdr_mask_off = np.zeros_like(pvalues_off, dtype=np.bool)
102+
_fdr_mask_off = np.zeros_like(pvalues_off, dtype=bool)
103103
_fdr_mask_off[fdr_corrected_pvalues_off < alpha] = True
104104
components_off, number_of_components_off = get_components(_fdr_mask_off)
105105

allensdk/brain_observatory/receptive_field_analysis/utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_shuffle_matrix(data, event_vector, A, number_of_shuffles=5000, response_
130130
size = number_of_events + int(np.round(response_detection_error_std_dev*number_of_events*np.random.randn()))
131131
shuffled_event_inds = np.random.choice(evr, size=size, replace=False)
132132

133-
b_tmp = np.zeros(len(event_vector), dtype=np.bool)
133+
b_tmp = np.zeros(len(event_vector), dtype=bool)
134134
b_tmp[shuffled_event_inds] = True
135135
shuffle_data[:, ii] = A[:,b_tmp].sum(axis=1)/float(size)
136136

@@ -270,7 +270,7 @@ def get_components(receptive_field_data):
270270
return_array = np.zeros((len(component_list), receptive_field_data.shape[0], receptive_field_data.shape[1]))
271271

272272
for ii, component in enumerate(component_list):
273-
curr_component_mask = np.zeros_like(receptive_field_data, dtype=np.bool).flatten()
273+
curr_component_mask = np.zeros_like(receptive_field_data, dtype=bool).flatten()
274274
curr_component_mask[component] = True
275275
return_array[ii,:,:] = curr_component_mask.reshape(receptive_field_data.shape)
276276

allensdk/brain_observatory/stimulus_info.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ def lsn_image_to_screen(self, img, stimulus_type, origin='lower', background_col
518518

519519
def natural_scene_image_to_screen(self, img, origin='lower', translation=(0,0)):
520520

521-
# assert img.dtype == np.float32
522-
# img = img.astype(np.uint8)
523-
524521
full_image = np.full((self.n_pixels_r, self.n_pixels_c), 127, dtype=np.uint8)
525522
mr, mc = natural_scene_coordinate_to_monitor_coordinate((0, 0), (self.n_pixels_r, self.n_pixels_c))
526523
Mr, Mc = natural_scene_coordinate_to_monitor_coordinate((img.shape[0], img.shape[1]), (self.n_pixels_r, self.n_pixels_c))
@@ -756,7 +753,7 @@ def warp_stimulus_coords(vertices,
756753
distance = float(distance)
757754
mon_res_x, mon_res_y = float(mon_res[0]), float(mon_res[1])
758755

759-
vertices = vertices.astype(np.float)
756+
vertices = vertices.astype('float')
760757

761758
# from pixels (-1920/2 -> 1920/2) to stimulus space (-0.5->0.5)
762759
vertices[:, 0] = vertices[:, 0] / mon_res_x

allensdk/core/json_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def json_handler(obj):
164164
return float(obj)
165165
elif isinstance(obj, np.integer):
166166
return int(obj)
167-
elif (isinstance(obj, np.bool) or
167+
elif (isinstance(obj, bool) or
168168
isinstance(obj, np.bool_)):
169169
return bool(obj)
170170
elif hasattr(obj, 'isoformat'):

allensdk/core/mouse_connectivity_cache.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,11 @@ def rank_structures(
572572
:, output_keys
573573
]
574574

575-
records = this_experiment_unionizes.to_dict("record")
575+
this_experiment_unionizes = unionizes[unionizes['experiment_id'] == eid]
576+
this_experiment_unionizes = this_experiment_unionizes.sort_values(by=rank_on, ascending=False)
577+
this_experiment_unionizes = this_experiment_unionizes.loc[:, output_keys]
578+
579+
records = this_experiment_unionizes.to_dict('records')
576580
if len(records) > n:
577581
records = records[:n]
578582
results.append(records)

allensdk/internal/mouse_connectivity/interval_unionize/data_utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ def get_projection_data(projection_density_path, projection_energy_path,
9393
logging.info('getting aav exclusion fraction')
9494
aav_exclusion_fraction = read(aav_exclusion_fraction_path)
9595
aav_exclusion_fraction[aav_exclusion_fraction > 0] = 1
96-
aav_exclusion_fraction = aav_exclusion_fraction.astype(np.bool_, order='C')
96+
aav_exclusion_fraction = aav_exclusion_fraction.astype(bool, order='C')
9797

9898
except (IOError, OSError, RuntimeError):
9999
logging.info('skipping aav exclusion fraction')
100-
aav_exclusion_fraction = np.zeros(projection_density.shape, dtype=np.bool_, order='C')
100+
aav_exclusion_fraction = np.zeros(projection_density.shape, dtype=bool, order='C')
101101

102102
return {'projection_density': projection_density,
103103
'projection_energy': projection_energy,

allensdk/test/brain_observatory/ecephys/stimulus_analysis/test_stimulus_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_conditionwise_statistics(ecephys_api):
185185
["spike_count", "stimulus_presentation_count", "spike_mean", "spike_std", "spike_sem"]
186186
)
187187
obtained = stim_analysis.conditionwise_statistics.loc[(0, 1)]
188-
pd.testing.assert_series_equal(expected, obtained[expected.index], check_less_precise=5, check_names=False)
188+
pd.testing.assert_series_equal(expected, obtained[expected.index], check_dtype=True, check_names=False, rtol=1e-5, atol=1e-8)
189189

190190

191191
def test_presentationwise_spike_times(ecephys_api):

allensdk/test/brain_observatory/ecephys/test_write_nwb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def test_add_raw_running_data_to_nwbfile(
563563
def test_read_stimulus_table(tmpdir_factory, presentations,
564564
column_renames_map, columns_to_drop, expected):
565565
expected = expected.set_index(
566-
pd.Int64Index(range(expected.shape[0]),
566+
pd.Index(range(expected.shape[0]),
567567
name='stimulus_presentations_id'))
568568
dirname = str(tmpdir_factory.mktemp("ecephys_nwb_test"))
569569
stim_table_path = os.path.join(dirname, "stim_table.csv")

requirements.txt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
psycopg2-binary
22
hdmf<=3.4.7
33
h5py
4-
matplotlib>=1.4.3
5-
numpy
6-
pandas>=1.1.5
7-
jinja2>=3.0.0
8-
scipy>=1.4.0,<2.0.0
9-
six>=1.9.0,<2.0.0
10-
pynrrd>=0.2.1,<1.0.0
11-
future >= 0.14.3,<1.0.0
12-
requests<3.0.0
13-
requests-toolbelt<1.0.0
14-
simplejson>=3.10.0,<4.0.0
15-
scikit-image>=0.14.0
16-
scikit-build<1.0.0
4+
matplotlib
5+
numpy<1.24
6+
pandas==1.5.3
7+
jinja2
8+
scipy<1.11
9+
six
10+
pynrrd
11+
future
12+
requests
13+
requests-toolbelt
14+
simplejson
15+
scikit-image
16+
scikit-build
1717
statsmodels
18-
simpleitk>=2.0.2,<3.0.0
19-
argschema>=3.0.1,<4.0.0
20-
glymur==0.8.19
21-
xarray
22-
pynwb
18+
simpleitk
19+
argschema
20+
glymur
21+
xarray<2023.2.0
22+
pynwb<=2.3.3
2323
tables
24-
seaborn<1.0.0
25-
aiohttp==3.7.4
24+
seaborn
25+
aiohttp
2626
nest_asyncio
27-
tqdm>=4.27
28-
ndx-events<=0.2.0
29-
boto3==1.17.21
27+
tqdm
28+
ndx-events
29+
boto3
3030
semver
31-
cachetools>=4.2.1,<5.0.0
31+
cachetools
3232
sqlalchemy
3333
python-dateutil

setup.cfg

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ author = David Feng
44
author-email = [email protected]
55
summary = Core libraries for the allensdk.
66
description-file = README.md
7-
classifier =
8-
Development Status :: 3 - Alpha',
9-
Intended Audience :: Science/Research',
10-
Natural Language :: English',
11-
Operating System :: OS Independent',
12-
Programming Language :: Python
13-
Programming Language :: Python :: 2
14-
Programming Language :: Python :: 2.7
15-
Topic :: Scientific/Engineering :: Bio-Informatics
167

178
[build_sphinx]
189
source-dir = .

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ def prepend_find_packages(*roots):
8686
"License :: Other/Proprietary License", # Allen Institute License
8787
"Natural Language :: English",
8888
"Operating System :: OS Independent",
89+
"Programming Language :: Python",
90+
"Programming Language :: Python :: 3",
91+
'Programming Language :: Python :: 3 :: Only',
8992
"Programming Language :: Python :: 3.8",
9093
"Programming Language :: Python :: 3.9",
9194
"Programming Language :: Python :: 3.10",
95+
"Programming Language :: Python :: 3.11",
9296
"Topic :: Scientific/Engineering :: Bio-Informatics",
9397
],
9498
)

0 commit comments

Comments
 (0)