Skip to content

Commit efedfa4

Browse files
AronT-TLVclaude
andauthored
Use CalculusWithJuliaSquared instead of a direct Plots dependency (#2)
* Use CalculusWithJuliaSquared instead of a direct Plots dependency Adds CalculusWithJuliaSquared (personal pure-Julia fork of CalculusWithJulia.jl, unregistered -- installed from its GitHub URL, Manifest pins repo-url tracking master) and reexports it from the Calculus module. It brings Plots, Symbolics, Roots, LinearAlgebra, SpecialFunctions, and IntervalSets through its own reexport chain, plus calculus utilities (riemann, fubini, lim, sign_chart, tangent, secant, D/f' notation) and plotting recipes (plotif, trimplot, riemann_plot, newton_plot!, ...), so: - Plots removed from Project.toml (arrives transitively) - The module's GKSwstype headless-CI block removed -- CalculusWithJuliaSquared runs the same pattern at its own load time - copilot-instructions.md gains a "What CalculusWithJuliaSquared Provides" section so future sessions know what already exists before writing new functions; source.instructions.md dependency/module sections updated to match reality (also drops BlockArrays/LAlatex mentions that were template leftovers never actually in Project.toml) Test suite passes; verified `using Calculus` alone provides plot, @variables, riemann, and the L"..." macro. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add [sources] entry so CI can resolve the unregistered dependency CI failed with "expected package CalculusWithJuliaSquared to be registered": Pkg.add(url=...) records the GitHub source only in the Manifest, which is gitignored in this repo, so CI resolving from Project.toml alone looked for the package in the General registry. The [sources] section (Julia 1.11+) declares the URL in the committed Project.toml, making instantiation work from a clean clone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Instructions: document the [sources] requirement for the unregistered dep Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Truth up notebooks.instructions.md: LAlatex/BlockArrays are not reexported The claim that LAlatex, BlockArrays, and LaTeXStrings are re-exported by the module was never true (inherited from the canonical template, where it is false for Linear_Algebra as well -- only LaTeXStrings is reexported). LAlatex and BlockArrays live in notebooks/Project.toml only and need their own `using` in the setup cell. Also fixes a leftover "using Linear_Algebra" mention and the plot_param_line example from the template, pointing at the CalculusWithJuliaSquared recipes instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 886c514 commit efedfa4

5 files changed

Lines changed: 35 additions & 20 deletions

File tree

.github/copilot-instructions.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@
88

99
### Core Architecture
1010

11-
- **`src/Calculus.jl`**: Main module; uses `@reexport` to re-export `Plots`, `BlockArrays`, `LAlatex`, `LaTeXStrings` — consumers get all exported names with a single `using Calculus`
11+
- **`src/Calculus.jl`**: Main module; uses `@reexport` to re-export `CalculusWithJuliaSquared` and `LaTeXStrings` — consumers get all exported names with a single `using Calculus`
1212
- **`test/`**: Tests using `Calculus` and `Test` only — re-exported names are available via `@reexport`, no explicit `using` needed in test files
1313
- **`docs/`**: Documenter.jl deploying to `https://study.fourm.info/calculus/` (cross-repo to `math_tech_study`)
1414
- **`notebooks/`**: Jupyter notebooks for exploration (not tested in CI)
1515

16+
### What CalculusWithJuliaSquared Provides
17+
18+
[`CalculusWithJuliaSquared`](https://github.com/FourMInfo/CalculusWithJuliaSquared.jl) is a personal, pure-Julia (zero-Python) fork of `CalculusWithJulia.jl`. It's **unregistered**, so its GitHub URL is declared in `Project.toml`'s `[sources]` section — required because Manifests are gitignored here, and without `[sources]` a clean clone (e.g. CI) tries the General registry and fails. Keep that section intact. It reexports `Plots`, `Symbolics`, `Roots`, `LinearAlgebra`, `SpecialFunctions`, and `IntervalSets`, and auto-configures the GR backend for headless CI at load time — so this repo needs **no direct `Plots` dependency and no GKS setup of its own**. Available after `using Calculus`:
19+
20+
- **Plotting recipes**: `plotif`, `trimplot`, `signchart`, `plot_parametric`(`!`), `plot_polar`(`!`), `implicit_plot`(`!`), `vectorfieldplot`(`3d`), `arrow`(`!`), `riemann_plot`(`!`), `newton_plot!`, `plot_implicit_surface`
21+
- **Calculus utilities**: `riemann` (8 methods), `fubini`, `lim` (limit tables), `sign_chart`, `tangent`, `secant`, `D` and the `f'` prime notation (via ForwardDiff), `unzip`, `rangeclamp`, `const e`
22+
- **Symbolic math** (pure Julia): `@variables` etc. via Symbolics, plus symbolic `gradient`/`divergence`/`curl` for `Symbolics.Num`; ``, `∇⋅`, `∇×` operators work numerically and symbolically
23+
- **Root finding**: `fzero`/`fzeros` via Roots
24+
25+
To update to a newer CWJS commit: `julia --project=. -e 'using Pkg; Pkg.update("CalculusWithJuliaSquared")'`. Never re-add `Plots`/`SymPy` directly here — plotting comes through CWJS, and CWJS's whole purpose is keeping Python out.
26+
1627
## Julia Workspace Layout
1728

1829
This repository uses a Julia workspace. The root `Project.toml` has a `[workspace]` table listing

.github/instructions/notebooks.instructions.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ All notebooks should start with the standard setup cell:
1010
```julia
1111
using Revise
1212
using Calculus
13+
using LAlatex, BlockArrays
1314

1415
LAlatex.set_backend!(:symbolics)
1516
LAlatex.reset_display_defaults!()
1617
```
1718

18-
`LAlatex`, `BlockArrays`, and `LaTeXStrings` are re-exported by `Calculus`, so no separate `using` is needed. In particular, the `L"..."` string macro is available immediately after `using Linear_Algebra`.
19+
What comes from where:
20+
21+
- `using Calculus` provides everything the module reexports — `LaTeXStrings` (the `L"..."` macro) plus the full `CalculusWithJuliaSquared` chain (`Plots`, `Symbolics`, `Roots`, calculus utilities and plotting recipes — see "What CalculusWithJuliaSquared Provides" in `copilot-instructions.md`).
22+
- `LAlatex` and `BlockArrays` are **notebooks-environment dependencies only** (in `notebooks/Project.toml`, not the root project), so they need their own `using` line — they are *not* re-exported by `Calculus`.
23+
1924
`set_backend!(:symbolics)` is required because this package uses Symbolics.jl; the default `:latexify` backend gives worse output for symbolic expressions.
2025
`reset_display_defaults!()` ensures a clean display state on every kernel restart.
2126

@@ -32,11 +37,11 @@ LAlatex.reset_display_defaults!()
3237

3338
- Plots render inline in Jupyter notebooks
3439
- No need for headless mode configuration
35-
- Use the same plotting functions from the package (`plot_param_line`, etc.)
40+
- Prefer the ready-made recipes from `CalculusWithJuliaSquared` (`plotif`, `riemann_plot`, `plot_parametric`, `vectorfieldplot`, …) and this package's own plotting functions before writing new ones
3641

3742
## LAlatex Display
3843

39-
[LAlatex.jl](https://github.com/ea42gh/LAlatex.jl) (by ea42gh) is re-exported by `Linear_Algebra` and provides clean LaTeX rendering of linear algebra objects in notebooks. Use it instead of raw `println` or `display` whenever presenting mathematical results.
44+
[LAlatex.jl](https://github.com/ea42gh/LAlatex.jl) (by ea42gh) is available in the notebooks environment (`using LAlatex` in the setup cell) and provides clean LaTeX rendering of mathematical objects in notebooks. Use it instead of raw `println` or `display` whenever presenting mathematical results.
4045

4146
### Core functions
4247

.github/instructions/source.instructions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All code uses `@reexport` pattern and exports both computational + plotting func
1010
```julia
1111
# Main module uses @reexport for clean interface
1212
using Reexport
13-
@reexport using Plots, BlockArrays, LAlatex, LaTeXStrings
13+
@reexport using CalculusWithJuliaSquared, LaTeXStrings
1414

1515
# Pure computational functions (no plotting dependencies)
1616
export calculate_derivative, calculate_integral
@@ -19,9 +19,11 @@ export calculate_derivative, calculate_integral
1919
export plot_function, plot_derivative
2020
```
2121

22+
`CalculusWithJuliaSquared` brings `Plots`, `Symbolics`, `Roots`, `LinearAlgebra`, `SpecialFunctions`, and `IntervalSets` with it, plus ready-made calculus utilities and plotting recipes (see the "What CalculusWithJuliaSquared Provides" section in `copilot-instructions.md`). **Check there before writing a new function — it may already exist** (e.g. `riemann_plot`, `plotif`, `tangent`, `lim`).
23+
2224
## CI/Interactive Detection
2325

24-
Module auto-configures at load time using `GKSwstype`. See the `julia-coding-conventions` skill for the canonical pattern. The check goes in the main module file (`Calculus.jl`) after the `@reexport` block.
26+
Handled by `CalculusWithJuliaSquared` at its own load time (the canonical `GKSwstype` pattern from the `julia-coding-conventions` skill lives there now). This module needs no GKS configuration of its own.
2527

2628
## Julia Coding Standards
2729

@@ -65,11 +67,9 @@ end
6567

6668
## Dependencies & Libraries
6769

68-
**Main Dependencies**: Plots, BlockArrays, LAlatex, LaTeXStrings, Reexport, DrWatson
70+
**Main Dependencies**: CalculusWithJuliaSquared (unregistered, installed by GitHub URL), LaTeXStrings, Reexport
6971

7072
### Libraries Used
71-
- **Plots.jl**: For visualization functions
72-
- **BlockArrays.jl**: For block-structured arrays
73-
- **LAlatex.jl**: For LaTeX rendering in notebooks
73+
- **CalculusWithJuliaSquared.jl**: calculus utilities, plotting recipes, and the full reexport chain (Plots, Symbolics, Roots, LinearAlgebra, SpecialFunctions, IntervalSets) — pure Julia, zero Python by design; never add `Plots` or `SymPy` directly here
7474
- **LaTeXStrings.jl**: For `L"..."` string macro
7575
- **Reexport.jl**: For `@reexport` clean module interface

Project.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ authors = ["Aron T"]
77
projects = ["test", "docs"]
88

99
[deps]
10+
CalculusWithJuliaSquared = "f826098b-d57e-4440-b91e-2a05d35c24ae"
1011
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
11-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1212
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1313

14+
[sources]
15+
CalculusWithJuliaSquared = { url = "https://github.com/FourMInfo/CalculusWithJuliaSquared.jl" }
16+
1417
[compat]
18+
CalculusWithJuliaSquared = "0.5.0"
1519
julia = "1.12"

src/Calculus.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
module Calculus
22
using Reexport
3-
@reexport using Plots, LaTeXStrings
4-
5-
# GR backend — auto-configures for CI or interactive use
6-
if haskey(ENV, "CI") || get(ENV, "GKSwstype", "") == "100"
7-
ENV["GKSwstype"] = "100"
8-
gr(show=false)
9-
else
10-
gr()
11-
end
3+
# CalculusWithJuliaSquared reexports Plots, Symbolics, Roots, LinearAlgebra,
4+
# SpecialFunctions, and IntervalSets, and auto-configures the GR backend for
5+
# CI/interactive use at load time — no separate `using Plots` or GKS setup needed.
6+
@reexport using CalculusWithJuliaSquared, LaTeXStrings
127

138
# Pure computational functions (no plotting dependencies)
149

0 commit comments

Comments
 (0)