ashlr-plugin 1.36.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +39 -0
- package/.claude-plugin/plugin.json +36 -0
- package/.codex/agents/README.md +9 -0
- package/.codex/agents/ashlr-explorer.md +36 -0
- package/.codex/agents/ashlr-worker.md +38 -0
- package/.codex-plugin/plugin.json +45 -0
- package/.mcp.json +14 -0
- package/LICENSE +21 -0
- package/README.md +311 -0
- package/agents/ashlr-code.md +69 -0
- package/agents/ashlr-explore.md +44 -0
- package/agents/ashlr-plan.md +54 -0
- package/bench/fixtures/notebook-large.ipynb +660 -0
- package/bench/fixtures/notebook-small.ipynb +39 -0
- package/bench/fixtures/tasklist-closed.json +62 -0
- package/bench/fixtures/tasklist-large-mixed.json +27 -0
- package/bench/fixtures/tasklist-sprint-open.json +79 -0
- package/bench/fixtures/websearch-bun-runtime.json +32 -0
- package/bench/fixtures/websearch-react-hooks-patterns.json +32 -0
- package/bench/fixtures/websearch-typescript-generics.json +38 -0
- package/bench/refs/node-sdk/.refrev +1 -0
- package/bench/refs/node-sdk/README.md +17 -0
- package/bench/refs/node-sdk/src/agent/agent.ts +163 -0
- package/bench/refs/node-sdk/src/agent/create-agent-ui-stream.ts +83 -0
- package/bench/refs/node-sdk/src/agent/tool-loop-agent.ts +238 -0
- package/bench/refs/node-sdk/src/embed/embed-many.ts +409 -0
- package/bench/refs/node-sdk/src/embed/embed-result.ts +50 -0
- package/bench/refs/node-sdk/src/embed/embed.ts +257 -0
- package/bench/refs/node-sdk/src/error/invalid-argument-error.ts +34 -0
- package/bench/refs/node-sdk/src/error/invalid-tool-input-error.ts +33 -0
- package/bench/refs/node-sdk/src/error/no-object-generated-error.ts +70 -0
- package/bench/refs/node-sdk/src/generate-image/generate-image-result.ts +42 -0
- package/bench/refs/node-sdk/src/generate-image/generate-image.ts +362 -0
- package/bench/refs/node-sdk/src/generate-object/generate-object-result.ts +67 -0
- package/bench/refs/node-sdk/src/generate-object/generate-object.ts +501 -0
- package/bench/refs/node-sdk/src/generate-object/inject-json-instruction.ts +30 -0
- package/bench/refs/node-sdk/src/generate-object/output-strategy.ts +415 -0
- package/bench/refs/node-sdk/src/generate-object/repair-text.ts +12 -0
- package/bench/refs/node-sdk/src/generate-object/stream-object.ts +960 -0
- package/bench/refs/node-sdk/src/generate-speech/generate-speech.ts +191 -0
- package/bench/refs/node-sdk/src/generate-text/generate-text.ts +1484 -0
- package/bench/refs/node-sdk/src/generate-text/stream-text.ts +2708 -0
- package/bench/refs/node-sdk/src/generate-text/tool-call.ts +59 -0
- package/bench/refs/node-sdk/src/generate-text/tool-result.ts +36 -0
- package/bench/refs/node-sdk/src/telemetry/create-telemetry-dispatcher.ts +146 -0
- package/bench/refs/node-sdk/src/telemetry/telemetry-registry.ts +15 -0
- package/bench/refs/node-sdk/src/telemetry/telemetry.ts +223 -0
- package/bench/refs/node-sdk/src/util/async-iterable-stream.ts +94 -0
- package/bench/refs/node-sdk/src/util/consume-stream.ts +31 -0
- package/bench/refs/node-sdk/src/util/create-stitchable-stream.ts +112 -0
- package/bench/refs/node-sdk/src/util/download/download.ts +74 -0
- package/bench/refs/node-sdk/src/util/error-handler.ts +1 -0
- package/bench/refs/node-sdk/src/util/fix-json.ts +401 -0
- package/bench/refs/node-sdk/src/util/merge-objects.ts +79 -0
- package/bench/refs/python-lib/.refrev +1 -0
- package/bench/refs/python-lib/README.md +18 -0
- package/bench/refs/python-lib/pandas/core/_numba/executor.py +249 -0
- package/bench/refs/python-lib/pandas/core/_numba/extensions.py +586 -0
- package/bench/refs/python-lib/pandas/core/_numba/kernels/mean_.py +198 -0
- package/bench/refs/python-lib/pandas/core/_numba/kernels/min_max_.py +178 -0
- package/bench/refs/python-lib/pandas/core/_numba/kernels/sum_.py +255 -0
- package/bench/refs/python-lib/pandas/core/_numba/kernels/var_.py +251 -0
- package/bench/refs/python-lib/pandas/core/accessor.py +520 -0
- package/bench/refs/python-lib/pandas/core/api.py +138 -0
- package/bench/refs/python-lib/pandas/core/array_algos/masked_accumulations.py +97 -0
- package/bench/refs/python-lib/pandas/core/array_algos/masked_reductions.py +252 -0
- package/bench/refs/python-lib/pandas/core/array_algos/putmask.py +150 -0
- package/bench/refs/python-lib/pandas/core/array_algos/quantile.py +232 -0
- package/bench/refs/python-lib/pandas/core/array_algos/replace.py +159 -0
- package/bench/refs/python-lib/pandas/core/array_algos/take.py +609 -0
- package/bench/refs/python-lib/pandas/core/arraylike.py +534 -0
- package/bench/refs/python-lib/pandas/core/arrays/_arrow_string_mixins.py +434 -0
- package/bench/refs/python-lib/pandas/core/arrays/_mixins.py +630 -0
- package/bench/refs/python-lib/pandas/core/arrays/_ranges.py +276 -0
- package/bench/refs/python-lib/pandas/core/arrays/_utils.py +77 -0
- package/bench/refs/python-lib/pandas/core/arrays/arrow/accessors.py +521 -0
- package/bench/refs/python-lib/pandas/core/arrays/arrow/extension_types.py +174 -0
- package/bench/refs/python-lib/pandas/core/arrays/boolean.py +454 -0
- package/bench/refs/python-lib/pandas/core/arrays/floating.py +192 -0
- package/bench/refs/python-lib/pandas/core/arrays/integer.py +296 -0
- package/bench/refs/python-lib/pandas/core/arrays/masked.py +2140 -0
- package/bench/refs/python-lib/pandas/core/arrays/numeric.py +305 -0
- package/bench/refs/python-lib/pandas/core/arrays/numpy_.py +701 -0
- package/bench/refs/python-lib/pandas/core/arrays/period.py +1586 -0
- package/bench/refs/python-lib/pandas/core/arrays/sparse/accessor.py +505 -0
- package/bench/refs/python-lib/pandas/core/arrays/sparse/scipy_sparse.py +208 -0
- package/bench/refs/rust-project/.refrev +1 -0
- package/bench/refs/rust-project/README.md +17 -0
- package/bench/refs/rust-project/tokio/src/doc/os.rs +68 -0
- package/bench/refs/rust-project/tokio/src/fs/dir_builder.rs +129 -0
- package/bench/refs/rust-project/tokio/src/fs/file.rs +1113 -0
- package/bench/refs/rust-project/tokio/src/fs/mocks.rs +176 -0
- package/bench/refs/rust-project/tokio/src/fs/mod.rs +324 -0
- package/bench/refs/rust-project/tokio/src/fs/open_options.rs +856 -0
- package/bench/refs/rust-project/tokio/src/fs/read.rs +80 -0
- package/bench/refs/rust-project/tokio/src/fs/read_dir.rs +357 -0
- package/bench/refs/rust-project/tokio/src/fs/write.rs +99 -0
- package/bench/refs/rust-project/tokio/src/future/maybe_done.rs +123 -0
- package/bench/refs/rust-project/tokio/src/future/try_join.rs +82 -0
- package/bench/refs/rust-project/tokio/src/io/async_buf_read.rs +117 -0
- package/bench/refs/rust-project/tokio/src/io/async_read.rs +133 -0
- package/bench/refs/rust-project/tokio/src/io/async_seek.rs +96 -0
- package/bench/refs/rust-project/tokio/src/io/async_write.rs +402 -0
- package/bench/refs/rust-project/tokio/src/io/blocking.rs +339 -0
- package/bench/refs/rust-project/tokio/src/io/interest.rs +345 -0
- package/bench/refs/rust-project/tokio/src/io/join.rs +130 -0
- package/bench/refs/rust-project/tokio/src/io/mod.rs +308 -0
- package/bench/refs/rust-project/tokio/src/io/poll_evented.rs +319 -0
- package/bench/refs/rust-project/tokio/src/io/read_buf.rs +344 -0
- package/bench/refs/rust-project/tokio/src/io/ready.rs +322 -0
- package/bench/refs/rust-project/tokio/src/io/split.rs +166 -0
- package/bench/refs/rust-project/tokio/src/io/stderr.rs +148 -0
- package/bench/refs/rust-project/tokio/src/io/stdin.rs +98 -0
- package/bench/refs/rust-project/tokio/src/io/stdio_common.rs +222 -0
- package/bench/refs/rust-project/tokio/src/io/stdout.rs +197 -0
- package/bench/refs/rust-project/tokio/src/io/util/buf_reader.rs +311 -0
- package/bench/refs/rust-project/tokio/src/io/util/buf_stream.rs +207 -0
- package/bench/refs/rust-project/tokio/src/io/util/buf_writer.rs +310 -0
- package/bench/refs/rust-project/tokio/src/io/util/chain.rs +144 -0
- package/commands/_spawn-patterns.json +32 -0
- package/commands/ashlr-allow.md +21 -0
- package/commands/ashlr-benchmark.md +53 -0
- package/commands/ashlr-brief.md +97 -0
- package/commands/ashlr-budget.md +76 -0
- package/commands/ashlr-compact.md +54 -0
- package/commands/ashlr-dashboard.md +37 -0
- package/commands/ashlr-doctor.md +56 -0
- package/commands/ashlr-eco-mode.md +92 -0
- package/commands/ashlr-genome-init.md +24 -0
- package/commands/ashlr-genome-keygen.md +36 -0
- package/commands/ashlr-genome-loop.md +118 -0
- package/commands/ashlr-genome-push.md +36 -0
- package/commands/ashlr-genome-rewrap.md +48 -0
- package/commands/ashlr-genome-team-init.md +67 -0
- package/commands/ashlr-handoff.md +23 -0
- package/commands/ashlr-help.md +86 -0
- package/commands/ashlr-hook-timings.md +30 -0
- package/commands/ashlr-leaderboard.md +50 -0
- package/commands/ashlr-ollama-setup.md +39 -0
- package/commands/ashlr-orchestrate-status.md +72 -0
- package/commands/ashlr-orchestrate.md +83 -0
- package/commands/ashlr-parallelize.md +63 -0
- package/commands/ashlr-report-crash.md +33 -0
- package/commands/ashlr-resume.md +72 -0
- package/commands/ashlr-savings.md +24 -0
- package/commands/ashlr-settings.md +50 -0
- package/commands/ashlr-spawn.md +61 -0
- package/commands/ashlr-start.md +60 -0
- package/commands/ashlr-status.md +64 -0
- package/commands/ashlr-team-invite.md +47 -0
- package/commands/ashlr-tier.md +122 -0
- package/commands/ashlr-tour.md +60 -0
- package/commands/ashlr-update.md +155 -0
- package/commands/ashlr-upgrade.md +96 -0
- package/commands/goal.md +58 -0
- package/commands/loop.md +40 -0
- package/docs/CNAME +1 -0
- package/docs/PRO_TIER.md +104 -0
- package/docs/README.md +21 -0
- package/docs/architecture.md +415 -0
- package/docs/ashlr-pipe.md +161 -0
- package/docs/assets/logo.svg +19 -0
- package/docs/assets/og.png +0 -0
- package/docs/assets/og.svg +41 -0
- package/docs/benchmarks-v2.json +355 -0
- package/docs/benchmarks.json +102 -0
- package/docs/benchmarks.md +211 -0
- package/docs/billing.md +185 -0
- package/docs/cloud-genome.md +155 -0
- package/docs/competitive-wozcode.md +92 -0
- package/docs/deploy.md +325 -0
- package/docs/email-templates.md +113 -0
- package/docs/embed-tuning.md +103 -0
- package/docs/genome.md +120 -0
- package/docs/github-oauth-onboarding.md +127 -0
- package/docs/hero-video-script.md +129 -0
- package/docs/index.html +2262 -0
- package/docs/install-prompt.md +78 -0
- package/docs/install-windows.md +132 -0
- package/docs/install.ps1 +171 -0
- package/docs/install.sh +146 -0
- package/docs/launch/README.md +114 -0
- package/docs/launch/hn.md +49 -0
- package/docs/launch/reddit.md +45 -0
- package/docs/launch/x.md +65 -0
- package/docs/launch-post.md +112 -0
- package/docs/legal.md +78 -0
- package/docs/llm-providers.md +99 -0
- package/docs/multi-host-mcp.md +217 -0
- package/docs/multi-turn-architecture.md +108 -0
- package/docs/operations/deployment.md +108 -0
- package/docs/operations/error-monitoring.md +70 -0
- package/docs/operations/weekly-digest.md +70 -0
- package/docs/operations.md +494 -0
- package/docs/platform-support.md +133 -0
- package/docs/policy-packs.md +188 -0
- package/docs/press-kit/fact-sheet.md +78 -0
- package/docs/press-kit/founder-bio.md +3 -0
- package/docs/press-kit/logo.svg +33 -0
- package/docs/press-kit/screenshots.md +146 -0
- package/docs/pricing.md +251 -0
- package/docs/pro-backend-architecture.md +523 -0
- package/docs/producthunt.md +52 -0
- package/docs/router-migration.md +110 -0
- package/docs/session-log-schema.md +68 -0
- package/docs/social.md +95 -0
- package/docs/team-genome.md +528 -0
- package/docs/telemetry.md +194 -0
- package/docs/test-isolation.md +100 -0
- package/docs/upgrade.md +159 -0
- package/hooks/_hook-errors.ts +87 -0
- package/hooks/_hook-perf-emit.ts +113 -0
- package/hooks/_hook-timing-ledger.ts +1133 -0
- package/hooks/_nudge-throttle.ts +127 -0
- package/hooks/_recent-blocks.ts +127 -0
- package/hooks/audit-upload.ts +86 -0
- package/hooks/codex-hooks.json +171 -0
- package/hooks/commit-attribution.ts +179 -0
- package/hooks/edit-batching-nudge.ts +154 -0
- package/hooks/genome-scribe-hook.ts +219 -0
- package/hooks/hooks.json +294 -0
- package/hooks/orient-nudge-hook.ts +242 -0
- package/hooks/policy-enforce.ts +214 -0
- package/hooks/post-tool-use-embedding.ts +93 -0
- package/hooks/post-tool-use-genome.sh +37 -0
- package/hooks/post-tool-use-genome.ts +69 -0
- package/hooks/posttooluse-correlate.ts +122 -0
- package/hooks/posttooluse-dedupe-output.ts +241 -0
- package/hooks/posttooluse-genome-refresh.ts +223 -0
- package/hooks/posttooluse-native-nudge.ts +205 -0
- package/hooks/posttooluse-stale-result.ts +277 -0
- package/hooks/pretooluse-bash.ts +63 -0
- package/hooks/pretooluse-budget-guard.ts +318 -0
- package/hooks/pretooluse-common.ts +985 -0
- package/hooks/pretooluse-eco-router.ts +196 -0
- package/hooks/pretooluse-edit.sh +93 -0
- package/hooks/pretooluse-edit.ts +197 -0
- package/hooks/pretooluse-glob.ts +70 -0
- package/hooks/pretooluse-grep.sh +85 -0
- package/hooks/pretooluse-grep.ts +96 -0
- package/hooks/pretooluse-notebookedit.ts +121 -0
- package/hooks/pretooluse-read.sh +118 -0
- package/hooks/pretooluse-read.ts +118 -0
- package/hooks/pretooluse-task.ts +130 -0
- package/hooks/pretooluse-webfetch.ts +66 -0
- package/hooks/pretooluse-websearch.ts +85 -0
- package/hooks/pretooluse-write.ts +128 -0
- package/hooks/pulse-emit.ts +197 -0
- package/hooks/session-end-consolidate.sh +35 -0
- package/hooks/session-end-consolidate.ts +188 -0
- package/hooks/session-end-stats-gc.ts +80 -0
- package/hooks/session-log-append.sh +94 -0
- package/hooks/session-log-append.ts +116 -0
- package/hooks/session-start.ts +993 -0
- package/hooks/sessionend-hook-health-nudge.ts +451 -0
- package/hooks/sessionend-savings-nudge.ts +318 -0
- package/hooks/sessionend-status-line-nudge.ts +296 -0
- package/hooks/sessionstart-brief.ts +140 -0
- package/hooks/sessionstart-cost-refactor.ts +95 -0
- package/hooks/sessionstart-efficient.ts +110 -0
- package/hooks/sessionstart-genome-author.ts +93 -0
- package/hooks/sessionstart-lean-tools.ts +98 -0
- package/hooks/sessionstart-search.ts +97 -0
- package/hooks/stop-accounting.ts +152 -0
- package/hooks/subagent-stop-rollup.ts +162 -0
- package/hooks/userpromptsubmit-brief-trigger.ts +156 -0
- package/package.json +56 -0
- package/ports/README.md +108 -0
- package/ports/cursor/mcp.json +11 -0
- package/ports/goose/recipe.yaml +26 -0
- package/scripts/ashlr-mcp.ts +40 -0
- package/scripts/auto-update.ts +177 -0
- package/scripts/baseline-scan.ts +831 -0
- package/scripts/bench-orchestrate.ts +377 -0
- package/scripts/benchmark-refs.ts +292 -0
- package/scripts/bootstrap.mjs +100 -0
- package/scripts/brief-eval.ts +234 -0
- package/scripts/bump-version.ts +82 -0
- package/scripts/bun-resolve.d.mts +11 -0
- package/scripts/bun-resolve.mjs +59 -0
- package/scripts/calibrate-grep.ts +467 -0
- package/scripts/capture-grep-workload.ts +260 -0
- package/scripts/check-tier.ts +61 -0
- package/scripts/check-version-sync.ts +97 -0
- package/scripts/cli-orchestrate-status.ts +386 -0
- package/scripts/cli-orchestrate.ts +303 -0
- package/scripts/cli.ts +478 -0
- package/scripts/cloud-smoke-test.ts +313 -0
- package/scripts/coach-report.ts +373 -0
- package/scripts/context-db-migrate.ts +137 -0
- package/scripts/context-status.ts +43 -0
- package/scripts/demo-run.ts +255 -0
- package/scripts/deploy-smoke.sh +140 -0
- package/scripts/doctor.ts +992 -0
- package/scripts/embed-file-worker.ts +104 -0
- package/scripts/embed-tune.ts +308 -0
- package/scripts/errors-report.ts +428 -0
- package/scripts/find-test-leak.ts +69 -0
- package/scripts/generate-badge.ts +357 -0
- package/scripts/genome-auto-consolidate.ts +533 -0
- package/scripts/genome-auto-propose.ts +578 -0
- package/scripts/genome-cloud-pull.ts +363 -0
- package/scripts/genome-cloud-push.ts +382 -0
- package/scripts/genome-cloud-sync.ts +587 -0
- package/scripts/genome-commit-watcher.ts +295 -0
- package/scripts/genome-init.ts +986 -0
- package/scripts/genome-key.ts +233 -0
- package/scripts/genome-keygen.ts +168 -0
- package/scripts/genome-link.ts +59 -0
- package/scripts/genome-refresh-worker.ts +364 -0
- package/scripts/genome-rewrap.ts +90 -0
- package/scripts/genome-synthesizer.ts +679 -0
- package/scripts/genome-team-init.ts +312 -0
- package/scripts/handoff-pack.ts +438 -0
- package/scripts/hook-bootstrap.mjs +75 -0
- package/scripts/hook-timing-reader.ts +371 -0
- package/scripts/hook-timings-report.ts +554 -0
- package/scripts/install-genome-hooks.ts +196 -0
- package/scripts/install-onnx-model.ts +154 -0
- package/scripts/install-permissions.ts +276 -0
- package/scripts/install-status-line.ts +150 -0
- package/scripts/mcp-entrypoint.sh +78 -0
- package/scripts/mcp-entrypoint.ts +130 -0
- package/scripts/mdx-angle-bracket-lint.ts +152 -0
- package/scripts/measure-cold-start.ts +126 -0
- package/scripts/migrate-stats-to-sqlite.ts +86 -0
- package/scripts/ollama-setup.ts +498 -0
- package/scripts/onboarding-wizard.ts +1691 -0
- package/scripts/orchestrate-emit-telemetry.ts +177 -0
- package/scripts/orchestrate-expand.ts +517 -0
- package/scripts/orchestrate-run.ts +744 -0
- package/scripts/print-legend.ts +50 -0
- package/scripts/product-metadata.ts +38 -0
- package/scripts/prune-old-memories.ts +208 -0
- package/scripts/publish.sh +88 -0
- package/scripts/read-calibration.ts +122 -0
- package/scripts/report-crash.ts +226 -0
- package/scripts/run-benchmark.ts +750 -0
- package/scripts/run-root-tests.ts +28 -0
- package/scripts/savings-dashboard.ts +1258 -0
- package/scripts/savings-report-extras.ts +447 -0
- package/scripts/savings-status-line.ts +873 -0
- package/scripts/session-event-emit.ts +266 -0
- package/scripts/session-greet.ts +686 -0
- package/scripts/session-log-report.ts +551 -0
- package/scripts/session-resume.ts +614 -0
- package/scripts/set-hook-mode.ts +83 -0
- package/scripts/smoke-cross-platform.ts +117 -0
- package/scripts/smoke-realtime.ts +257 -0
- package/scripts/smoke-tools.ts +21 -0
- package/scripts/stats-cloud-pull.ts +213 -0
- package/scripts/stats-cloud-sync.ts +261 -0
- package/scripts/telemetry-flush.ts +160 -0
- package/scripts/telemetry-status.ts +266 -0
- package/scripts/timing-budget.ts +35 -0
- package/scripts/ui-animation.ts +120 -0
- package/scripts/ui.ts +431 -0
- package/scripts/upgrade-flow.ts +775 -0
- package/scripts/weekly-digest.ts +394 -0
- package/servers/_accounting.ts +78 -0
- package/servers/_ask-router.ts +84 -0
- package/servers/_ast-chunker.ts +434 -0
- package/servers/_ast-helpers.ts +183 -0
- package/servers/_ast-languages.ts +153 -0
- package/servers/_ast-refactor/_shared.ts +221 -0
- package/servers/_ast-refactor/cross-file-rename.ts +560 -0
- package/servers/_ast-refactor/extract-function.ts +357 -0
- package/servers/_ast-refactor/file-local-rename.ts +172 -0
- package/servers/_ast-refactor.ts +41 -0
- package/servers/_ast-skeleton.ts +107 -0
- package/servers/_bash-summarizers-registry.ts +1096 -0
- package/servers/_crash-dump.ts +210 -0
- package/servers/_cwd-clamp.ts +342 -0
- package/servers/_edit-log.ts +28 -0
- package/servers/_edit-match.ts +236 -0
- package/servers/_edit-validate.ts +196 -0
- package/servers/_embed-calibration.ts +123 -0
- package/servers/_embedding-cache.ts +401 -0
- package/servers/_embedding-model.ts +329 -0
- package/servers/_events.ts +113 -0
- package/servers/_genome-cache.ts +154 -0
- package/servers/_genome-commits.ts +172 -0
- package/servers/_genome-crypto-v2.ts +242 -0
- package/servers/_genome-crypto.ts +259 -0
- package/servers/_genome-discoveries.ts +140 -0
- package/servers/_genome-embed-populator.ts +216 -0
- package/servers/_genome-freshness.ts +134 -0
- package/servers/_genome-issues.ts +171 -0
- package/servers/_genome-live.ts +263 -0
- package/servers/_genome-prs.ts +188 -0
- package/servers/_genome-search.ts +479 -0
- package/servers/_genome-sync.ts +297 -0
- package/servers/_history-tracker.ts +279 -0
- package/servers/_http-helpers.ts +151 -0
- package/servers/_identity-hash.ts +151 -0
- package/servers/_llm-providers/anthropic.ts +132 -0
- package/servers/_llm-providers/cloud.ts +195 -0
- package/servers/_llm-providers/index.ts +350 -0
- package/servers/_llm-providers/local.ts +127 -0
- package/servers/_llm-providers/onnx.ts +393 -0
- package/servers/_llm-providers/types.ts +27 -0
- package/servers/_manifest-v2.ts +447 -0
- package/servers/_mcp-host.ts +93 -0
- package/servers/_nudge-events.ts +451 -0
- package/servers/_orchestrate-executor.ts +316 -0
- package/servers/_prefetch.ts +435 -0
- package/servers/_pricing.ts +256 -0
- package/servers/_pro.ts +381 -0
- package/servers/_read-cache.ts +44 -0
- package/servers/_router-handlers.ts +46 -0
- package/servers/_router.ts +55 -0
- package/servers/_run-with-timeout.ts +173 -0
- package/servers/_savings-render.ts +214 -0
- package/servers/_stats-sqlite.ts +640 -0
- package/servers/_stats.ts +1183 -0
- package/servers/_status-line-cells.ts +469 -0
- package/servers/_streaks.ts +162 -0
- package/servers/_summarize.ts +208 -0
- package/servers/_task-graph-render.ts +217 -0
- package/servers/_task-graph.ts +545 -0
- package/servers/_telemetry.ts +719 -0
- package/servers/_test-parsers.ts +530 -0
- package/servers/_test-watch.ts +626 -0
- package/servers/_text-helpers.ts +37 -0
- package/servers/_token-measure.ts +160 -0
- package/servers/_tool-base.ts +248 -0
- package/servers/_weekly-digest.ts +391 -0
- package/servers/ask-server-handlers.ts +49 -0
- package/servers/ask-server.ts +174 -0
- package/servers/bash-server-handlers.ts +138 -0
- package/servers/bash-server.ts +1136 -0
- package/servers/bench.ts +186 -0
- package/servers/diff-semantic-server-handlers.ts +39 -0
- package/servers/diff-semantic-server.ts +566 -0
- package/servers/diff-server-handlers.ts +317 -0
- package/servers/diff-server.ts +20 -0
- package/servers/edit-server-handlers.ts +31 -0
- package/servers/edit-server.ts +209 -0
- package/servers/edit-structural-server-handlers.ts +322 -0
- package/servers/efficiency-server-handlers.ts +161 -0
- package/servers/efficiency-server.ts +1135 -0
- package/servers/flush-server-handlers.ts +21 -0
- package/servers/flush-server.ts +19 -0
- package/servers/genome-server-handlers.ts +118 -0
- package/servers/genome-server.ts +397 -0
- package/servers/github-server-handlers.ts +187 -0
- package/servers/github-server.ts +856 -0
- package/servers/glob-server-handlers.ts +233 -0
- package/servers/glob-server.ts +20 -0
- package/servers/grep-server-handlers.ts +61 -0
- package/servers/grep-server.ts +564 -0
- package/servers/http-server-handlers.ts +36 -0
- package/servers/http-server.ts +149 -0
- package/servers/logs-server-handlers.ts +42 -0
- package/servers/logs-server.ts +359 -0
- package/servers/ls-server-handlers.ts +166 -0
- package/servers/ls-server.ts +20 -0
- package/servers/multi-edit-server-handlers.ts +51 -0
- package/servers/multi-edit-server.ts +422 -0
- package/servers/notebook-edit-server-handlers.ts +34 -0
- package/servers/notebook-edit-server.ts +181 -0
- package/servers/orient-server-handlers.ts +52 -0
- package/servers/orient-server.ts +436 -0
- package/servers/pipe-server-handlers.ts +68 -0
- package/servers/pipe-server.ts +300 -0
- package/servers/read-server-handlers.ts +42 -0
- package/servers/read-server.ts +206 -0
- package/servers/rename-file-server-handlers.ts +67 -0
- package/servers/rename-file-server.ts +699 -0
- package/servers/savings-server-handlers.ts +27 -0
- package/servers/savings-server.ts +54 -0
- package/servers/search-replace-regex-server-handlers.ts +96 -0
- package/servers/search-replace-regex-server.ts +751 -0
- package/servers/sql-server-handlers.ts +58 -0
- package/servers/sql-server.ts +505 -0
- package/servers/task-server-handlers.ts +358 -0
- package/servers/task-server.ts +24 -0
- package/servers/test-server-handlers.ts +351 -0
- package/servers/test-server.ts +20 -0
- package/servers/tree-server-handlers.ts +503 -0
- package/servers/tree-server.ts +20 -0
- package/servers/webfetch-server-handlers.ts +166 -0
- package/servers/webfetch-server.ts +20 -0
- package/servers/websearch-server-handlers.ts +215 -0
- package/servers/websearch-server.ts +19 -0
- package/servers/write-server-handlers.ts +27 -0
- package/servers/write-server.ts +97 -0
- package/skills/ashlr-brief/SKILL.md +80 -0
- package/skills/ashlr-codex-doctor/SKILL.md +21 -0
- package/skills/ashlr-codex-efficient-tools/SKILL.md +17 -0
- package/skills/ashlr-codex-genome-refresh/SKILL.md +20 -0
- package/skills/ashlr-codex-parallel-explore/SKILL.md +20 -0
- package/skills/ashlr-codex-savings/SKILL.md +17 -0
- package/skills/ashlr-cost-refactor/SKILL.md +50 -0
- package/skills/ashlr-efficient/SKILL.md +64 -0
- package/skills/ashlr-genome-author/SKILL.md +43 -0
- package/skills/ashlr-lean-tools/SKILL.md +43 -0
- package/skills/ashlr-search/SKILL.md +46 -0
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import functools
|
|
4
|
+
from typing import (
|
|
5
|
+
TYPE_CHECKING,
|
|
6
|
+
cast,
|
|
7
|
+
overload,
|
|
8
|
+
)
|
|
9
|
+
import warnings
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
from pandas._libs import (
|
|
14
|
+
algos as libalgos,
|
|
15
|
+
lib,
|
|
16
|
+
)
|
|
17
|
+
from pandas.errors import Pandas4Warning
|
|
18
|
+
from pandas.util._exceptions import find_stack_level
|
|
19
|
+
|
|
20
|
+
from pandas.core.dtypes.cast import maybe_promote
|
|
21
|
+
from pandas.core.dtypes.common import (
|
|
22
|
+
ensure_platform_int,
|
|
23
|
+
is_1d_only_ea_dtype,
|
|
24
|
+
)
|
|
25
|
+
from pandas.core.dtypes.missing import na_value_for_dtype
|
|
26
|
+
|
|
27
|
+
from pandas.core.construction import ensure_wrapped_if_datetimelike
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
from pandas._typing import (
|
|
31
|
+
ArrayLike,
|
|
32
|
+
AxisInt,
|
|
33
|
+
npt,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
from pandas.core.arrays._mixins import NDArrayBackedExtensionArray
|
|
37
|
+
from pandas.core.arrays.base import ExtensionArray
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@overload
|
|
41
|
+
def take_nd(
|
|
42
|
+
arr: np.ndarray,
|
|
43
|
+
indexer,
|
|
44
|
+
axis: AxisInt = ...,
|
|
45
|
+
fill_value=...,
|
|
46
|
+
allow_fill: bool = ...,
|
|
47
|
+
) -> np.ndarray: ...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@overload
|
|
51
|
+
def take_nd(
|
|
52
|
+
arr: ExtensionArray,
|
|
53
|
+
indexer,
|
|
54
|
+
axis: AxisInt = ...,
|
|
55
|
+
fill_value=...,
|
|
56
|
+
allow_fill: bool = ...,
|
|
57
|
+
) -> ArrayLike: ...
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def take_nd(
|
|
61
|
+
arr: ArrayLike,
|
|
62
|
+
indexer,
|
|
63
|
+
axis: AxisInt = 0,
|
|
64
|
+
fill_value=lib.no_default,
|
|
65
|
+
allow_fill: bool = True,
|
|
66
|
+
) -> ArrayLike:
|
|
67
|
+
"""
|
|
68
|
+
Specialized Cython take which sets NaN values in one pass
|
|
69
|
+
|
|
70
|
+
This dispatches to ``take`` defined on ExtensionArrays.
|
|
71
|
+
|
|
72
|
+
Note: this function assumes that the indexer is a valid(ated) indexer with
|
|
73
|
+
no out of bound indices.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
arr : np.ndarray or ExtensionArray
|
|
78
|
+
Input array.
|
|
79
|
+
indexer : ndarray
|
|
80
|
+
1-D array of indices to take, subarrays corresponding to -1 value
|
|
81
|
+
indices are filed with fill_value
|
|
82
|
+
axis : int, default 0
|
|
83
|
+
Axis to take from
|
|
84
|
+
fill_value : any, default np.nan
|
|
85
|
+
Fill value to replace -1 values with
|
|
86
|
+
allow_fill : bool, default True
|
|
87
|
+
If False, indexer is assumed to contain no -1 values so no filling
|
|
88
|
+
will be done. This short-circuits computation of a mask. Result is
|
|
89
|
+
undefined if allow_fill == False and -1 is present in indexer.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
subarray : np.ndarray or ExtensionArray
|
|
94
|
+
May be the same type as the input, or cast to an ndarray.
|
|
95
|
+
"""
|
|
96
|
+
if fill_value is lib.no_default:
|
|
97
|
+
fill_value = na_value_for_dtype(arr.dtype, compat=False)
|
|
98
|
+
elif lib.is_np_dtype(arr.dtype, "mM"):
|
|
99
|
+
dtype, fill_value = maybe_promote(arr.dtype, fill_value)
|
|
100
|
+
if dtype != arr.dtype:
|
|
101
|
+
# GH#53910
|
|
102
|
+
warnings.warn(
|
|
103
|
+
"reindexing with a fill_value that cannot be held by the "
|
|
104
|
+
"original dtype is deprecated. Explicitly cast to a common "
|
|
105
|
+
f"dtype (in this case {dtype}) instead.",
|
|
106
|
+
Pandas4Warning,
|
|
107
|
+
stacklevel=find_stack_level(),
|
|
108
|
+
)
|
|
109
|
+
if arr.dtype != dtype:
|
|
110
|
+
# EA.take is strict about returning a new object of the same type
|
|
111
|
+
# so for that case cast upfront
|
|
112
|
+
arr = arr.astype(dtype)
|
|
113
|
+
|
|
114
|
+
if not isinstance(arr, np.ndarray):
|
|
115
|
+
# i.e. ExtensionArray,
|
|
116
|
+
# includes for EA to catch DatetimeArray, TimedeltaArray
|
|
117
|
+
if not is_1d_only_ea_dtype(arr.dtype):
|
|
118
|
+
# i.e. DatetimeArray, TimedeltaArray
|
|
119
|
+
arr = cast("NDArrayBackedExtensionArray", arr)
|
|
120
|
+
return arr.take(
|
|
121
|
+
indexer, fill_value=fill_value, allow_fill=allow_fill, axis=axis
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
return arr.take(indexer, fill_value=fill_value, allow_fill=allow_fill)
|
|
125
|
+
|
|
126
|
+
arr = np.asarray(arr)
|
|
127
|
+
return _take_nd_ndarray(arr, indexer, axis, fill_value, allow_fill)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _take_nd_ndarray(
|
|
131
|
+
arr: np.ndarray,
|
|
132
|
+
indexer: npt.NDArray[np.intp] | None,
|
|
133
|
+
axis: AxisInt,
|
|
134
|
+
fill_value,
|
|
135
|
+
allow_fill: bool,
|
|
136
|
+
) -> np.ndarray:
|
|
137
|
+
if indexer is None:
|
|
138
|
+
indexer = np.arange(arr.shape[axis], dtype=np.intp)
|
|
139
|
+
dtype, fill_value = arr.dtype, arr.dtype.type()
|
|
140
|
+
else:
|
|
141
|
+
indexer = ensure_platform_int(indexer)
|
|
142
|
+
|
|
143
|
+
dtype, fill_value, mask_info = _take_preprocess_indexer_and_fill_value(
|
|
144
|
+
arr, indexer, fill_value, allow_fill
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
flip_order = False
|
|
148
|
+
if arr.ndim == 2 and arr.flags.f_contiguous:
|
|
149
|
+
flip_order = True
|
|
150
|
+
|
|
151
|
+
if flip_order:
|
|
152
|
+
arr = arr.T
|
|
153
|
+
axis = arr.ndim - axis - 1
|
|
154
|
+
|
|
155
|
+
# at this point, it's guaranteed that dtype can hold both the arr values
|
|
156
|
+
# and the fill_value
|
|
157
|
+
out_shape_ = list(arr.shape)
|
|
158
|
+
out_shape_[axis] = len(indexer)
|
|
159
|
+
out_shape = tuple(out_shape_)
|
|
160
|
+
if arr.flags.f_contiguous and axis == arr.ndim - 1:
|
|
161
|
+
# minor tweak that can make an order-of-magnitude difference
|
|
162
|
+
# for dataframes initialized directly from 2-d ndarrays
|
|
163
|
+
# (s.t. df.values is c-contiguous and df._mgr.blocks[0] is its
|
|
164
|
+
# f-contiguous transpose)
|
|
165
|
+
out = np.empty(out_shape, dtype=dtype, order="F")
|
|
166
|
+
else:
|
|
167
|
+
out = np.empty(out_shape, dtype=dtype)
|
|
168
|
+
|
|
169
|
+
func = _get_take_nd_function(
|
|
170
|
+
arr.ndim, arr.dtype, out.dtype, axis=axis, mask_info=mask_info
|
|
171
|
+
)
|
|
172
|
+
if mask_info is not None:
|
|
173
|
+
_, needs_fill = mask_info
|
|
174
|
+
else:
|
|
175
|
+
needs_fill = allow_fill
|
|
176
|
+
func(arr, indexer, out, fill_value, allow_fill=needs_fill)
|
|
177
|
+
|
|
178
|
+
if flip_order:
|
|
179
|
+
out = out.T
|
|
180
|
+
return out
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def take_2d_multi(
|
|
184
|
+
arr: np.ndarray,
|
|
185
|
+
indexer: tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]],
|
|
186
|
+
fill_value=np.nan,
|
|
187
|
+
) -> np.ndarray:
|
|
188
|
+
"""
|
|
189
|
+
Specialized Cython take which sets NaN values in one pass.
|
|
190
|
+
"""
|
|
191
|
+
# This is only called from one place in DataFrame._reindex_multi,
|
|
192
|
+
# so we know indexer is well-behaved.
|
|
193
|
+
assert indexer is not None
|
|
194
|
+
assert indexer[0] is not None
|
|
195
|
+
assert indexer[1] is not None
|
|
196
|
+
|
|
197
|
+
row_idx, col_idx = indexer
|
|
198
|
+
|
|
199
|
+
row_idx = ensure_platform_int(row_idx)
|
|
200
|
+
col_idx = ensure_platform_int(col_idx)
|
|
201
|
+
indexer = row_idx, col_idx
|
|
202
|
+
mask_info = None
|
|
203
|
+
|
|
204
|
+
if lib.is_float(fill_value) and fill_value.is_integer():
|
|
205
|
+
# Avoid warning if possible
|
|
206
|
+
fill_value = int(fill_value)
|
|
207
|
+
|
|
208
|
+
# check for promotion based on types only (do this first because
|
|
209
|
+
# it's faster than computing a mask)
|
|
210
|
+
dtype, fill_value = maybe_promote(arr.dtype, fill_value)
|
|
211
|
+
if dtype != arr.dtype:
|
|
212
|
+
# check if promotion is actually required based on indexer
|
|
213
|
+
row_mask = row_idx == -1
|
|
214
|
+
col_mask = col_idx == -1
|
|
215
|
+
row_needs = row_mask.any()
|
|
216
|
+
col_needs = col_mask.any()
|
|
217
|
+
mask_info = (row_mask, col_mask), (row_needs, col_needs)
|
|
218
|
+
|
|
219
|
+
if not (row_needs or col_needs):
|
|
220
|
+
# if not, then depromote, set fill_value to dummy
|
|
221
|
+
# (it won't be used but we don't want the cython code
|
|
222
|
+
# to crash when trying to cast it to dtype)
|
|
223
|
+
dtype, fill_value = arr.dtype, arr.dtype.type()
|
|
224
|
+
|
|
225
|
+
if dtype != arr.dtype and not (
|
|
226
|
+
arr.dtype.kind in "iub"
|
|
227
|
+
and lib.is_float(fill_value)
|
|
228
|
+
and np.isnan(fill_value)
|
|
229
|
+
):
|
|
230
|
+
# GH#53910
|
|
231
|
+
warnings.warn(
|
|
232
|
+
"reindexing with a fill_value that cannot be held by the "
|
|
233
|
+
"original dtype is deprecated. Explicitly cast to a common "
|
|
234
|
+
f"dtype (in this case {dtype}) instead.",
|
|
235
|
+
Pandas4Warning,
|
|
236
|
+
stacklevel=find_stack_level(),
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
# at this point, it's guaranteed that dtype can hold both the arr values
|
|
240
|
+
# and the fill_value
|
|
241
|
+
out_shape = len(row_idx), len(col_idx)
|
|
242
|
+
out = np.empty(out_shape, dtype=dtype)
|
|
243
|
+
|
|
244
|
+
func = _take_2d_multi_dict.get((arr.dtype.name, out.dtype.name), None)
|
|
245
|
+
if func is None and arr.dtype != out.dtype:
|
|
246
|
+
func = _take_2d_multi_dict.get((out.dtype.name, out.dtype.name), None)
|
|
247
|
+
if func is not None:
|
|
248
|
+
func = _convert_wrapper(func, out.dtype)
|
|
249
|
+
|
|
250
|
+
if mask_info is not None:
|
|
251
|
+
_, (row_needs, col_needs) = mask_info
|
|
252
|
+
needs_fill = row_needs or col_needs
|
|
253
|
+
else:
|
|
254
|
+
needs_fill = True
|
|
255
|
+
|
|
256
|
+
if func is not None:
|
|
257
|
+
func(arr, indexer, out=out, fill_value=fill_value, allow_fill=needs_fill)
|
|
258
|
+
else:
|
|
259
|
+
# test_reindex_multi
|
|
260
|
+
_take_2d_multi_object(
|
|
261
|
+
arr, indexer, out, fill_value=fill_value, mask_info=mask_info
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
return out
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@functools.lru_cache
|
|
268
|
+
def _get_take_nd_function_cached(
|
|
269
|
+
ndim: int, arr_dtype: np.dtype, out_dtype: np.dtype, axis: AxisInt
|
|
270
|
+
):
|
|
271
|
+
"""
|
|
272
|
+
Part of _get_take_nd_function below that doesn't need `mask_info` and thus
|
|
273
|
+
can be cached (mask_info potentially contains a numpy ndarray which is not
|
|
274
|
+
hashable and thus cannot be used as argument for cached function).
|
|
275
|
+
"""
|
|
276
|
+
tup = (arr_dtype.name, out_dtype.name)
|
|
277
|
+
if ndim == 1:
|
|
278
|
+
func = _take_1d_dict.get(tup, None)
|
|
279
|
+
elif ndim == 2:
|
|
280
|
+
if axis == 0:
|
|
281
|
+
func = _take_2d_axis0_dict.get(tup, None)
|
|
282
|
+
else:
|
|
283
|
+
func = _take_2d_axis1_dict.get(tup, None)
|
|
284
|
+
if func is not None:
|
|
285
|
+
return func
|
|
286
|
+
|
|
287
|
+
# We get here with string, uint, float16, and complex dtypes that could
|
|
288
|
+
# potentially be handled in algos_take_helper.
|
|
289
|
+
# Also a couple with (M8[ns], object) and (m8[ns], object)
|
|
290
|
+
tup = (out_dtype.name, out_dtype.name)
|
|
291
|
+
if ndim == 1:
|
|
292
|
+
func = _take_1d_dict.get(tup, None)
|
|
293
|
+
elif ndim == 2:
|
|
294
|
+
if axis == 0:
|
|
295
|
+
func = _take_2d_axis0_dict.get(tup, None)
|
|
296
|
+
else:
|
|
297
|
+
func = _take_2d_axis1_dict.get(tup, None)
|
|
298
|
+
if func is not None:
|
|
299
|
+
func = _convert_wrapper(func, out_dtype)
|
|
300
|
+
return func
|
|
301
|
+
|
|
302
|
+
return None
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def _get_take_nd_function(
|
|
306
|
+
ndim: int,
|
|
307
|
+
arr_dtype: np.dtype,
|
|
308
|
+
out_dtype: np.dtype,
|
|
309
|
+
axis: AxisInt = 0,
|
|
310
|
+
mask_info=None,
|
|
311
|
+
):
|
|
312
|
+
"""
|
|
313
|
+
Get the appropriate "take" implementation for the given dimension, axis
|
|
314
|
+
and dtypes.
|
|
315
|
+
"""
|
|
316
|
+
func = None
|
|
317
|
+
if ndim <= 2:
|
|
318
|
+
# for this part we don't need `mask_info` -> use the cached algo lookup
|
|
319
|
+
func = _get_take_nd_function_cached(ndim, arr_dtype, out_dtype, axis)
|
|
320
|
+
|
|
321
|
+
if func is None:
|
|
322
|
+
|
|
323
|
+
def func(arr, indexer, out, fill_value=np.nan, allow_fill: bool = True) -> None:
|
|
324
|
+
indexer = ensure_platform_int(indexer)
|
|
325
|
+
_take_nd_object(
|
|
326
|
+
arr, indexer, out, axis=axis, fill_value=fill_value, mask_info=mask_info
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
return func
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def _view_wrapper(f, arr_dtype=None, out_dtype=None, fill_wrap=None):
|
|
333
|
+
def wrapper(
|
|
334
|
+
arr: np.ndarray,
|
|
335
|
+
indexer: np.ndarray,
|
|
336
|
+
out: np.ndarray,
|
|
337
|
+
fill_value=np.nan,
|
|
338
|
+
allow_fill: bool = True,
|
|
339
|
+
) -> None:
|
|
340
|
+
if arr_dtype is not None:
|
|
341
|
+
arr = arr.view(arr_dtype)
|
|
342
|
+
if out_dtype is not None:
|
|
343
|
+
out = out.view(out_dtype)
|
|
344
|
+
if fill_wrap is not None:
|
|
345
|
+
# FIXME: if we get here with dt64/td64 we need to be sure we have
|
|
346
|
+
# matching resos
|
|
347
|
+
if fill_value.dtype.kind == "m":
|
|
348
|
+
fill_value = fill_value.astype("m8[ns]")
|
|
349
|
+
else:
|
|
350
|
+
fill_value = fill_value.astype("M8[ns]")
|
|
351
|
+
fill_value = fill_wrap(fill_value)
|
|
352
|
+
|
|
353
|
+
f(arr, indexer, out, fill_value=fill_value, allow_fill=allow_fill)
|
|
354
|
+
|
|
355
|
+
return wrapper
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def _convert_wrapper(f, conv_dtype):
|
|
359
|
+
def wrapper(
|
|
360
|
+
arr: np.ndarray,
|
|
361
|
+
indexer: np.ndarray,
|
|
362
|
+
out: np.ndarray,
|
|
363
|
+
fill_value=np.nan,
|
|
364
|
+
allow_fill: bool = True,
|
|
365
|
+
) -> None:
|
|
366
|
+
if conv_dtype == object:
|
|
367
|
+
# GH#39755 avoid casting dt64/td64 to integers
|
|
368
|
+
arr = ensure_wrapped_if_datetimelike(arr)
|
|
369
|
+
arr = arr.astype(conv_dtype)
|
|
370
|
+
f(arr, indexer, out, fill_value=fill_value, allow_fill=allow_fill)
|
|
371
|
+
|
|
372
|
+
return wrapper
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
_take_1d_dict = {
|
|
376
|
+
("int8", "int8"): libalgos.take_1d_int8_int8,
|
|
377
|
+
("int8", "int32"): libalgos.take_1d_int8_int32,
|
|
378
|
+
("int8", "int64"): libalgos.take_1d_int8_int64,
|
|
379
|
+
("int8", "float64"): libalgos.take_1d_int8_float64,
|
|
380
|
+
("int16", "int16"): libalgos.take_1d_int16_int16,
|
|
381
|
+
("int16", "int32"): libalgos.take_1d_int16_int32,
|
|
382
|
+
("int16", "int64"): libalgos.take_1d_int16_int64,
|
|
383
|
+
("int16", "float64"): libalgos.take_1d_int16_float64,
|
|
384
|
+
("int32", "int32"): libalgos.take_1d_int32_int32,
|
|
385
|
+
("int32", "int64"): libalgos.take_1d_int32_int64,
|
|
386
|
+
("int32", "float64"): libalgos.take_1d_int32_float64,
|
|
387
|
+
("int64", "int64"): libalgos.take_1d_int64_int64,
|
|
388
|
+
("uint8", "uint8"): libalgos.take_1d_bool_bool,
|
|
389
|
+
("uint16", "uint16"): libalgos.take_1d_uint16_uint16,
|
|
390
|
+
("uint32", "uint32"): libalgos.take_1d_uint32_uint32,
|
|
391
|
+
("uint64", "uint64"): libalgos.take_1d_uint64_uint64,
|
|
392
|
+
("int64", "float64"): libalgos.take_1d_int64_float64,
|
|
393
|
+
("float32", "float32"): libalgos.take_1d_float32_float32,
|
|
394
|
+
("float32", "float64"): libalgos.take_1d_float32_float64,
|
|
395
|
+
("float64", "float64"): libalgos.take_1d_float64_float64,
|
|
396
|
+
("object", "object"): libalgos.take_1d_object_object,
|
|
397
|
+
("bool", "bool"): _view_wrapper(libalgos.take_1d_bool_bool, np.uint8, np.uint8),
|
|
398
|
+
("bool", "object"): _view_wrapper(libalgos.take_1d_bool_object, np.uint8, None),
|
|
399
|
+
("datetime64[ns]", "datetime64[ns]"): _view_wrapper(
|
|
400
|
+
libalgos.take_1d_int64_int64, np.int64, np.int64, np.int64
|
|
401
|
+
),
|
|
402
|
+
("timedelta64[ns]", "timedelta64[ns]"): _view_wrapper(
|
|
403
|
+
libalgos.take_1d_int64_int64, np.int64, np.int64, np.int64
|
|
404
|
+
),
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
_take_2d_axis0_dict = {
|
|
408
|
+
("int8", "int8"): libalgos.take_2d_axis0_int8_int8,
|
|
409
|
+
("int8", "int32"): libalgos.take_2d_axis0_int8_int32,
|
|
410
|
+
("int8", "int64"): libalgos.take_2d_axis0_int8_int64,
|
|
411
|
+
("int8", "float64"): libalgos.take_2d_axis0_int8_float64,
|
|
412
|
+
("int16", "int16"): libalgos.take_2d_axis0_int16_int16,
|
|
413
|
+
("int16", "int32"): libalgos.take_2d_axis0_int16_int32,
|
|
414
|
+
("int16", "int64"): libalgos.take_2d_axis0_int16_int64,
|
|
415
|
+
("int16", "float64"): libalgos.take_2d_axis0_int16_float64,
|
|
416
|
+
("int32", "int32"): libalgos.take_2d_axis0_int32_int32,
|
|
417
|
+
("int32", "int64"): libalgos.take_2d_axis0_int32_int64,
|
|
418
|
+
("int32", "float64"): libalgos.take_2d_axis0_int32_float64,
|
|
419
|
+
("int64", "int64"): libalgos.take_2d_axis0_int64_int64,
|
|
420
|
+
("int64", "float64"): libalgos.take_2d_axis0_int64_float64,
|
|
421
|
+
("uint8", "uint8"): libalgos.take_2d_axis0_bool_bool,
|
|
422
|
+
("uint16", "uint16"): libalgos.take_2d_axis0_uint16_uint16,
|
|
423
|
+
("uint32", "uint32"): libalgos.take_2d_axis0_uint32_uint32,
|
|
424
|
+
("uint64", "uint64"): libalgos.take_2d_axis0_uint64_uint64,
|
|
425
|
+
("float32", "float32"): libalgos.take_2d_axis0_float32_float32,
|
|
426
|
+
("float32", "float64"): libalgos.take_2d_axis0_float32_float64,
|
|
427
|
+
("float64", "float64"): libalgos.take_2d_axis0_float64_float64,
|
|
428
|
+
("object", "object"): libalgos.take_2d_axis0_object_object,
|
|
429
|
+
("bool", "bool"): _view_wrapper(
|
|
430
|
+
libalgos.take_2d_axis0_bool_bool, np.uint8, np.uint8
|
|
431
|
+
),
|
|
432
|
+
("bool", "object"): _view_wrapper(
|
|
433
|
+
libalgos.take_2d_axis0_bool_object, np.uint8, None
|
|
434
|
+
),
|
|
435
|
+
("datetime64[ns]", "datetime64[ns]"): _view_wrapper(
|
|
436
|
+
libalgos.take_2d_axis0_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
437
|
+
),
|
|
438
|
+
("timedelta64[ns]", "timedelta64[ns]"): _view_wrapper(
|
|
439
|
+
libalgos.take_2d_axis0_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
440
|
+
),
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
_take_2d_axis1_dict = {
|
|
444
|
+
("int8", "int8"): libalgos.take_2d_axis1_int8_int8,
|
|
445
|
+
("int8", "int32"): libalgos.take_2d_axis1_int8_int32,
|
|
446
|
+
("int8", "int64"): libalgos.take_2d_axis1_int8_int64,
|
|
447
|
+
("int8", "float64"): libalgos.take_2d_axis1_int8_float64,
|
|
448
|
+
("int16", "int16"): libalgos.take_2d_axis1_int16_int16,
|
|
449
|
+
("int16", "int32"): libalgos.take_2d_axis1_int16_int32,
|
|
450
|
+
("int16", "int64"): libalgos.take_2d_axis1_int16_int64,
|
|
451
|
+
("int16", "float64"): libalgos.take_2d_axis1_int16_float64,
|
|
452
|
+
("int32", "int32"): libalgos.take_2d_axis1_int32_int32,
|
|
453
|
+
("int32", "int64"): libalgos.take_2d_axis1_int32_int64,
|
|
454
|
+
("int32", "float64"): libalgos.take_2d_axis1_int32_float64,
|
|
455
|
+
("int64", "int64"): libalgos.take_2d_axis1_int64_int64,
|
|
456
|
+
("int64", "float64"): libalgos.take_2d_axis1_int64_float64,
|
|
457
|
+
("uint8", "uint8"): libalgos.take_2d_axis1_bool_bool,
|
|
458
|
+
("uint16", "uint16"): libalgos.take_2d_axis1_uint16_uint16,
|
|
459
|
+
("uint32", "uint32"): libalgos.take_2d_axis1_uint32_uint32,
|
|
460
|
+
("uint64", "uint64"): libalgos.take_2d_axis1_uint64_uint64,
|
|
461
|
+
("float32", "float32"): libalgos.take_2d_axis1_float32_float32,
|
|
462
|
+
("float32", "float64"): libalgos.take_2d_axis1_float32_float64,
|
|
463
|
+
("float64", "float64"): libalgos.take_2d_axis1_float64_float64,
|
|
464
|
+
("object", "object"): libalgos.take_2d_axis1_object_object,
|
|
465
|
+
("bool", "bool"): _view_wrapper(
|
|
466
|
+
libalgos.take_2d_axis1_bool_bool, np.uint8, np.uint8
|
|
467
|
+
),
|
|
468
|
+
("bool", "object"): _view_wrapper(
|
|
469
|
+
libalgos.take_2d_axis1_bool_object, np.uint8, None
|
|
470
|
+
),
|
|
471
|
+
("datetime64[ns]", "datetime64[ns]"): _view_wrapper(
|
|
472
|
+
libalgos.take_2d_axis1_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
473
|
+
),
|
|
474
|
+
("timedelta64[ns]", "timedelta64[ns]"): _view_wrapper(
|
|
475
|
+
libalgos.take_2d_axis1_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
476
|
+
),
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
_take_2d_multi_dict = {
|
|
480
|
+
("int8", "int8"): libalgos.take_2d_multi_int8_int8,
|
|
481
|
+
("int8", "int32"): libalgos.take_2d_multi_int8_int32,
|
|
482
|
+
("int8", "int64"): libalgos.take_2d_multi_int8_int64,
|
|
483
|
+
("int8", "float64"): libalgos.take_2d_multi_int8_float64,
|
|
484
|
+
("int16", "int16"): libalgos.take_2d_multi_int16_int16,
|
|
485
|
+
("int16", "int32"): libalgos.take_2d_multi_int16_int32,
|
|
486
|
+
("int16", "int64"): libalgos.take_2d_multi_int16_int64,
|
|
487
|
+
("int16", "float64"): libalgos.take_2d_multi_int16_float64,
|
|
488
|
+
("int32", "int32"): libalgos.take_2d_multi_int32_int32,
|
|
489
|
+
("int32", "int64"): libalgos.take_2d_multi_int32_int64,
|
|
490
|
+
("int32", "float64"): libalgos.take_2d_multi_int32_float64,
|
|
491
|
+
("int64", "int64"): libalgos.take_2d_multi_int64_int64,
|
|
492
|
+
("int64", "float64"): libalgos.take_2d_multi_int64_float64,
|
|
493
|
+
("float32", "float32"): libalgos.take_2d_multi_float32_float32,
|
|
494
|
+
("float32", "float64"): libalgos.take_2d_multi_float32_float64,
|
|
495
|
+
("float64", "float64"): libalgos.take_2d_multi_float64_float64,
|
|
496
|
+
("object", "object"): libalgos.take_2d_multi_object_object,
|
|
497
|
+
("bool", "bool"): _view_wrapper(
|
|
498
|
+
libalgos.take_2d_multi_bool_bool, np.uint8, np.uint8
|
|
499
|
+
),
|
|
500
|
+
("bool", "object"): _view_wrapper(
|
|
501
|
+
libalgos.take_2d_multi_bool_object, np.uint8, None
|
|
502
|
+
),
|
|
503
|
+
("datetime64[ns]", "datetime64[ns]"): _view_wrapper(
|
|
504
|
+
libalgos.take_2d_multi_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
505
|
+
),
|
|
506
|
+
("timedelta64[ns]", "timedelta64[ns]"): _view_wrapper(
|
|
507
|
+
libalgos.take_2d_multi_int64_int64, np.int64, np.int64, fill_wrap=np.int64
|
|
508
|
+
),
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def _take_nd_object(
|
|
513
|
+
arr: np.ndarray,
|
|
514
|
+
indexer: npt.NDArray[np.intp],
|
|
515
|
+
out: np.ndarray,
|
|
516
|
+
axis: AxisInt,
|
|
517
|
+
fill_value,
|
|
518
|
+
mask_info,
|
|
519
|
+
) -> None:
|
|
520
|
+
if mask_info is not None:
|
|
521
|
+
mask, needs_masking = mask_info
|
|
522
|
+
else:
|
|
523
|
+
mask = indexer == -1
|
|
524
|
+
needs_masking = mask.any()
|
|
525
|
+
if arr.dtype != out.dtype:
|
|
526
|
+
arr = arr.astype(out.dtype)
|
|
527
|
+
if arr.shape[axis] > 0:
|
|
528
|
+
arr.take(indexer, axis=axis, out=out)
|
|
529
|
+
if needs_masking:
|
|
530
|
+
outindexer = [slice(None)] * arr.ndim
|
|
531
|
+
outindexer[axis] = mask
|
|
532
|
+
out[tuple(outindexer)] = fill_value
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def _take_2d_multi_object(
|
|
536
|
+
arr: np.ndarray,
|
|
537
|
+
indexer: tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]],
|
|
538
|
+
out: np.ndarray,
|
|
539
|
+
fill_value,
|
|
540
|
+
mask_info,
|
|
541
|
+
) -> None:
|
|
542
|
+
# this is not ideal, performance-wise, but it's better than raising
|
|
543
|
+
# an exception (best to optimize in Cython to avoid getting here)
|
|
544
|
+
row_idx, col_idx = indexer # both np.intp
|
|
545
|
+
if mask_info is not None:
|
|
546
|
+
(row_mask, col_mask), (row_needs, col_needs) = mask_info
|
|
547
|
+
else:
|
|
548
|
+
row_mask = row_idx == -1
|
|
549
|
+
col_mask = col_idx == -1
|
|
550
|
+
row_needs = row_mask.any()
|
|
551
|
+
col_needs = col_mask.any()
|
|
552
|
+
if fill_value is not None:
|
|
553
|
+
if row_needs:
|
|
554
|
+
out[row_mask, :] = fill_value
|
|
555
|
+
if col_needs:
|
|
556
|
+
out[:, col_mask] = fill_value
|
|
557
|
+
for i, u_ in enumerate(row_idx):
|
|
558
|
+
if u_ != -1:
|
|
559
|
+
for j, v in enumerate(col_idx):
|
|
560
|
+
if v != -1:
|
|
561
|
+
out[i, j] = arr[u_, v]
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def _take_preprocess_indexer_and_fill_value(
|
|
565
|
+
arr: np.ndarray,
|
|
566
|
+
indexer: npt.NDArray[np.intp],
|
|
567
|
+
fill_value,
|
|
568
|
+
allow_fill: bool,
|
|
569
|
+
mask: npt.NDArray[np.bool_] | None = None,
|
|
570
|
+
):
|
|
571
|
+
mask_info: tuple[np.ndarray | None, bool] | None = None
|
|
572
|
+
|
|
573
|
+
if not allow_fill:
|
|
574
|
+
dtype, fill_value = arr.dtype, arr.dtype.type()
|
|
575
|
+
mask_info = None, False
|
|
576
|
+
else:
|
|
577
|
+
# check for promotion based on types only (do this first because
|
|
578
|
+
# it's faster than computing a mask)
|
|
579
|
+
if lib.is_float(fill_value) and fill_value.is_integer():
|
|
580
|
+
# Avoid warning if possible
|
|
581
|
+
fill_value = int(fill_value)
|
|
582
|
+
dtype, fill_value = maybe_promote(arr.dtype, fill_value)
|
|
583
|
+
if dtype != arr.dtype:
|
|
584
|
+
if not (
|
|
585
|
+
(lib.is_float(fill_value) and np.isnan(fill_value))
|
|
586
|
+
or (arr.dtype.kind == "U" and isinstance(fill_value, str))
|
|
587
|
+
):
|
|
588
|
+
# GH#53910
|
|
589
|
+
warnings.warn(
|
|
590
|
+
"reindexing with a fill_value that cannot be held by the "
|
|
591
|
+
"original dtype is deprecated. Explicitly cast to a common "
|
|
592
|
+
f"dtype (in this case {dtype}) instead.",
|
|
593
|
+
Pandas4Warning,
|
|
594
|
+
stacklevel=find_stack_level(),
|
|
595
|
+
)
|
|
596
|
+
# check if promotion is actually required based on indexer
|
|
597
|
+
if mask is not None:
|
|
598
|
+
needs_masking = True
|
|
599
|
+
else:
|
|
600
|
+
mask = indexer == -1
|
|
601
|
+
needs_masking = bool(mask.any())
|
|
602
|
+
mask_info = mask, needs_masking
|
|
603
|
+
if not needs_masking:
|
|
604
|
+
# if not, then depromote, set fill_value to dummy
|
|
605
|
+
# (it won't be used but we don't want the cython code
|
|
606
|
+
# to crash when trying to cast it to dtype)
|
|
607
|
+
dtype, fill_value = arr.dtype, arr.dtype.type()
|
|
608
|
+
|
|
609
|
+
return dtype, fill_value, mask_info
|