Skip to content

Drop deprecated copy keyword from astype call in from_fcs - #184

Open
xyf5432 wants to merge 1 commit into
dpeerlab:masterfrom
xyf5432:fix/pandas3-astype-copy-deprecation
Open

Drop deprecated copy keyword from astype call in from_fcs#184
xyf5432 wants to merge 1 commit into
dpeerlab:masterfrom
xyf5432:fix/pandas3-astype-copy-deprecation

Conversation

@xyf5432

@xyf5432 xyf5432 commented Aug 24, 2026

Copy link
Copy Markdown

PR: Guard deprecated astype copy keyword by pandas version in from_fcs

Fixes #183

Changes

Guard the deprecated copy keyword of DataFrame.astype by pandas
version in from_fcs, so behaviour is preserved on every supported
version:

Verification

The copy keyword never affects the result of astype on any
pandas version, only whether an extra copy is made; the branch keeps
that behaviour exactly as it was on each side of the boundary. Runtime
checks on pandas 2.3.3 and 3.0.5, simulating the from_fcs data flow
(fcsparser.parse-like DataFrame → astype → metadata-channel filter →
np.arcsinh(np.divide(...))):

  • pandas 2.3.3 takes the copy=False branch: already-float64 columns
    still share the buffer (np.shares_memory = True), exactly as before
    the change; int64float64 columns allocate a new array either
    way (a dtype change cannot be done in place).
  • pandas 3.0.5 takes the plain branch: no Pandas4Warning is emitted,
    final arcsinh results bit-identical to pandas 2.3.3.
  • Modified files pass python -m py_compile.

@katosh

katosh commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Hi @xyf5432,

Thank you for the issue and PR! This overall looks great, there is just two things we should do:

  1. v1.4.5 already shipped. Write a new ### Version 1.4.6 (future) section in the changelog instead.
  2. Since copy=False can only skip an allocation when the frame is already float64, the old code was inert, and we can simply do data = data.astype(np.float64) and skip the version check. This also avoids introducing the packaging dependency.

Let me know if you need help with that!

Pandas 4 removes the deprecated `copy` keyword of DataFrame.astype.
`copy=False` was inert here — it can only skip an allocation when the
frame is already float64 — so the plain cast behaves identically on
pandas 2 and 3. Changelog entry moved to a new 1.4.6 (future) section.

Co-Authored-By: Claude <noreply@anthropic.com>
@xyf5432
xyf5432 force-pushed the fix/pandas3-astype-copy-deprecation branch from 5a3c368 to bf9d7c3 Compare August 25, 2026 01:05
@xyf5432 xyf5432 changed the title Guard deprecated astype copy keyword by pandas version in from_fcs Drop deprecated copy keyword from astype call in from_fcs Aug 25, 2026
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.

astype(..., copy=False) in from_fcs emits Pandas4Warning on pandas ≥3.0 — drop the deprecated copy keyword

2 participants