scipy / xsf

Special function implementations
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

ENH: Migrate xsf header files from scipy repo to xsf repo #2

Closed steppi closed 1 week ago

steppi commented 1 week ago

This PR migrates header files (and .clang-format) from scipy/scipy/special/xsf to xsf/include/xsf while preserving git history.

I used git-filter-repo as described here, https://github.com/scipy/xsf/issues/1#issuecomment-2386979391, but in order to preserve history across the rename from scipy/scipy/special/special to scipy/scipy/special/xsf here https://github.com/scipy/scipy/pull/21297/files,

  1. Did git-filter-branch for all of scipy/scipy/special
  2. Did a scripted interactive rebase, picking only commits which touched a file in one of scipy/scipy/special/special or scipy/scipy/special/xsf.

The interactive rebase was done by setting GIT_SEQUENCE_EDITOR to the script in the details section below. Carrying out the rebase involved a tedious process of manually fixing merge conflicts, typically just using git rm to remove files which were added or updated in scipy/scipy/special but which are not part of the scalar kernel header library. However, sometimes there were merge conflicts because git seems to get confused when you try to rebase through an intermediate merge of main. I made a mistake resolving one of them in xsf/amos.h and needed to fix it in an additional commit here.

I've used git diff --no-index ~/scipy/scipy/special/xsf ~/include/xsf from within the xsf repo to confirm that no unwanted changes have creeped in.

```bash #!/bin/bash # Get the full commit hashes that touched the directories of interest COMMITS_TO_KEEP=$(git log --format="%H" -- $HOME/xsf-migration/scipy/include/xsf/scipy/special/special $HOME/xsf-migration/scipy/include/xsf/scipy/special/xsf) echo $COMMITS_TO_KEEP # Read the rebase sequence file into an array mapfile -t LINES < "$1" # Create a temporary file to store the new rebase sequence TEMP_FILE=$(mktemp) # Loop through each line of the rebase sequence for LINE in "${LINES[@]}"; do # Extract the commit hash from the line (this could be variable-length) COMMIT_HASH=$(echo "$LINE" | cut -d' ' -f2) # Loop through the full commit hashes in COMMITS_TO_KEEP to check for a match for FULL_HASH in $COMMITS_TO_KEEP; do # Check if the commit hash from the rebase file is a prefix of any full hash if [[ "$FULL_HASH" == "$COMMIT_HASH"* ]]; then # If there's a match, write the line to the temp file (keep the commit) echo "$LINE" >> "$TEMP_FILE" break fi done done # Overwrite the original rebase sequence file with the modified one mv "$TEMP_FILE" "$1" # Exit successfully exit 0 ```
steppi commented 1 week ago

Putting this on hold. I talked to @izaid, and there's still a few things that should be done on the SciPy side before we can split things off.

  1. Getting https://github.com/scipy/scipy/pull/21568 in.
  2. Some updates to API of special functions that can return derivatives of the function. I'll make an RFC about this on scipy soon.
  3. Removing dependence of xsf ufunc generation on SciPy's sf_error code.
  4. Closing some of the issues from here, https://github.com/scipy/scipy/issues/20223, that @mdhaber and I have been working together on.