Skip to content

Migrate ldsc from Python 2.7 to Python 3.6+ (based on bulik/ldsc#360)#2

Merged
jhjiang2020 merged 5 commits intodevfrom
copilot/review-pull-360-and-align
Oct 30, 2025
Merged

Migrate ldsc from Python 2.7 to Python 3.6+ (based on bulik/ldsc#360)#2
jhjiang2020 merged 5 commits intodevfrom
copilot/review-pull-360-and-align

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 30, 2025

Migrates the codebase from Python 2.7 to Python 3.6+ following bulik/ldsc#360, while preserving fork-specific enhancements from commit 1698c1b (--ref-ld-cts support, enhanced make_annot.py, and str match bug fix).

Core Changes

Python 3 Compatibility:

  • Removed from __future__ import division
  • xrangerange
  • print statements → print() functions
  • Pandas .ix.iloc/.loc
  • pd.set_option('precision')pd.set_option('display.precision')
  • Added functools.reduce import
  • Updated ldscore module to relative imports (import jackknifefrom . import jackknife)
  • Added rcond=None to np.linalg.lstsq calls
  • map()list(map()) where needed

Configuration:

  • requirements.txt: Updated dependencies, replaced nose with pytest
  • environment.yml: Python 2.7 → Python >=3.6
  • README.md: Updated version to 2.0.0

Code Quality:

  • Converted all tabs to 4-space indentation
  • Fixed indentation in munge_sumstats.py daner_n block
  • Fixed test assertions and pytest.raises usage

Example

Before (Python 2):

for i in xrange(n_blocks):
    print >>log_fh, msg
    ref_ld = ref_ld.ix[ii, :]

After (Python 3):

for i in range(n_blocks):
    print(msg, file=log_fh)
    ref_ld = ref_ld.loc[ii, :]

Verification

  • All scripts import successfully with Python 3.12
  • CodeQL security scan: 0 alerts
Original prompt

this is a forked repo from the original ldsc package. Some one created a pull request in the original repo bulik#360 that migrate the code base from python 2 to python 3. review this pull request throughly, and create a separate pull request to my fork. note that I have commits that are ahead of bulik:master, review these commits first and make sure the pull request to be created correctly align with my commits


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits October 30, 2025 21:10
- Remove 'from __future__ import division' statements
- Replace xrange with range
- Update print statements to print() function calls
- Replace .ix with .iloc/.loc as appropriate
- Update pandas set_option('precision') to set_option('display.precision')
- Add functools.reduce import
- Update relative imports in ldscore module
- Update np.linalg.lstsq to include rcond=None parameter
- Update map() calls to list(map()) where needed
- Update version to 2.0.0
- Preserve fork-specific enhancements in make_annot.py and ldscore/sumstats.py

Co-authored-by: jhjiang2020 <75499605+jhjiang2020@users.noreply.github.com>
- Apply Python 3 migration changes to all test files
- Update requirements.txt to remove version constraints
- Update environment.yml to require Python >=3.6
- Update README.md with Python 3 requirements and version 2.0.0
- Update pandas.util.testing imports to pandas.testing
- Replace print statements with print() in test files
- Replace xrange with range in test files
- Remove from __future__ imports from test files

Co-authored-by: jhjiang2020 <75499605+jhjiang2020@users.noreply.github.com>
- Convert all tabs to spaces (4-space indentation)
- Fix indentation error in munge_sumstats.py daner_n block
- Fix tab in ldscore.py
- Update requirements.txt to use pytest instead of nose
- All scripts now import successfully

Co-authored-by: jhjiang2020 <75499605+jhjiang2020@users.noreply.github.com>
- Fix assert statements in test_munge_sumstats.py to use proper comparison syntax
- Fix pytest.raises usage in test_ldscore.py (use context manager instead of decorator)
- Fix indentation in munge_sumstats.py for column validation loops

Co-authored-by: jhjiang2020 <75499605+jhjiang2020@users.noreply.github.com>
Copilot AI changed the title [WIP] Review and align changes from pull request 360 Migrate ldsc from Python 2.7 to Python 3.6+ (based on bulik/ldsc#360) Oct 30, 2025
Copilot AI requested a review from jhjiang2020 October 30, 2025 21:27
@jhjiang2020 jhjiang2020 marked this pull request as ready for review October 30, 2025 21:32
@jhjiang2020 jhjiang2020 merged commit 1654914 into dev Oct 30, 2025
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.

2 participants