Skip to content

Draft#24

Open
argens1203 wants to merge 38 commits into2-commits-priorfrom
main
Open

Draft#24
argens1203 wants to merge 38 commits into2-commits-priorfrom
main

Conversation

@argens1203
Copy link
Copy Markdown
Owner

No description provided.

argens1203 and others added 25 commits October 3, 2025 14:49
…empty core eg.: class 2 never loses to class 1
- Remove unused sqlite3.Date import in main.py
- Fix unreachable code in explainer.py (return before return 1)
- Clean up ~350 lines of commented debug code across multiple files:
  - main.py: remove experimental config comments (297 → 16 lines)
  - experiment.py: remove commented input() statements
  - encoder.py: remove debug print statements
  - model.py: remove stale TODOs and debug code
  - dataset.py: remove commented Caltech101Dataset code
- Reorganize README with proper structure:
  - Add table of contents
  - Add LGN Explanation Framework section with CLI reference
  - Document supported datasets, arguments, and usage examples
  - Consolidate installation notes
  - Remove internal notes and TODOs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace repetitive switch-case patterns with DATASET_REGISTRY dict
- Add LEGACY_DATASETS dict for image datasets without proper classes
- Consolidate get_dataset(), input_dim_of_dataset(), num_classes_of_dataset()
- Add docstrings explaining function behavior and requirements
- Export registry constants from __init__.py for extensibility
- Keep Caltech101Dataset placeholder for backwards compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move mid-file imports to top in lgn/model/model.py
- Remove unused imports:
  - logging from lgn/dataset/dataset.py
  - time from lgn/explanation/explainer.py
  - Dict, ModelArgs from experiment/experiment.py
  - dataclass from lgn/model/model.py
- Extract magic numbers to named constants:
  - NUM_BINARY_OPS = 16 in lgn/model/model.py
  - TORCH_NUM_THREADS = 1 in experiment/experiment.py
- Add explanatory comment for torch.set_num_threads()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive type annotations to improve code clarity and IDE support:

- lgn/dataset/dataset.py:
  - Add TypedDict for LegacyDatasetInfo
  - Type DATASET_REGISTRY and LEGACY_DATASETS
  - Add return types to all functions

- experiment/experiment.py:
  - Add types to Experiment class methods
  - Type debug(), run(), setup_preset_args(), etc.

- difflogic/difflogic.py:
  - Add types to LogicLayer and GroupSum classes
  - Type forward methods with Union[Tensor, PackBitsTensor]
  - Add Optional for nullable parameters

- lgn/model/model.py:
  - Type get_model() and compile_model() functions

- lgn/encoding/encoding.py:
  - Add types to Encoding class constructor and methods
  - Type all getter methods with proper return types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
argens1203 and others added 9 commits December 30, 2025 21:25
- Add SPLIT_DATASETS registry for datasets with explicit train/test splits
- Add RANDOM_SPLIT_DATASETS set for datasets using random splitting
- Add FACTORY_DATASETS for datasets needing factory functions (MNIST)
- Extract common logic into helper functions:
  - _create_data_loaders() for DataLoader creation
  - _load_split_dataset() for datasets with splits
  - _load_random_split_dataset() for random split datasets
- Add comprehensive type hints and docstrings
- Add DEFAULT_TRAIN_RATIO constant (0.8)
- Improve error messages with available dataset list
- Reduce code duplication from 88 lines to cleaner 127 lines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace 16 individual parameters with a typed configuration dataclass:
- Type-safe Literal types for valid option values
- Factory methods (small, full, custom) for common configurations
- Backward compatible: legacy parameters still work
- Clean conversion to experiment args via to_exp_args()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract single-responsibility classes from Context:
- MemoryProfiler: tracemalloc-based memory tracking
- DeduplicationTracker: encoding deduplication statistics
- SolvingStats: SAT solver clause/variable statistics
- OutputFormatter: CSV and table output formatting

Context maintains backward compatibility by delegating to these
new classes while preserving the original API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive type annotations to:
- experiment/helpers/util.py: seed_all, get_enc_type, loaders
- experiment/helpers/sat_context.py: SatContext class
- experiment/helpers/results.py: Results class with all methods
- lgn/encoding/encoders/encoder.py: Encoder class
- lgn/encoding/encoders/util.py: get_eq_constraints, _get_layers

Includes docstrings for all public functions and classes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Note that this repository is a modified version of the original
difflogic repository, extended as part of the Master's thesis
"Efficient Formal Explainability of Logic Gate Networks" at
Monash University by Argens Ng, supervised by Alexey Ignatiev.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Quick Start section with virtualenv setup instructions
- Fix experiment commands (experiments/main.py -> main.py)
- Remove references to non-existent main_baseline.py and --get_formula
- Fix test instructions (cd experiments -> python -m pytest)
- Add SSL certificate fix section for macOS users
- Update main.py to support CLI arguments via Experiment.run_with_cmd()
- Add missing datasets (compas, lending) to argparse choices
- Remove difflogic from requirements.txt (local dev uses source)
- Fix INSTALLATION_SUPPORT.md path reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove test_util.py (meaningless assertion)
- Remove test_sat.py (only skipped/commented tests)
- Remove test_session.py (empty file)
- Convert test_bdd.py to modern pytest style:
  - Replace unittest.TestCase with pytest fixtures
  - Fix broken setup_class method
  - Remove unused imports
  - Add fixture docstrings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
refactor: remove dead code and improve README documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant