[elpa] master aef00fd: *packages/arbitools: Fixed some bugs

2019-07-08 Thread David Gonzalez Gandara
branch: master
commit aef00fd4f42d21a7783d4da298f0c015a1e66d77
Author: David Gonzalez Gandara 
Commit: David Gonzalez Gandara 

*packages/arbitools: Fixed some bugs
---
 packages/arbitools/arbitools.el | 81 +
 1 file changed, 34 insertions(+), 47 deletions(-)

diff --git a/packages/arbitools/arbitools.el b/packages/arbitools/arbitools.el
index 2c85dd2..b0fd83b 100644
--- a/packages/arbitools/arbitools.el
+++ b/packages/arbitools/arbitools.el
@@ -3,7 +3,7 @@
 ;; Copyright 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gonzalez Gandara 
-;; Version: 0.976
+;; Version: 0.977
 ;; Package-Requires: ((cl-lib "0.5"))
 
 ;; This program is free software: you can redistribute it and/or modify
@@ -106,6 +106,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'seq)
 
 (defvar arbitools-verbose nil)
 (defvar arbitools-elo-floor 1000 "Rating floor for calculations")
@@ -129,20 +130,12 @@
 (rankstring (substring-no-properties linestring 5 8))
 (namestring (substring-no-properties linestring 14 47))
 (elostring (substring-no-properties linestring 48 52))
-(playerinfo)
-;;(playerinfo  ;; FIXME: this suggestion did not work, check 
why
- ;; `(,rankstring
- ;;   ,namestring
- ;;   ,elostring
- ;;   0))
-   )
+(playerinfo))
+   
 (push rankstring playerinfo)
 (push namestring playerinfo)
 (push elostring playerinfo)
 (push '0 playerinfo)
-;; FIXME: Why append it to the end (which requires traversing the whole
-;; list) rather than add it to the front (which is super-cheap)?
-   ;;  (add-to-list 'arbitools-players-info playerinfo t)
  (add-to-list 'arbitools-players-info (reverse playerinfo) t)
 
 (defun arbitools-do-pairings (round)
@@ -252,10 +245,13 @@
   "Create userTB.txt file for file generated with ARPO app.
Use in crosstable.txt generated in Vega.
You need to open the ARPO1.txt file in another buffer."
+
+  ;; FIXME: Right now the buffer is modified to perform the operations.
+  ;; It should be done without modifying
   (interactive)
   (save-excursion
 (goto-char (point-min))
-(forward-line 7) ;; where the data starts in crosstable.txt
+(forward-line 7) ;; where the data starts in crosstable.txt. This can be 
improved with regex
 (let* ((continue t)
   (arpodata "data")
   (arpopoint "point")
@@ -265,6 +261,14 @@
   (when (not (get-buffer "userTB.txt")) (generate-new-buffer "userTB.txt"))
   (with-current-buffer "userTB.txt"
 (erase-buffer) (insert "  User Tie-Break  ;"))
+  (let ((case-fold-search t)) ;; removing the string "(W)" in players who 
withdrew. This should be replaced afterwards
+
+   (goto-char (point-min))
+   (forward-line 7)
+   (while (search-forward "(W)" nil t)
+ (replace-match "   "))
+   (goto-char (point-min))
+   (forward-line 7))
   (while continue ;; loop over crosstable.txt
 (beginning-of-line) (forward-word)
(if (thing-at-point 'word)
@@ -1021,13 +1025,9 @@ Only do it if `arbitools-verbose' is non-nil."
  (result 0))
 
   (goto-char (point-min))
-  (let* (;; (linestring (thing-at-point 'line))
-(maxlength 0)
+  (let* ((maxlength 0)
 (numberofrounds)
-(offset 0)
-;; (rankstring (substring-no-properties linestring 5 8))
-;; (rank (string-to-number rankstring))
- )
+(offset 0))
 
 (re-search-forward (format "^001[[:space:]]\\{1,4\\}%d" player))
(end-of-line)
@@ -1245,9 +1245,11 @@ Only do it if `arbitools-verbose' is non-nil."
  (push difference differences))
 
;; check if the model converges
-   (when (and (< (abs (- (nth 1 differences) (nth 0 differences))) 
0.01) ;; define here the value of epsilon
-  (< (abs (- (nth (- numberofplayers 1) differences) (nth 0 
differences))) 0.01))
- (setq converges t)) ;; TODO: improve this to check more members
+   ;;(when (and (< (abs (- (nth 1 differences) (nth 0 differences))) 
0.01) ;; define here the value of epsilon
+   ;; (< (abs (- (nth (- numberofplayers 1) differences) (nth 0 
differences))) 0.01))
+   ;;  (setq converges t)) ;; TODO: improve this to check more members
+   (when (< (- (seq-max differences)(seq-min differences)) 0.01)
+ (setq converges t))
 
(setq iterations (+ iterations 1))
(when (or converges (= iterations 300)) (setq continue nil))) ;; define 
here maximum number of iterations
@@ -1263,7 +1265,7 @@ Only do it if `arbitools-verbose' is non-nil."
(goto-char (point-min))
(delete-region (point-min)(point-max))
(insert "rank Name   ARPO\n"))
-  (with-current-

[elpa] externals/persist 5b83259 1/2: perist can now work with values other than numbers

2019-07-08 Thread Phillip Lord
branch: externals/persist
commit 5b832595f448189572e8886baaa260e164bba543
Author: Phillip Lord 
Commit: Phillip Lord 

perist can now work with values other than numbers

No longer compare arbitrary values with `=` in persist-save.
---
 persist.el|  4 +--
 test/persist-tests.el | 76 ++-
 2 files changed, 53 insertions(+), 27 deletions(-)

diff --git a/persist.el b/persist.el
index a741b6d..223f239 100644
--- a/persist.el
+++ b/persist.el
@@ -132,8 +132,8 @@ variables persist automatically when Emacs exits."
   (unless (persist--persistant-p symbol)
 (error (format
 "Symbol %s is not persistant" symbol)))
-  (when (not (= (symbol-value symbol)
-(persist-default symbol)))
+  (unless (equal (symbol-value symbol)
+ (persist-default symbol))
 (let ((dir-loc
(file-name-directory
 (persist--file-location symbol
diff --git a/test/persist-tests.el b/test/persist-tests.el
index 2e06dc6..9fa406f 100644
--- a/test/persist-tests.el
+++ b/test/persist-tests.el
@@ -21,11 +21,15 @@
   ;; do not save not persist variables
   (should-error
(with-local-temp-persist
-(persist-save (cl-gensym)
+(persist-save (cl-gensym)))
+   :type 'error
+   :exclude-subtypes t))
 
 (ert-deftest test-persist-save ()
   (with-local-temp-persist
(let ((sym (cl-gensym)))
+ ;; precondition
+   (should-not (file-exists-p (persist--file-location sym)))
  (set sym 10)
  (persist-symbol sym 10)
  (persist-save sym)
@@ -43,6 +47,27 @@
  (should-error
   (persist-save 'fred)
 
+(ert-deftest test-persist-save-non-number ()
+  "Test saving something that is not a number.
+
+`test-persist-save' missed "
+  (with-local-temp-persist
+   (let ((sym (cl-gensym)))
+ (set sym "fred")
+ (persist-symbol sym "fred")
+ (persist-save sym)
+ (should t)
+ (should-not (file-exists-p (persist--file-location sym)))
+ (set sym "george")
+ (persist-save sym)
+ (should (file-exists-p (persist--file-location sym)))
+ (should
+  (string-match-p
+   "george"
+   (with-temp-buffer
+ (insert-file-contents (persist--file-location sym))
+ (buffer-string)))
+
 (ert-deftest test-persist-load ()
   (with-local-temp-persist
(let ((sym (cl-gensym)))
@@ -75,27 +100,28 @@
   (persist-default 'test-persist-variable)
 
 (ert-deftest test-persist-location ()
-   (let ((sym (cl-gensym)))
- (set sym 10)
- (persist-symbol sym 10)
- (persist-location sym "./persist-defined-location")
- (should
-  (equal (expand-file-name
-  (symbol-name sym)
-  "./persist-defined-location/")
- (persist--file-location sym)))
- (persist-save sym)
- (should t)
- (should-not (file-exists-p (persist--file-location sym)))
- (set sym 20)
- (persist-save sym)
- (should (file-exists-p (persist--file-location sym)))
- (should
-  (string-match-p
-   "20"
-   (with-temp-buffer
- (insert-file-contents (persist--file-location sym))
- (buffer-string
- (should-error
-  (persist-save 'fred))
- (delete-directory "./persist-defined-location" t)))
+  (unwind-protect
+  (let ((sym (cl-gensym)))
+(delete-directory "./persist-defined-location" t)
+(set sym 10)
+(persist-symbol sym 10)
+(persist-location sym "./persist-defined-location")
+(should
+ (equal (expand-file-name
+ (symbol-name sym)
+ "./persist-defined-location/")
+(persist--file-location sym)))
+(persist-save sym)
+(should-not (file-exists-p (persist--file-location sym)))
+(set sym 20)
+(persist-save sym)
+(should (file-exists-p (persist--file-location sym)))
+(should
+ (string-match-p
+  "20"
+  (with-temp-buffer
+(insert-file-contents (persist--file-location sym))
+(buffer-string
+(should-error
+ (persist-save 'fred)))
+(delete-directory "./persist-defined-location" t)))



[elpa] externals/persist updated (41a888f -> 2a2f83b)

2019-07-08 Thread Phillip Lord
phillord pushed a change to branch externals/persist.

  from  41a888f   Add .elpaignore
   new  5b83259   perist can now work with values other than numbers
   new  2a2f83b   Bump version


Summary of changes:
 persist.el|  6 ++--
 test/persist-tests.el | 76 ++-
 2 files changed, 54 insertions(+), 28 deletions(-)



[elpa] externals/persist 2a2f83b 2/2: Bump version

2019-07-08 Thread Phillip Lord
branch: externals/persist
commit 2a2f83b4d63734ed48603008c813cfacd9e99404
Author: Phillip Lord 
Commit: Phillip Lord 

Bump version
---
 persist.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/persist.el b/persist.el
index 223f239..091e428 100644
--- a/persist.el
+++ b/persist.el
@@ -5,7 +5,7 @@
 ;; Author: Phillip Lord 
 ;; Maintainer: Phillip Lord 
 ;; Package-Type: multi
-;; Version: 0.3
+;; Version: 0.4
 
 ;; The contents of this file are subject to the GPL License, Version 3.0.