namo.rb 0.32.7 → 0.32.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG +22 -6
- data/lib/Namo/Row.rb +3 -1
- data/lib/Namo/VERSION.rb +1 -1
- data/test/namo_test.rb +32 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ac4c2ed4449845cc475c09c946ae8af32b1ba977bed2353b1a665d597e108e5
|
|
4
|
+
data.tar.gz: 6e221c9bbe2cfc562018b57fdbd4b8476868c203385bc3ca1d9dbd19c209dda0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9331f7db05e3764548010efdc808f09b12f183a31ff6c6655f0a90644653128ce3696062b090921f47f941441a0a1d92f676a2b54a8c1e3c53aabbbeecafbcc
|
|
7
|
+
data.tar.gz: 511c00d86f20a981154be910d1345d309c6fdd45636e33a7bceeee626803a69f46553fa969495210f264d1f7921e6f29d3c800f1cb8f5b23592cc02e8e996371
|
data/CHANGELOG
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
## 20261102
|
|
4
4
|
|
|
5
|
+
0.32.9: + comparison/setup: Builds the environments the comparison/*_claims scripts run in, at the versions COMPARISON.md names, or with --latest the newest releases.
|
|
6
|
+
|
|
7
|
+
1. + comparison/setup: Builds .venv/ with uv, and in .tools/ R and its packages with micromamba from conda-forge and Julia from its tarball, checked against the sha256 julialang.org publishes, with its packages; then removes the downloads and package caches. Pins pyarrow besides the packages COMPARISON.md names, since pandas stores strings with it where it is installed, which shows in what pandas_claims.py prints.
|
|
8
|
+
2. ~ comparison/README.md: The setup instructions are comparison/setup, and each script runs with what it builds, where they had been the uv commands for Python and "given an environment" for R and Julia.
|
|
9
|
+
3. ~ CHANGELOG: The 0.21.0 and 0.22.0 summaries end at their commit subjects, the rest moved into their numbered items; the 0.23.0 summary /body/collection/, as its commit subject has it.
|
|
10
|
+
4. ~ Namo::VERSION: /0.32.8/0.32.9/
|
|
11
|
+
|
|
12
|
+
0.32.8: ~ Namo::Row#match?: A Range selects by cover?, so beginless and endless ranges of Dates and Strings select rather than raising TypeError.
|
|
13
|
+
|
|
14
|
+
1. ~ Namo::Row#match?: A Range is tested with cover? and an Array with include?, where both had been tested with include?, which raises for a beginless or endless range of anything not numeric. A bounded range of Strings now selects by ordering, as a bounded range of numbers already did, rather than by membership of its succ sequence.
|
|
15
|
+
2. + test/namo_test.rb: beginless and endless ranges of Dates and of Strings select; a two-arity formula windows over Dates.
|
|
16
|
+
3. ~ COMPARISON.md: - the note that the windowed formulae want numeric dates.
|
|
17
|
+
4. ~ comparison/namo_claims.rb: - the comment saying a beginless range of Dates raises.
|
|
18
|
+
5. ~ ROADMAP.md: + 0.32.8.
|
|
19
|
+
6. ~ Namo::VERSION: /0.32.7/0.32.8/
|
|
20
|
+
|
|
5
21
|
0.32.7: ~ COMPARISON.md: Verify and where necessary correct claims made about pandas, Polars, xarray, dplyr, and DataFrames.jl; + comparison/*_claims, which contain executable verification code.
|
|
6
22
|
|
|
7
23
|
1. + comparison/namo_claims.rb, pandas_claims.py, polars_claims.py, xarray_claims.py, dplyr_claims.R, dataframes_claims.jl: each runs every snippet COMPARISON.md shows for its tool, on inline data, then the probes behind its claims.
|
|
@@ -297,7 +313,7 @@ A base Namo's constituents are formularies and rows: << dispatches a Module to a
|
|
|
297
313
|
|
|
298
314
|
## 20260627
|
|
299
315
|
|
|
300
|
-
0.23.0: + Namo::Formulary — A formulary is a reusable
|
|
316
|
+
0.23.0: + Namo::Formulary — A formulary is a reusable collection of derived dimensions a Namo instance may draw upon.
|
|
301
317
|
|
|
302
318
|
1. + lib/Namo/Formulary.rb: + Namo::Formulary, an empty marker module. A module includes it to brand itself a formulary; attach raises ArgumentError for an untagged module, so an ordinary module of helpers can't be mistaken for a body of derivations.
|
|
303
319
|
2. ~ lib/Namo/Formulae.rb: + attach(modul), aliased as << — after the marker guard, extends a single memoised inert host (@host ||= Object.new) with the module and stores each of its public_instance_methods(false) as a Method bound to that host, then returns self. One host per Formulae across all attaches, so the bound Methods share a self-free receiver and a formulary method can't shadow Namo's API. No other change: derive, key?, required_parameter_count, keys, merge/dup/reject, and ==/eql?/hash are the 0.22.0 store-only methods, and they handle the formulary methods because the formulary methods are now store entries.
|
|
@@ -309,19 +325,19 @@ A base Namo's constituents are formularies and rows: << dispatches a Module to a
|
|
|
309
325
|
|
|
310
326
|
## 20260626
|
|
311
327
|
|
|
312
|
-
0.22.0: + Formulae#derive — move formula invocation out of Row#[] and into Formulae.
|
|
328
|
+
0.22.0: + Formulae#derive — move formula invocation out of Row#[] and into Formulae.
|
|
313
329
|
|
|
314
|
-
1. ~ lib/Namo/Formulae.rb: + derive(name, row, namo, *arguments), the formula resolver — invocation mechanics lifted whole from Row's formula branch (collection-scoped formulae are called (row, namo, *arguments), row-only formulae (row)). + required_parameter_count(name), public, a property of the stored callable. collection_scoped? and raise_unless_namo_context move in as private; the latter takes namo as a parameter rather than closing over Row's @namo. [] and []= are untouched — []
|
|
315
|
-
2. ~ lib/Namo/Row.rb: #[] delegates formula resolution to @formulae.derive(name, self, @namo, *arguments); Row keeps only the fail-fast argument guard, the formula-vs-data dispatch (@formulae.key?), and the data fallback (@row[name]). collection_scoped?, required_parameter_count, and raise_unless_namo_context are gone (now Formulae's). expected_argument_counts sources the count from @formulae.required_parameter_count and the fixed-vs-variadic check from @formulae[name].arity.
|
|
330
|
+
1. ~ lib/Namo/Formulae.rb: + derive(name, row, namo, *arguments), the formula resolver — resolves a named formula to its value, the invocation mechanics lifted whole from Row's formula branch (collection-scoped formulae are called (row, namo, *arguments), row-only formulae (row)). derive over call: the receiver is the collection, not the callable, so the verb says the collection derives a value via the named rule rather than borrowing Proc#call's "invoke the receiver"; and the result is whatever the proc returns, not necessarily numeric, which a neutral verb leaves open. + required_parameter_count(name), public, a property of the stored callable. collection_scoped? and raise_unless_namo_context move in as private; the latter takes namo as a parameter rather than closing over Row's @namo. [] and []= are untouched — [] keeps its meaning, the stored callable as at 0.21.0: indexing a Formulae is storage access, not a Namo operation, so [] returning the callable carries no inconsistency with the dimension-value [] of Namo and Row — different domains, same spelling.
|
|
331
|
+
2. ~ lib/Namo/Row.rb: #[] delegates formula resolution to @formulae.derive(name, self, @namo, *arguments); Row keeps only the fail-fast argument guard, the formula-vs-data dispatch (@formulae.key?), and the data fallback (@row[name]). collection_scoped?, required_parameter_count, and raise_unless_namo_context are gone (now Formulae's). expected_argument_counts sources the count from @formulae.required_parameter_count and the fixed-vs-variadic check from @formulae[name].arity. Behaviour-preserving at the usage level: row[:revenue], namo[:x] = formula, values, and selections are unchanged.
|
|
316
332
|
3. + test/Namo/Formulae_test.rb: + #derive tests (row-only to value, collection-scoped with namo context, missing-namo-context raise, parameterised with arguments) and + #required_parameter_count tests (row-only, collection-scoped, parameterised, variadic). The #[] and #[]= blocks are unchanged — [] still returns the callable.
|
|
317
333
|
4. ~ test/Namo/Row_test.rb: the formulae fixture is a Namo::Formulae, not a bare {} — Row now delegates formula resolution to its collaborator (call, required_parameter_count), which production always wraps (lib/namo.rb initialize). The data-only equality/match tests keep their {} literals: they never resolve a formula, so Hash#key? alone answers.
|
|
318
334
|
5. ~ Namo::VERSION: /0.21.0/0.22.0/
|
|
319
335
|
|
|
320
336
|
## 20260625
|
|
321
337
|
|
|
322
|
-
0.21.0: + Namo::Formulae; @formulae: /Hash/Namo::Formulae/.
|
|
338
|
+
0.21.0: + Namo::Formulae; @formulae: /Hash/Namo::Formulae/.
|
|
323
339
|
|
|
324
|
-
1. + lib/Namo/Formulae.rb: + Namo::Formulae, a thin class wrapping a Hash @store. Responds to exactly the subset of Hash that lib/namo.rb and Row send the formula collection: [], []=, keys, key?, empty?, each, delete, merge, reject, dup; includes Enumerable (each yields [name, callable] pairs, giving map/select/etc. for free). Three deliberate choices: to_h returns a copy (@store.dup) so callers cannot mutate internals; ==/eql?/hash are names-only (keys.sort), matching Namo's own formula equality where two sets with the same names but different proc objects are equivalent; merge/reject/dup return a Formulae, not a Hash.
|
|
340
|
+
1. + lib/Namo/Formulae.rb: + Namo::Formulae, a thin class wrapping a Hash @store. Behaviour-preserving: no new capability, just an object for the formula collection to accrete behaviour onto later, mirroring the 0.1.0 extraction of Row. Responds to exactly the subset of Hash that lib/namo.rb and Row send the formula collection: [], []=, keys, key?, empty?, each, delete, merge, reject, dup; includes Enumerable (each yields [name, callable] pairs, giving map/select/etc. for free). Three deliberate choices: to_h returns a copy (@store.dup) so callers cannot mutate internals; ==/eql?/hash are names-only (keys.sort), matching Namo's own formula equality where two sets with the same names but different proc objects are equivalent; merge/reject/dup return a Formulae, not a Hash.
|
|
325
341
|
2. ~ lib/namo.rb: + the require; initialize now normalises the incoming formulae to a Formulae (Formulae.new(formulae) unless already one). This is the single behavioural seam — every existing internal construction passes a Hash and is wrapped, while operator results that now pass a Formulae (merge/dup return Formulae) pass through. No other call site changed: each sends a message Formulae answers.
|
|
326
342
|
3. ~ test/namo_test.rb: the two assertions comparing the public #formulae accessor to a literal {} now assert emptiness (must_be_empty). The accessor returns a Formulae, not a Hash; the formula set being empty is the unchanged behaviour these tests pin. + two construction tests pinning the normalisation seam: a Hash given by keyword is wrapped in a Formulae, and a Formulae given by keyword passes through unchanged (same object).
|
|
327
343
|
4. + test/Namo/Formulae_test.rb: + unit test pinning the three deliberate choices (to_h copy, names-only ==/eql?/hash, the Hash-compatible surface plus Enumerable map/select).
|
data/lib/Namo/Row.rb
CHANGED
|
@@ -27,8 +27,10 @@ class Namo
|
|
|
27
27
|
def match?(selections)
|
|
28
28
|
selections.all? do |dimension, coordinate|
|
|
29
29
|
case coordinate
|
|
30
|
-
when Array
|
|
30
|
+
when Array
|
|
31
31
|
coordinate.include?(self[dimension])
|
|
32
|
+
when Range
|
|
33
|
+
coordinate.cover?(self[dimension])
|
|
32
34
|
when Proc
|
|
33
35
|
coordinate.call(self[dimension])
|
|
34
36
|
when Regexp
|
data/lib/Namo/VERSION.rb
CHANGED
data/test/namo_test.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
2
|
require 'minitest-spec-context'
|
|
3
3
|
|
|
4
|
+
require 'date'
|
|
5
|
+
|
|
4
6
|
require_relative '../lib/namo'
|
|
5
7
|
|
|
6
8
|
module SupportedFlow
|
|
@@ -559,6 +561,36 @@ describe Namo do
|
|
|
559
561
|
_(sales[quantity: 100..].to_a.count).must_equal 2
|
|
560
562
|
end
|
|
561
563
|
|
|
564
|
+
it "supports beginless and endless ranges of Dates" do
|
|
565
|
+
dated = Namo.new([
|
|
566
|
+
{date: Date.new(2026, 1, 1), close: 1},
|
|
567
|
+
{date: Date.new(2026, 1, 2), close: 2},
|
|
568
|
+
{date: Date.new(2026, 1, 3), close: 3},
|
|
569
|
+
])
|
|
570
|
+
_(dated[date: ..Date.new(2026, 1, 2)].values(:close)).must_equal [1, 2]
|
|
571
|
+
_(dated[date: Date.new(2026, 1, 2)..].values(:close)).must_equal [2, 3]
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
it "supports beginless and endless ranges of Strings" do
|
|
575
|
+
dated = Namo.new([
|
|
576
|
+
{date: "2026-01-01", close: 1},
|
|
577
|
+
{date: "2026-01-02", close: 2},
|
|
578
|
+
{date: "2026-01-03", close: 3},
|
|
579
|
+
])
|
|
580
|
+
_(dated[date: .."2026-01-02"].values(:close)).must_equal [1, 2]
|
|
581
|
+
_(dated[date: "2026-01-02"..].values(:close)).must_equal [2, 3]
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
it "windows a two-arity formula over Dates" do
|
|
585
|
+
dated = Namo.new([
|
|
586
|
+
{date: Date.new(2026, 1, 1), close: 1},
|
|
587
|
+
{date: Date.new(2026, 1, 2), close: 2},
|
|
588
|
+
{date: Date.new(2026, 1, 3), close: 3},
|
|
589
|
+
])
|
|
590
|
+
dated[:running] = proc{|row, namo| namo[date: ..row[:date]].values(:close).sum}
|
|
591
|
+
_(dated.values(:running)).must_equal [1, 3, 6]
|
|
592
|
+
end
|
|
593
|
+
|
|
562
594
|
it "composes with projection in a single call" do
|
|
563
595
|
result = sales[:product, :quantity, quantity: 50..120]
|
|
564
596
|
_(result.to_a).must_equal [
|