librasteve / raku-physics-measure Goto Github PK
View Code? Open in Web Editor NEWdo calculations on objects with value, units and error
License: Artistic License 2.0
do calculations on objects with value, units and error
License: Artistic License 2.0
FIXME test corner cases
This gives type => Length, Reach
Custom Measures
To make a custom Measure, you can use this incantation:
GetMeaUnit('nmile').NewType('Reach');
class Reach is Measure {
has $.units where *.name eq <nm nmile nmiles>.any;
#| override .in to perform identity 1' (Latitude) == 1 nmile
method in( Str $s where * eq <Latitude> ) {
my $nv = $.value / 60;
Latitude.new( value => $nv, compass => <N> )
}
}
[17:40]Anton Antonov: @librasteve I have a complaint on "Physics::Unit" :
from https://discord.com/channels/538407879980482560/768511641758466088/1133076220037312552
eg l/100km
change factor and offset to Rat for short cut round trip (ie for knots = nmiles/hrs)
currently this relies on round-to to give one results
https://uk-air.defra.gov.uk/assets/documents/reports/empire/naei/annreport/annrep99/app1_212.html
eg. kg N / year
eg. kg CH4/head/year
also ...
N2O(AWMS) = 44/28 . å NT . Nex(T) . AWMS(T) . EF(AWMS)
where
N2O(AWMS) = N2O emissions from animal waste managment systems
(kg N2O/yr)
NT = Number of animals of type T
Nex(T) = N excretion of animals of type T (kg N/animal/yr)
AWMS(T) = Fraction of Nex that is managed in one of the different
waste management systems of type T
EF(AWMS) = N2O emission factor for an AWMS (kg N2O-N/kg of Nex in AWMS)
fro @kjpye
The default output with say (i.e. using the non-existent gist method) is also problematic. Perhaps a new gist method which does the same as a (possibly upgraded) Str method would be more suitable.
eg. togg
The error coming from the following would be more useful if it were to complain about the undefined value in some way; what I really want is a documented way to test if it's undefined like this. For the record, calling defined($!height)
inside foo()
also fails.
#!/usr/bin/raku
use Physics::Unit;
use Physics::Measure;
class Test {
has Length $.length;
has Length $.width;
method foo {
say $!length <=> $!width;
}
}
my $a = Test.new();
$a.foo();
HTH,
documentation (see recent issues)
normalisation
avoid zef compiling AffixUnit.rakumod --- e.g. new module Physics::UnitAffix
(then split Physics::Unit and Physics::Measure - to stop someone else camping on Physics::Unit)
then call it v1.0.0??
406 #Synonyms for Length...
407 #FIXME need eg. my Distance $d = 42cm
408 class Distance is Length is export {}
409 class Breadth is Length is export {}
410 class Width is Length is export {}
411 class Height is Length is export {}
412 class Depth is Length is export {}
right now
$distance ~~ Length #ok
$length ~~ Distance #fail
add ± for symmetric % errors
selectable load of units subsets :all, :SI, :metric, :imperial, :US
Did you actually add this module to the ecosystem, or upload to CPAN?
#rakulang tip of the day: if you're using a multi method new, you probably want to define a proto method new(|) {*} along with it. Otherwise the default new method will be one of the candidates which can lead to some confusing errors.
Maybe m^3 / 1000?
If you follow the suggestion, it kinda displays something, but I'm not sure it's what we want.
27 ** <1/3> #3
viz. https://www.nntp.perl.org/group/perl.perl6.users/2020/07/msg8916.html
When accessing https://mybinder.org/v2/gh/p6steve/raku-Physics-Measure-Jupyter/master the Jupyter Notebook is not showing up.
my \area = ♎️ '60 sq km';
my \n2g = ♎️ '0.5 ①';
my \φ = 0.2;
my \sat = 0.7;
say my \volume = area * d * n2g * φ * sat;
dd volume;
my \vol = volume.norm();
In one of the recent C++ podcasts (CPP Cast), there was an interview with an effort to standardize a units library for C++ (https://cppcast.com/physical-units-mateusz-pusz/).
need to double check if current macOS Alt-0 [º] or Alt-k [˚] is the right symbol for degree (or both)
Consider this... only works ootb with t * t and not t ** 2
1 #!/usr/bin/env raku
2 use lib '../lib';
3 use Physics::Measure :ALL;
4
5 GetMeaUnit('s^2').NewType('TimesSquare');
6 class TimesSquare is Measure {}
7 GetMeaUnit('m^2/s^2').NewType('SpeedSquare');
8 class SpeedSquare is Measure {}
9
10 my \d = 42m; say ~d; #42 m
11 my \t = 10s; say ~t; #10 s
12
13 my \u = d / t; say ~u; #4.2 m/s
14 my \a = u / t; say ~a; #0.42 m/s^2
15
16 my \m = 25kg; say ~m; #25 kg
17 my \f = m * a; say ~f; #10.5 N
18
19 my \v = u + at; say ~v; #8.4 m/s
20 ##my \s = ut + (1/2) * a * tt; say ~s; #63 m
21 my \s = ut + (1/2) * a * t**2; say ~s; #63 m
22
23 my \pe = f * s; say ~pe; #661.5 J
24
25 my \ke1 = (1/2) * m * uu;
26 my \ke2 = (1/2) * m * vv;
27
28 my \Δke = ke2 - ke1;
29 (pe cmp Δke).say; #Same
$ zef --verbose install Physics::Measure
===> Searching for: Physics::Measure
===> Found: Physics::Measure:ver<1.0.5>:authzef:p6steve:api<1> [via Zef::Repository::Ecosystems]
===> Searching for missing dependencies: Physics::Unit, Physics::Error
===> Found dependencies: Physics::Error:ver<0.1.1>:authzef:p6steve:api<1>, Physics::Unit:ver<1.1.9>:authzef:p6steve:api<1> [via Zef::Repository::Ecosystems]
===> Searching for missing dependencies: SVG, SVG::Plot
===> Found dependencies: SVG::Plot, SVG [via Zef::Repository::Ecosystems]
===> Searching for missing dependencies: XML::Writer
===> Found dependencies: XML::Writer [via Zef::Repository::Ecosystems]
===> Fetching [OK]: Physics::Measure:ver<1.0.5>:authzef:p6steve:api<1> to /Users/stevedondley/.zef/tmp/1654343335.25217.1668.456363682831/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz
===> Fetching [OK]: Physics::Unit:ver<1.1.9>:authzef:p6steve:api<1> to /Users/stevedondley/.zef/tmp/1654343335.25217.757.8403821563973/b4a3a245c4ed42d15089f263514b2a61db91ffc4.tar.gz
===> Fetching [OK]: Physics::Error:ver<0.1.1>:authzef:p6steve:api<1> to /Users/stevedondley/.zef/tmp/1654343335.25217.6759.642564553906/f83a8dfe57695e4855f7d79ef94b07714d139108.tar.gz
===> Fetching [OK]: SVG to /Users/stevedondley/.zef/tmp/1654343335.25217.7283.084125426776/svg.git
===> Fetching [OK]: SVG::Plot to /Users/stevedondley/.zef/tmp/1654343335.25217.8532.353125146228/svg-plot.git
===> Fetching [OK]: XML::Writer to /Users/stevedondley/.zef/tmp/1654343335.25217.4940.226940977098/xml-writer.git
===> Extraction [OK]: Physics::Measure to /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz
===> Extraction [OK]: Physics::Error to /Users/stevedondley/.zef/tmp/f83a8dfe57695e4855f7d79ef94b07714d139108.tar.gz
===> Extraction [OK]: Physics::Unit to /Users/stevedondley/.zef/tmp/b4a3a245c4ed42d15089f263514b2a61db91ffc4.tar.gz
===> Extraction [OK]: SVG::Plot to /Users/stevedondley/.zef/tmp/svg-plot.git
===> Extraction [OK]: SVG to /Users/stevedondley/.zef/tmp/svg.git
===> Extraction [OK]: XML::Writer to /Users/stevedondley/.zef/tmp/xml-writer.git
===> Testing: XML::Writer
[XML::Writer] t/escaping.t ... ok
[XML::Writer] t/structure.t .. ok
[XML::Writer] All tests successful.
[XML::Writer] Files=2, Tests=11, 1 wallclock secs ( 0.01 usr 0.01 sys + 0.86 cusr 0.09 csys = 0.97 CPU)
[XML::Writer] Result: PASS
===> Testing [OK] for XML::Writer
===> Testing: SVG
[SVG] t/basics.t .. ok
[SVG] All tests successful.
[SVG] Files=1, Tests=3, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.44 cusr 0.04 csys = 0.49 CPU)
[SVG] Result: PASS
===> Testing [OK] for SVG
===> Testing: SVG::Plot
[SVG::Plot] t/series.t .. ok
[SVG::Plot] t/ticks.t ... ok
[SVG::Plot] All tests successful.
[SVG::Plot] Files=2, Tests=10, 1 wallclock secs ( 0.01 usr 0.01 sys + 0.79 cusr 0.09 csys = 0.90 CPU)
[SVG::Plot] Result: PASS
===> Testing [OK] for SVG::Plot
===> Testing: Physics::Unit:ver<1.1.9>:authzef:p6steve:api<1>
[Physics::Unit] t/01-tst.t ....... ok
[Physics::Unit] t/02-dim.t ....... ok
[Physics::Unit] t/99-testMETA.t .. ok
[Physics::Unit] All tests successful.
[Physics::Unit] Files=3, Tests=34, 14 wallclock secs ( 0.01 usr 0.01 sys + 15.51 cusr 0.42 csys = 15.95 CPU)
[Physics::Unit] Result: PASS
===> Testing [OK] for Physics::Unit:ver<1.1.9>:authzef:p6steve:api<1>
===> Testing: Physics::Error:ver<0.1.1>:authzef:p6steve:api<1>
[Physics::Error] t/00-sanity.t .... ok
[Physics::Error] t/99-testMETA.t .. ok
[Physics::Error] All tests successful.
[Physics::Error] Files=2, Tests=7, 1 wallclock secs ( 0.01 usr 0.01 sys + 0.69 cusr 0.08 csys = 0.79 CPU)
[Physics::Error] Result: PASS
===> Testing [OK] for Physics::Error:ver<0.1.1>:authzef:p6steve:api<1>
===> Testing: Physics::Measure:ver<1.0.5>:authzef:p6steve:api<1>
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in block at t/01-new.t line 23
[Physics::Measure] # You planned 21 tests, but ran 5
[Physics::Measure] t/01-new.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 16/21 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/02-asn.t line 17
[Physics::Measure] # You planned 11 tests, but ran 3
[Physics::Measure] t/02-asn.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 8/11 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/03-add.t line 14
[Physics::Measure] t/03-add.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 26/26 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/04-uni.t line 31
[Physics::Measure] # You planned 37 tests, but ran 7
[Physics::Measure] t/04-uni.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 30/37 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/05-cvt.t line 13
[Physics::Measure] t/05-cvt.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 52/52 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/06-com.t line 12
[Physics::Measure] t/06-com.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 37/37 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/07-ugg.t line 10
[Physics::Measure] t/07-ugg.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 39/39 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/08-syn.t line 13
[Physics::Measure] t/08-syn.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 12/12 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/09-cmp.t line 10
[Physics::Measure] t/09-cmp.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 14/14 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/10-sap.t line 10
[Physics::Measure] t/10-sap.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 19/19 subtests
[Physics::Measure] t/11-pwr.t ....... ok
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/12-uax.t line 47
[Physics::Measure] # You planned 22 tests, but ran 17
[Physics::Measure] t/12-uax.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 5/22 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/13-nrm.t line 26
[Physics::Measure] # You planned 6 tests, but ran 3
[Physics::Measure] t/13-nrm.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 3/6 subtests
[Physics::Measure] Type check failed in assignment to $!error; expected Physics::Error::Error but got Bool (Bool::False)
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 54
[Physics::Measure] in method new at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 66
[Physics::Measure] in sub prefix:<♎️> at /Users/stevedondley/.zef/tmp/4419122c24a1a93fe1d5f391a12beccf93c406b6.tar.gz/dist/lib/Physics/Measure.rakumod (Physics::Measure) line 562
[Physics::Measure] in block at t/14-err.t line 53
[Physics::Measure] # You planned 16 tests, but ran 2
[Physics::Measure] t/14-err.t .......
[Physics::Measure] Dubious, test returned 255 (wstat 65280, 0xff00)
[Physics::Measure] Failed 14/16 subtests
[Physics::Measure] t/99-testMETA.t .. ok
[Physics::Measure] Test Summary Report
[Physics::Measure] -------------------
[Physics::Measure] t/01-new.t (Wstat: 65280 Tests: 5 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 21 tests but ran 5.
[Physics::Measure] t/02-asn.t (Wstat: 65280 Tests: 3 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 11 tests but ran 3.
[Physics::Measure] t/03-add.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 26 tests but ran 0.
[Physics::Measure] t/04-uni.t (Wstat: 65280 Tests: 7 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 37 tests but ran 7.
[Physics::Measure] t/05-cvt.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 52 tests but ran 0.
[Physics::Measure] t/06-com.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 37 tests but ran 0.
[Physics::Measure] t/07-ugg.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 39 tests but ran 0.
[Physics::Measure] t/08-syn.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 12 tests but ran 0.
[Physics::Measure] t/09-cmp.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 14 tests but ran 0.
[Physics::Measure] t/10-sap.t (Wstat: 65280 Tests: 0 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 19 tests but ran 0.
[Physics::Measure] t/12-uax.t (Wstat: 65280 Tests: 17 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 22 tests but ran 17.
[Physics::Measure] t/13-nrm.t (Wstat: 65280 Tests: 3 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 6 tests but ran 3.
[Physics::Measure] t/14-err.t (Wstat: 65280 Tests: 2 Failed: 0)
[Physics::Measure] Non-zero exit status: 255
[Physics::Measure] Parse errors: Bad plan. You planned 16 tests but ran 2.
[Physics::Measure] Files=15, Tests=43, 36 wallclock secs ( 0.04 usr 0.03 sys + 42.20 cusr 1.74 csys = 44.01 CPU)
[Physics::Measure] Result: FAIL
===> Testing [FAIL]: Physics::Measure:ver<1.0.5>:authzef:p6steve:api<1>
Aborting due to test failure: Physics::Measure:ver<1.0.5>:authzef:p6steve:api<1> (use --force-test to override)
Apply labels for 8 base unit types: ":m, :s, :kg, :l ..."
Apply labels for prefix: ":c, :d, :μ..." maybe bucket to ":tiny, :macro, :vast"
Right now with 81 combinations on (all prefixes / just :m, :kg, :s, :l) and 566 off compile time (ie. no precomp is 66sec), uncomment all and compile time is ~30 mins
Long term fix is macros (or faster raku)
The idea of the libra operator is interesting, but I think particularly for this type of a module where the information is fairly simple (that is, /+ +/), using postfixes might work better on top of being more easily typed (or at least as an addition). See https://codereview.stackexchange.com/questions/159150/mass-and-length-calculator-using-perl-6-custom-operator/227804#227804 for an example.
If you're ammenable to it, I'd be happy to work it up and submit a pull request.
When running the code below, the velocity is not calcualted from time and length.
Error: "cannot convert in to different type Length"
in method in at /opt/rakudo-star-2020.01/install/share/perl6/site/sources/E184BD56357B91198F066C3A2CD14FEB4D0BDB42 (Physics::Measure) line 199
in method rebase at /opt/rakudo-star-2020.01/install/share/perl6/site/sources/E184BD56357B91198F066C3A2CD14FEB4D0BDB42 (Physics::Measure) line 206
in method divide at /opt/rakudo-star-2020.01/install/share/perl6/site/sources/E184BD56357B91198F066C3A2CD14FEB4D0BDB42 (Physics::Measure) line 153
in sub infix:</> at /opt/rakudo-star-2020.01/install/share/perl6/site/sources/E184BD56357B91198F066C3A2CD14FEB4D0BDB42 (Physics::Measure) line 477
in block at test.pl6 line 6
Environment: "Rakudo version 2020.01 built on MoarVM version 2020.01.1 implementing Perl 6.d."
<---------------------->
use Physics::Measure;
use Physics::UnitPostfix;
my $s = Measure.new(value => 5.1, units => 'm'); say ~$s;
my $t = Measure.new(value => 2.3, units => 's'); say ~$t;
my $v = $s / $t; say ~$v;
<---------------------->
#snagging
See Part 1 here => #36
Consider if embedding eg. bold unicode chars in definition could be used to (i) separate types (ie Nitrogen-Emissions are different type than Methane-Emissions) and (ii) to tell UnitGrammar to otherwise ignore.
there is a general dislike of our scope things that can be set from consumers of class
nevertheless the behaviour of rounding is something that should be changed as a setting
The following fails with an error:
#!/usr/bin/raku
use Physics::Unit;
use Physics::Measure;
my $a = Length.new(value => 21.006, units => 'cm');
say $a;
Metres work fine, cm don't.
Version 0.0.3
Thanks for your work on this!
Better placed as consumer defined
#!/usr/bin/raku
use Physics::Unit;
use Physics::Measure;
use Physics::UnitPostfix;
my $a;
# Works
$a = Length.new('7.27 in');
say $a;
# Fails
$a = Length.new('7.27in');
say $a;
Here's the output:
Physics::Measure::Length.new(value => 7.27, units => Unit.new( factor => 0.0254, offset => 0, defn => 'ft/12', type => '',
dims => [1,0,0,0,0,0,0,0], dmix => ("ft"=>1).MixHash,
names => ['in','inch','inchs'] );
)
Cannot convert 0+7.27i to Real: imaginary part not zero
in sub extract at [redacted] (Physics::Measure) line 32
in method new at [redacted] (Physics::Measure) line 53
in block <unit> at ./intest line 14
Using the same version as last time (0.0.3)
HTH!
from @kjpye
The default output with say (i.e. using the non-existent gist method) is also problematic. Perhaps a new gist method which does the same as a (possibly upgraded) Str method would be more suitable.
need to worry about trig functions - AB = BCcos(theta) take unit from BC
ie. automatically adjust value and insert prefix
[moved in from https://github.com/librasteve/raku-Physics-Constants/issues/2]
raku -pne '$_ = .Int.polymod(60,60).reverse.join(":")'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.