Repository navigation
Ci/linux fix - #15
Merged
Merged
Ci/linux fix#15
Conversation
A seed outside a boundary that is not convex lost its cell: index gave it the cell that holds the point, which is NA outside the boundary, so cell_values_at(seeds =) filled or mislabelled locations near the edge. build_tessellation() and create_voronoi_polygons() now carry each cell's generator through the clip, and for seeds (the package's seed layers, a selection's seeds, or points given with a cover) index names the cell the seed generates. A seed keeps NA only when the clip removed its whole cell, and the warning now says so. Plain points keep the observation rule. The cells themselves are unchanged. The work-round section in ?cell_values_at is removed. Two tests that pinned the old index are turned round, and test-fix-cells-seed-index.R covers the notched layers, every kind of seed layer and a seed whose cell the clip removed.
- select_resolution()'s size note calls 4.5 rows per cell "the default" rather than "the caller's choice". - The pooled print of a column with tau2 = 0 shows the full block and says each value is its neighbours' mean. - A profile with one level prints "1 level" and drops the WSS-steps clause when fewer than two levels have a WSS; the WSS-steps count on a row subset now counts that subset. The help and the resolution vignette no longer say the size stands because the caller set it. One frozen record, small_five_rows, changes in two printed lines; dev/baseline-core-frozen.R gains a --retake mode to take a record from new code.
…lbow The default on_no_elbow is now "na": with no elbow, too short a ladder or too few distinct points, the call returns NA_integer_ with a spatialkit_no_elbow warning that carries k, sag and structured = FALSE. On the model-aware criteria the NA also carries the sweep's diagnostics. A count the elbow chose carries structured and sag. on_no_elbow = "warn" gives the earlier count and warning exactly. get_voronoi_seeds(n = NA) stops with a message naming the default. The help, README, ?spatialkit and the vignettes tie the NA to the elbow, not to clusters; getting-started names on_no_elbow = "warn". Four frozen calls name "warn" and no record changes.
- Cp no longer takes a nugget at the variogram fit's lower bound; it takes the finest level's residual mean square instead. - Cp's noise variance is held to the short-lag semivariance, and attr(, "cp_noise") and the print say which source was used. - The two variogram warnings carry classes, spatialkit_variogram_unusable and spatialkit_cp_noise. - A cp selection carries a count_rule record, so a pooled summary on its cells raises spatialkit_estimate_mismatch. - A profile without an estimate fitted to a subsample refits the chosen level to every point before handing on its seeds. A profile with an estimate keeps the centres it scored. NEWS and ?spatialkit name the two ways the old-default call no longer gives the old count. 76 frozen records are retaken; test-fix-cp-predictor- path.R covers the repair, including a held-out regret check on six fields.
A cross-validated error is the error at the distance the folds put between held-out points and their training data. The help, vignettes, README, tour scripts and make_folds()'s warnings said instead that random folds flatter, that blocked folds are the ones to report, or that a score leaks, with no target. They now say which way the error reads for predictions farther from or closer to the data, the cv_*() pages state what folds = NULL estimates, and three vignettes check their folds against the map with fold_separation(). The reporting vignette's reading had the direction backwards for its own map and is now computed. No default changes. test-fix-cv-direction-wording.R checks the wording rule across the help, vignettes and scripts.
determine_optimal_levels() switched criterion = "geometric", the default, to "combined" whenever both response_var and predictor_vars were given, also when "geometric" was named, so the count read the response unasked. "combined" averaged the rank of the WSS curve's log-log sag with the rank of Moran's z of the cell means, which put first ten, the lowest count Moran's z can be computed at, or the count after it: on 600 uniform points with a smooth field, under on_no_elbow = "warn", it returned 10 6 5 where "geometric" returns 6 5 7. Its sag came from a curve carrying the WSS of the k-means re-run, so where the re-run landed in a worse optimum at the elbow another count went first, and on eighteen loose clusters the elbow, 15, dropped out of the counts returned. The criterion the caller names, or the default, now stands. With both variables under "geometric", a line logged at INFO says they are not read. "combined" ranks the counts around the elbow by the sag of the sweep's WSS curve, the one the elbow is read from, so the elbow comes first. moran_i, moran_z and wss_eval stay in the diagnostics and rank nothing. Where Moran's I can be computed at no count of a window that reaches ten cells, "combined" ranks as usual and returns the diagnostics with moran_i and moran_z NA and a logged warning, where it fell back to the geometric ranking without them; "morans_i" still falls back there. Two Breaking changes entries in NEWS describe this. A call with both variables and no criterion returns the geometric vector with no "diagnostics" attribute. "combined" returns 11 12 10 on eleven clusters, where it returned 10 11 12, and the same vector with select_on = "split" or a constant response. It raises no spatialkit_diagnostic_ranking warning; that warning comes with "morans_i" alone, its condition no longer carries `upgraded`, and its message names resolution_profile() and select_resolution() in place of select_resolution(criterion = "cp"), an error on the default profile. A factor response is refused only under a criterion that reads it. The help, the class list on the resolution_profile() help page, the vignette, script 02, the README troubleshooting entry and four older NEWS entries are brought in line. No frozen record changes. Tests turned round: the ranking-warning test in test-fix-resolution-moran-diagnostic.R (no `upgraded`, the plain advice, no warning from "combined", "geometric" with both variables); two tests in test-review3-S1-resolution.R, now "combined ranks the window on the log-log sag alone, the elbow first" and "combined on points with no elbow keeps the geometric order"; the "warn" leg in test-fix-levels-no-elbow.R, which expects the ranking class under "morans_i" only; test-resolution-profile.R and test-return-accounting.R, which expect no ranking warning from "combined"; and test-audit-pass5.R, which names criterion = "combined" for the factor-response error. Calls in test-select-on.R and test-review-resolution.R name the criterion. test-fix-levels-combined.R is new.
.estimate_icc() returned 0 both for an ICC it could not estimate (a column's values all in one cell, fewer than two cells holding two or more of them, fewer than four values) and for an estimate at or below 0, so summarize_by_cell(deff = "kish"), and a "variogram" request that fell back to it, gave an unidentified column the uncorrected standard errors under the label of an ICC of 0. Under deff = "variogram", a response with no spatial structure gave every predictor a design effect of 1 in silence, whatever structure the predictor had of its own. .estimate_icc() now returns NA with a reason in the first case and 0 in the second. It reads whether a column varies from all its non-missing values, rows with no cell id included, and names columns whose values fall in no cell or differ only there. For a column with an NA ICC the ..se_*, ..neff_* and ..ci_* values are NA in every cell of two or more values (..df_* stays n - 1), and so is cell_weight when that column sets it; a cell of one value keeps a weight of 1. A column that does not vary keeps standard errors of 0 with no warning. A warning of class spatialkit_icc_unavailable (fields columns and reason) names the withheld columns. attr(, "icc") gains a reason field only when some ICC is NA, the variogram fallback warning names those columns, and under estimate = "pooled" the method of attr(, "intervals") names them after 1 as after "kish", with .intervals_table() still giving the default's text for the other columns. A predictor summarised under a no-structure verdict gets a warning of class spatialkit_deff_no_structure (fields columns and reason); its numbers do not change. NEWS records both under Breaking changes. Three records of tests/testthat/fixtures/core-frozen.rds are retaken: values_one_region (its standard errors, effective n, intervals and cell_weight become NA, with one spatialkit_icc_unavailable warning), values_one_row_regions and values_constant (attr(, "icc") gains reason). No existing test is turned round. "the ICC guard matches its documentation" in test-audit-pass5.R and "a variogram fallback with no fit reports why, as an R warning" in test-review2-assignment.R gain expectations for the NA ICC.
area_of_applicability() measured location for a forest fitted with include_coords = TRUE only through its ..x and ..y predictor columns. Under weights = "auto" those columns take the forest's own importance, so a forest that barely split on its coordinates gave location almost no weight. With half of 50 prediction points one half to one and a half extents beyond the training data, 41 read as inside, 16 of them beyond the extent. Such a forest now gets the location index a gwr_fit and a bayesian_fit get (DI_location, element location), with the same folds and the same rule for repeated locations, and a point is inside only when it is inside on both indices. ..x and ..y stay in the predictor index with the same weights, so DI and threshold are unchanged and DI <= threshold is the old answer. The location coordinates are read after the coordinate block, so a CRS on one side only is reconciled and warned about once. In the example above none of the 25 points beyond the extent is inside. For the forest, params$coords reads "location index and predictors", print() adds "and as the predictors ..x and ..y" under the location line, and plot() counts points outside on location in its subtitle. A threshold the caller passes sets the predictor index alone, and coords = "no" leaves the coordinates out of both indices. The Breaking changes entry in NEWS states the rest: a row outside on location is FALSE also when a predictor is missing, where it was NA; folds that split repeat visits can give a location threshold of 0 with the spatialkit_aoa_zero_threshold warning; and a train_sf in a geographic CRS is refused. The data.frame refusal now suggests coords = "no". No frozen record changes. The test "a forest with the coordinates as predictors keeps its own path" in test-fix-aoa-rf-location.R is turned round to "... keeps them and gains the location index", and the reprojection test in test-area-of-applicability.R also compares DI_location. New tests are in test-fix-aoa-coord-forest.R.
With 2 to 9 cells, summarize_by_cell() takes each cell's target as the mean of every row outside it, so a cell whose own weight is below its share of the column's rows gets a pooled value on the far side of the overall mean from its plain mean. With two cells and `tau2` at 0 every own weight is 0, and each cell's pooled value is the other cell's mean. The spatialkit_pool_few_cells warning said only that a cell "with a small own weight" crosses the overall mean and that two cells can change order. The warning now gives the share of the column's rows as the bound, and adds one sentence naming the columns with two cells and `tau2` at 0: "For 'p' and 'q', with 2 cells and `tau2` at 0, each cell's pooled value is the other cell's mean: the two cells' values change places." The sentence is left out when no column is in that state. The "Conditions" entry of ?summarize_by_cell says the same, and says such a column has `cells` 2 and `own_weight` 0. The pooled values, the condition's class and its fields (`columns`, `cells`, `own_weight`) are unchanged. NEWS has a Bug fixes entry, and nothing goes under Breaking changes. No frozen fixture record was retaken. Two tests were turned round: "with 2 to 9 cells the target is the mean of all the other cells, with a warning" in test-core-pool-edge.R pinned the old sentence for 2, 3 and 9 cells, and "no number stands in those texts but the simulation's figures, its settings and the code's constants" in test-core-docs.R gains 2 and 0 for the "Conditions" entry. New tests check the exchange sentence, that it names no other column, the share when values are missing, and the help and NEWS text.
Texts that print only in a particular case misstated that case. Each now says what happened: - FNN installs with spatialkit, and the texts for when it cannot be loaded said to install it: the work limits of resolution_profile(), summarize_by_cell() and cell_values_at(), the density kind's log line, area_of_applicability(use_fnn = TRUE), the k-NN weights and spatialkit_moran_skipped. They say it could not be loaded and is to be reinstalled. The work-limit errors wrote both numbers with %.2g, so a work 0.04 percent over the limit read "1e+10 ... above the limit of 1e+10"; .count_text() writes them in full with the digits that tell them apart, and the fit guard no longer offers "the FNN package installed". - On a constant response the spatialkit_constant_response warning left out `loo`, `loo_se` and `own_weight`, which are NA too, and summary() stopped with an error that named neither the constant response nor `loo`. The warning names the three, and the error says the response is constant and names `loo`. - select_resolution() said one mean was "within 2% of the optimum" also where it was lower; it says "is not above the optimum by more than 2%", the rule. After Cp's note the variogram's no-structure note was pasted in lower case with its close said twice; it is a sentence of its own. summary() said that one cell does as well where the cells beat one cell and only the F test or the variogram showed no structure; it says which, in attr(, "not_identified"), and picks that agree read "every pick is 60 cells" in place of "picks span 60 to 60 cells (1.0x)". - The support-ceiling hint said to lower min_cell_n, which moves every level; it names `levels`. The prints write "the default" for the default size, "(1 of 1 level)", "(133 cells)", "1 k-means++ restart" and the numbers of one line in one notation (.one_notation()). The profile's print marks a bound nugget where no level gives a noise variance, and says that `cp` is NA. - summarize_by_cell()'s no-structure warning called predictors "the response"; it says "the column" or "the columns". cell_values_at() on a logical, factor or character column advised a summary that summarize_by_cell() cannot make; it says how to convert each class. assign_features_to_polygons() blamed the polygons or the CRS for features with empty geometry; it counts them. - make_folds(auto_range = TRUE) with a `block_size` said the range set the minimum block size; it says the `block_size` does and gives the grid of blocks. On one row it writes "1 fold" and offers no fewer folds. A random or provided seeding's density warning names the method in place of the density kind. model_metrics(se.fit = TRUE) names cv_bayes() only for draws or a Bayesian fit. The REML fallback of estimate_sac_range() said the fit did not converge below 30 locations or without nlme; it says it was not fitted, and why. kriging_adequacy()'s print says what its gain is under a pure nugget. voronoi_seeds_kmeans() and voronoi_seeds_random() refuse the NA of determine_optimal_levels() with the note that names `on_no_elbow`. NEWS has four Bug fixes entries and two under Breaking changes. resolution_profile() raises one spatialkit_size_not_reached for all the sizes held for the same reason, where it raised one a size; its `obs_per_cell` and `wanted` are vectors in ladder order, and one size held gives the condition it gave. The rejected_reason of estimate_sac_range() when fewer than three lag bins hold pairs is "no variogram model could be fitted: fewer than three lag bins hold point pairs", where it ended "(singular fits)". The frozen fixture retakes the 24 records whose value, print, conditions or log carry these texts: select_density_cp, select_density_arguments_cp, select_density_clustered_cp, select_integer_cp, select_lattice_cp, select_lattice_density_cp, select_lonlat_density_cp, select_min_cell_n_cp, select_n_levels_cp, select_sampled_cp, seeds_density_selection, seeds_density_profile, kmeans_density_selection, kmeans_density_profile, count_kmeans_selection_kmeans_named, select_noise_cp, small_five_rows_selected, small_five_rows_count, count_hex_noise, count_kmeans_noise, count_seeds_noise, seeds_noise_selection, seeds_random_power_named and summary_constant; the last two are retaken for the first time. Tests that pinned the old texts are turned round in test-core-count-ladder.R, test-core-count-loo.R, test-core-count-size.R, test-core-pool-edge.R, test-core-pool-properties.R, test-core-pool-summary.R, test-core-seeding-starts.R, test-core-values-at.R, test-fix-resolution-bound-warning.R, test-fix-resolution-structure-test.R and test-fix-resolution-usability.R. test-fix-resolution-no-structure.R accepts the capitalised variogram note, and "kriging_adequacy() says why there is no variogram model, and whose" takes the new reason. New tests are in test-fix-texts-misstated.R, and test-fix-cp-predictor-path.R checks the bound-nugget print.
Four run-time texts said which way an error errs with no word on the map it errs for. print() on an rf_fit called the out-of-bag error "optimistic under spatial autocorrelation"; the caution that fit_rf_model(include_coords = TRUE) logs said the out-of-bag error and random cross-validation "overstate its accuracy"; the caution that select_features_forward(method = "random_kfold") logs said random inner folds "leak spatial autocorrelation" and that a blocked outer loop reports "honest-looking numbers"; and the warning of .remap_folds() on its fallback to random folds said blocked folds "avoid optimistic performance estimates". Each text now says what the error is the error of and names the predictions it reads low for. The out-of-bag error and random folds are the error of predicting among the samples, which reads low for predictions made farther from the data, and the advice is cv_rf() or make_folds() on folds at the distances the map will predict at (?fold_separation). The random_kfold caution says the inner folds choose the variables that predict best among the samples and a blocked outer loop scores the chosen set at the blocks' distance, for which it was not chosen, and it advises inner folds that hold points out as the outer ones do: 'block_kfold', the default. A forest with no row out of bag closes its print with how to score it with cv_rf() in place of the paragraph on an out-of-bag error it does not have. Only the text of a print, two log lines and one warning changes: no result, default, class or error. NEWS has one Bug fixes entry. It leaves out the .remap_folds() warning, which no exported function reaches, since each caller builds block_kfold folds when folds is NULL. Three pins of the old wording are turned round to refuse it and match the new sentences: "print.rf_fit states the out-of-bag caveat" (now "print.rf_fit says what the out-of-bag error is the error of") in test-model-rf.R, the first test of test-fix-aoa-rf-coords-text.R, and "random inner folds are permitted but warned about" in test-feature-selection.R. test-fix-cv-direction-wording.R bars four more phrases and judges the new texts, with the prints of a forest fitted with coordinates and of one with no row out of bag, by the rules the pages follow, each header line of a print as a sentence of its own, and test-review3-S8-bayes-rf.R pins the closing lines of the no-OOB print. No frozen fixture record is retaken.
.crs_distance_error() also scores a layer of fewer than 40 polygons or lines on its outlines' vertices, and above 160 vertices it thinned them at even spacing along the rows of st_coordinates(), which follow the order of the features. Five outlines of 200 vertices over the conterminous United States got an Albers CRS in three of eight feature orders and a Lambert azimuthal one in the other five. .crs_area_error() measures at most 200 of a layer's polygons and took them at even spacing along the rows, so the area error moved with the order: 300 cells in a UTM zone, one of them 700 km east of its central meridian, were refused by summarize_by_cell(area = TRUE) in five of eight orders. The outline is now thinned along its distinct vertices sorted by x and then y, as a point layer's points are sampled: a vertex listed twice (a ring's closing vertex, a border two features share) counts once, and a thinned outline is no longer densified between the vertices kept. Above 200 polygons, the new internal .polygon_sort_keys() orders the polygons by bounding box and then by the means of their vertices' x, y, x^2, y^2 and x*y, which separates polygons that share a box, such as Delaunay triangles of gridded points. The 200 are taken at even spacing along that order, and the polygons with the smallest xmin and ymin and the largest xmax and ymax are always added, so up to 203 are measured. For a given layer the chosen CRS, attr(, "area_error") and the outcome of the area check in summarize_by_cell(area = TRUE) and in ensure_projected(purpose = "area") on projected input can differ from before, and are the same in every row order. The help for the `area` argument of summarize_by_cell() says how the cells are sampled, and NEWS has an entry under Bug fixes. No default or exported contract changes, so there is no Breaking changes entry. No frozen fixture record is retaken and no existing test is turned round. tests/testthat/test-fix-crs-polygon-order.R checks the CRS, the area error and the refusal over several row orders, rings started from another vertex, shared borders, cells that share a bounding box, and a far cell at the edge of the layer.
build_tessellation(crs = 4326) builds the cells of the scored centres in the profile's projected CRS and transforms them. On gridded locations four centres can stand the same distance from one point, and two cells meet there at two corners less than a nanometre apart. The transform to degrees puts them at one point, s2 refused the cell, and assign_features_to_polygons() stopped with "duplicate vertex" on rows in lon/lat. On 16 lattices with rows in EPSG:4326, 27 of 32 paths under the two kinds stopped, and 3 of the other 5 put rows on an edge in another cell than the profile's. When the polygons are in lon/lat and their count record says a profile scored them and holds its centres in a projected CRS, assign_features_to_polygons() moves the join's copy of the features and the polygons to the record's CRS and joins there. The rows returned keep the coordinates they arrived with. Projected cells are joined in their own CRS as before, and lon/lat cells without the record, or with scored_cells = FALSE, still go to s2. On such cells every row lands in the cell the profile scored it in, a point on an edge goes to its nearest centre's cell, and the check in summarize_by_cell() reads "match" on all 32 paths. Features that are not points get overlaps and areas measured in the projected CRS, rows without a CRS join instead of stopping, and cell_values_at() without seeds places locations there too. The help for assign_features_to_polygons(), summarize_by_cell(), create_voronoi_polygons() and build_tessellation() says which cells s2 can still refuse, and NEWS has a Bug fixes entry. In the test "only points on cells with the scored centres in a CRS the join can measure are placed by the profile's rule", the meridian squares with a record in EPSG:32617 now expect the nearer centre's cell for all five points in place of the sphere's answer, and the six points and squares in lon/lat with that record now expect the profile's rule on the points' coordinates in EPSG:32617. No frozen record is retaken.
The seeding functions attach the convex hull of the points they cluster as attr(, "cover"), and .cover_follow() moves it into the cells' CRS with its edges read as straight lines in degrees. For lon/lat points .cover_of() built the hull with s2, whose great-circle edges bow toward the pole. Over the box of the conterminous United States one of 800 points lay 130 km outside the moved cover against a 127 km margin and fell in no cell at 44 and 178 seeds. Round a pole the hull held none of the seeds and was set aside with spatialkit_no_cover (230 of 600 points in no cell at 10 seeds), round the globe it was the whole sphere, and for points on both sides of 180 degrees it ran the long way round. .cover_of() now takes the planar hull of the bare coordinates and sets the layer's CRS on it after. For lon/lat points the new .lon_narrowest() reads the longitudes from -180 to 180 or from 0 to 360, whichever spans fewer degrees, so points on both sides of 180 get a hull whose longitudes run past 180 (-170 as 190). .cover_follow() moves such a cover as it is into a CRS that joins the two sides of 180, as tested by the new .joins_across_180(). Into a CRS that splits the map there, as Web Mercator does, the new .cut_at_180() cuts it at 180 and moves the far part back by 360 degrees, before the edges are densified, so the edges along 180 follow a curved 180th meridian in Mollweide or Equal Earth. On these layers every observation has a cell, the summary's check reads "match", and between 170 E and 170 W the cells on 10 seeds go from 11 times to 1.3 times the points' hull. Cells on seeds placed from lon/lat points can differ at their outer edge, and differ throughout where the cover was set aside or ran the long way round. Layers in a projected CRS, seeds drawn in a boundary and the hull a profile keeps are unchanged. ?get_voronoi_seeds and ?voronoi_seeds_kmeans describe the cover, and NEWS has a Bug fixes entry; nothing goes under Breaking changes. Ten records in core-frozen.rds are retaken, in value only, with and without FNN and Matrix: seeds_lonlat, seeds_lonlat_density, seeds_lonlat_selection, kmeans_lonlat, kmeans_lonlat_density, cells_lonlat, cells_lonlat_selection, values_lonlat, values_lonlat_variogram and values_lonlat_area. Their cover has the same vertices in another order, and the cells move by at most 2.2e-5 m. The test "cells returned in EPSG:4326 are joined in the profile's CRS: rows in degrees on the sixteen lattices ..." in test-core-gridded-ties.R is turned round: s2 now refuses a cell on 10 of the 16 density-kind lattices, where it was 11. New tests are in test-fix-cells-cover.R.
With `what = "loo"` (the same rows in the same number of cells, another leave-one-out error), the spatialkit_cells_differ warning from summarize_by_cell() said that rows exactly on a boundary between two cells (gridded locations) can be assigned to the other cell. assign_features_to_polygons() gives such a row the cell the profile scored it in on the scored cells that carry their count record, kept in the CRS the profile measured the rows in. The sentence named a cause that no longer applies there and left out the ones that do. The closing sentence now names those cases: rows the polygons alone placed (rows without a CRS, rows assigned to cells without their count record, such as cells read back from a file, and rows given their cells by another join than assign_features_to_polygons()), cells built in, or transformed to, another CRS than the one in the count record, cells that are not the Voronoi cells of the scored centres (seeds moved, cells edited), and coordinates that reached that CRS by another transformation. The `what = "cells"` sentence is unchanged. The condition's class, its fields and every result are unchanged. ?summarize_by_cell names the same cases, says that cells transformed to another projected CRS are joined there, and that on a layer wider than a UTM zone the round trip of cells returned in a geographic `crs` can move a corner past the join's margin. NEWS has a Bug fixes entry, and nothing goes under Breaking changes. No frozen fixture record was retaken. Two tests were turned round: "two rows exchanged between neighbouring cells are told from rows dropped" in test-core-count-rule.R pinned the old sentence and now pins the new one, and checks that a cell moved whole into its neighbour reads `what = "cells"`; the else branch of "on gridded locations the check says match exactly when no row was placed in another cell" in test-core-pipeline.R pinned the old cause and now pins the polygons-alone clause. New tests in test-core-gridded-ties.R cover cells drawn in a projected CRS the caller names, rows the polygons alone place, cells transformed to EPSG:5070 and 3857, and the help and NEWS text.
new_spatial_fit() checked only that subclass was one string and built a
fit from any data_sf, formula, response_var, predictor_vars and info. A
column number or a factor as response_var made summary() and
model_metrics() score the fitted values against the column at that
position, since a factor indexes by its code. A misspelt name, the
geometry column's name or a list as data_sf failed later in another
function with a message about something else, a data_sf without
geometry made residual_morans_i() blame a missing residuals() method,
and a data.frame as info stopped with "replacement has 0 rows".
The constructor now stops, without a call and with a message that names
the argument and what it got, unless subclass is one non-empty class
name, data_sf an sf object, formula a formula, response_var one string
naming an attribute column of data_sf, predictor_vars a character
vector of attribute columns (character(0) for none) and info a list.
The geometry column, the one sf names whatever it is called, is refused
as the response or a predictor with a message of its own. NULL as info
is still taken as list(). The response's type is not checked, since a
Bayesian fit can have a factor or ordinal response; summary() and
model_metrics() refuse a non-numeric one as before.
NEWS has a Breaking changes entry, and ?new_spatial_fit says what the
constructor checks and what each argument must be. A fit_fn that passed
st_drop_geometry(train_sf) has to pass train_sf, and a brms::bf()
formula is passed as its $formula. A fit that names a column the
training rows lack fails every fold of cv_spatial() with the
constructor's message in fold_status. In select_features_forward(), a
fit_fn whose fit for no predictors is refused (predictor_vars = NULL,
say) gets the training-fold mean as its baseline, and baseline$type
says "fold mean".
In "new_spatial_fit builds the documented structure" in
test-spatial-fit-s3.R, the expect_error() for subclass = c("a", "b")
now matches "`subclass` must be one class name", and the check that a
cache passed in info is kept, which held only because testthat's
edition 3 finds two empty environments equal, now expects the fresh
cache the constructor puts in its place. "area_of_applicability takes
training data from a fitted model" gives its stand-in fit the response
column z it named. test-fix-new-spatial-fit-args.R pins each refusal
and what still builds. No frozen fixture record is retaken.
With seeds, cell_values_at() fills a location whose cell has no row in values from its nearest scored row. When no seed carried the ID of a cell of values (an ID column from elsewhere, the index of another tessellation, or IDs that are all NA), every location was filled and nothing was raised: on a layer of 107 cells, seeds numbered 1001 to 1107 filled all 120 locations asked for, and 18 values differed from those of the locations' own cells. A values with no cell ID gave every location NA. Seeds without a CRS beside points with one stopped with an error that named no CRS, though get_voronoi_seeds() returns seeds without one for rows in lon/lat without a CRS. cell_values_at() now compares the seeds' IDs with those of values before any CRS work or search, and stops when none matches. The error names the seeds' ID column and says to set it from the tessellation's index; IDs that are all NA get a text of their own. When values carries the cell polygons and some seed ID is NA, the check runs after seeds outside every polygon take the cells they generate, so points placed by hand outside the boundary still run. A values with no row or only NA IDs is an error that names values. One matching seed is enough. Seeds without a CRS beside points with one are read as build_tessellation() reads a boundary without one, with a plain warning. Beside a projected CRS, coordinates that look like lon/lat are taken as EPSG:4326 and transformed, and others are given the CRS of points. Beside a geographic CRS, coordinates inside the lon/lat ranges are given it, and others are an error that names the CRS the summary measured in. newdata without a CRS is still refused. The help for cell_values_at() and two Bug fixes entries in NEWS describe both. In "what `seeds` and `values` must be", a values of no rows with seeds now expects the values error in place of every value NA. In "`newdata` without a CRS is refused beside rows with one, and runs beside rows without", seeds without a CRS now expect one warning and the values of the call with the CRS set. In "a location the same distance from two scored locations takes the lower x, then the lower y", the lone seed with an NA ID gains a second seed at (1e4, 1e4) with the ID of cell 1; every expectation is as it was. No frozen record is retaken.
Under select_on = "split", resolution_profile() scores the estimate on the rows of the selection half that have a response, and the check that estimate has rows to read is made on the layer. A layer whose rows with a response all lay in the estimation half passed it, under a named estimate and under "auto", which became "pooled". The profile returned loo and the estimate's other columns NA at every level, as were rss, cp, moran_i and moran_z, and said nothing. Its print said "fewer than two rows", the count record's print read "in NA cells", select_resolution(criterion = "loo") said loo needs a cell that holds two rows with a response, and summary() said "cp needs a response". The columns stay NA. After the levels are scored, resolution_profile() raises one warning of class spatialkit_no_scored_rows that names the NA columns and counts the rows of the selection half and the rows with a finite value, all in the estimation half. The condition carries reason, n, selection, n_response and column. A call a guard stops raises none. Both prints now read "loo NA: no row of the selection half has a response", select_resolution(criterion = "loo"), the criterion a profile of plain means is read by, stops with that reason, and summary() of the profile names the selection half in its error. The other criteria keep their own refusals. No number, default, column or result class changes, and NEWS has one Bug fixes entry. The help for resolution_profile() (estimate, Value, Conditions) and select_resolution() says when the columns are NA and why. The new test-fix-split-no-response.R pins the warning and its fields, on halves of different sizes too, the prints, the refusals of select_resolution() and summary(), and the calls that raise no warning. No test is turned round and no frozen fixture record is retaken.
fit_bayesian_spatial_model() merged `control` over list(adapt_delta = 0.9, max_treedepth = 12). At 0.9 ordinary data left a few divergent transitions, and one is enough to set `convergence_ok` to FALSE and raise spatialkit_convergence: four layers of 250 points over a smooth field with a 60 km range, fitted at the default four chains of 2,000 iterations from three seeds each, had 1 to 24 in every fit. The warning's advice printed adapt_delta with %.2f, so 0.975 read 0.97, 0.995 read 0.99 and 0.999 read 1.00, and a fit raised to 0.995 was told it ran at 0.99. The defaults are now one list, .bayes_control_default, with adapt_delta 0.99 and max_treedepth 12, and `control` is still merged over it. The four layers had no divergent transition at 0.99. cv_bayes(), compare_models_cv() and every other call that leaves `control` unset take the new default. The advice prints adapt_delta with %.15g, which follows neither options(digits) nor options(OutDec). The `control` entry of ?fit_bayesian_spatial_model gives the measurement, the cost, the way back and 0.995 or 0.999 for divergences that remain at 0.99, as on a weak spatial field; `check_convergence` says its R-hat figures come from fits at 0.9 or 0.95; and the example says Stan may warn about effective sample size. Sampling takes about two to three times as long, and a fit at a given seed draws other values, so its estimates, intervals and predictions change. `control = list(adapt_delta = 0.9)` restores the previous setting. NEWS has a Breaking changes entry, and the README says its recorded compare_models_cv() timing was taken at 0.9. No frozen fixture record was retaken. Four pins were turned round: "a supplied control list keeps the package's adapt_delta default" in test-bayes-smoke.R expects 0.99 after a partial `control`; in test-fix-bayes-convergence.R, "divergences and low E-BFMI fail; tree-depth saturation is recorded only" and "several failures arrive as one warning" expect "(now 0.99)" at the default, and ".bayes_convergence_advice() gives the remedy for the checks that failed" expects "(now 0.9)" for an explicit 0.9. New tests check the merged control, the advice under options(digits) and OutDec, and the help and NEWS text, and test-fix-bayes-default-control.R (opt-in with SPATIALKIT_TEST_BRMS) fits the four layers at the default and expects no divergent transition.
estimate_sac_range() held its floor of 30 against rows. Rows that share a location are one place to the variogram and to its test for spatial structure, which runs on the location means. Five locations visited 20 times passed the floor, got a variogram of ten pairs of locations and a structure test on five means, which called most such layers unstructured even where the range was three times the extent, and summarize_by_cell(deff = "variogram") then gave a design effect of 1 in every cell. After the n_max subsample and before the detrending, the function now counts the distinct locations of the rows the variogram is computed on with .sac_locations(), where two rows are at one location when both coordinates are equal to the last bit after the projection. Below 30 it logs a WARN line, fits nothing and returns the unclassed NA whose rejected_reason, from the new .sac_reason_few_locations(), gives the count: "<k> distinct location(s) among the <n> point(s) with a finite value to model, fewer than the 30 a variogram range is estimated from". When the layer has 30 or more locations and the subsample kept fewer, the counts are the subsample's and the reason says "of the n_max subsample". The check runs again after the rows with no finite value to model are dropped. With detrend = "reml" no REML fit is tried and no REML warning is raised, and the warning that the variogram is fitted to the raw response comes only once the floor has passed. A layer of 30 or more rows at 2 to 29 locations, which 2.0.0 fitted, gets the NA (Breaking changes in NEWS): the range is NA, summarize_by_cell(deff = "variogram") returns Kish standard errors with spatialkit_deff_fallback, make_folds(auto_range = TRUE) builds geometric blocks, kriging_adequacy() stops with the reason, and the Bayesian fit's check before fitting reports the range as not estimated. A layer whose rows all lie at one location gets this reason in place of "the points have no extent". The help of estimate_sac_range() states the floor under Details, predictor_vars, n_max, seed, detrend and Value, and NEWS has Bug fixes and New features entries as well. test-fix-variogram-locations.R is new. Two tests are turned round: "estimate_sac_range()'s early NA returns carry a rejected_reason and nothing else" in test-review3-final-B.R expects the location reason for 40 rows at one location, and "the REML detrending on fewer than 30 locations is said not to be fitted" in test-fix-texts-misstated.R expects no REML warning and the location NA for 40 rows at 20 locations. No frozen fixture record is retaken.
On a lattice two to four locations are equally near. .sac_short_lag() paired each location with its nearest other one through FNN's kd-tree or the base-R search, and the two took different ones, so short_lag_pairs, short_lag_semivariance, Cp's noise variance and the `cp` column differed between a session with FNN and one without (80 pairs against 143 on a 12 x 12 lattice). The pooling's searches, .region_neighbours() and .nearest_location_search(), counted exact ties alone, and lattice centroids that tie in one unit differ in their last bits in another or after a shift of the origin. The same layer in metres and in feet gave some cells other neighbours, and since `tau2` is fitted over the layer every pooled value of summarize_by_cell() moved, and so did the leave-one-out error of resolution_profile(). Squared distances within one part in ten million (.TIE_TOL) of the least are now a tie. A tie goes to the lower x, then the lower y, coordinates within .TIE_TOL times the distance counting as equal, then to the lowest number: .knn_exact_rows() and .knn_tied_rows() take `tol` and `num`, and a new .knn_pick_rows() applies the rule. The partition passes neither and keeps exact ties. .region_neighbours() passes the region's own number, so regions whose centroids coincide stay told apart by number when rounding parts them, and the FNN paths widen their shortlist margins by .TIE_TOL. .sac_short_lag() puts the locations in coordinate order, takes each one's nearest other location from .nearest_location_search() with FNN or .knn_exact_rows(tol = .TIE_TOL) without, and computes the separation in R. On gridded layers a session with FNN now gets the short-lag pairs and `cp` values the search without FNN gave where ties were exact; on a square lattice the pairs run along x. summarize_by_cell() gives the same neighbours and pooled values in another unit or origin while the spacing is above about a ten-millionth of the coordinates. Where three or more cells' centroids coincide the values agree to rounding, and where ten or more do, which 8 each takes can still change. ?summarize_by_cell and ?sac_nugget state the rule, and ?resolution_profile now says the density kind's cells can differ in another unit or origin, since the partition counts exact ties alone. No default, class or error changes. NEWS has two Bug fixes entries and nothing under Breaking changes. Nine frozen records are retaken, each to the record the fixture held for its call without FNN: profile_lattice, profile_lattice_density and profile_integer (value, conditions, printed, log: short_lag_pairs 80 to 143, the semivariance and cp_noise 0.1507 to 0.1257 on the lattice and 15.18 to 12.81 for profile_integer, the `cp` column, the print's variogram line and the two variogram warnings), and select_lattice_cp, summary_lattice, select_lattice_density_cp, summary_lattice_density, select_integer_cp and summary_integer (value). Turned round in test-core-pool-properties.R: .pt_neighbours() and .pt_nearest_other() write the rule with the tolerance and the number through a new .pt_pick(), test 13 holds squared distances nearest first to within .TIE_TOL, the spies on .knn_exact_rows() and .knn_tied_rows() pass `...` on, and the kd-tree stand-ins group candidates within .TIE_TOL (was 1e-9). test-fix-neighbour-ties.R is new.
.no_spread() compared a column's sums of squares with the size of its values. So 1e15 plus a spread of 1, whose values are stored to an eighth, and 1e6 plus 1e-9 times a spread of 1 were called constant, and so were values near 1e200 or 1e-170, whose squares overflow or underflow, whatever their spread. summarize_by_cell() then said their values "do not vary inside any cell" and returned the plain means with weights 1, and resolution_profile() left `loo` NA. The standard error of a leave-one-out error squares the squares, so `loo_se` was Inf for residuals above about 1e77 and lost its precision, then read 0, below about 1e-80. .pool_fit() now reads no spread twice: on the raw values, and on the column centred on its median and scaled by powers of two (.spread_scaled()). A column has no spread only where neither reading finds any. On the scaled column a standard deviation, over all the rows or inside the cells, of at most .POOL_ULPS (3) units in the last place of the largest absolute value is rounding (.scaled_rounding()), so a column whose values differ only by their rounding (0.1 beside 0.3 / 3, 2 beside sqrt(2)^2) is constant as before. Where the raw values lose their spread and the scaled column keeps it, the fit runs on the scaled column with the column's own readings and is put back in its units (.pool_unscale()). A column that is not constant, with an absolute value above 1e150 or a largest distance from its median below 1e-150, is refused with the status "values out of range". .loo_mean_square() divides residuals whose largest lies outside 2^-255 to 2^255 by a power of two before it squares them, and inside those bounds gives the formula's numbers bit for bit. resolution_profile() reads its estimate's columns by the same test (.constant_column()); its test of a constant response for `cp` still reads the raw values alone. summarize_by_cell() pools 1e15 plus a spread of 1, with the weights, `sigma2`, `tau2` and leave-one-out errors of the spread alone. The degenerate warning says the values do not vary inside any cell "to the precision of the values". A column beyond the bounds gets NA pooled columns and a spatialkit_pool_unavailable warning whose `reason` is "values out of range"; at 800 rows, 1e150 to 1e152 and 1e-151 to 1e-160 times a spread of 1 were fitted before and are now refused. `loo_se` is finite inside the bounds, in the record and in resolution_profile(). The profile scores `loo` for 1e15 plus a spread of 1; where the test for `cp` calls the response constant and the estimate's test does not, the warning, print() and select_resolution(criterion = "cp" or "moran_z") say what each test found and that `loo` is scored. Beyond the bounds the profile raises one spatialkit_pool_unavailable warning, which names `cp`, `moran_i` and `moran_z` too where the test for `cp` calls the values constant, and print(), summary() and select_resolution() say the values are out of range. NEWS has a Bug fixes entry, and the Breaking changes list of reasons for spatialkit_pool_unavailable adds values beyond what the arithmetic of pooled values holds. No frozen fixture record was retaken. Four tests were turned round: "11. the rule for no spread is relative to the size of the values" in test-core-pool-properties.R, now "11. the rule for no spread does not depend on where the values sit or on their size", expects 1e6 plus 1e-9 times noise to be fitted as the noise; "a constant response has no loo, and the warning names it among the columns that are NA" in test-core-count-loo.R expects that response constant to the test for `cp` and scored by `loo`; "ten constant predictors raise one spatialkit_pool_degenerate, six of them named" in test-core-pool-summary.R holds the new warning text; and "a response that is constant to within rounding scores nothing, as the message says" in test-fix-resolution-usability.R expects select_resolution(p, "cp") to say what the test for `cp` found, and holds the old error on a profile with `estimate = NULL`. test-fix-pool-extreme-scales.R tests the two readings, the rounding bound, the fit of the scaled column, the bounds and their warnings, the standard errors and the profile's texts.
.crs_distance_error() adds the outline of a layer with fewer than 40 features and, when the outline has fewer than 40 distinct vertices, fills each of its edges with points. An edge two features shared was filled once from each end, some copies of an added point differed in their last bits, unique() kept both, and the pair, about 1e-9 m apart, set the worst-case ratio of every candidate CRS. Two lon/lat boxes of 12 by 15 degrees, one above the other, scored 0.7692 in EPSG:32613 and 0.8682 in EPSG:5070, where their outline as one box scores 0.0051 and 0.1087, and ensure_projected() kept UTM zone 13 with "76.92% vs 76.92%". A 2 by 2 grid of 3.7 by 2.9 degree boxes scored 0.2715 and 0.0965 against 0.0066 and 0.0098, and moved to a Lambert azimuthal CRS with "11.22% against the zone's 13.50%" where its outline gives 0.06% and 0.26%. Two boxes side by side scored 0.3179 and 1, and two boxes one above the other across the antimeridian scored 0.7923 in a Lambert azimuthal CRS on 180, where their outline scores 0.0025. The same held where an added point fell on a corner of another feature (a T-junction, or a corner touching an edge) or on a point added along an edge that overlaps it in part: a T of boxes at (-111.7, 28.3) scored 0.5605 and 1 against its union's 0.0049 and 0.0069. .crs_distance_error() now fills each edge from the end with the smaller longitude, or the smaller latitude when the longitudes are equal, so the two copies of a point on a shared edge are computed the same way and are the same double, whichever way each ring runs. The added points are sorted by coordinate and put after the vertices, and an added point is left out when it shares a cell of 1e-9 degrees (about 0.1 mm) with an earlier point, the cells in each coordinate taken from two grids half a cell apart (round() and floor() of the coordinate times 1e9), so copies a few bits apart are never kept either side of a cell's border. The vertices are kept as they are. The comments and the internal doc of `x_ll` say why. The layers above score within a tenth of a percentage point of their outlines, and the log of ensure_projected() quotes the outlines' figures. A layer on which no added point lies within 1e-9 degrees of another point scores as before, but for the last bits. For the others the CRS, attr(, "crs_choice") and the logged figures can differ from before, and the score no longer depends on the direction of a ring or the order of the features. No default, class or error changes. NEWS has a Bug fixes entry and nothing under Breaking changes. No frozen fixture record is retaken, and no test is turned round. test-fix-crs-shared-edges.R tests shared edges, an edge across the antimeridian, ring direction, feature order and ring start, the figures ensure_projected() logs, corners on another feature's edge, points either side of a half step of the 9th decimal, and pins the scores of layers with no added point on another feature's point.
.crs_area_error() took the geodesic areas of all its probes in one call
on their copy in EPSG:4326. Two corners a fraction of a nanometre apart
in the cells' CRS can fall on one point in degrees, where s2 refuses the
ring ("duplicate vertex"), and a vertex listed twice, which GEOS
accepts, does the same; one such probe made the call fail and the
figure NA for the whole layer. The k-means cells of a 30 by 20 lattice
at 30 m, built and kept in EPSG:32615 from rows in degrees, are all
valid in EPSG:32615 and s2 refused 4 of the 133, so
summarize_by_cell(area = TRUE) stopped because "the area distortion of
`cells_sf`'s CRS could not be measured". ensure_projected(purpose =
"area") skipped its check on projected input in silence the same way:
20 cells of 1 degree from 30N to 69N in Web Mercator, which distort
areas by 214 percent, logged nothing when one cell had such a pair of
corners.
When the one call fails, .crs_area_error() now takes the geodesic
areas one probe at a time, and a probe s2 refuses is measured again
without the vertices that repeat the one before them in degrees. A new
helper, .drop_repeated_vertices(), drops them from each ring of a
POLYGON or MULTIPOLYGON, holes included, comparing x and y alone, so
the ring's points and its area stay as they were. A probe s2 refuses
even then, such as one whose edges cross or one with a spike, makes the
figure NA as before: leaving such probes out of the spread could leave
out the ones that carry the distortion.
st_make_valid() is not used: it snaps vertices to 1e-7 degrees and on
cells a few metres across moves the ratio by more than the tolerance.
The lattice's k-means cells now get a density, with attr(, "area_error")
the spread over all 133 cells (below 1 percent). For the Web Mercator
cells ensure_projected() logs the warning, and summarize_by_cell(area =
TRUE) refuses them for their distortion, no longer because it could not
be measured. A layer whose probes s2 all accepts gets the same figure
as before, to the last bit. A cell s2 refuses for another reason still
leaves the spread unmeasured, and the request is refused as before.
?summarize_by_cell says how a cell s2 refuses is measured and when the
request is still refused. No default, class or error changes. NEWS has
a Bug fixes entry and nothing under Breaking changes.
No frozen fixture record is retaken, and no existing test is turned
round. test-fix-crs-area-refused-probe.R tests the lattice's k-means
cells with rows in degrees and in EPSG:32615, the one-call figure kept
where s2 accepts every probe, cells with a corner beside another or a
repeated vertex in Web Mercator, UTM and a Lambert conformal conic
layer of 300 cells, multipolygons, holes and z coordinates, the log of
ensure_projected() and the error of summarize_by_cell(), and the NA
for a bowtie or a spike.
assign_features_to_polygons() joins rows to lon/lat cells on the sphere
with s2 unless the cells' record names the projected CRS a profile
scored them in. Cells returned in lon/lat can hold two corners that
differ only by rounding and fall on one point in degrees, which s2
refuses. Three kinds of cell still went to s2: cells that had lost their
record, cells whose record says `scored_cells = FALSE`, and cells
without a CRS, which take the rows' EPSG:4326. On them the plain join
stopped with s2's "Loop 0 is not valid: Edge 20 is degenerate (duplicate
vertex)", an error with no class that named neither the polygon nor a
way on. s2 refuses 4 of the 133 k-means cells of a 30 by 20 lattice at
30 m returned in EPSG:4326; with their record the cells joined 600 rows,
and without the record or the CRS the join stopped. The cells of centres
refitted to every point on a 50 by 40 lattice at 250 m stopped it the
same way. A hole that crossed its outer ring and two holes that shared
an edge stopped it with s2's bare message too. The largest-overlap join
wrapped a refusal that outlived its repair in advice to pass
`largest = FALSE`, which meets the same refusal.
The plain join now runs inside withCallingHandlers(), and the
largest-overlap join's handler calls .stop_cells_degenerate() before its
own message. That helper acts when the error names a ring ("Loop N" or
"loop orientations"), the polygons are in lon/lat, sf_use_s2() is on and
sf::st_is_valid() reads at least one polygon as invalid; otherwise it
returns NULL and the error is raised as before.
.raise_cells_degenerate() builds the error of class
spatialkit_cells_degenerate. It gives the number of polygons s2 refuses
and their rows (six at most, then "and N more"), quotes the first line
of s2's message, names the cause of two corners read as one point where
s2's reason is "duplicate vertex", and says to transform `polygons_sf`
to a projected CRS, such as the one the cells were built in or the one
ensure_projected() picks, and assign again; for polygons without a CRS
it says to set the CRS with sf::st_set_crs() first. The condition
carries `rows`, `n`, `reasons` and `parent` (s2's error) and no call.
cell_values_at() without `seeds` catches the class around its join and
raises it again through .raise_cells_degenerate() in its own words: it
names `values` and the placement of the locations, gives the rows of
`values` (rows without an ID are not handed to the join), counts "the N
polygons of `values` that carry an ID" when some lack one, and says to
call cell_values_at() again.
A join on polygons s2 refuses now stops with spatialkit_cells_degenerate
where it stopped with sf's bare message or the advice to pass
`largest = FALSE`. Polygons s2 accepts join as before, the
largest-overlap join still repairs the polygons it can, with its
warning, and runs, and an error of another kind keeps its own message.
No default changes. The Details of ?assign_features_to_polygons, step 3
of ?cell_values_at and `crs` in ?create_voronoi_polygons name the error.
NEWS has a Bug fixes entry and nothing under Breaking changes, since
every call that now raises the class stopped before.
No frozen fixture record is retaken and no test is turned round.
test-fix-join-cells-degenerate.R tests the refused squares and the rows
the message gives, the join in degrees with s2 off, a bowtie, squares
without a CRS, an error of another kind and the predicate's own
condition, the largest-overlap join with a mocked repair, a crossing
hole and two identical holes on both joins and after the transform, a
hole that runs the way its outer ring runs, the lattice's cells without
their record or CRS, cell_values_at() on the lattice summary with and
without its record, an ID or a CRS, the refitted centres' cells, and
the help and NEWS text.
Under the model-aware criteria determine_optimal_levels() re-runs k-means at each count of the window around the elbow, the elbow plus or minus max(4, `top_n`). The re-runs drew from one random stream in order, so a `top_n` above 4 started the window lower, more re-runs came before each count, and every count in the window got other cells, and with them another `wss_eval`, `moran_i` and `moran_z`. On 480 points in twelve clusters with `max_levels = 30` and `set_seed = 123`, "morans_i" put 15 first at `top_n` 1 to 4, 16 at 5 and 17 at 6 and 7, though 15 and 16 lie in all of those windows, and k = 17 had a |z| of 0.0013 at `top_n = 6` and of 0.30 at `top_n = 7`. Of the 21 pairs of calls at `top_n` 1 to 7, 30 columns differed at a shared count under "morans_i" and 45 under "combined", whose ranking stayed while its diagnostics moved. After the sweep the function now draws one integer, `rerun_seed`, from 1 to .Machine$integer.max - k_max, and runs the re-run at k (.partition_centres()) under .with_seed(rerun_seed + k), putting the stream back after each re-run. The integer depends on `set_seed`, or with `set_seed = NULL` on the caller's stream. With the other arguments fixed, a count gets the same cells, `wss_eval` and Moran's I whichever `top_n` sets the window. A wider window still scores more counts, and under "morans_i" one of them can rank first: on the same layer the first count is 15 at `top_n` 1 to 4, 17 at 5 and 18 at 6 and 7, each the count of smallest |z| in its window. For a given seed `moran_i`, `moran_z`, `wss_eval` and the "morans_i" ranking can differ from before, and a "morans_i" call can fall back to the geometric ranking where it ranked, or rank where it fell back; the sweep, the elbow and the "combined" ranking are as before. With `set_seed = NULL` the re-runs take one draw from the caller's stream in place of the draws of every re-run, so the stream after the call no longer depends on `top_n`. ?determine_optimal_levels says under `top_n` that it sets the counts scored and that a count scores the same whichever `top_n` puts it in the window, and its Details say each re-run draws from a stream of its own. No default, class or error changes. NEWS has a Bug fixes entry and nothing under Breaking changes. No frozen fixture record is retaken: levels_morans and levels_combined run at `max_levels = 8`, where every count of the window has fewer than ten cells and the call returns the geometric ranking before any re-run value is stored. No test is turned round. The new test-fix-levels-rerun-seed.R checks that a count scores the same in every window that holds it under both model-aware criteria, on twelve clusters at two seeds and on eighteen clusters under `select_on` "all" and "split"; that under "morans_i" a wider window moves the first count only to a count it adds, with a smaller |z|; that the re-run at a count starts from the same stream in every window; that the caller's stream is left as it was and not read; that the re-runs depend on `set_seed`; that with `set_seed = NULL` the scores and the stream after the call do not depend on `top_n`; and that the help and NEWS say so.
summarize_by_cell(deff = "kish") skipped a column as one that does not vary when its standard deviation was below .Machine$double.eps (about 2.2e-16), on all its values and again on the rows with a cell id, whatever the size of its values. A column that varies, in units that make its values of order 1e-16 or smaller, got an ICC of NA with the reason "the column does not vary", no design effect and the uncorrected standard errors, with no warning. On 800 points in 178 cells the ICC was 0.478 at a scale of 1 and of 1e-14 and NA at 1e-17, 1e-20 and 1e-100, and the median standard error over the scale fell from 0.666 to 0.303. Where only the rows with a cell id were that small, the ICC was NA with "its values differ only on rows that fall in no cell" and the standard errors were NA. A column near 1e200 had an ICC of NA with "the variance decomposition is undefined". The standard deviation inside a cell, behind ..sd_*, ..se_*, ..neff_*, ..df_* and ..ci_*, squared the raw deviations. Above about 1e154 the squares overflowed, and in each cell where they did ..sd_* was Inf and the standard errors and intervals NA, under any deff and with no warning: 7 of 60 cells at 1e154 and all 60 at 1e155 and 1e200. At a spread of 1e-170 ..sd_* and the standard errors were 0. .estimate_icc() inside summarize_by_cell() now reads a column whose standard deviation is below .Machine$double.eps or not finite again with .constant_column(), the pool's test, and skips it only where neither its raw values nor its values centred and scaled show spread beyond their rounding. On the rows with a cell id, such a column with spread is z-scored from .spread_scaled(), which divides by powers of two; the ICC does not change under a shift and a scale. Where the standard deviation is finite and at or above the floor, the raw arithmetic is as it was. A new internal .cell_sd() returns sd(x, na.rm = TRUE) where that is finite and at or above .POOL_Y_MIN (1e-150), and elsewhere the standard deviation of .spread_scaled() of the values times its scale. The ..sd_ closure and .col_stats() call it. After the summarise, a cell whose standard deviation is still Inf raises a warning of the new class "spatialkit_sd_overflow", whose fields `columns` and `cells` give the columns and the number of such cells of each. The internal documentation of .constant_column() names the Kish ICC as a reader. The 800-point layer now gives an ICC of 0.478 and a median standard error over the scale of 0.666 at every scale from 1 to 1e-100, and the ICC of the column near 1e200 is estimated. ..sd_*, ..se_* and the intervals follow the unit of the column from 1e150 to 1e-310, under deff = 1 and "kish", with no NA, no 0 and no warning. A column whose values are all equal still has an ICC of NA and standard errors of 0. A column whose standard deviation is below the floor and whose values differ only by their rounding (0.1 beside 0.3 / 3) still reads "the column does not vary", with standard errors of 0 in a cell whose values are equal and of the size of that rounding in a cell whose values differ. A cell whose spread is of order 1e308 still has ..sd_* of Inf and standard errors of NA, now with the warning. No default or error changes, and the one new class is that of the warning. ?summarize_by_cell gains a sentence on columns that differ only by their rounding and a paragraph on ..sd_* at any size and the new warning class. NEWS has two Bug fixes entries and nothing under Breaking changes. No frozen fixture record is retaken: the one frozen call that reaches the new ICC reading, values_constant, has a column of one value that .constant_column() keeps constant, and the raw standard deviation stays sd(x, na.rm = TRUE), so no ..sd_* record moves. No test is turned round. test-fix-cells-icc-small-units.R is new: the ICC and standard errors over the scale do not depend on the unit, rows with a cell id in small units beside rows with no cell id get the ICC, a column whose standard deviation overflows gets its ICC, a column of one value or of values equal to their rounding still does not vary, the standard deviation and standard error inside a cell and the interval of a cell do not depend on the unit, a cell beyond the largest double is named in the warning, and a column just above the floor keeps the ICC of its raw values.
On gridded locations the density partition depended on the unit and the origin of the coordinates. On a lattice many distances tie exactly, and the last bits of the coordinates, which move with the unit and the origin, settled the ties in four places: the neighbour searches of the density weights and the nearest-centre search of Lloyd's iteration counted exact ties alone; the first k-means++ centre was drawn from weights equal but for their last bits, which sample.int() read as different; the locations the random draws index were put in order by first coordinates equal but for their last bits; and of two starts whose sums agreed to rounding, the rounding chose. On a 40 by 30 lattice at 250 m the default resolution_profile() gave `loo` 0.2978 in EPSG:26915, 0.3068 in UTM 15N in US feet and 0.3006 with the false origin moved by 0.1 m, and `rss` 258.33, 270.72 and 258.80. A profile that drew a subsample took its rows in exact coordinate order, so it drew other locations after a change of origin: on a 50 by 40 lattice with no response, wss as a fraction of the total was 0.6958 in metres and in US feet and 0.6997 with the origin moved. The density partition now uses the pooling's tie rule: squared distances within .TIE_TOL (one part in ten million) of each other are a tie. .knn_locations() passes `tol = .TIE_TOL` to .knn_tied_rows() and .knn_exact_rows(), so a tie between neighbours goes to the lower first coordinate, then the lower second, and its FNN margin widens by .TIE_TOL. .nearest_exact() finds the least squared distance and then the lowest-numbered centre within .TIE_TOL of it, in two passes, and .nearest_centre()'s FNN re-check widens to .TIE_TOL. .wkmeanspp() draws the first centre on the weights with runs of near ties given the run's lowest value. A new .near_columns() counts first coordinates within .TIE_TOL of the extent as one column, and a new .locations_by_column() puts the locations of .density_kmeans() in order by column and then by the second coordinate. .density_kmeans() keeps a later start only when its sum is lower by more than .TIE_TOL. resolution_profile() orders its rows by .near_columns(), then the second and the first coordinate, the response and the predictors, under either kind. .values_at_nearest() takes the same tie between centres and widens its kd-tree shortlist by .TIE_TOL. .scored_edge_cells() searches every point row placed in a cell, and for a row the rule gives to a centre that ties with the strictly nearer centre of the cell holding it, the margin adds the row's distance from the bisector of the two, measured in the record's CRS and scaled to the join's CRS by the ratio of the centres' separations; every other row keeps the margin it had. The lattice above gives `loo` 0.3016 and `rss` 262.94 and the same regions in all three frames, and a uniform layer gives the profile it gave. The regions get_voronoi_seeds() and voronoi_seeds_kmeans() draw under partition = "density" no longer move with the unit or origin either. The cells are the same in another unit or origin as long as no coordinate moves by more than about a forty-millionth of the distance between neighbouring locations; coordinates rounded more coarsely, such as a lattice at 250 m stored in feet to four decimals, can still give other cells. On layers with near ties in distances, weights, first coordinates or starts' sums the regions, and every figure drawn from them, can differ from before for the same seed, under partition = "kmeans" too where two first coordinates are that close. A row the profile scores in the cell of the lower-numbered of two tied centres is assigned there by assign_features_to_polygons() and placed there by cell_values_at(), so summarize_by_cell() still reads `cells = "match"`. ?resolution_profile states the tie rules and the bound in place of the sentence that the cells still differed in another unit or origin; ?assign_features_to_polygons names the tolerance and the wider margin; ?summarize_by_cell names the tolerance; ?cell_values_at names it and says another unit or origin of the same CRS settles its ties the same way; and the diagnostics vignette names the tolerance. No default, class or error changes. NEWS has a new Bug fixes entry, the earlier Bug fixes entry on tied neighbours loses its sentence that the partition still counted exact ties, and the New features entry on the count record names the tolerance; nothing goes under Breaking changes. Fourteen frozen records are retaken. The lattice records profile_lattice_density, select_lattice_density_cp, select_lattice_density_moran_z_diagnostic, summary_lattice_density, seeds_lattice_density and kmeans_lattice_density move with the tie rules. profile_density_clustered, select_density_clustered_cp, select_density_clustered_elbow and select_density_clustered_moran_z_diagnostic, and under the k-means kind profile_geometry, select_geometry_elbow, profile_geometry_sac and select_geometry_sac_reliability, move with the new order: the clustered layer has one pair of first coordinates 7.5e-8 of the extent apart, which now count as one column. Turned round: "the kd-tree's search and the exact search pick by one rule, and the partition keeps exact ties" in test-fix-neighbour-ties.R, now "... counts near ties as ties"; "tied neighbour distances are settled by the kd-tree as the exact search settles them" in test-core-partition-properties.R passes .TIE_TOL and expects the first tied locations in coordinate order; "the nearest centre is the exact one where centres are nearly the same distance away" in test-core-values-at.R, now "centres whose squared distances agree to one part in ten million tie, and the lower number takes the point", with a case whose first kd-tree shortlist ends inside the tie; in test-core-gridded-ties.R the platform pins of moved rows (the polygons alone move rows on 15 of the 16 lattices under the density kind, not 11), of rows elsewhere, and of refused cells (s2 refuses a k-means cell on 15 of the 16 lattices, not 16, and a density cell on 11, not 10), the row a projected CRS puts elsewhere, the round trip through degrees and the cells of seeds moved by 1e-9; and the platform pin of rows on an edge in test-core-pipeline.R, now 0 2 0 0. The helper drop_in_own_crs() of test-fix-crs-area-refused-probe.R keeps a ring closed where the vertex it drops closes it, and "the cells of centres refitted to every point, returned in lon/lat, stop with the error where s2 refuses one" in test-fix-join-cells-degenerate.R uses the k-means kind, since s2 now refuses none of the density cells of its lattice. test-core-gridded-ties.R gains "a point two centres tie for goes to the lower-numbered one beyond the margin of an edge, and only such a point". test-fix-partition-ties.R is new: the lattice in three frames, the subsample, the bound in the help, the uniform layer, each tie rule and the assignment of a tied row.
A cell whose centroid shared its point with 8 other cells or more took the first 8 of them without a search, but .region_neighbours() found the point by exact equality. In another unit, or with the origin moved, rounding parted such centroids by a few units in the last place, and the cells were then searched for among themselves by those distances. Twelve cells of 1 to 12 rows on one point beside a 10 by 10 lattice of one-row cells at 250 m gave 3 cells other neighbours in feet and in US feet, and all 12 with the origin moved by 0.1 m. Since `tau2` is fitted over the layer, every pooled value of summarize_by_cell() moved, by up to 0.171 in feet and 0.208 with the origin moved, and so did the leave-one-out error of resolution_profile() on the same cells. Rows that carry a placeholder or a coarser unit's coordinates make such crowds. .region_neighbours() now finds points with the reach of a tie, .TIE_TOL times the largest absolute coordinate, through a new .shared_points(). Centroids that chains of pairs within the reach in x and in y link are one point while they lie within the reach of one another, and equal centroids are one point in any case. A chain that spans further is linked again at half the reach, the chains still too wide at a quarter, and so on; centroids left apart to the last fall back to exact equality. The linkage is in .reach_chains(), which puts each chain's centroids in squares of the reach's side counted from the chain's own least x and y, and .chain_span() measures a chain along one coordinate. A crowded point's centroids are ordered by region number, and each takes the first 8 of the others. No new constant is added. summarize_by_cell() gives crowded cells the same neighbours and pooled values in another unit and with the origin moved by little against the coordinates. On a point of nine or more centroids, centroids that lie within the reach of one another without coinciding (about 0.46 m at UTM northings) now take each other by ID, not by distance. The reach follows the largest coordinate, so with the origin moved far, to the corner of the data, such centroids can lie beyond it and their cells then take the nearest. A layer whose centroids are equal or further apart than the reach in x or in y gets the neighbours and values it got before. ?summarize_by_cell states the rule and the far-origin limit, and says values agree to rounding where three to eight centroids coincide, not three or more. No default, class or error changes. NEWS has a new Bug fixes entry, and the earlier Bug fixes entry on tied neighbours narrows "three or more" to "three to eight" and drops its sentence that with ten or more cells on one point which 8 each takes can still change. Nothing is added under Breaking changes. No frozen fixture record is retaken. One test is turned round in test-fix-neighbour-ties.R: "regions whose centroids coincide to rounding get the rule's neighbours on both paths" treats its triple of regions 25, 26 and 50, a few units in the last place apart, as one point, so at one neighbour region 25 takes 26 where the rule by distance took 50; its reference fnt_neighbours() gains the reach and the halving, and an expectation pins 25, 26 and 50 to 26, 25 and 25. The new test-fix-neighbour-crowds.R checks crowds of ten or more in metres, feet, US feet and with the origin moved by 0.1, with and without FNN, a crowd beside centroids that chain on beyond the reach, a crowd parted by rounding, summarize_by_cell() at UTM magnitudes, centroids within the reach against centroids beyond it, the far-origin case and its help and NEWS text, and .shared_points() against the rule written out.
cell_values_at(seeds = ) checked that some seed has the ID of a cell of `values`, and counted every seed whatever its geometry. A seed with an empty point, or a coordinate that is not finite or lies beyond 1e150, is the nearest seed of no location, yet it passed the check, and the coordinates were read only as given, so seeds that leave the globe in the working CRS (metres stamped EPSG:4326, a latitude beyond 90) passed too. Seeds that kept their IDs and lost their points left every location without a cell, and each location took the value of the cell of its nearest scored row with no error: the seeds of a tessellation of 107 cells, every point emptied, filled all 120 locations asked for, and so did the one seed with a cell's ID emptied among seeds numbered from 1001. A seed at a northing of 1e200 in EPSG:32618 came back finite in EPSG:32617 and was searched where it landed. .values_at_free_cells() took a cell as named by any seed with its ID, so a seed without a location kept that cell from a point placed by hand outside the boundary, and the 144 locations of that cell were filled. cell_values_at() now reads the seeds' coordinates as given with .values_at_xy() before any CRS work. The check counts only seeds with a location that carry a cell's ID; the check that waits for step 3 needs a seed with a location and an NA ID beside polygons in `values`, and reads the seeds with a location in the working CRS. Once the seeds are placed, a seed without a location as given has none there either, and when the seeds with cells' IDs have a location as given and none in the working CRS, the call stops before the free cells and before any search. .values_at_no_seed_cell() takes `nowhere`, `crs` and `seeds_crs` and returns the two new texts, and the first stop passes whether `values` carries polygons, so seeds with no location and IDs that are all NA keep the text for polygons. .values_at_free_cells() takes a cell as named only by a seed with a location in the working CRS. Such seeds now stop with an error, raised without a call and with no warning for seeds without a CRS: "every seed in `seeds` with the ID of a cell of `values` has no location", or, when they had one as given, a text that names the working CRS and the CRS of `seeds` (or says it has none) and points to sf::st_set_crs(). One seed with a location and the ID of a cell is still enough for the call to run. A seed with a coordinate beyond 1e150 is no longer searched where a move between CRSs puts it. Beside a seed without a location that carries a cell's ID, points placed by hand outside the boundary take their own cells. No default or class changes. ?cell_values_at says which seeds count. NEWS has a Bug fixes entry, and the entry for seeds whose IDs match no cell now says one seed with a location and a cell's ID is enough; nothing under Breaking changes. No frozen fixture record is retaken; no cell_values_at() call is recorded. One test is turned round in test-core-values-at.R: "`seeds` without a CRS beside rows with one are read as build_tessellation() reads a boundary without one" pinned the silent fill for seeds of which none has a location, and now expects the error with and without their CRS and no warning, and calls .values_at_bare_seeds() for the reader's own rule. Two tests are added there, "seeds with the IDs of cells and no location are refused, and one with a location suffices" and "seeds with the IDs of cells and no location in the working CRS are refused, and seeds that have one there run", and "points placed by hand whose IDs are all NA outside the cell polygons of `values` take the cells they generate, and the call is refused only when none does" gains a seed with a cell's ID and an empty point or x = Inf. No test file is new.
Seven test files failed on Linux on x86-64 with 28 failures, because they pinned last bits or library output that move with the platform, and NEWS and two help pages stated as fixed what differs between platforms: - PROJ transforms differ in their last bits: a CRS score of 0.0132024764199927 on Linux against the pin 0.0132024764199938 (8e-14 relative), and 0.0096997787497988 against 0.0096997787498165. - The test of the plain mean at an offset of 1e15 took sum(y) / n as its reference, which is 1e15 + 0.375 on Linux, where sum() adds in long double, while the package gives 1e15 on both platforms. - In the test of the row subsamples, a z-scored standard error and a cell weight moved by 7e-12 and 1.4e-11 relative through chol() of a dense covariance. - s2's clip of a square grid in degrees leaves two cells with a repeated corner on Linux against one on macOS, and two cells of a grid overlap by 2.4e-7 m2 as they arrive on Linux. - stats::kmeans() settles ties by the last bits of its compiled arithmetic, so the 40 by 30 lattice at 250 m gives loo 0.2910275057 on Linux against 0.2928720572 on macOS, while NEWS said it gives 0.2929 in all three frames. - A figure eight pinched on the shared edge of two cells gives a piece that s2 refuses on macOS (it holds 39.644999999999996 twice), so the join by largest overlap stops; on Linux the piece holds 39.644999999999989 then 39.644999999999996, s2 accepts it and the join gives 1, 2, 2, 4, 5, 6. No package code changes. The roxygen of assign_features_to_polygons() (R/assignment.R) and resolution_profile() (R/resolution-profile.R) and the internal note beside .kmeans_frame() (R/partition.R) now say that these results follow the last bits s2 and stats::kmeans() compute, which differ between platforms. Users see the same results as before; ?assign_features_to_polygons says that a figure eight pinched on the edge of a polygon of the other layer can give a piece s2 refuses on macOS on arm64 and accepts on Linux on x86-64, where the join runs and gives the largest overlap, and ?resolution_profile says the kind "kmeans" can return other regions, and every column read off them, on another platform from the same coordinates and seed. NEWS has no new entry. Two existing Bug fixes entries are corrected: the s2 join entry says the same as the help, and the gridded k-means entry says the lattice gives the same regions in all three frames and other regions on Linux than on macOS, in place of loo 0.2929. No frozen fixture record is retaken. Tests turned round, each keeping what it tests: the CRS scores compare to their pins within 1e-10 relative; the 1e15 mean takes its reference from rowsum() in doubles, as the pool fit does, plus a bound of 0.5 on the exact mean; the subsample figures take a tolerance of 1e-9 relative; the s2 grid test asks for at least one refused cell and checks each; the stable ids test asks for no overlap beyond the pairs the input holds; the k-means test asks for one loo per kind across the three frames and pins the new NEWS and help sentences; and the figure eight tests read on each platform whether s2 accepts the pieces and pin that branch, the classed error and its fields or the join equal to the largest overlap read with GEOS in EPSG:5070. A new test pins the help and NEWS sentences on the join.
Closed
sf::st_sample() draws the points asked for times the ratio of the bounding box to the area in the box and keeps those inside, and the seeders passed that draw on without a bound. Two 0.05 degree squares at (10, 45) and (120, -30) in EPSG:3857 stopped get_voronoi_seeds(method = "kmeans", n = 10), get_voronoi_seeds(method = "random", n = 2000) and voronoi_seeds_random(k = 2000) with R's "vector memory limit of 3.0 Gb reached", and a strip 50 km long and 1 m wide at a slant did the same. In R/seeding.R, .sample_draw_plan() now reads the draw sf will make without touching the random stream. .robust_st_sample() runs as before at or under max(1e6, 10 n) box points, so those seeds are identical; above it the boundary goes to .sample_by_piece() in any CRS, which shares the points among the polygons by area in one rmultinom() draw, or is drawn whole by .sample_whole_bounded() where .sample_cost() finds that cheaper, and .sample_bounded() draws a piece in sf calls of at most 1e6 box points and keeps the first n. Before any draw, .sample_total_check() stops, in the caller's name, when the draws would need more than max(2e7, 10 n) box points, with the ratio, the points needed and the remedy (pass sample_points or ask for fewer seeds). The squares on two continents now give all their seeds, all inside, in 0.1 s; the cloud of the 1 m strip (5e7 box points) is refused by name. Line midpoints in a CRS whose unit sf cannot name were off the middle: sf::st_line_sample() measured the line in metres and read half that length in the CRS's unit. LINESTRING (0 0, 10 0, 20 0) got its point at x = 20 under +to_meter=2, at x = 5 under +to_meter=0.5 and at 3.047973 in EPSG:2314, in coerce_to_points() modes "auto" and "line_midpoint", in prep_model_data(pointize = "line_midpoint") and for a MULTILINESTRING's longest part. The new .planar_line_lengths() and .planar_line_midpoints() in R/crs-geometry.R set the CRS aside so GEOS and GDAL work in the CRS's own unit, and the point is now at x = 10 in every unit; lines in metres, in a unit sf names and in lon/lat with tmp_project = TRUE get the same points as before. create_voronoi_polygons() and build_tessellation(method = "voronoi") grew the hull and the cover by 0.02 * max(diagonal, 1), so 9 points over a 500 m square gave edge cells of 315127.5 m2 in metres and 324193.1 m2 in a kilometre CRS. The new .voronoi_grow() in R/tessellation.R grows by 2 percent of the diagonal in every unit (0.02 for one location, as before), and both give 315127.5 m2; a diagonal of 1 unit or more gets the same cells as before. clip_target_for() also called a side degenerate when all.equal() of its ends held, which reads the origin: a 3 km x 2 km box at x = 1e12 came back as disks of area 211961 in place of 6000000. Sides are now read against the span only, as the help says. With no boundary, points none of which has a location stopped it with R's "missing value where TRUE/FALSE needed"; they are now refused with an error that says no point has a location, and with a boundary they still get it. NEWS has five Bug fixes entries, one for the draws and four for the lines, the Voronoi frame and clip_target_for(). No frozen fixture record is retaken. One test is turned round in test-fix-boundary-degrees.R: the boundaries whose draws exceed the cap now take the piece-by-piece path, as intended. New tests are in test-fix-sample-draw-size.R, test-fix-line-midpoint-units.R and test-fix-voronoi-frame-units.R. The two changes applied cleanly together.
fit_gwr_model(), gwr_model_selection() and cv_gwr() squared the raw residuals of the response, so a response whose squares overflow or underflow gave wrong criteria and a wrong bandwidth: - On 50 rows times 2^-530, AICc was -36665.62885 where -36665.6146 is exact, and gwr_model_selection()'s gaps were 0, 6.50871, 25.44469, 36.67925 where 0, 6.48441, 25.42920, 36.66152 are right. - Times 2^530, the search took 50 neighbours where the unscaled response gets 23, fitted values moved by up to 1.01 times the factor, AICc was NA (also at a supplied bandwidth of 15), the fit warned in error that tr(S) = 6.14 is not below n - 2 and that a fitted value cannot be estimated, and gwr_model_selection() stopped with "no model produced a finite criterion" and no cause. A constant response gave the same text. - The search's own criterion at 2^400 was 9.754167 where the fit's AICc is 33363.996496. Two more defects sat beside these. The boxcar kernel tested d <= h, so on a 7 x 7 lattice with 12 neighbours, distances tied with the k-th rounded apart between metres and US survey feet and 16 of 49 fitted values moved, by up to 0.0262. gwr_model_selection() on a layer with no rows stopped with sp's "addAttrToGeom: subscript out of bounds", and with a fixed bandwidth 1 or 3 rows ended in "no model produced a finite criterion", because its row check ran after the conversion to sp and only with adaptive = TRUE. .gwr_centre() (R/model-gwr.R) now divides the response, less any centre, by the exact power of two .spread_scaled() gives, only where its spread is below 1e-100 or its largest absolute value above 1e100, and returns the scale (1 otherwise, where every fit is bit-identical). fit_gwr_model() runs the search, the local solve and the diagnostics on the scaled response. .gwr_engine() puts the scale back on fitted values, residuals, local coefficients and standard errors and on $engine$lm; .gwr_diagnostics_unscaled() adds 2 n log(scale) to AIC, AICc and BIC and multiplies RSS and sigma2 by its square through .gwr_unscale_ss(), NA where a double cannot hold the product, with one warning that names the order of the response's spread; .gwr_bw_search_unscaled() does the same for the criterion and curve of info$bandwidth_search. .gwr_ms_engine() (R/model-selection-gwr.R) sweeps on the scaled response and unscales every model's AIC, AICc and RSS. predict.gwr_fit() (R/model-classes.R) takes se.fit from the residual standard deviation where sigma2 is NA on a scaled fit. The new .gw_boxcar_inside() tests d <= h * sqrt(1 + .TIE_TOL) in .gw_kernel_weights() and .gw_window(). gwr_model_selection() checks the number of rows before .to_sp() at any bandwidth and refuses a constant response in fit_gwr_model()'s words. Users now get bandwidth 23 at both scales, AICc -36665.6146 and 36807.98654 (the exact shifts), exact fitted values, identical gaps at both scales and one warning where a sum of squares cannot be held. fit$engine$centres$scale records the factor. The boxcar gives 0 of 49 fitted values that differ between units. gwr_model_selection() on 0, 1 or 3 rows now says "observations cannot support a local fit of 2 candidate predictors plus an intercept", and with a fixed bandwidth refuses a layer with no more rows than the full model's parameters. ?fit_gwr_model (The local solve) says how the response is scaled. NEWS has three Bug fixes entries. No frozen fixture record is retaken and no test is turned round. test-fix-gwr-response-scale.R (8 tests) pins the fits, the search's criterion and curve, the selection gaps, the sums of squares at 2^400 and 2^-400, the leave-one-location-out scores and the warning against the unscaled reference, and test-fix-boxcar-window-ties.R (2 tests) pins the lattice across units and the edge at h (1 + 4e-8), kept, and h (1 + 6e-8), dropped, at h = 559, 1e200 and 1e-200.
fit_bayesian_spatial_model() handed brms an exgaussian or asym_laplace response as given, whatever its origin and units, since the centre and scale of the response were taken off under gaussian, student and skew_normal alone. At y + 1e8 the fitted values were 6.8e7 response SDs off under exgaussian and 4.1e5 under asym_laplace; in units of 1e-20 they were 6e14 to 2e15 SDs off, and looic was off by 2.3e3 to 5e4. The rule of the other three families does not hold these two at moderate sizes either: brms's default prior on exgaussian's beta and Stan's starting values are fixed in the units brms is given. On a response of SD 1.36 (beta 0.4605, sigma 0.1765, looic 74.5 under exgaussian; sigma 0.111, looic 75.3 under asym_laplace), the exgaussian fit at y * 100 gave beta 0.022 with R-hat 2.1, at y * 1e3 and at y - 300 it had no draws, at y + 300 beta was 19.6; the asym_laplace fit at y * 1e-4 gave sigma 1.035 and looic 231, at y - 300 and y + 300 sigma 0.200 and 0.198, looic 126 and 116. A fit with no draws came back with convergence_ok NA, looic NA and no warning, and fitted() stopped later. .bayes_location_scale_families (R/model-bayesian.R) gains exgaussian and asym_laplace with an identity link, and .bayes_scale_free_classes gains quantile. The new .bayes_narrow_families put these two under a narrower rule (.BAYES_NARROW_*): the centre is taken off at more than 4 spreads from zero, where every value still lies within a factor of two of it, and an SD outside 2^-2 to 2^2 is divided by the power of two nearest it. .bayes_response_scaling() returns the rule that applied and .bayes_response_scaling_text() names it in the message. A prior on beta or sigma keeps the response as given, with the warning spatialkit_response_scale; a prior on the quantile keeps the transform. Right after brms::brm(), a Stan fit with no posterior draws is now an error that gives the response as brms was given it, its median and SD, and the family; cv_bayes() records such a fold as failed. Users now get these fits in the response's units from any origin and in any unit: at y * 100 beta 0.453 and sigma 0.169, at y * 1e3 and y * 1e5 beta 0.461 and 0.456, at y * 1e-4 beta 0.462, at y +/- 300 beta 0.451; asym_laplace at y * 1e-4 sigma 0.111, at y +/- 300 sigma 0.109. fitted(), predict() and its draws, residuals(), coef(), looic and sdgp are put back in the response's units. The gaussian, student and skew_normal rule is unchanged. ?fit_bayesian_spatial_model states the narrower rule and why, says a fit with no draws is an error, and lists beta of exgaussian among the prior classes on the response's scale. NEWS: the response scale entry names the five families and the narrower rule, and a new Bug fixes entry says the function returned a fit with no posterior draws and said nothing. No frozen fixture record is retaken and no test is turned round. test-fix-bayes-response-scale.R gains tests of the narrower rule, of a prior on sigma at y + 1e8 under gaussian, exgaussian and asym_laplace, of lognormal and zero_inflated_asym_laplace reaching brms as given, and of the refusal of a Stan fit with no draws; its opt-in sampler test covers y * 100, y * 1e3, y * 1e-4 and y - 300, checks sigma and beta within 30 percent of the base fit, and allows fitted values 0.25 response SDs on average where it allowed 0.15, against a base fit of one chain.
A point layer whose geometry column is the general class sfc_GEOMETRY (every row a POINT) still stopped outside the fits and folds. On 40 synthetic points in EPSG:32617, summarize_by_cell(), cell_values_at() (newdata, points and seeds), determine_optimal_levels(), resolution_profile() and so select_resolution(), create_voronoi_polygons(), build_tessellation(method = "triangles"), get_voronoi_seeds(method = "kmeans") with sample_points, voronoi_seeds_kmeans() and predict_surface() (grid and covariates) stopped with sf's "not implemented for objects of class sfc_GEOMETRY". On the column sf::st_cast(x, "GEOMETRY") returns, which has no classes attribute, sf::st_union() stops with "Not compatible with STRSXP", so the hull of build_tessellation() and create_voronoi_polygons() and the join of assign_features_to_polygons() stopped with it. The plots returned by plot_tessellation_map() (features_sf, seeds_sf or boundary, with a target_crs), plot_folds() and plot() of a fit whose layer is such a column stopped with it when built or printed, and create_grid_polygons_cached() stopped with it on such points as boundary where create_grid_polygons() refuses a boundary that is not polygonal. The same held for MULTIPOINT features in such a column, and build_tessellation(method = "triangles") stopped with sf's message on a layer that mixes POINT and MULTIPOINT, which sf holds in an sfc_GEOMETRY column. .typed_points() (R/utils.R) now also casts a column whose geometries are all MULTIPOINT to sfc_MULTIPOINT, as it casts an all-POINT one to sfc_POINT, and is called at each reader: .pooled_xy() and the join copy of assign_features_to_polygons() (R/assignment.R), .values_at_xy() and cell_values_at() (R/cell-values-at.R), determine_optimal_levels() (R/level-selection.R), resolution_profile() (R/resolution-profile.R), get_voronoi_seeds() and voronoi_seeds_kmeans() (R/seeding.R), create_voronoi_polygons() and build_tessellation() on points_sf and cover before the hull (R/tessellation.R), .dedup_points() (R/utils.R), .surface_nearest_rows() (R/predict-surface.R), the layer moves of plot_tessellation_map() (R/plotting.R), plot_folds() and plot.spatial_fit() (R/plotting-fits.R), and the boundary of create_grid_polygons_cached() before its cache key (R/stable-ids-cache.R). The triangles branch of build_tessellation() reads the vertices of a POINT and MULTIPOINT mix from the same features cast to sfc_MULTIPOINT. Users see these calls run on such a layer and give what the same features in sfc_POINT, or sfc_MULTIPOINT, give: each plot builds identical to the plot of the typed layer, and create_grid_polygons_cached() gives create_grid_polygons()'s refusal. A moved layer, and the rows assign_features_to_polygons() returns, come back in the cast class; predict_surface() keeps a grid it does not move in its own class. The k-means seeders accept POINT only and refuse MULTIPOINT and a mix with the package's message, as before. NEWS: the Bug fixes entry on sfc_GEOMETRY points now names the cell summaries, the tessellations, the seeders and the surface, the calls above, the MULTIPOINT cast and the triangles on a mix. No frozen fixture record is retaken and no test is turned round. tests/testthat/test-fix-geometry-class-points.R gains 11 tests: each reader on both forms of the column, the builders with duplicates kept, the MULTIPOINT and mixed layers, the three plots built with ggplot_build(), and the cached grid's refusal. R CMD check warned that tests/testthat/test-fix-bayes-response-scale.R calls posterior:: without declaring posterior. Its helper for the posterior mean of a distributional parameter now calls brms::as_draws_df(), the same function, which brms exports; brms is in Suggests.
Three readings moved with the origin or the unit of the coordinates: - The k-nearest-neighbour weights took two neighbour distances as one when they differed by less than 1e-9 of the largest coordinate: 2e-6 m at offset 0, 0.1 m at 1e8, 1000 m at 1e12 and 1e6 m at 1e15. On 80 points with whole-metre coordinates in a 2000 x 1500 m box of EPSG:32615, k = 8 gave 8 neighbours per row at offset 0, 46 to 79 at 1e12 and 79 at 1e15; estimate_sac_range() read Moran's I 0.6662 at 0, 0.0384 at 1e12 and -1/79 at 1e15, and at 1e15 structure_p 1 and "no spatial structure detected at the nearest-neighbour scale". - The default ladder of cv_block_size_sweep() took its bottom rung as exp(log(side / 25)), a hair off a twenty-fifth of the shorter side, and the blocks per side as floor(side / size). On 70 points over 3000 x 2102 m in UTM 15 with k = 3 and n_sizes = 2, side / rung was 24.999999999999996 in metres and 25.000000000000032 in micrometres, so the bottom rung's blocks were 87.583 m high (24 rows) in metres and US feet and 84.08 m (25 rows) in km and micrometres. - On a layer with no CRS, the check that folds were built on the data took two locations as one within 1e-9 of the largest coordinate, and compare_models() took two responses as one within 1e-10 of the largest response. On 60 points in 4000 x 3000 units, folds built on the layer were refused on the layer moved by 500 units at offset 0 and applied to it at 1e12 and 1e15, and a response near 1e12 and the same plus 50 passed as one response. .knn_pairs() (R/evaluation.R) now ties two distances when their squares are within .TIE_TOL (1e-7) of each other, compared as distances so no square overflows, with no term in the size of the coordinates; a distance of 0 ties only with 0. .sac_structure_test() (R/cross-validation.R) takes its kd-tree shortcut only where no row's (k+1)-th distance ties with its k-th by the same rule. The sweep's ladder (R/block-size-sweep.R) starts at side / 25 and ends at its top exactly, and .block_dims_from_size() reads a quotient within .TIE_TOL below a whole number as that number, which is also the grid of make_folds(block_size = ). The new .same_values_tol() gives a margin of a part of the values' spread plus 8 units in the last place of their size; .check_fold_probe() and .same_rowset_xy() read locations with it at 1e-9, .same_rowset() responses at 1e-10. The lon/lat margin of 1e-6 degrees is unchanged. Users now get 8 neighbours per row, Moran's I 0.666242 and structure_p 1.57e-41 on the 80 points at offsets 1e12 and 1e15 as at 0, wherever the doubles hold the coordinates to about one part in 1e8 of the neighbour distances; a lattice ties as before. On a layer in UTM metres, distances less than 4 mm apart but more than that part apart no longer share a slot. The sweep's bottom rung gives 84.08 m blocks, 85.714 m wide and 84.08 m high, 66 blocks used, in m, km, US feet and micrometres alike. The moved layer is refused and the two responses told apart at 0, 1e12 and 1e15, and the same layer passes at every offset. ?residual_morans_i, ?estimate_sac_range and ?make_folds state the rules. NEWS has three Bug fixes entries, and the earlier entry on the 1e-9 floor is in the past tense and points to them. Five frozen fixture records are retaken: profile_missing, profile_min_cell_n, profile_sampled, profile_density_clustered and select_min_cell_n_moran_z_diagnostic. Their layers lie in UTM metres near y = 5,000,000, where the removed term was 5 mm, and 1 to 7 rows per graph have the k-th and next distance 0.7 to 5 mm apart. One test is turned round: in test-fix-knn-tie-units.R the near twin 2 units in the last place from an exact twin at a UTM northing no longer shares the k = 1 slot; the test now holds the weights to a reference of the new rule at k = 1, 2 and 4 and under 2^-50 and 2^-60. test-fix-knn-tie-offset.R, test-fix-sweep-ladder-unit.R and test-fix-check-margin-offset.R are new.
Tests failed on machines that differ from the one they were written on: - In a CI job without ranger, test-fix-geometry-class-points.R failed in six blocks with "there is no package called 'ranger'", 9 failures in all. 17 more files reached gstat (a variogram fit or kriging) or Matrix, both in Suggests, with no skip: without gstat, test-fix-knn-tie-offset.R failed where estimate_sac_range() returns NA before its structure test; with Matrix missing, test-return-accounting.R, test-core-frozen.R and test-fix-residual-moran-scale.R failed. - On GitHub's x86-64 runners, test-fix-subsample-order.R failed: a z-scored standard error moved by 7.7e-9 relative against a pin of 1e-9, a cell weight by 1.42e-8 against 1e-9, the area of applicability threshold by 1.1e-12 against 1e-12, and Moran's I and its z by 1.6e-12 against 1e-12. - The child processes of test-fix-crs-places-rows.R cleared R_TESTS through system2(env =), which Windows pastes into the command line, and a child that died with no output (an access violation ends it with status 5 there) left a failure that named no call. No package code changes. Each test block now skips on the Suggests package it calls, and only the part that calls it: the CRS, map, MULTIPOINT, fit, cross-validation and surface blocks of test-fix-geometry-class-points.R are split so the checks that need no optional package run everywhere, and the GWR parts, which need sp only, run without ranger. With ranger missing that file passes 167 checks and skips 10; with every optional package missing it passes 131 and skips 17. test-return-accounting.R sums the rows of the weights with Matrix::rowSums() only where they are a Matrix. Each figure that test-fix-subsample-order.R recorded is held identical to the same call with no cap in the same process and to the recorded value within 1e-6 relative, since the responses pass through chol() of a dense covariance and the design effect through a variogram fit; its checks of row order keep 1e-12 and identical(). test-fix-kriging-ties.R holds three figures of gstat's variogram fit and kriging solve within 1e-6 relative. The child runner of test-fix-crs-places-rows.R clears R_TESTS with withr::local_envvar() around system2() and passes no `env`. The child writes the text of each top-level step to a progress file before it runs it, and a failure gives the exit status, also in hexadecimal, the last step reached and the end of the output. Users see no change. NEWS has no new entry and no frozen fixture record is retaken. Tests turned round, each keeping what it tests: in test-core-frozen.R the platform record test sets a package missing on this machine as installed on the other side, where it compared NA with NA; the row sums check in test-return-accounting.R; the figures of test-fix-subsample-order.R, from 1e-9 and 1e-12 to 1e-6 relative plus identical() to the uncapped call; and three figures of test-fix-kriging-ties.R from 1e-9 to 1e-6 relative. A new test in test-fix-crs-places-rows.R checks that the child runner calls system2() without `env`, that the child does not see R_TESTS while this process keeps it, and that a child that quits with status 5 is reported with "exit status 5 (0x5)" and the step it ended in.
Where the learner of select_features_forward() cannot fit an empty predictor set (a forest, or a GWR fit_fn that refuses character(0)) and no null_fn is given, the sweep's baseline is the mean response of each fold's training rows. .fs_fold_mean_predictions() scored it on the raw response and the raw training means, which a double holds at 1e15 to an eighth. On 300 points with a GWR learner refusing the empty set (bandwidth 60, k = 3, seed = 1), the baseline gave RMSE 2.4701727 and MAE 1.9004936 at 0 and 1e8, but RMSE 2.4737792 and MAE 1.9033333 at 1e15 (2.4701674 at 1e12). The sweep's step-0 score and its message "the baseline is the training-fold mean" read 2.4480 at 0 and 2.4521 at 1e15, while every candidate set scored the same at both. .fs_fold_mean_predictions() (R/feature-selection.R) now gives each row a centre and its fold's training mean less that centre: the centre of the GWR fit where the fold's fit took the response about one, otherwise the centre the fold recorded, otherwise 0. Where any row has a centre the frame carries yhat_centred, so .cv_overall_metrics() scores it on its centred path; where none has, the frame is the old one to the bit. The fold records its centre on request: run_set() in select_features_forward() sets a request in the new package environment .cv_request just before its cv_spatial() call and clears it on exit; cv_spatial() (R/cross-validation.R) reads and clears it as its first statement, so a cv_spatial() run inside a learner never sees it, and passes the internal argument fold_mean_centre through .cv_run_folds() to .cv_fit_one_fold(). There, when asked, a fold whose fit has no centre and whose raw training response loses its spread to rounding (.regression_centre() not 0) adds the columns ..y_mean_centre and ..y_train_mean_about to its prediction rows. No exported signature or help page changes. Users now get the baseline RMSE 2.4701727 and MAE 1.9004936 at 0, 1e8, 1e12 and 1e15 on that layer, and the step-0 score and message 2.4480 at both offsets. fit_gwr_model() takes this response about a centre from an offset of 1e4, so with a refusing GWR learner the baseline at 1e4 to 1e12 moves in its last digits to the value at 0 (at 1e8, 2.4480192780 before and 2.4480192791 after). cv_spatial(), cv_gwr(), cv_rf() and select_features_forward() with a null-model baseline return what they returned before. The selected set did not change in any case checked. NEWS has one Bug fixes entry. No frozen fixture record is retaken and no test is turned round. test-fix-fs-fold-mean-offset.R is new: the baseline of cv_spatial() GWR folds and of the sweep with a GWR and a forest learner under RMSE and MAE and both rules agree at 0 and 1e15 to 1e-8 relative, the frame is the plain one where no fold has a centre, cv_spatial() adds the two columns only when asked and once, the sweep leaves no request behind, and a sweep whose folds record a centre in some folds only runs. The blocks that fit a GWR skip without sp, as the other tests skip on the optional packages they reach, so the file passes with every optional package missing.
GDAL returns a point it cannot move as an empty point and drops such a
vertex from a line or a ring. ensure_projected() warned about this only
on its moves out of longitude and latitude; every other move of a
caller's layer into another CRS returned the row emptied or short of a
vertex, with no word:
- harmonize_crs(a, b, prefer = "b") with b in EPSG:32646 (UTM zone 46)
returned the point (10, 0.1) of a empty and LINESTRING (10 0, 90 0,
170 0) as LINESTRING (166021.4 0, 14547126 0), and the same with
target_crs = 32646.
- A ring with a vertex at latitude 95 went from 5 vertices to 4
through harmonize_crs() and through the boundary of
predict_surface().
- ensure_projected(target_crs = 32646) took a line in EPSG:3857 from 3
vertices to 2, where the same line in EPSG:4326 warned.
- clip_target_for(), create_voronoi_polygons() and
build_tessellation() with a lon/lat boundary holding a vertex at
(10, 0) beside points in EPSG:32646, get_voronoi_seeds(method =
"provided") with a seed at (10, 0.1), the k-means sample_points, a
point cover, the cells_sf of kriging_adequacy(), both moves of
assign_features_to_polygons() and its scored join, and the free
cells of cell_values_at() said nothing either.
In R/crs-geometry.R, .warn_rows_unplaced() now takes the caller's
label, remedy, rows and row count and names the CRS the layer was in
through the new .crs_of_location() ("longitude and latitude",
"EPSG:<code>", the CRS name, or "its coordinates" for a layer with no
CRS). .rows_unplaced() compares vertex counts and x and y row by row,
so an XYZ point among XY points is not counted as unplaced. The new
.unplaced_in_words_of() lets an inner function's warning name the
outer function, its argument and its rows, and .as_harmonize_read()
gives a lon/lat layer with no CRS the EPSG:4326 that harmonize_crs()
reads it in. ensure_projected(target_crs =) warns from any source CRS,
and harmonize_crs() warns after each move of a or b, but not after
the on_transform_error = "set_crs" stamp. In R/utils.R,
.transform_or_stamp() warns on both its moves and .align_crs() takes
the caller, argument and label and warns; its call sites in
R/seeding.R, R/tessellation.R and R/kriging-adequacy.R pass the
caller's words, and .cover_follow() does the same for the cover.
assign_features_to_polygons() (R/assignment.R) gives harmonize_crs()'s
warning as features_sf or polygons_sf and moves the features of the
scored join with .transform_keep_unlocated(). cell_values_at()
(R/cell-values-at.R) names the rows of values and newdata it was given
and reports seeds without a CRS in its own words only.
Users now get one warning of class spatialkit_rows_unplaced for each
such move, in the words of the function called and the argument
passed, for example "harmonize_crs(): the move of `a` to EPSG:32646
cannot place every vertex of row 2 of its 2, which has a location in
longitude and latitude". The rows come back as before. Layers the
target CRS places in full raise no new warning and give identical()
results, among them nc.shp to EPSG:32119, 39 stations to EPSG:5070
from EPSG:4326 and EPSG:3857, and an XYZ point or line among XY rows.
?harmonize_crs and ?ensure_projected say so. NEWS has one Bug fixes
entry, which names the functions that warn, and nothing under
Breaking changes.
No frozen fixture record is retaken. Five tests are turned round, each
keeping its value checks: in test-fix-unlocated-rows.R the
resolution_profile() test, whose row at (3e7, 3e7) in EPSG:5070 now
warns before the drop line, and in test-fix-fold-probe-far.R four
tests whose projected row beyond 1e10 is emptied by the move to
degrees as before and now warns. test-fix-movers-unplaced.R is new,
with 15 tests that pin each warning, its rows and its words, and the
layers placed in full against sf::st_transform().
Two functions also raised a warning about a later step and then
refused the call, so the warning described work that never ran.
resolution_profile() on 300 points with a trend on w and a sac of
residuals on w, with levels = 1 or levels = 5000, warned that sac is
a variogram of detrended residuals while the profile scores the raw
response, and then stopped with "no usable value in `levels`"; with
the variogram estimated, levels = c(400, 500) raised
spatialkit_variogram_unusable before the same error. Without FNN and
with options(spatialkit.exact_pairs_max = 1000), levels = c(5, 10)
and the default ladder of counts warned and then stopped on the work
limit (work 3000 and 9900). estimate_sac_range() on 60 points with z
constant and w missing on every row, under detrend = "ols" or "reml",
returned NA "the response is constant" with the warning that "the
variogram is fitted to the RAW response instead"; 40 points 1e-300
apart gave NA "the points have no extent" with the same warning. With
detrend = "reml" and a factor w of one level, the fallback warning
said the REML detrending "did not converge", though nlme::gls() never
iterated: the design of the trend cannot be built.
In resolution_profile() (R/resolution-profile.R), on a ladder that is
not of sizes, the parts of the ceiling, the check of levels and the
work guard on the search of each scored row's nearest centre now run
before the variogram is estimated or read. The guard reads max(levels)
for levels the caller gave, else the ceiling the ladder ends at. In
estimate_sac_range() (R/cross-validation.R) the raw-response warning
is raised after the constant-response and no-extent refusals, and the
failed lm() of the sibling site is deferred the same way.
.reml_trend() returns the error of model.matrix() where no start gave
a fit and the design cannot be built on the rows of the fit, and the
warning then says the REML detrending "could not be fitted (contrasts
can be applied only to factors with 2 or more levels)".
Users now get the levels error alone on those three calls, and the
work limit error alone with the same work 3000 and 9900; under
sample_n = 40 and n_levels = 4 the guard reads the subsample's
ceiling of 20, so a limit of 6000 returns levels up to 20 and 5999
stops with work 6000. levels = c(5, 10) keeps its warning and returns
levels 5 and 10, and a call that returns a profile computes the same
values. estimate_sac_range() gives the same NA and reason with no R
warning, and a structured response with w missing, or with a factor w
of one level, fits the raw response and keeps its one warning.
?resolution_profile (levels) and ?estimate_sac_range (predictor_vars,
detrend) say so. NEWS has three Bug fixes entries.
No frozen fixture record is retaken. One test is turned round: the
help pin of test-fix-variogram-locations.R now pins the new
predictor_vars sentence. test-fix-warn-after-refusal.R is new, with 7
tests on the levels refusals and the work guard with no warning,
levels = 299 kept and 300 refused on 300 points, the refusals after a
failed detrending, the raw-response fit keeping its warning, the REML
text and the help sentences.
One place recorded twice, the two records differing only in the last bits of their coordinates, was settled by those bits, so the record taken moved with the unit and the origin. In predict_surface() with point covariates, a 3 by 3 lattice of stations 1 km apart in EPSG:26915 with the centre station recorded a second time one unit in the last place (9.3e-10 m) north, and a grid point 300 m east and 200 m north of it, took w 4 and .pred 4.33 in metres and US feet but w 100 and .pred 98.97 with the false origin moved by 0.1 m, at 6 of 20 positions. In cell_values_at() without seeds, with the two records scored in two cells and a location 2.5 km north of them in no cell, the fill came from cell 2 in metres and US feet and from cell 1 with the origin moved, at 7 of 20 positions. The points' bounding box had a last-bits small diagonal, so .near_columns() parted the two records into two columns by those bits, and the raw y read after the column chose between them. The new internal .near_points_extent() (R/cell-values-at.R) gives the extent the column step is a part of: the diagonal of the points' box, or one part in 1e10 of their largest coordinate over the tie margin where that is more. .surface_nearest_rows() (R/predict-surface.R) now orders the points by column and then by row, y read by the same rule, then by row of the layer. cell_values_at() orders the scored locations by column, then by row read the same way, then by the first cell in ID order among the rows at each location; the distinct locations stay the exact coordinate pairs. Users now get w 100 and .pred 98.97 at every position and in every frame, the first row of the layer, and cell_values_at() fills from cell 1, the first in ID order, in every frame. On a layer whose box diagonal is more than a thousandth of its largest coordinate the extent is the diagonal, as before. ?predict_surface (covariates) and ?cell_values_at (Ties) state the rule with the floor; ?predict_surface adds that a grid point closer to such a pair than about twenty million times the distance between them (2 cm for points 1e-9 m apart) takes the nearer as its coordinates give it. NEWS amends the two entries on these ties under the development version. No frozen fixture record is retaken and no test is turned round. test-fix-coincident-point-ties.R is new: both functions give the same row or cell in metres, US feet and with the origin moved, in other row orders and with FNN mocked off, including where only the station's two records are scored and where two locations share a column and a row; .near_points_extent() gives the diagonal or the floor; and ?predict_surface states which grid points take the same covariates. The help-text tests of test-fix-nearest-ties.R and test-fix-values-at-column-ties.R take the new wording.
Two faults came from the size of the response. - estimate_sac_range() and kriging_adequacy() squared a response near 1e160 or 1e-160 as given. Near 1e160 the semivariances overflowed: estimate_sac_range() refused with "fewer than three lag bins hold point pairs", which was false, made no structure test, and make_folds(auto_range = TRUE) built other folds (69 of 150 rows moved); kriging_adequacy() refused for the same reason. Near 1e-160 Moran's I read 0.585076 for 0.585048, the range 724.18 for 724.26, kriging_adequacy() kriged 0 of 9 cells and its se moved by up to 0.3 percent. With detrend = "reml" on 150 points the REML fit failed at 2^530 and 1e160, so the range came from the OLS fallback (979.10 for 1405.66) with a warning that REML "did not converge". - A response far from zero was read without a word where doubles do not hold a millionth of its spread. At an offset of 1e15 make_folds(auto_range = TRUE) took the range 725.39 for 724.26 and built other folds, and select_features_forward(rule = "se") selected x2 where the same response near zero selects none. .sac_structure_test() (R/cross-validation.R) now divides the response by the power of two .spread_scaled() gives. Where the response's standard deviation lies outside 1e-150 to 1e150, estimate_sac_range() computes the semivariances, the model and the nugget in units of .pow2_floor() of it and puts them back by its square, in the result and in the log lines; kriging_adequacy() (R/kriging-adequacy.R) does the same for the variogram, the kriging, the cross-validation and the per-cell variances, takes the per-cell se from .cell_sd() where var() underflows, and divides a supplied model down. .reml_value_frame() divides each column by a power of two of its range outside the same bounds, and .reml_trend() returns the frame's variance and scale, from which the REML model is built in the scaled units. kriging_adequacy() refuses a supplied model whose partial sill is Inf, and says it overflowed. The new .warn_response_imprecise() (R/utils.R) raises class spatialkit_response_imprecise where one unit in the last place of the response's largest absolute value exceeds 1e-6 of its standard deviation; prep_model_data() (R/model-prep.R), estimate_sac_range(), select_features_forward() (R/feature-selection.R) and kriging_adequacy(), with or without sac, call it, once per response column for the run. A warning muffled inside make_folds()'s range diagnostic no longer counts as said, so compare_models_cv(folds = NULL) warns once, and cv_spatial() warns once for its folds when its fit_fn prepares each fold again. Users now get from a response times 2^-530 or 2^530 the range, the test, the folds and the kriged values of the response itself, times the factor where they carry its unit; with detrend = "reml" the range is 1405.66 at 1, 2^-530, 2^530, 1e-160 and 1e160 with no warning. Values in the response's units squared (the variogram, the nugget, the REML variance, kr_var, plain_var) are Inf near 1e160 and subnormal near 1e-160, as ?estimate_sac_range says. A response with a standard deviation of 1 at about 1e10 (2^33) or beyond draws the new warning, which gives the spacing of doubles there and the standard deviation; its values are read as given. A response of ordinary size gives the same results as before. ?estimate_sac_range and ?prep_model_data state the scaling, the warning and when it is raised. NEWS has two Bug fixes entries. No frozen fixture record is retaken and no test is turned round. test-fix-sac-response-scale.R (13 tests) and test-fix-response-precision.R (9 tests) are new: the range, nugget, short-lag semivariances, directional fits, replicates, kriging and REML at 2^-530 to 2^530 and 1e-160 to 1e160 against the unscaled response, the refusal of an Inf sill, and the warning's threshold and count across make_folds(), compare_models_cv(), cv_spatial() and kriging_adequacy(). test-fix-spread-summaries.R expects the new warning once at an origin of 1e12 or more and none below.
Two sets of faults are fixed.
Rows without a location were read as located, and polygons got points
off themselves:
- The test of a row's location, .unlocated_features()
(R/assignment.R), read the layer's bounding box first and no vertex
when the box was finite. sf::st_bbox() skips NA, so a ring or line
with one vertex at NA passed: prep_model_data() kept 12 of 12 rows
and make_folds() put the row in a fold. sf keeps the box it stored
on a column after `[[<-`, so a point edited in place to (1e200,
4e6) passed too, and make_folds(random_kfold) assigned 40 rows of
40. kriging_adequacy() never read cells_sf through the test: a cell
with a vertex at NA or Inf was repaired into the rest of its ring
and kriged (kr_pred -1.008), and one at 1e200 stopped sp with
"invalid Polygon object".
- coerce_to_points() gave a polygon with a vertex at NA or Inf a point
under every mode ((501000, 4000000) under "auto", (Inf, 4000500)
under "bbox_center"), and assign_features_to_polygons() joined such
a polygon: the Inf one took 15 points, its neighbours' too, and one
at 1e200 stopped GEOS with "orientationIndex encountered NaN/Inf
numbers".
- coerce_to_points() passed on sf's "st_point_on_surface may not give
correct results for longitude/latitude data" for every lon/lat
polygon, and a polygon across longitude 180 could get a point off
itself. summarize_by_cell(estimate = "pooled") and cell_values_at()
muffled that text and read such points: on 36 squares across 180
dist_nearest was 9820.9 m where the correct points give 4937.6 m,
and plot_tessellation_map() put the label of a square from 179.5 to
-179.5 at longitude 0.
.unlocated_features() now reads the coordinates themselves, point by
point for POINT layers. kriging_adequacy() (R/kriging-adequacy.R)
empties such cells and leaves them out as empty cells, with a warning
of their own, and print() counts them apart from thin cells.
coerce_to_points() (R/crs-geometry.R) empties unlocated rows of any
type before any mode, and assign_features_to_polygons() empties such
rows of polygons_sf before harmonize_crs(). The new .surface_points()
muffles sf's text on polygons under 180 degrees wide, whose points are
unchanged to the bit; on a lon/lat polygon wider than that it tests
GEOS's point on the sphere with s2, takes a point off it again with
the longitudes read from 0 to 360, and raises class
spatialkit_surface_point_off naming the rows it still cannot place. A
layer with no CRS whose coordinates look like degrees is read so too,
with a warning naming the rows that reading moves. .pooled_xy() no
longer muffles the text, and plot_tessellation_map() (R/plotting.R)
takes its label points with .surface_points(), still under
suppressWarnings() for sf's lon/lat box warning.
Users now see such rows dropped with the "without a location" line
(11 of 12 rows kept; 39 of 40 rows in folds, the edited row in none,
the folds those of the layer built whole), an EMPTY POINT from
coerce_to_points() in every mode, a join of 55 rows with "5 of 60
feature(s) fall inside no polygon", and kriging_adequacy() cells with
kr_ columns NA and an empty geometry, each identical to the same layer
with that row empty. On the 36 squares the summaries match the correct
points, and the label sits at 180. ?coerce_to_points,
?assign_features_to_polygons and ?kriging_adequacy say so. NEWS has
three Bug fixes entries.
resolution_profile() gave a false reason for cp being NA. Without a
nugget cp takes as noise variance the residual mean square of the
finest level whose cells hold at least two scored rows on average, and
is NA at every level when that is 0. On 40 locations of three rows of
one value each, at levels 5 and 40, with the nugget at its bound, the
spatialkit_cp_noise warning and the print said no level's cells hold
two scored rows on average, attr(, "cp_noise") was NULL, and
select_resolution(criterion = "cp") gave its general text. With no
usable variogram nothing said cp is NA, and five warnings and log lines
said cp "takes its noise variance from the finest level" with no
condition. With predictor_vars the residuals of such rows differ in
their last bits, so cp took a mean square of 2.37e-31 as its noise
variance and select_resolution() picked the finest level.
The fallback in R/resolution-profile.R now reads the finest level's
mean square as 0 within the rounding of the fit (the size of each
row's response and fitted terms), raises the warning on every path,
and records list(source, value, level, rows_per_cell, rms, reason).
The print and select_resolution() name the level, its 3 scored rows a
cell and its mean square of 0 ("to within rounding (2.37e-31)" with
predictors). The five texts and the not-converged warning share one
clause: cp takes its noise variance from the finest level whose cells
hold at least two scored rows on average, and is NA at every level
when none does. Rows that differ by 1e-6 keep their noise variance.
?resolution_profile states the same. NEWS has two Bug fixes entries.
No frozen fixture record is retaken and no test is turned round. New
tests: test-fix-unlocated-na.R, test-fix-lonlat-surface-warning.R and
test-fix-cp-noise-text.R. The two batches met in NEWS.md, where all
entries are kept, and in R/kriging-adequacy.R without conflict.
kriging_adequacy() tabulated each cell's points over the cells' IDs,
which hold no level for NA. On four 500 m cells with 80 points (n 22,
22, 18, 18), one cell with ID NA warned that 22 points match no cell
and then stopped with base R's "replacement has 3 rows, data has 4";
every ID NA stopped with "replacement has 0 rows, data has 4". With
two of the four IDs NA the two counts left were recycled over the four
rows with no error: n came back 22, 18, 22, 18, and cell B took cell
D's n 18 and mean -0.2383 (its own: n 22, mean 1.189). A double NaN ID
was matched as the text "NaN", where cell_values_at() reads it as no
ID, every cell NaN stopped with "factor level [2] is duplicated", and
two cells sharing an ID stopped with "factor level [5] is duplicated".
kriging_adequacy() (R/kriging-adequacy.R) now reads the cell and point
IDs as text with NA taken on the raw column first, so NA, NaN and a
factor's NA level are no ID. A cells_sf in which no cell has an ID is
refused before anything is fitted, in words that name cells_sf, its
ID column and id_col; two cells with one ID are refused in words that
name the column and the IDs, as assign_features_to_polygons() refuses
them. n, mean and se are tabulated over the cells that have an ID: a
cell whose ID is NA comes back with n 0 and mean, se, plain_var,
kr_gain and kr_shift NA, and is kriged as any other (kr_pred 1.248,
kr_var 0.00536 in the case above). Points are matched with
incomparables = NA, so a point without an ID is never counted in such
a cell, and a point whose ID is NaN is counted in no cell without a
warning, as one whose ID is NA is. Layers whose cells all have their
own ID give results identical to before. ?kriging_adequacy (id_col)
says so, and NEWS has one Bug fixes entry.
Five texts of the tessellation functions stated something false:
- voronoi_seeds_kmeans() on 10 points at 10 positions with k = 10
said "only 10 unique positions among 10 point(s); clamping to 9",
giving the positions as the reason for a bound the number of points
sets. It now says "the points support at most 9 (10 unique
position(s) among 10 point(s)); clamping.", as get_voronoi_seeds()
says it, and prints a count that is not whole as requested
(k = 9.5 said "requested 9 seeds"), here and in get_voronoi_seeds().
?voronoi_seeds_kmeans (k) says the bound is one fewer than the
points with a location, so 12 rows of which 2 have none clamp to 9.
- A direct create_voronoi_polygons() call warned and logged in the
name of build_tessellation() ("build_tessellation(): 26 of 30
point(s) ... fall in no cell"), and build_tessellation(method =
"voronoi") warned about cover points in the name of
create_voronoi_polygons(). The body is now the internal worker
.voronoi_polygons() (R/tessellation.R), which each caller passes its
own name, and .build_point_cell_index() and .cover_points_outside()
take that name for their warnings and log lines.
- The refusal of cell_values_at(seeds =) on points placed by hand
advised `seeds$cell_id <- tess$index`, which had been done. It now
says why index repeats an ID (a point in no cell but within a
thousandth of the median cell width of another seed's cell takes
that cell) and names get_voronoi_seeds(method = "provided"), and
?cell_values_at and ?create_voronoi_polygons describe the snap.
- With make_valid = TRUE the refusal warning of
ensure_stable_poly_id() (R/stable-ids-cache.R) said "the geometry
returned is the caller's own" while the rows came back repaired. It
now says the rows returned are the repaired polygons.
- clip_target_for() at one location said "degenerate bbox; using
small buffer around points." for a disk of radius 1 unit of the CRS.
It now says the points sit at one location and the disk has a
radius of 1 metre (1 unit of the CRS), or names the units of the
coordinates where there is no CRS, and how to get a target of real
size; two points 5e-324 apart are said to lie that close.
?clip_target_for says the same.
No result of the tessellation functions changes. NEWS has five Bug
fixes entries. The frozen record kmeans_more_than_locations is retaken
for its warning and log text; its value is unchanged. Tests turned
round: test-seeding.R and test-core-partition-properties.R pinned the
old clamp text, and test-core-values-at.R's full refusal is extended
with the new sentences. New tests: test-fix-kriging-na-ids.R,
test-fix-tessellation-msgs.R and test-fix-hand-seeds-snapped.R. The two
changes met only in NEWS.md, where every entry is kept.
plot_tessellation_map() and plot_folds() drew rows without a location. Four 100 m cells in EPSG:32617 with a vertex of cell 3 at Inf gave a map whose x range ran from 5e5 to Inf with no word; at 1e200 it ran from -5e198 to 1.05e200 with ggplot2's "Position guide is perpendicular to the intended axis", and the same held for a point at 1e200 in features_sf or seeds_sf. plot_folds() drew the point make_folds() had left out of every fold: on 40 points in EPSG:4326 near (-80, 36) with point 7 at (-80.2, 95), block_kfold left it out once projected and the map drew it with no word, its y range 33.06 to 97.95 without blocks. The labels of a map with an NA cell_id, or an empty cell, raised ggplot2's "Removed 1 row containing missing values". With target_crs = 4326, CRS-less squares at x 5e5, y 4e6 were stamped EPSG:4326 with sf's "bounding box has potentially an invalid value range for longlat data", and drawn over y 3999995 to 4000105. Overlays with a CRS other than the plot's were moved with sf::st_transform(), so a point at latitude 95 or a boundary vertex there was emptied or dropped in silence. The new .plot_drop_unlocated() and .plot_keep_located() (R/plotting.R) read each layer with .unlocated_features() before it is moved into the plot CRS and leave the marked rows out after the move, with one warning per call naming each argument and its count. plot_tessellation_map() runs its four layers through them; plot_folds() runs points_sf and boundary, and also leaves out a point with no fold that is empty or that the CRS the folds were built in cannot place. A located point with no fold is still drawn in the NA colour. Labels are taken only for cells with a label and a location; with none left they are skipped with a log line. maybe_transform() moves a layer through .transform_or_stamp(), which reports a row it cannot place with spatialkit_rows_unplaced. .transform_or_stamp() (R/utils.R) now stops when a CRS-less layer is to take a lon/lat CRS and its located coordinates have an x outside -180 to 360 or a y beyond 90 (its new argument lat_max); create_grid_polygons() and build_tessellation() pass 180 for boundary, where they refuse a latitude beyond 90 row by row as before. The help of make_folds(), area_of_applicability(), predict_surface() and plot_tessellation_map() says such a stamp is refused. Users now get the map of the other rows (x 499980 to 500420, as the clean layer) and the warning "plot_tessellation_map(): not drawing 1 row(s) of `tessellation_sf` without a location (...)"; the latitude-95 case draws 39 points with a y range below 37 without blocks; labels 1, 3 and 4 with no ggplot2 warning; and, for the squares in metres, an error that names the box and the target and says to set the CRS or pass a projected target_crs. x 200 to 350 is stamped as before, and a moved overlay warns for each row it cannot place; the built plot is otherwise identical to the old one. Since rows with an NA vertex are now read as unlocated, the maps leave those out too. The label points are still taken with .surface_points(), so a cell across longitude 180 keeps its label on it; only cells with a label are passed to it. NEWS has entries on the rows left out, the labels and the lon/lat stamp, and the entry on layers moved into the CRS of their data names plot_tessellation_map() for every layer it moves. make_folds() advised fold counts that give the same folds or none. On 5 rows, random_kfold with k = 10 warned "pass k <= 5 for fewer, larger folds", where k = 5 gives the same one-row folds; 4 groups under leave_location_out with k = 6 advised k <= 4; 2 rows or 2 groups with k = 3 advised k <= 2, where no smaller k exists; kNNDM on 6 rows with k = 10 advised k <= 6. kNNDM on 8 rows with k = 10 and min_train = 0.9 warned "returning 8 folds", then refused min_train and advised "or more folds", and returned nothing. .k_fewer_folds_hint() (R/cross-validation.R) now ends the k-reduction message with k <= n - 1, leaves the advice out where no smaller k exists, and under kNNDM starts at the smallest k that min_train allows, giving the reason. .knndm_k_meets() holds the existing min_train test, read by both the refusal and the advice, and .knndm_k_min() gives the smallest k that meets it. kNNDM now cuts k, tests min_train, then warns, and offers "or more folds" only where that smallest k is at most n. Users now see "pass k <= 4" and "pass k <= 3 to hold out several groups per fold.", "This is leave-one-out." where 2 rows are left, "pass k <= 5" for kNNDM on 6 rows, "pass k = 7 ... (min_train = 0.85 needs k >= 7)" on 8 rows, and for min_train = 0.9 on 8 rows the error alone, ending "Use min_train <= 0.875.". The folds, k, params$k_requested, the condition fields and the random stream are unchanged. ?make_folds (k) says the warning gives a setting that works where there is one. NEWS has a new Bug fixes entry, and the earlier entry on spatialkit_k_reduced says "where there is one". No frozen fixture record is retaken and no test is turned round. test-fix-plot-unlocated.R (8 tests) and test-fix-folds-k-text.R (7 tests) are new.
Three texts of resolution_profile() and select_resolution() said something false about the ceiling of the cell counts: - Under select_on = "split" on a subsample, the warning of class spatialkit_response_ceiling called the selection half's rows of the subsample that carry a response all the subsample's rows that carry one. On 3000 points with a response on 1500 at random and sample_n = 500 it said "141 of the 500 points of the subsample carry a response", where 271 carry one, and "about 10.6 times as many" for the factor by which the layer's cells hold more scored rows than cell_resp_mean shows, taken over both halves. With no scored row in the subsample it printed "about NA times as many". Where min_cell_n set the ceiling (4000 points, a response on 400, sample_n = 3500, min_cell_n = 30) the factor was 2.14 where the selection half gives 1.2. - The warning of class spatialkit_not_supported for a range floor above the ceiling said "the profile runs from 2 to 6" over the levels 4 and 5 given in `levels`, and named min_cell_n or the size as the bound where the distinct locations set it: on 60 rows at 5 stations "60 points at min_cell_n = 9 support at most 5", of a min_cell_n that allows 6; with obs_per_cell = 3 "the 5 cells that size gives" of a size that asks for 20; on 40 distinct points with obs_per_cell = 1 "support at most 39" of a size that asks for 40. - Where min_cell_n and the distinct locations set the same ceiling (45 rows at 5 stations, min_cell_n = 9), an optimum at the ceiling was labelled "the support ceiling (n / min_cell_n)", and the note advised `levels` past it and a lower min_cell_n, neither of which moves it: levels = c(2, 5, 7, 9) scores 2 and 5 only, and min_cell_n = 3 leaves the ceiling at 5. resolution_profile() (R/resolution-profile.R) now says under the split that the count is of the selection half and gives the layer's rows with a response in either half, takes the factor from the selection half (split$n_response / n_scored) in both branches of the warning, and leaves the factor's sentence out when no row of the subsample is scored. The floor warnings of the min_cell_n ladder and of .size_ladder() name the bound that sets the ceiling by the test ceiling_from takes: min_cell_n, the distinct locations, or the most cells k-means can fit, and a size whose cells k-means cannot all place is named with the count it asks for. With `levels` given, the warning and the log line that asks for a larger sample_n say the levels asked for are scored as given. .ladder_edge() in select_resolution() names "the support ceiling (as many cells as the distinct locations allow)" at the tie, with no remedy, in the edge, its print, summary() and the spatialkit_bound_chosen warning of get_voronoi_seeds(). Users see only these texts change: no rule, ceiling, level, ceiling_from value or condition field moves, and the text without the split with a scored row is the same as before. ?resolution_profile gives the factor under the split and says that given levels are scored as given when the floor is above the ceiling. NEWS has three Bug fixes entries. No frozen fixture record is retaken and no test is turned round. test-fix-split-ceiling-text.R is new (14 tests): the split's count and factor, the missing factor, each bound the floor warning names, the held size on repeated and on distinct points, the tie and a size that asks for exactly the cells k-means can place. test-core-count-ladder.R and test-core-count-size.R gain a test of the held finest size's whole message and of the edge label at the tie.
Three texts called a default something the caller asked for. On 400
points with the default pipeline, print(sel) read "size : 4.5 rows per
cell, the default (obs_per_cell)" while print(sel$count_rule) read
"Count: 89 cells, set by size (4.5 rows per cell asked; 400 rows / 89
cells = 4.49)", and the record on the seeds and on a summary printed
the same. On 5 points with the defaults, the subtitle of plot() of the
profile read "1 level of 2 cells (floor 2, ceiling 2); fewer than two
cells of the size asked for", and the plain mean's default ladder on
two scored rows said the same of its finest size, 2. On 400 points
with estimate = "mean", select_resolution(pm, obs_per_cell = 6) was
refused with "criterion = \"auto\" was asked for, which reads this
profile by \"loo\"", though the caller named no criterion; the same
held for "cp" on a profile without an estimate.
Two internal helpers in R/resolution-profile.R decide by value where a
size came from: .size_is_default() is TRUE for 4.5 exactly or the seven
sizes of the plain mean's ladder in any order, and FALSE for any other
size or ladder and for a value that holds an NA or is not numeric;
.size_source_text() gives ", the default" or " asked". The selection's
print and note, print.spatialkit_count_rule() (R/count-rule.R) and the
new .too_few_size_text() (R/plotting-diagnostics.R), which builds the
subtitle's clause, go through them. select_resolution() writes
"criterion = \"auto\", the default, reads this profile by ..." where
the criterion is "auto", and keeps "criterion = \"loo\" was asked for"
for a criterion the caller names.
Users now see "Count: 89 cells, set by size (4.5 rows per cell, the
default; 400 rows / 89 cells = 4.49)", the subtitle "fewer than two
cells of the size (obs_per_cell = 4.5, the default)" or "(obs_per_cell
= 2, the finest of the default sizes)", and the refusal "...
criterion = \"size\" only, and criterion = \"auto\", the default, reads
this profile by \"loo\"." A size or ladder the caller names (6, 5,
c(6, 4.5)) is still "asked" or "asked for". The selection's own print
and note are byte-identical, and no refusal, count or record changes.
NEWS has one Bug fixes entry.
No frozen fixture record is retaken. Tests turned round, as they pinned
the false text: four record lines in test-core-count-rule.R ("4.5 rows
per cell asked" now "4.5 rows per cell, the default"), and in
test-core-count-size.R the two "auto" refusal texts and the subtitle on
six rows at 4.5. New tests: the record's print names the size as the
selection's print does; a size is the default by its value (including
4.6, 4.5 + 1e-9 and an NA beside the default); a size beside the
default criterion is refused without calling the default asked for; and
the plot's subtitle names a size too coarse for the layer by where it
came from.
Four readings of the response failed at the ends of the double range: - mean() sums in a long double, and where that is no wider than a double (as on macOS on Apple silicon) mean(c(x, x, x / 2, -x)) is -Inf for x = .Machine$double.xmax, whose mean is 0.375 x. Every out-of-sample R-squared is scored against the training mean, so model_metrics(newdata =) of a fit trained on those values gave NA for 0.9894806, and cv_spatial() on 120 points scaled by 2^1020 gave fold 1 a training mean of -Inf and that fold's R-squared and the pooled one NA, where every scale up to 2^1019 gives 0.7655072031. select_features_forward() dropped that fold's rows from its training-fold-mean baseline. - select_features_forward() compared each candidate's score with the intercept-only score by all.equal(tolerance = 1e-12), which compares absolute differences below 1e-12. On 60 points with the response in units of 1e-20 (RMSE 1.2e-20) a working linear fit_fn selected x1 and drew the warning that it "appears to be ignoring its second argument". - cv_block_size_sweep()'s fold_sd and the standard error of select_features_forward(rule = "se") were sd() of fold scores, whose squared deviations underflow near 1e-160 and overflow near 1e160. For a response scaled by 2^-530 fold_sd over the scale was off by up to 5.68e-4 relative; at 2^530 it was Inf, and the "se" rule on pure noise selected a predictor, warning that fewer than two folds could be scored while saying 5 were. - prep_model_data() reads the shift of the dropped rows' response in standard deviations of the response. On 60 points with 6 rows missing a predictor the warning says the dropped rows sit 1.18 SD from the kept ones; at 2^-560 (sd() 0) and 2^530 (sd() Inf) that sentence was missing and response_std_diff was NA. The new .train_mean() (R/utils.R) returns mean() of the finite values, less a centre, where that is finite, and otherwise reads the mean on the values divided by a power of two, which is exact. .cv_fit_one_fold() (R/cross-validation.R) takes it for the plain and centred training means, model_metrics() with newdata (R/model-classes.R) and select_features_forward()'s score_holdout (R/feature-selection.R) for theirs. select_features_forward() now tests abs(step - null) <= 1e-12 * abs(null), relative to the intercept-only score. fold_sd (R/block-size-sweep.R), the "se" rule's paired gain and prep_model_data()'s spread (R/model-prep.R) take .sd_any_size(), which is sd() where that is finite and at least 1e-150 and reads the spread on a power of two otherwise; it now returns 0 only where every value is the same, where it gave 0 for c(1, 2, 3, 4) * 1e-170, whose spread is 1.290994e-170. That also reaches cv_bayes()'s yhat_sd for draws that small. Users now get model_metrics() R2 0.9894806 at xmax, the pooled cv_spatial() R2 0.7655072031 at 2^1020, no warning for a working fit_fn at 1, 1e-20, 1e20, 2^-530 and 2^530 and the warning at each for one that ignores its predictors (also under R2, whose null score is 0), fold_sd over the scale 0.09445242009 0.15863083796 0.10033509059 0.05240713278 at 1, 2^-530 and 2^530, the "se" rule selecting nothing at every scale, and the 1.18 SD sentence at all three scales. Where mean() and sd() hold, every result is the same to the last bit. NEWS has four Bug fixes entries. No frozen fixture record is retaken and no test is turned round. test-fix-train-mean-range.R is new, with 12 tests: the helpers identical() to mean() and sd() on ordinary vectors and right from 2^-1000 to 2^1000, cv_spatial() at 2^1019 and 2^1020, model_metrics(newdata =) at xmax and about a centre, the sweep's R2 at 2^1020, the fit_fn check under RMSE and R2, fold_sd and the "se" rule at 2^-530 and 2^530, and the prep_model_data() shift at 2^-560 and 2^530. It compares at 1e-12 relative, since the reading on a power of two sums in another order, which moves last bits by platform.
Three readings of lon/lat layers went wrong without a word: - A row of a layer in a geographic CRS with a vertex at a latitude beyond 90 was read where it was written. sf's bare "bounding box has potentially an invalid value range for longlat data" reached the caller from coerce_to_points(), prep_model_data() and the fits on polygons, the k-means seeders and assign_features_to_polygons(). A square at 35 N with one vertex at 95 got its box centre at (-79.95, 65.00) under pointize = "bbox_center", about 3,300 km from its other vertices, and ensure_stable_poly_id() keyed that row and returned it in silence. ensure_stable_poly_id() with method "centroid" or "surface_point" on a layer whose every polygon is empty, and with "surface_point" on one row with a vertex at 95, stopped with base R's "missing value where TRUE/FALSE needed". - get_voronoi_seeds() and voronoi_seeds_kmeans() moved the centres of a profile passed as n or k, and the k-means cloud, into the CRS of boundary or points_sf with no word where the move could not place them: in an orthographic CRS on longitude -87 all 10 centres came back empty, and a cloud point at (10, 0.1) moved to UTM zone 46 was dropped. - coerce_to_points(mode = "bbox_center"), "centroid" with s2 off or on a layer without a CRS read as degrees, and "auto" on a MULTIPOINT with s2 off, put a geometry written across longitude 180 near longitude 0: a square from 179.5 to -179.5 at latitude 10 got (0, 10.5), and a line and a MULTIPOINT got (0, 10.25), 17,624 to 17,707 km from their geometries. prep_model_data(pointize = "bbox_center") then projected three such squares in a Lambert azimuthal centred on the North Pole. .unlocated_features() and .empty_unlocated() (R/assignment.R) take lat = TRUE, under which a row of a geographic layer with a vertex beyond 90 has no location; .beyond_pole_features() (R/crs-geometry.R) reads the coordinates, not the stored box. The readers in R/assignment.R, R/crs-geometry.R, R/cross-validation.R, R/model-prep.R, R/seeding.R and R/stable-ids-cache.R empty such rows first. coerce_to_points() gives such a row an EMPTY POINT with one warning of class spatialkit_lat_beyond_90 that names the rows; prep_model_data() and the fits drop and count it, the seeders drop it from the cloud, the join leaves it unassigned, .pooled_xy() leaves it out of summarize_by_cell() and cell_values_at(), and ensure_stable_poly_id() keys it as an empty polygon after the located ones and returns it as it came. "surface_point" there takes the points on the surface of the geometry column. .seeds_in_crs_of() and .scored_seeds_record() (R/seeding.R) move centres and cloud with .transform_keep_unlocated() and warn spatialkit_rows_unplaced, naming "the seeds of `n`" (or `k`) or sample_points and the remedy. coerce_to_points() reads a geometry more than 180 degrees wide as written and no more than 180 with the longitudes below 0 read from 180 to 360 in that reading, and brings its box centre or GEOS centroid back into -180 to 180 (.lon_span(), .unwrap_lon(), .wrap_lon(), .across_180(), factored out of .surface_points()). Users now get, for the square with a vertex at 95, an EMPTY POINT, a dropped, unassigned or last-keyed row in the caller's own words, which name "a latitude beyond 90 degrees" for a lon/lat layer, and no sf warning; ensure_stable_poly_id() gives every row an ID on those layers. The seeders warn once where centres or cloud points cannot be placed; seeds and records are unchanged. The squares, line and MULTIPOINT across 180 get (180, 10.5) and (180, 10.25), and prep_model_data() takes the projection "auto" chooses, centred on longitude -180. A square from 170 to 171 keeps (170.5, 10.5), and layers with no latitude beyond 90 give the same results. ?coerce_to_points, ?ensure_stable_poly_id, ?prep_model_data, ?summarize_by_cell and the seeders' pages state the rules. NEWS has two new Bug fixes entries, and the entry on moved rows names the centres of a profile. No frozen fixture record is retaken. test-fix-lonlat-beyond-90.R and test-fix-antimeridian-box-centre.R are new and test-fix-movers-unplaced.R gains four tests. Tests turned round, each still pinning its full text or value: in test-fix-fold-probe-far.R the two moves of scored seeds now expect the spatialkit_rows_unplaced warning; in test-fix-far-rows-moved.R metres stamped EPSG:4326 expect the lon/lat text, and the pinned sentence of ?summarize_by_cell is the new one; test-core-docs.R allows the number 90 in that section.
estimate_sac_range() refuses a fitted range past range_frac * cutoff * max_dist, and its warning and help said three things the code does not do: - At cutoff = 1 the over-cutoff warning advised "Raise `cutoff` to fit longer lags", and a cutoff above 1 is refused. On 300 points on a 1 km square with t = x / 50 plus noise (seed 4) it gave that advice for a range past the lags. - With range_frac below 1 the bound is that share of the largest lag, so a range inside the lags is refused, and the warning said it "exceeds the largest lag the variogram was fitted over" and that the variogram never reached a sill. On 300 points with an exponential field of scale 150 m on 1 km (seed 1, cutoff = 1, range_frac = 0.3) the range was 776 inside lags of 1293, refused at 388, and the advice to raise cutoff missed the cause. - ?sac_nugget and ?estimate_sac_range said nugget_at_bound marks a nugget "within 1e-4 of the sill", where the rule is a nugget of at most 1e-4 times the sill, and ?sac_nugget said a nugget equal to its floor keeps the mark FALSE. The mark does not read the floor: 600 locations visited twice with a visit sd of 1e-3 give a nugget equal to its floor of 1.021e-06 under a sill of 1.009, marked TRUE. range_frac's help called a range past the bound one beyond the longest lag, true only at range_frac = 1. The over-cutoff branch of estimate_sac_range() (R/cross-validation.R) now tells the cases apart, as plot()'s caption does. A range within the largest lag gets "fitted range (776) exceeds the largest range `range_frac` accepts (388 = 0.3 x the largest lag fitted, 1293), although it lies within that lag", with the advice to raise range_frac or set a block size. A range past the largest lag keeps the old warning; below cutoff = 1 it still advises a larger cutoff, and at 1 it says the lags already run to the farthest pair of points, or of the n_max subsample when there is one. The help of sac_nugget() and estimate_sac_range() now gives the bound as 0 or at most 10^-4 of the sill, says a nugget at a floor of at most that share is marked, and says the range_frac sentence holds at the default of 1. Users see only new warning text and help. The value (NA), rejected_reason, rejected_range and the rules do not change. NEWS has two Bug fixes entries and two Documentation entries. No frozen fixture record is retaken. One test is turned round: in test-sac-range.R, the large-sample check of the block on small samples refused as decreasing with distance ran range_frac = 1e-6 and expected the old "flat from the first lag" text for a range of about 80 inside lags of about 640; it now expects the range_frac text and no "never reached a sill". test-core-docs.R gains five blocks on the help text, the advice at and below cutoff = 1 (0.99 included), the n_max subsample, the range_frac refusal inside the lags and the floor sentence; two comments in test-fix-variogram-lags.R are reworded.
ensure_stable_poly_id() went wrong in three ways: - method = "surface_point" passed on sf's warning "st_point_on_surface may not give correct results for longitude/latitude data" on every polygon layer moved to the sort CRS (EPSG:4326 by default), although the key is a sort order in degrees. - PROJ returns a row it cannot move to the sort CRS as an empty row, or a ring without the vertices it cannot place, instead of stopping. A UTM layer shifted by 1e8, 1e12 or 1e15 then had a NaN key for every row and was numbered by row order, so the same polygon took another ID when the rows came in another order, and create_grid_polygons_cached() numbered its cells the same way. A key not in degrees was rounded to 7 decimals at any magnitude: a 4 x 4 grid of 100.11 m squares in EPSG:32617 placed 2^40 - 250 m from the origin came out c0r2 c0r3 c0r0 c0r1 c1r2 ..., and a hex grid over a 4.5 km box at 1e12, with no CRS or with transform_for_sort = NULL, began with northings 3992098 3989837, other IDs than at the origin. - POLYGON((5 5, 5 5)) beside two squares stopped the call with GEOS's "Invalid number of points in LinearRing found 2" in EPSG:32617 and with sf's "To set the crs to NA, first remove the full polygons" in EPSG:4326. A non-s2 error in measuring the key was raised again. With make_valid = TRUE an empty polygon came back as LINESTRING EMPTY and flat rings at latitude 87 as a GEOMETRYCOLLECTION, without a warning. transform_for_sort = "+proj=bogus" passed on GDAL's "Unknown projection" warning beside the fallback's log line. In R/stable-ids-cache.R, .key_surface_points() muffles that one sf text, as .pooled_xy() does. After the move of the sort copy, .rows_unplaced() sends a layer with an unplaced located row to the documented fallback in its own CRS, with the reason "the sort CRS cannot place every row"; a move that stops no longer passes on GDAL's warning. A key in a CRS that is not geographic is ordered by the centre rounded at one step for the layer, then at each feature's own step, then by area and row (.key_extent(), .key_steps(), .key_round()): the power of two at or above 2^-44 of the largest absolute coordinate, never under 1e-7, so a layer within about 1.7e6 units of its origin keeps its key bit for bit. The shift of the copy to near the origin (.key_near_origin()) is removed. .sort_key_with_refusals() no longer raises other errors again: the features are measured one by one (.sort_key_rowwise()), and a feature that stops alone is keyed by the centre of its box with area 0. .drop_short_rings() drops rings of fewer than four points from the key copy and before the repair. .make_valid_rows() keeps an empty row as given, keeps the polygonal parts of a row repaired to a collection, and returns a row left with no polygon as given; the function then warns once with class spatialkit_cells_degenerate, naming the rows in the caller's numbering of polygons_sf. Users now get no sf or GDAL warning from these calls, the 4 x 4 grid ordered c0r0 c0r1 c0r2 c0r3 c1r0 ... as at the origin, the hex grid at 1e12 beginning 3989837 3992098 3990799 3993113 as at the origin, IDs for the two-point ring in both CRSs with one warning naming row 1 under the repair, and repaired rows that stay polygons. Layers keyed in degrees get the IDs they got. ?ensure_stable_poly_id states the steps. NEWS has three Bug fixes entries. No frozen fixture record is retaken. One test is turned round: in test-stable-ids-crossing-edges.R, "an error that is not s2's is raised again as it was" now checks that the features are measured one by one. test-fix-stable-ids-unplaced.R and test-fix-stable-ids-warnings.R are new.
The seeders gave no way forward, or no answer, on a lon/lat boundary along a parallel: - On POLYGON((10 60, 11 60, 12 60, 10 60)) in EPSG:4326, or a ring around a pole at 87 N or 87 S, voronoi_seeds_random() and get_voronoi_seeds(method = "random" or "kmeans") stopped with "`boundary` cannot be sampled (its bounding box, read from its coordinates, has no height), so no seed can be drawn in it." and nothing more, though the ring has an area once projected. On a boundary sampled piece by piece the error said the box of `boundary` had no height when only one of its polygons had none. - On most other parallels that test was never reached. The s2 union moves the latitudes by a few units in the last place (a box 1e-15 to 2e-14 degrees high), and sf, which without lwgeom draws in the box and keeps the points in the region, drew without end: a ring at 30 N and a sliver 1e-7 degrees tall at 60 N gave no return within 90 s, and which latitudes hung differed between macOS and Linux. A triangle 120 degrees wide at 80 N, whose box holds 0.42 times its area, took seeds only in the part inside the box. - With sf_use_s2(FALSE), get_voronoi_seeds() repaired every lon/lat row in the plane, flattened the 60 N ring to a line and refused it as a row s2 refuses. - voronoi_seeds_random() on a ring along one meridian from 80 S to 80 N, whose union on the sphere is a MULTILINESTRING, returned five MULTIPOINT seeds, two of them empty. .sample_box_check() (R/seeding.R) now ends the no-height error, for a geographic box with a width at a latitude other than 0 or 90, with the remedy from the new .sample_project_remedy(): transform `boundary` to a projected CRS in which a parallel is a curve, such as the one ensure_projected() picks for it (a polar one such as EPSG:3413 or 3031 for a ring around a pole). It names "one of the polygons of `boundary`" where only one piece has no height. The new .sample_box_short() in .robust_st_sample() refuses, before any draw, a lon/lat region whose box has less than half the region's area on the sphere, with the same remedy, where sf reads the box from the coordinates (.sf_box_from_coordinates(), lwgeom absent). .boundary_mend(all = TRUE) repairs lon/lat rows on the sphere whatever sf_use_s2() says, and a union that leaves no polygon is refused with the reason "the union of its rows leaves no polygon with an area"; the reason for an all-rows repair no longer blames s2. create_grid_polygons() and make_folds() take the unchanged path. Users now get the remedy on the 60 N and polar rings, and the ring at 30 N (box 3.9e-12 times its area), the ring at 45 N near 100 W, the 1e-7 sliver and the 80 N triangle are refused at once, with s2 on and off. Each of these seeds five points once projected with the CRS ensure_projected() picks, the polar rings also in 3413 and 3031; on the 60 N and polar rings the seeds lie within 1 cm of the ring. A ring on the equator, a meridian or a pole, a box that is one point and a projected boundary with no height get no remedy, since projecting them gives no area. With s2 off, get_voronoi_seeds() gives the seeds it gives with s2 on. The help of get_voronoi_seeds() and voronoi_seeds_random() says so. NEWS has two Bug fixes entries. No frozen fixture record is retaken. Tests turned round: in test-fix-boundary-unlocated.R the exact message for the 60 N ring and the regex for the sliver now end with the remedy; in test-fix-s2-boundaries.R the reference union with s2 off repairs on the sphere, and the seeds with s2 off equal those with s2 on. test-fix-boundary-degrees.R gains 12 tests: the remedy for all three seeders with s2 on and off, the projected ring seeded, no remedy where projecting cannot help (with EPSG:3857, 3395 and 4087 keeping the ring flat), the piece named, the half-area refusal with the draw mocked to stop instead of hanging, nothing refused with lwgeom, regions whose box holds half their area or more drawn as before, and the meridian ring refused.
A point counts as on an edge while it lies within a margin of it, and .edge_tol() took that margin as one part in 1e10 of the largest coordinate. On a 3 km layer that was 2e-7 at the origin but 100 at an offset of 1e12 and 1e5 at 1e15. Four points alternating between two polygons, A B A B, were joined as A A A B at 1e12 and A A A A at 1e15. Block folds moved 27 of 60 rows at 1e12, and at 1e15 make_folds() refused with a false "single block covering the whole extent". The 60 points fell in 39 Voronoi cells at 1e12 and in 1 at 1e15. At 1e15, where doubles are 0.125 apart, block and grid edges are rounded to that spacing and a point near an edge changed block with nothing said. clip_target_for() drew its buffer at the same rounding: one location at 1e15 got a disk of area 2.6875 for pi and two points 0.5 m apart on a line an empty LINESTRING, with no warning. Points less than about 3e-153 apart got a MULTIPOINT, an empty line or a disk of subnormal area, and a box 1e-320 on a side came back as a POINT. .edge_tol() (R/count-rule.R) is now the old margin capped at a millionth of the diagonal of the coordinates' box (.bb_diagonal(), computed without overflow) and floored at four units in the last place of the largest coordinate. The box is read by its names, so .seeds_as_centres() and .near_points_extent() (R/cell-values-at.R) pass a named .xy_box(). The new .warn_xy_imprecise() (R/utils.R) warns once per call, with class spatialkit_xy_imprecise, where the spacing of doubles at the coordinates is more than a millionth of the layer's extent. make_folds() (block_kfold and buffered_loo), assign_features_to_polygons(), create_grid_polygons(), create_voronoi_polygons() and build_tessellation() call it, and runs of folds say it once. In clip_target_for() (R/tessellation.R) the buffer of points on a line or at one location warns the same way, `quiet` does not silence it, and an empty buffer or one with no area is refused with class spatialkit_xy_imprecise_error. A side or a share of the spread below the square root of the smallest normal double (.SQRT_XMIN) counts as none, so such points get the 1-unit disk. Users now get A B A B at every offset, the same folds at 1e8, 1e12 and 1e15, 60 Voronoi cells at every offset, and 24 grid cells at 1e15 where create_grid_polygons() stopped with "the clip to `boundary` left zero cells". At 1e15 each of these callers warns once; at 0, 1e8 and 1e12 none does. clip_target_for() gives a polygon of area pi with its message for the tiny spreads, warns at 1e12 and 1e15, and refuses the 0.5 m line at 1e15. The margin is unchanged where the diagonal is at least a ten-thousandth of the largest coordinate; on a smaller layer it is now a millionth of its diagonal (28 micrometres on a layer 20 m across, so a point 3e-4 m from a shared edge of 200 m by 100 m cells is no longer a tie). The help of assign_features_to_polygons(), make_folds(), create_grid_polygons(), build_tessellation(), predict_surface() and cell_values_at() states the new margin; the help of the callers that warn, create_voronoi_polygons() and clip_target_for() states the warning or the refusal. NEWS has four Bug fixes entries. No frozen fixture record is retaken. Tests turned round: test-core-gridded-ties.R pins the margin of a 20 m layer at a northing of 5,000 km as a millionth of its diagonal; in test-fix-assignment-ties.R the point 3e-4 east of the shared edge lies in one cell and a point at 2e-4 is added within the margin; test-fix-coincident-point-ties.R checks the floor of .near_points_extent() in x and y; test-fix-nearest-ties.R, test-fix-values-at-column-ties.R and test-fix-tessellation-msgs.R take the new help sentences. test-fix-edge-margin-offset.R and test-fix-xy-precision.R are new: they compare rows, IDs and folds exactly on layers whose coordinates are multiples of 1/8, areas to 1e-5, and the buffer below the rounding by property.
The nearest-centre searches counted two centres as a tie only when their squared distances agreed to one part in ten million. Two records of one station one unit in the last place apart (9.31e-10 m at a UTM northing) have squared distances from a point r away that differ by about 2r times that spacing, inside the bound only for r above about 2 cm. Closer, the last bits chose the record, and they move with the unit and the origin. With two covariate points one ulp apart at 40 positions near (450500, 4550500) in EPSG:26915, and 8 grid points on a circle of radius r about each, predict_surface() gave 49 of 320 grid points another covariate row in UTM 15N in US feet or with the false origin moved by 0.1 m at r = 0.1 mm and 1 mm, 48 at 5 mm and 60 at 2 cm (0 at r = 0 and at 0.1 m). cell_values_at() filled 20 of 160 locations 1 mm from the station from another cell. R/partition.R has two new helpers. .centres_tol() is .edge_tol() of the box of the centres that have a location (0 when none), taken once per search from all centres and passed down. .tie_bound() counts a squared distance as tied with the least, best, when it is at most best * (1 + 1e-7 + slack) + tol * (2 * sqrt(best) + tol); with tol 0 it is the relative bound alone, so a squared distance that overflows no longer gives NaN. .nearest_exact(), the FNN close test of .nearest_centre() (its 1e-9 slack kept on the relative part) and the shortlist's nn and stop tests of .values_at_nearest() (R/cell-values-at.R) use the one margin. Ties still go to the lower centre number, or to the column order the callers give. No exported signature changes. Users now get the same covariate row and the same filled cell in all three frames: 0 of 320 grid points move at every radius, with or without a third point 7 km away, and 0 of 160 locations at 1 mm and 0.1 m. A point whose two nearest centres differ in distance by less than the margin now takes the lower-numbered one. The margin grows with the largest coordinate, about 0.46 mm at a UTM northing near 4,550 km and about half a micrometre with the origin next to data 5 km across, so such a point can take the lower-numbered centre with one origin and the nearer with another; the k-means steps of the density partition and of knndm run in a frame centred on the data and do not. ?predict_surface, ?cell_values_at, ?resolution_profile, ?make_folds, ?summarize_by_cell, ?assign_features_to_polygons and the diagnostics vignette state the margin; ?predict_surface no longer says "twenty million times". NEWS has a new Bug fixes entry, and the entry on point covariate ties adds the margin to its rule. No frozen fixture record is retaken. Tests turned round: test-fix-coincident-point-ties.R and test-fix-nearest-ties.R take the help sentences with the margin. test-fix-near-pair-ties.R is new: the pair in the three frames with FNN on and off, with a far point and a far lattice, through predict_surface() and cell_values_at(); one answer from the three searches on a 200 x 200 lattice; three records of one station among more than 16 centres, which reaches the shortlist's stop test; the overflow case; the margin moving with the origin, as the help states, at offsets well inside or well outside it so no last bits decide; and the help and vignette text.
A layer without a CRS whose coordinates cannot be longitude and latitude was already refused a CRS in degrees by the shared alignment, but several other paths still stamped one. With ten CRS-less points at x 500000 to 502000 and y 4000000 to 4002000: - harmonize_crs() beside a layer in EPSG:4326, either way round, or with target_crs = 4326, returned the layer stamped EPSG:4326 at its box in metres with the warning "stamping 'EPSG:4326' onto it WITHOUT reprojection"; the same at y 100 to 120. - ensure_projected(target_crs = 4326) stamped EPSG:4326 with a log line only. - assign_features_to_polygons() with polygons in EPSG:4326 warned of the stamp, gave sf's bounding-box warning three times and "none of the 10 feature(s) fall inside any polygon"; polygons in metres beside points in EPSG:4326 stopped on an s2 refusal that blamed reading polygons_sf as longitude and latitude. - After fit_rf_model() on CRS-less degrees, predict() on CRS-less points at x 5e5, y 4e6 returned every value NA with a warning that the rows have a location in longitude and latitude, and predict_surface() gave 10 of 10 grid and 30 of 30 covariate values NA, and "no grid points fall inside `boundary`" for such a boundary. - cell_values_at() with CRS-less newdata at x 500100 to 500300 beside CRS-less points in degrees gave three rows NA in every column, filled 0, and a warning about points only; the same for seeds. The new .refuse_lonlat_stamp() (R/crs-geometry.R), beside .looks_like_lonlat(), holds the test and the words of the refusal in .transform_or_stamp() (R/utils.R, unchanged). It is called before the stamp in .resolve_crsless() of harmonize_crs(), in the CRS-less branch of ensure_projected(target_crs =), in assign_features_to_polygons() (R/assignment.R) on the CRS-less layer beside one in degrees, in .replay_crs_assumption(), which serves predict() on random forest, GWR and Bayesian fits and predict_surface(), and in .values_at_place() of cell_values_at() (R/cell-values-at.R). Users now get an error in each case that names the caller and the argument, gives the box and the target CRS and asks for the layer's CRS, or, in harmonize_crs() and ensure_projected() with a target_crs, for a projected target_crs; no warning is raised. A projected target, a box inside the envelope, a layer with no located coordinate and CRS-less degrees behave as before. ?harmonize_crs, ?ensure_projected, ?assign_features_to_polygons, ?cell_values_at, ?predict.gwr_fit and ?predict_surface state the refusal. NEWS: the Bug fixes entry on layers without a CRS stamped in degrees names these calls and what each did before, and its last sentence now says a projected target is stamped with a log line in ensure_projected(target_crs =). No frozen fixture record is retaken and no test is turned round. test-fix-lonlat-stamp-siblings.R is new: the refusal on every path, each bound of the envelope refused half a unit past it and stamped at it, and the unchanged cases.
The neighbour searches tie two squared distances within 1e-7 of each
other. Far from the origin the doubles round the coordinates more
coarsely than that tie can absorb, so a lattice whose coordinates are
not on the doubles' grid has its nominal ties stored apart, and which
neighbour a row takes follows the rounding, with no warning:
- estimate_sac_range() on an 8 x 8 lattice at 100.1 m in UTM 15N read
Moran's I 0.413642 at offsets 0 and 1e10, 0.411652 at 1e11 and
0.412706 at 1e12.
- The k-nearest-neighbour searches, the density partition's k-means
step, the nearest other location of the pooling and of the short-lag
semivariances and the kriging neighbourhoods of kriging_adequacy()
gave other picks than at offset 0 at 1e11 and 1e12 for 100.1 m, and
from 1e10 for 0.7 m.
- fit_gwr_model(adaptive = TRUE, bandwidth = 12, kernel = "boxcar") on
a 10 x 10 lattice gave the fitted values of offset 0 at 1e10, and
values moved by up to 0.148 at 1e11 and 0.159 at 1e12 (100.1 m).
R/utils.R gains, beside .warn_xy_imprecise(), .tie_lost_by_rounding()
(the one-sided test of a distance past a tie against the rounding),
.tie_rounding(), .tie_note() and .tie_watch(), whose closing function
warns once when the exported call returns and says nothing on a call
that stops or that has already given the extent warning of the same
class; .tie_carry() and .tie_merge() bring the notes of a forked fold
worker back to .cv_run_folds() (R/cross-validation.R). The searches
note their k-th or nearest squared distance and the least one past the
tie: .knn_pairs() and the kd-tree shortcut of .sac_structure_test(),
.knn_exact_rows(), .knn_tied_rows(), .knn_locations(),
.nearest_exact() and .nearest_centre() in the scaled frames of
.density_kmeans() and .knndm_kmeans(), .nearest_location_search(),
the kriging .tie_pick_note() and .tie_count_note() in
.cell_neighbourhoods(), and the boxcar window edge in
.gwr_local_solve() (R/model-gwr.R). The searches return what they
returned before.
residual_morans_i(), estimate_sac_range(), determine_optimal_levels(),
fit_bayesian_spatial_model(), resolution_profile(),
select_resolution(), get_voronoi_seeds(), voronoi_seeds_kmeans(),
build_tessellation(), make_folds(), summarize_by_cell(),
kriging_adequacy(), fit_gwr_model(), predict() on its fit, cv_gwr(),
gwr_model_selection() and cv_block_size_sweep() now warn once, with
class "spatialkit_xy_imprecise", where some neighbour distances lie
past a tie by less than the rounding, naming the rounding, the
distance and the remedy. On the lattices above the warning is raised
at 1e11 and 1e12 for 100.1 m and from 1e10 for 0.7 m, and nothing is
raised at 0, on a 250 m lattice up to 1e12 or with the bisquare
kernel. Results do not change. ?residual_morans_i and
?estimate_sac_range state the warning, and ?fit_gwr_model no longer
says the boxcar window holds whatever the origin of the coordinates.
NEWS has one Bug fixes entry.
No frozen fixture record is retaken and no test is turned round.
test-fix-tie-precision-warning.R is new: each search site against the
same call without a watch, each exported call against the same call
with the warning muffled, the GWR calls, one warning per call after
the extent warning, the plural message with a crs, and the notes of a
forked worker reaching the parent. Merged beside the refusal of a
lon/lat stamp on CRS-less metres with no conflict: a predict() that
the refusal stops raises no tie warning.
R CMD check warned "'loadNamespace' or 'requireNamespace' call not
declared from: 'lwgeom'". The cause is the earlier change that refuses
a lon/lat region mostly outside its box: .sf_box_from_coordinates()
(R/seeding.R) asks requireNamespace("lwgeom"), as sf does before it
draws, with the name written out, and lwgeom is not declared because
the package never calls it. It now passes the name as a value and
gives the same answer. test-fix-undeclared-namespace.R is new: every
package the namespace names by literal in requireNamespace(),
loadNamespace(), library(), require(), :: or ::: is declared in
DESCRIPTION, and the lwgeom test agrees with requireNamespace(),
which the test also asks with the name passed as a value.
Warnings, log lines, prints and plot captions printed lengths in CRS
units with %.0f or %.1f, so in a large unit they read 0. On a layer in
UTM 17N with +to_meter=1000000 (units of 1000 km),
estimate_sac_range() warned "fitted range (0) exceeds the largest lag
the variogram was fitted over (0.0006598 = 1 x cutoff 0)" of a range
of 0.002639, and make_folds() wrote "block_size (0.0) < estimated
autocorrelation range (0.0)", plot() "Effective range = 0.0 CRS
units", resolution_profile() "floor 16 from range 0", and the prints
of cv_block_size_sweep() and kriging_adequacy() "range 0.0". In metres
the same texts rounded the figures (cutoff 660 for 659.8, range 245
for 245.1). make_folds() advised supplied blocks "at least 1 units
across" for a range of 0.0004, from ceiling() of the range.
Each such distance now prints with four significant digits, as the
largest lag and the block widths already did. In R/cross-validation.R
the new helper .fmt_len() formats make_folds()'s range, block size,
block dimension, block_nx/block_ny, supplied-block scale and
farthest-by figures; estimate_sac_range()'s over-cutoff, range_frac
and hole-effect warnings, its REML and directional lines and the nndm
and knndm median distances take %.4g. The supplied-blocks advice uses
.block_size_at_least(), the rounding of the function's other advice
(the same figure for ranges of 10 units or more). The plot captions
and refusal subtitles in R/plotting-fits.R, the support warnings and
print of resolution_profile(), the print and plot of
cv_block_size_sweep() and the print of kriging_adequacy() follow.
Percentages, shares, ratios and counts keep their formats, and no
value, attribute or rule changes.
Users see the computed figures in place of 0 in large units, e.g.
"fitted range (0.002639) exceeds the largest lag ... (0.0006598 = 1 x
cutoff 0.0006598)" and "block_size (0.0001897) < estimated
autocorrelation range (0.0003793)", and four digits in metres (659.8,
245.1). NEWS has one Bug fixes entry.
23 frozen fixture records are retaken, text only: the printed lines of
16 resolution_profile() records and of print_default_digits ("range
245" to "range 245.1"), and the log of six records whose over-cutoff
warning read "cutoff 622" and now reads "cutoff 622.3". Tests turned
round, each pinning the old fixed-decimal text: test-core-docs.R
builds the range_frac line with %.4g; test-fix-area-crs-units.R reads
"median scale 1414" and the range with four digits and no longer
skips the 1000 km unit; test-fix-cv-direction-wording.R and
test-leakage-diagnostic.R read "block_size (100)". The new
test-fix-distance-figures.R reads each figure back from the text on a
layer in metres and in units of 1000 km and compares it with the
result's value to four significant digits, within 1e-3 relative,
since the values come from variogram fits whose last bits move with
the platform.
When the bandwidth search fails, fit_gwr_model(), gwr_model_selection() and compare_models() warn with the fallback bandwidth they use, and printed it with %.4f. On 80 points in a 100 m square with adaptive = FALSE, the three warnings read "fallback bandwidth = 46.1534" in metres, but in UTM 17N with +to_meter=1000000 they read "= 0.0000" and "used a fallback bandwidth (0.0000)" of a bandwidth of 4.61534e-05. An adaptive bandwidth, a count of neighbours, read "= 50.0000", and on six rows "= 6.0000 (derived as 10.0000, then clamped for 6 observation(s) and 3 parameter(s))". The new internal .fmt_bw(bw, adaptive) in R/model-gwr.R prints a whole adaptive count as an integer and anything else through .fmt_len(), with four significant digits. fit_gwr_model()'s fallback warning and its clamp clause use it with the fit's adaptive flag, and cv_gwr() passes that warning on. gwr_model_selection() (R/model-selection-gwr.R) uses it with its adaptive argument, and compare_models() (R/evaluation.R) with the fit's info$adaptive; a fit without that field prints through .fmt_len(), so 42 still reads "42". No value, attribute or rule changes. Users now see "46.15" in metres and "4.615e-05" in units of 1000 km in all three warnings, "= 50" and "(50)" for an adaptive fallback, and "= 6 (derived as 10, then clamped ...)" on six rows. The NEWS entry on distances in CRS units printed with a fixed number of decimals now names these warnings and the adaptive count, and closes with "Other percentages and counts keep their formats". No frozen fixture record is retaken and no test is turned round. test-fix-distance-figures.R has two new blocks: one forces the bandwidth search to fail and reads each of the three figures back as signif(info$bandwidth, 4) in metres and in units of 1000 km, with no "0.0000", and the adaptive texts with no ".0000"; the other holds .fmt_bw() to "12345" for an adaptive count and "12340" for a fixed bandwidth of 12345, and checks a large count, 4.615e-05, a count that is not whole and a missing flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.