Skip to content

Commit 53f3ddd

Browse files
committed
refactor redundancy utility
1 parent bee0d12 commit 53f3ddd

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

databases/catdat/scripts/redundancies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
type StructureMeta,
1414
} from './utils/deduction'
1515
import { get_functors, get_normalized_functor_implications } from './utils/functors'
16-
import { StructureType } from './config'
16+
import type { StructureType } from './config'
1717

1818
const db = get_client()
1919

@@ -45,7 +45,7 @@ function check_redundant_property_assignments(type: StructureType) {
4545
const structures: StructureMeta[] =
4646
type === 'category' ? get_categories(db) : get_functors(db)
4747

48-
const assignments = get_property_assignments_by_deduction(db, structures, type)
48+
const assignments = get_property_assignments_by_deduction(db, type)
4949
const ignore_dict = get_ignored_redundant_assignments(type)
5050

5151
const ignore_count = Object.keys(ignore_dict).reduce(

databases/catdat/scripts/utils/deduction.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ export function get_property_assignments(
140140
* grouped by structure, value (satisfied / unsatisfied), and deduced status.
141141
* We exclude undecidable properties here.
142142
*/
143-
export function get_property_assignments_by_deduction(
144-
db: Database,
145-
structures: { id: string }[],
146-
type: StructureType,
147-
) {
143+
export function get_property_assignments_by_deduction(db: Database, type: StructureType) {
148144
const rows = db
149145
.prepare<
150146
[string],
@@ -173,15 +169,14 @@ export function get_property_assignments_by_deduction(
173169
}
174170
> = {}
175171

176-
for (const structure of structures) {
177-
grouped[structure.id] = {
172+
for (const row of rows) {
173+
const { property_id, structure_id, is_satisfied, is_deduced } = row
174+
175+
grouped[structure_id] ??= {
178176
satisfied: { non_deduced: new Set(), deduced: new Set() },
179177
unsatisfied: { non_deduced: new Set(), deduced: new Set() },
180178
}
181-
}
182179

183-
for (const row of rows) {
184-
const { property_id, structure_id, is_satisfied, is_deduced } = row
185180
grouped[structure_id][is_satisfied ? 'satisfied' : 'unsatisfied'][
186181
is_deduced ? 'deduced' : 'non_deduced'
187182
].add(property_id)

0 commit comments

Comments
 (0)