Skip to content

Commit

Permalink
export scope-XXX-input.parquet. fix hulls bug
Browse files Browse the repository at this point in the history
  • Loading branch information
enjalot committed May 2, 2024
1 parent b9b0d4c commit c93b12a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
7 changes: 6 additions & 1 deletion latentscope/scripts/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,10 @@ def get_next_scopes_number(dataset):
if not os.path.exists(transactions_file_path):
with open(transactions_file_path, 'w') as f:
json.dump([], f)

input_df = pd.read_parquet(os.path.join(DATA_DIR, dataset_id, "input.parquet"))
combined_df = input_df[input_df.index.isin(scope_parquet['ls_index'])]
combined_df.to_parquet(os.path.join(directory, id + "-input.parquet"))

print("wrote scope", id)

print("wrote scope", id)
11 changes: 11 additions & 0 deletions latentscope/server/bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def change_cluster():

# write the parquet
df.to_parquet(scope_file)
update_combined(df, dataset_id, scope_id)

# recalculate the hulls
for c in clusters:
Expand Down Expand Up @@ -104,6 +105,9 @@ def change_cluster_name():
# update the label column in the parquet
df[df['cluster'] == cluster]['label'] = new_label
df.to_parquet(scope_file)

update_combined(df, dataset_id, scope_id)

#write the scope meta to file
with open(scope_meta_file, "w") as f:
json.dump(scope_meta, f, indent=2)
Expand Down Expand Up @@ -131,6 +135,8 @@ def delete_rows():

df.to_parquet(scope_file)

update_combined(df, dataset_id, scope_id)

# recalculate hulls
scope_meta_file = os.path.join(DATA_DIR, dataset_id, "scopes", scope_id + ".json")
with open(scope_meta_file) as f:
Expand All @@ -156,3 +162,8 @@ def delete_rows():
})
return jsonify({"success": True})

def update_combined(df, dataset_id, scope_id):
input_df = pd.read_parquet(os.path.join(DATA_DIR, dataset_id, "input.parquet"))
combined_df = input_df[input_df.index.isin(df['ls_index'])]
combined_df.to_parquet(os.path.join(DATA_DIR, dataset_id, "scopes", scope_id + "-input.parquet"))

38 changes: 19 additions & 19 deletions web/src/components/HullPlot.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useEffect, useRef } from 'react';
import { scaleLinear } from 'd3-scale';
import { useEffect, useRef } from 'react';
// import { scaleLinear } from 'd3-scale';
import { line, curveLinearClosed, curveCatmullRomClosed } from 'd3-shape';
import { select } from 'd3-selection';
import { transition } from 'd3-transition';
// import { transition } from 'd3-transition';
import { easeExpOut, easeExpIn, easeCubicInOut} from 'd3-ease';
import { interpolate } from 'flubber';
// import { interpolate } from 'flubber';

import "./HullPlot.css"

Expand Down Expand Up @@ -95,21 +95,21 @@ const HullPlot = ({
.delay(delay)
.ease(easeCubicInOut)
.style("opacity", 0.75)
// .attr("d", draw)
.attrTween("d", function(d,i) {
// console.log("d,i", d, i)
// console.log(d.hull, prevHulls.current.find(h => h.index == d.index).hull)
const prev = prevHulls.current ? prevHulls.current[i] : null
// console.log(d, prev)
if(!prev) return () => draw(d)
const inter = interpolate(
draw(prev),
draw(d)
);
return function(t) {
return inter(t)
}
})
.attr("d", draw)
// .attrTween("d", function(d,i) {
// // console.log("d,i", d, i)
// // console.log(d.hull, prevHulls.current.find(h => h.index == d.index).hull)
// const prev = prevHulls.current ? prevHulls.current[i] : null
// // console.log(d, prev)
// if(!prev) return () => draw(d)
// const inter = interpolate(
// draw(prev),
// draw(d)
// );
// return function(t) {
// return inter(t)
// }
// })


setTimeout(() => {
Expand Down

0 comments on commit c93b12a

Please sign in to comment.