Add CLAUDE.md#51
Open
ftavella wants to merge 13 commits into
Open
Conversation
Replace nested np.vectorize approach in __add__, __sub__, and concatenate_at with array-native functions. Each LightSchedule now stores an _array_func that operates on full numpy arrays efficiently. - __init__: detect array-capable functions and store as _array_func; constants use np.full_like instead of scalar lambdas - __add__ / __sub__: combine _array_func references without wrapping in a new np.vectorize call, cutting evaluation from O(n*L) to O(n+L) - concatenate_at: use boolean-index slicing on arrays instead of np.piecewise with pre-computed arrays (which was incorrect for array inputs) - _func kept as np.vectorize for backward compatibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests that LightSchedule.Chang14 (which uses both concatenate_at and __add__ internally) evaluates 14 days of data at dt=0.005h in under 1 second for all six typical_indoor_lux values from the original use-case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a LightSchedule is passed as a callable to another LightSchedule (e.g. ShiftWork's LightSchedule(total_schedule, period=...)), calling light(0.0) returns a 1-element array. In NumPy 1.25+ with warnings-as-errors, float(1-element-array) raises DeprecationWarning which was caught by the try/except and re-raised as a misleading ValueError rejecting valid input. Fix: use float(np.asarray(test_output).flat[0]) to safely extract a scalar from any numeric type without triggering the deprecation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap _func scalar extraction so np.vectorize always receives a Python float, even when the underlying callable (e.g. a nested LightSchedule) returns a 1-element array. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
LightSchedule.__call__ always returns a 1-d array; NumPy 2.4 strictly rejects putting that array into a float slot in np.vectorize. All 4 `return schedule(time)` calls in ground_truth_shift_schedule now extract a Python float explicitly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
CLAUDE.mdfile to guide Claude Code when working in this repository. Includes the nbdev development workflow, build/test commands, and a module overview table.Also includes CI fixes that were needed to get the test suite passing (same fixes as #48):
pkg_resources.parse_versionwithpackaging.version.Versioninsetup.py—pkg_resourceswas removed fromsetuptoolsin v82nbdev==2.4.14indev_requirements.txtLightSchedulevalidationnp.vectorizebreaking whenlight_fnreturns arrays (NumPy 2.4)ShiftWorkground-truth test returning scalar fornp.vectorizeNote: once #48 is merged, this PR will reduce to just the
CLAUDE.mdaddition.