Skip to content

Add CLAUDE.md#51

Open
ftavella wants to merge 13 commits into
Arcascope:mainfrom
ftavella:add-claude
Open

Add CLAUDE.md#51
ftavella wants to merge 13 commits into
Arcascope:mainfrom
ftavella:add-claude

Conversation

@ftavella
Copy link
Copy Markdown
Member

@ftavella ftavella commented Mar 18, 2026

Adds a CLAUDE.md file 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):

  • Replace pkg_resources.parse_version with packaging.version.Version in setup.pypkg_resources was removed from setuptools in v82
  • Sync notebooks and generated Python files with the correct version of nbdev (cell marker format update)
  • Pin nbdev==2.4.14 in dev_requirements.txt
  • Fix NumPy deprecation warning breaking LightSchedule validation
  • Fix np.vectorize breaking when light_fn returns arrays (NumPy 2.4)
  • Fix ShiftWork ground-truth test returning scalar for np.vectorize

Note: once #48 is merged, this PR will reduce to just the CLAUDE.md addition.

ftavella and others added 11 commits March 11, 2026 10:31
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>
@ftavella ftavella self-assigned this Mar 18, 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.

1 participant