Skip to content

Commit c86bfd9

Browse files
committed
fix: replace dict_cursor with lazy-loaded get_dict_cursor in DataFrame conversions
1 parent 740eb82 commit c86bfd9

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/vfbquery/vfb_queries.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def get_instances(short_form: str, return_dataframe=True, limit: int = -1):
846846
RETURN COUNT(r) AS total_count
847847
"""
848848
count_results = vc.nc.commit_list([count_query])
849-
count_df = pd.DataFrame.from_records(dict_cursor(count_results))
849+
count_df = pd.DataFrame.from_records(get_dict_cursor()(count_results))
850850
total_count = count_df['total_count'][0] if not count_df.empty else 0
851851

852852
# Define the main Cypher query
@@ -876,7 +876,7 @@ def get_instances(short_form: str, return_dataframe=True, limit: int = -1):
876876
results = vc.nc.commit_list([query])
877877

878878
# Convert the results to a DataFrame
879-
df = pd.DataFrame.from_records(dict_cursor(results))
879+
df = pd.DataFrame.from_records(get_dict_cursor()(results))
880880

881881
columns_to_encode = ['label', 'parent', 'source', 'source_id', 'template', 'dataset', 'license', 'thumbnail']
882882
df = encode_markdown_links(df, columns_to_encode)
@@ -934,7 +934,7 @@ def get_templates(limit: int = -1, return_dataframe: bool = False):
934934
RETURN COUNT(DISTINCT t) AS total_count"""
935935

936936
count_results = vc.nc.commit_list([count_query])
937-
count_df = pd.DataFrame.from_records(dict_cursor(count_results))
937+
count_df = pd.DataFrame.from_records(get_dict_cursor()(count_results))
938938
total_count = count_df['total_count'][0] if not count_df.empty else 0
939939

940940
# Define the main Cypher query
@@ -959,7 +959,7 @@ def get_templates(limit: int = -1, return_dataframe: bool = False):
959959
results = vc.nc.commit_list([query])
960960

961961
# Convert the results to a DataFrame
962-
df = pd.DataFrame.from_records(dict_cursor(results))
962+
df = pd.DataFrame.from_records(get_dict_cursor()(results))
963963

964964
columns_to_encode = ['name', 'dataset', 'license', 'thumbnail']
965965
df = encode_markdown_links(df, columns_to_encode)
@@ -1061,7 +1061,7 @@ def get_similar_neurons(neuron, similarity_score='NBLAST_score', return_datafram
10611061
RETURN COUNT(DISTINCT n2) AS total_count"""
10621062

10631063
count_results = vc.nc.commit_list([count_query])
1064-
count_df = pd.DataFrame.from_records(dict_cursor(count_results))
1064+
count_df = pd.DataFrame.from_records(get_dict_cursor()(count_results))
10651065
total_count = count_df['total_count'][0] if not count_df.empty else 0
10661066

10671067
main_query = f"""MATCH (c1:Class)<-[:INSTANCEOF]-(n1)-[r:has_similar_morphology_to]-(n2)-[:INSTANCEOF]->(c2:Class)
@@ -1087,7 +1087,7 @@ def get_similar_neurons(neuron, similarity_score='NBLAST_score', return_datafram
10871087
results = vc.nc.commit_list([main_query])
10881088

10891089
# Convert the results to a DataFrame
1090-
df = pd.DataFrame.from_records(dict_cursor(results))
1090+
df = pd.DataFrame.from_records(get_dict_cursor()(results))
10911091

10921092
columns_to_encode = ['name', 'source', 'source_id', 'thumbnail']
10931093
df = encode_markdown_links(df, columns_to_encode)
@@ -1151,7 +1151,7 @@ def get_individual_neuron_inputs(neuron_short_form: str, return_dataframe=True,
11511151
RETURN COUNT(DISTINCT c) AS total_count"""
11521152

11531153
count_results = vc.nc.commit_list([count_query])
1154-
count_df = pd.DataFrame.from_records(dict_cursor(count_results))
1154+
count_df = pd.DataFrame.from_records(get_dict_cursor()(count_results))
11551155
total_count = count_df['total_count'][0] if not count_df.empty else 0
11561156

11571157
# Define the part of the query for normal mode
@@ -1190,7 +1190,7 @@ def get_individual_neuron_inputs(neuron_short_form: str, return_dataframe=True,
11901190
results = vc.nc.commit_list([query])
11911191

11921192
# Convert the results to a DataFrame
1193-
df = pd.DataFrame.from_records(dict_cursor(results))
1193+
df = pd.DataFrame.from_records(get_dict_cursor()(results))
11941194

11951195
columns_to_encode = ['Neurotransmitter', 'Type', 'Name', 'Template_Space', 'Imaging_Technique', 'thumbnail']
11961196
df = encode_markdown_links(df, columns_to_encode)

0 commit comments

Comments
 (0)