Skip to content

Commit 0f73478

Browse files
author
flip phillips
committed
Tweaked versioning, added stats, parallel image stuff
1 parent 79cb160 commit 0f73478

File tree

15 files changed

+133
-13
lines changed

15 files changed

+133
-13
lines changed

.vscode/tasks.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
"type": "shell",
1818
"command": "/usr/bin/env wolframscript -f install.wls",
1919
"group": "build"
20+
},
21+
{
22+
"label": "release",
23+
"type": "shell",
24+
"command": "./release.sh",
25+
"group": "build"
2026
}
2127
]
2228
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
-->
1717

1818
## [Unreleased changes]
19+
### Added
20+
- `Statistics.wl` - routines from the pre v5 stats packages
21+
- `Overlap` - where do two lists of events overlap. There's probably a time-series function that does this but I just have data and don't want to have to cram it into a TS. (e.g., my data is spatial so TS is the wrong metaphor)
22+
- `ParallelImageApplyIndexed`
23+
- `GetCompilerFunctions`
1924

25+
### Fixed
26+
- missing trailing ; in `Sugar.wl`
2027

2128
* * *
2229

FPTools/Data.wl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ ImportAsDataset[f_,
3030

3131
True,
3232
Dataset[raw]]]
33+
34+
Overlap[d1_,d2_]:= {Max[{Min[d1], Min[d2]}],Min[{Max[d1], Max[d2]}]}

FPTools/FPTools.wl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Module[{files},
1414

1515
(* load in any session *)
1616
files={"Introspection.wl","Entity.wl","Image.wl","Internet.wl","Sugar.wl",
17-
"Versioning.wl","Globals.wl","Graphics.wl","Data.wl","Signals.wl","GA.wl"};
17+
"Versioning.wl","Globals.wl","Graphics.wl","Data.wl","Signals.wl","GA.wl","Statistics.wl"};
1818

1919
Map[Get[FileNameJoin[{DirectoryName[$InputFileName], #}]] &, files];
2020

FPTools/Image.wl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,22 @@ LensDistortionCorrection[i_,{tx_,ty_},\[Theta]_,{p1_,p2_},kVec_,opt:OptionsPatte
164164
rt=ut@*RotationTransform[\[Theta]];
165165

166166
ImageTransformation[i,rt[LensDistortPoint[tt[#],{p1,p2},kVec]]&,PlotRange->{{0.1,0.9},{0.1,0.5}},opt]]
167+
168+
(* this is still in development-ville, right now it is for a single image plane *)
169+
170+
ParallelImageApplyIndexed[f_, img_] :=
171+
Module[{rows, cols, ix, id, decode, pd, res},
172+
{rows, cols} = ImageDimensions[img];
173+
174+
decode[i_] := {Quotient[i - 1, rows] + 1, Mod[i - 1, rows] + 1};
175+
176+
(*ix=Table[{r,c},{r,1,cols},{c,1,rows}];*)
177+
178+
ix = Table[i, {i, 1, rows*cols}];
179+
id = Flatten[ImageData[img]];
180+
181+
pd = Transpose[{id, ix}];
182+
183+
res = ParallelMap[f[#[[1]], decode[#[[2]]]] &, pd];
184+
Image[Partition[res, rows]]
185+
]

FPTools/Introspection.wl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,5 @@ GetSymbolsDefinedInMX[mxfile_] := Module[
124124
];
125125
If[res=={{"System`Private`ConvertersPrivateDumpSymbol"}},None,res]
126126
];
127+
128+
GetCompilerFunctions[] := Sort[Compile`CompilerFunctions[]]

FPTools/PacletInfo.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Publisher -> "Skidmore Vision Lab",
66
Copyright -> "©2018- Flip Phillips & Misc Contributors",
77
License -> "MIT",
8-
Version -> "1.0.4",
9-
BuildNumber -> "160",
8+
Version -> "1.0.6",
9+
BuildNumber -> "185",
1010
MathematicaVersion -> "11.2+",
1111
URL -> "https://github.com/flipphillips/FPTools",
1212
Thumbnail -> "Documentation/icon.png",
@@ -21,7 +21,7 @@
2121
"FPTools`$FPToolsVersion","FPTools`$FPToolsDebug",
2222

2323
(* data *)
24-
"FPTools`ImportAsDataset",
24+
"FPTools`ImportAsDataset", "FPTools`Overlap",
2525

2626
(* Entity *)
2727
"FPTools`EntityPropertiesDataset",
@@ -38,6 +38,7 @@
3838
"FPTools`BlurFaces","FPTools`FindFaceImages",
3939
"FPTools`AddAlphaChannel",
4040
"FPTools`LensDistortPoint", "FPTools`LensDistortionCorrection",
41+
"FPTools`ParallelImageApplyIndexed",
4142

4243
(* ffmpeg *)
4344
"FPTools`$FFMpegPath", "FPTools`ImportMP4Frame", "FPTools`ImportMP4Frames", "FPTools`ImportWebFrame",
@@ -48,13 +49,25 @@
4849
(* introspection *)
4950
"FPTools`Spelunk","FPTools`PropertiesAvailability","FPTools`PropertiesDataset",
5051
"FPTools`NewKernelEvaluate","FPTools`GetSymbolsDefinedInMX",
52+
"FPTools`GetCompilerFunctions",
5153

5254
(* signals *)
5355
"FPTools`FindZeroCrossings","FPTools`UnitizedGaussianPDF",
5456
"FPTools`FFTShift",
5557
"FPTools`InverseFFTShift",
5658
"FPTools`RealSphericalHarmonicY",
5759

60+
(* statistics *)
61+
"FPTools`LocationReport",
62+
"FPTools`ShapeReport",
63+
"FPTools`DispersionReport",
64+
"FPTools`StandardDeviationMLE",
65+
"FPTools`VarianceMLE",
66+
"FPTools`StandardErrorOfSampleMean",
67+
"FPTools`VarianceOfSampleMean",
68+
"FPTools`CoefficientOfVariation",
69+
"FPTools`ZeroMean",
70+
5871
(* sugar *)
5972
"FPTools`ApplyIf",
6073
"FPTools`ToCartesianRules",

FPTools/Statistics.wl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
(* some routines I used to use from the old statistics packages *)
3+
4+
LocationReport[data_] := {Mean -> Mean[data],
5+
HarmonicMean -> HarmonicMean[data], Median -> Median[data]} /; VectorQ[data]
6+
7+
ShapeReport[list_] := {
8+
Skewness -> Skewness[list] ,
9+
QuartileSkewness -> QuartileSkewness[list] ,
10+
Kurtosis -> Kurtosis[list]} /; VectorQ[list]
11+
12+
DispersionReport[list_] :=
13+
{
14+
Variance -> Variance[list] ,
15+
StandardDeviation -> StandardDeviation[list] ,
16+
MinMax -> MinMax[list] ,
17+
MeanDeviation -> MeanDeviation[list] ,
18+
MedianDeviation -> MedianDeviation[list] ,
19+
QuartileDeviation -> QuartileDeviation[list]
20+
} /; VectorQ[list]
21+
22+
StandardDeviationMLE[data_] :=
23+
StandardDeviation[data] Sqrt[(Length[data] - 1)/Length[data]]
24+
25+
VarianceMLE[data_] := Variance[data] (Length[data] - 1)/Length[data]
26+
27+
StandardErrorOfSampleMean[data_] :=
28+
StandardDeviation[data]/Sqrt[Length[data]]
29+
30+
VarianceOfSampleMean[data_] := Variance[data]/Length[data]
31+
32+
CoefficientOfVariation[data_] := StandardDeviation[data]/Mean[data]
33+
34+
ZeroMean[data_] := data - Mean[data]

FPTools/Sugar.wl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ ApplyIf[f_, g_][x_] := ApplyIf[f, g, x];
77

88
ToCartesianRules[] :=
99
MapThread[
10-
Rule, {{r, \[Theta], \[Phi]}, ToSphericalCoordinates[{x, y, z}]}]
10+
Rule, {{r, \[Theta], \[Phi]}, ToSphericalCoordinates[{x, y, z}]}];
1111

1212
ToSphericalRules[] :=
1313
MapThread[
1414
Rule, {{x, y, z},
15-
FromSphericalCoordinates[{r, \[Theta], \[Phi]}]}];
15+
FromSphericalCoordinates[{r, \[Theta], \[Phi]}]}];

FPTools/Usage.wl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ PropertiesDataset::usage = "PropertiesDataset[object] returns a TableForm of the
2020
NewKernelEvaluate::usage = "NewKernelEvaluate[expr] evaluates expr in a fresh, clean kernel and returns the result.";
2121
GetSymbolsDefinedInMX::usage = "GetSymbolsDefinedInMX[mxfile] returns a list of symbols defined in mxfile.";
2222

23+
GetCompilerFunctions::usage = "GetCompilerFunctions[] returns the list of functions that are compilable.";
24+
2325
(* ::Section:: *)
2426
(*Entity*)
2527

@@ -48,6 +50,7 @@ LensDistortPoint::usage = "LensDistortPoint[{x,y},{p1,p2},{k1,...}] projects poi
4850

4951
LensDistortionCorrection::usage = "LensDistortionCorrection[image,{tx,ty},theta,{p1,p1},{k1,k2,k3...}] performs a lens distortion correction along with a generalized translation (t) and rotation (theta). p1 and p2 specify 1st order astygmatism and k1-6 the different orders of distortion beyond that. Note you only need to supply k's up to the desired order of correction.";
5052

53+
ParallelImageApplyIndexed::usage = "ParallelImageApplyIndexed[f,im] maps f over im using parallel kernels. At this point, its only a single image plane";
5154

5255
(* ::Section:: *)
5356
(*Internet*)
@@ -87,6 +90,8 @@ ImportAsDataset::usage = "ImportAsDataset[f] imports f and uses the first row as
8790

8891
UnitizedGaussianPDF::usage = "UnitizedGaussian[mu,sigma] gives a pure function of a PDF whose value at the mean = 1.0.";
8992

93+
Overlap::usage = "Overlap[l1,l2] gives the intersection of the range of two lists.";
94+
9095
(* ::Section:: *)
9196
(*Signals*)
9297

@@ -102,4 +107,22 @@ RealSphericalHarmonicY::usage = "RealSphericalHarmonicY[l,m,th,phi] returns real
102107

103108
GARepopulate::usage = "GARepopulate[pop,fitfunc] creates a new population using fitfunc.";
104109
GAMutate::usage = "GAMutate[chromo] mutates a chromosome.";
105-
GACrossover::usage = "GACrossover[c1,c2] performs a random crossover of c1 & c2. Returns two offspring.";
110+
GACrossover::usage = "GACrossover[c1,c2] performs a random crossover of c1 & c2. Returns two offspring.";
111+
112+
(* ::Section:: *)
113+
(*Statistics*)
114+
LocationReport::usage = "LocationReport[list] gives the Mean, HarmonicMean, and Median location statistics for list.";
115+
DispersionReport::usage = "DispersionReport[list] gives the Variance, StandardDeviation, SampleRange, MeanDeviation, MedianDeviation, and QuartileDeviation dispersion statistics for list.";
116+
ShapeReport::usage = "ShapeReport[list] gives the Skewness, QuartileSkewness, and KurtosisExcess shape statistics for list.";
117+
118+
StandardDeviationMLE::usage = "StandardDeviationMLE[list] gives the standard deviation of the entries in list. Division by n is used, giving a maximum likelihood estimate of the population standard deviation.";
119+
120+
VarianceMLE::usage = "VarianceMLE[list] gives the variance of the entries in list. Division by n (rather than n-1) is used, giving a maximum likelihood estimate of the population variance (use Variance[list] for an unbiased estimate).";
121+
122+
StandardErrorOfSampleMean::usage = "StandardErrorOfSampleMean[list] gives an unbiased estimate of the standard error (standard deviation) of the sample mean, using the entries in list as a sample from the population.";
123+
124+
VarianceOfSampleMean::usage = "VarianceOfSampleMean[list] gives an unbiased estimate of the variance of the sample mean, using the entries in list as a sample from the population.";
125+
126+
CoefficientOfVariation::usage = "CoefficientOfVariation[list] gives the coefficient of variation, defined as the ratio of the standard deviation to the mean of the entries in list. If the entries are not all positive, then $Failed is returned."
127+
128+
ZeroMean::usage = "Zeroize the data about the mean.";

0 commit comments

Comments
 (0)