[Git][java-team/libeuclid-java][upstream] New upstream version 2.0
Andrius Merkys (@merkys)
gitlab at salsa.debian.org
Thu Jan 6 09:05:17 GMT 2022
Andrius Merkys pushed to branch upstream at Debian Java Maintainers / libeuclid-java
Commits:
987f964d by Andrius Merkys at 2022-01-06T03:29:45-05:00
New upstream version 2.0
- - - - -
23 changed files:
- .github/workflows/maven.yml
- + CITATION.cff
- pom.xml
- src/main/java/org/xmlcml/euclid/IntRange.java
- src/main/java/org/xmlcml/euclid/IntSet.java
- src/main/java/org/xmlcml/euclid/Real2Vector.java
- src/main/java/org/xmlcml/euclid/RealArray.java
- src/main/java/org/xmlcml/euclid/RealMatrix.java
- src/main/java/org/xmlcml/euclid/RealSquareMatrix.java
- src/main/java/org/xmlcml/euclid/Util.java
- − src/main/java/org/xmlcml/euclid/util/MultisetUtil.java
- src/main/java/org/xmlcml/stml/STMLArray.java
- src/main/java/org/xmlcml/stml/STMLAttribute.java
- src/main/java/org/xmlcml/stml/STMLElement.java
- src/main/java/org/xmlcml/stml/STMLScalar.java
- src/main/java/org/xmlcml/stml/attribute/DoubleArraySTAttribute.java
- src/main/java/org/xmlcml/stml/attribute/DoubleSTAttribute.java
- src/main/java/org/xmlcml/stml/attribute/IdAttribute.java
- src/main/java/org/xmlcml/stml/attribute/IntArraySTAttribute.java
- src/main/java/org/xmlcml/stml/attribute/IntSTAttribute.java
- src/main/java/org/xmlcml/stml/attribute/StringArraySTAttribute.java
- src/main/java/org/xmlcml/stml/attribute/StringSTAttribute.java
- src/test/java/org/xmlcml/euclid/test/RealComparatorTest.java
Changes:
=====================================
.github/workflows/maven.yml
=====================================
@@ -8,13 +8,16 @@ jobs:
build:
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ java: [ 8, 11, 14 ]
+ name: Java ${{ matrix.java }}
steps:
- uses: actions/checkout at v2
- - name: Set up JDK 11
- uses: actions/setup-java at v2
+ - name: Set up Java
+ uses: actions/setup-java at v1
with:
- java-version: '11'
- distribution: 'adopt'
+ java-version: ${{ matrix.java }}
- name: Build with Maven
run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true
=====================================
CITATION.cff
=====================================
@@ -0,0 +1,22 @@
+cff-version: 1.2.0
+message: "If you use this software, please cite it as below."
+title: Euclid
+version: 2.0
+date-released: 2022-01-03
+url: "https://github.com/BlueObelisk/cmlxom"
+preferred-citation:
+ type: article
+ authors:
+ - family-names: Murray-Rust
+ given-names: Peter
+ - family-names: Rzepa
+ given-names: Henry S.
+ title: "CML: Evolution and design"
+ year: 2011
+ month: 10
+ day: 14
+ journal: Journal of Cheminformatics
+ volume: 3
+ issue: 44
+ doi: 10.1186/1758-2946-3-44
+ url: https://doi.org/10.1186/1758-2946-3-44
=====================================
pom.xml
=====================================
@@ -3,13 +3,12 @@
<groupId>org.blueobelisk</groupId>
<artifactId>euclid</artifactId>
- <version>1.6</version>
+ <version>2.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <guava.version>[31.0.1-jre,)</guava.version>
</properties>
<name>CML Euclid</name>
@@ -260,12 +259,7 @@
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
- <version>1.2.5</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
+ <version>1.3.7</version>
</dependency>
</dependencies>
=====================================
src/main/java/org/xmlcml/euclid/IntRange.java
=====================================
@@ -25,11 +25,6 @@ import java.util.regex.Pattern;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.xmlcml.euclid.util.MultisetUtil;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Multisets;
/**
* maximum and minimum values
@@ -334,13 +329,13 @@ public class IntRange implements EuclidConstants, Comparable<IntRange> {
if (matcher.matches()) {
String minS = matcher.group(1);
String maxS = matcher.group(2);
- min = (ANY.equals(minS)) ? -Integer.MAX_VALUE : new Integer(minS);
- max = (ANY.equals(maxS)) ? Integer.MAX_VALUE : new Integer(maxS);
+ min = (ANY.equals(minS)) ? -Integer.MAX_VALUE : Integer.parseInt(minS);
+ max = (ANY.equals(maxS)) ? Integer.MAX_VALUE : Integer.parseInt(maxS);
} else {
matcher = CURLY_PATTERN1.matcher(token);
if (matcher.matches()) {
String minS = matcher.group(1);
- min = (ANY.equals(minS)) ? -Integer.MAX_VALUE : new Integer(minS);
+ min = (ANY.equals(minS)) ? -Integer.MAX_VALUE : Integer.parseInt(minS);
max = min;
}
}
@@ -434,18 +429,6 @@ public class IntRange implements EuclidConstants, Comparable<IntRange> {
public boolean canJoin(IntRange range, int tolerance) {
return Math.abs(this.maxval - range.minval) <= tolerance;
}
-// public static Iterable<Multiset.Entry<Integer>> getIntegerEntriesSortedByCount(Multiset<Integer> integerSet) {
-// return Multisets.copyHighestCountFirst(integerSet).entrySet();
-// }
-
-
- public static List<Multiset.Entry<IntRange>> getIntRangeEntryListSortedByCount(Multiset<IntRange> intRangeSet) {
- return Lists.newArrayList(IntRange.getIntRangeEntriesSortedByCount(intRangeSet));
- }
-
- public static Iterable<Multiset.Entry<IntRange>> getIntRangeEntriesSortedByCount(Multiset<IntRange> intRangeSet) {
- return Multisets.copyHighestCountFirst(intRangeSet).entrySet();
- }
public void setMax(int max) {
=====================================
src/main/java/org/xmlcml/euclid/IntSet.java
=====================================
@@ -131,7 +131,7 @@ public class IntSet implements EuclidConstants {
throw new EuclidRuntimeException("Duplicate value: " + i);
}
array[i++] = ii;
- set.add(new Integer(ii));
+ set.add(ii);
}
}
@@ -165,7 +165,7 @@ public class IntSet implements EuclidConstants {
for (int i = 0; i < nToAdd; i++) {
array[i] = start + i;
if (addSet) {
- set.add(new Integer(array[i]));
+ set.add(array[i]);
}
}
}
@@ -270,7 +270,7 @@ public class IntSet implements EuclidConstants {
array = temp;
}
array[nelem++] = value;
- set.add(new Integer(value));
+ set.add(value);
return true;
}
=====================================
src/main/java/org/xmlcml/euclid/Real2Vector.java
=====================================
@@ -609,7 +609,7 @@ public class Real2Vector implements EuclidConstants {
*/
public static Real2Vector regularPolygon(int nsides, double rad, double angle) {
Real2Vector temp = new Real2Vector();
- double dangle = 2 * Math.PI / (new Integer(nsides).doubleValue());
+ double dangle = 2 * Math.PI / ((double)nsides);
for (int i = 0; i < nsides; i++) {
Real2 p = new Real2(rad * Math.sin(angle), rad * Math.cos(angle));
temp.add(p);
@@ -632,7 +632,7 @@ public class Real2Vector implements EuclidConstants {
*/
public static Real2Vector partOfRegularPolygon(int nsides, int pointn, double dist0n) {
Real2Vector temp = new Real2Vector();
- double dangle = 2 * Math.PI / (new Integer(nsides).doubleValue());
+ double dangle = 2 * Math.PI / ((double)nsides);
double sinAngle2 = Math.sin((double) pointn * dangle / 2.);
double rad = 0.5 * dist0n / sinAngle2;
double angle = dangle;
@@ -707,7 +707,7 @@ public class Real2Vector implements EuclidConstants {
Real2 pp = (Real2) vector.get(j);
p = p.plus(pp);
}
- double scale = 1.0 / (new Double(vector.size()).doubleValue());
+ double scale = 1.0 / ((double)vector.size());
p = p.multiplyBy(scale);
return p;
}
=====================================
src/main/java/org/xmlcml/euclid/RealArray.java
=====================================
@@ -16,11 +16,8 @@
package org.xmlcml.euclid;
import java.text.DecimalFormat;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.log4j.Logger;
@@ -217,7 +214,7 @@ public class RealArray extends ArrayBase implements Iterable<Double> {
array = new double[nelem];
bufsize = nelem;
for (int i = 0; i < nelem; i++) {
- array[i] = (new Double(ia.elementAt(i))).doubleValue();
+ array[i] = ia.elementAt(i);
}
}
/**
=====================================
src/main/java/org/xmlcml/euclid/RealMatrix.java
=====================================
@@ -183,7 +183,7 @@ public class RealMatrix implements EuclidConstants {
this(m.rows, m.cols);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
- flmat[i][j] = new Double(m.flmat[i][j]).doubleValue();
+ flmat[i][j] = m.flmat[i][j];
}
}
}
=====================================
src/main/java/org/xmlcml/euclid/RealSquareMatrix.java
=====================================
@@ -994,13 +994,13 @@ class Diagonalise implements EuclidConstants {
}
if (anorm > ZERO) {
anorm = Math.sqrt(anorm) * SQRT2;
- anrmx = anorm * range / (new Double(order).doubleValue());
+ anrmx = anorm * range / ((double)order);
/* initialize indicators and compute threshold, thr */
ind = 0;
thr = anorm;
// L80:
while (true) {
- thr /= new Double(order).doubleValue();
+ thr /= ((double)order);
// L90:
while (true) {
l = 1;
=====================================
src/main/java/org/xmlcml/euclid/Util.java
=====================================
@@ -2713,17 +2713,17 @@ public class Util implements EuclidConstants {
public static int getPrime(int i) {
if (primeList == null) {
primeList = new ArrayList<Integer>();
- primeList.add(new Integer(2));
- primeList.add(new Integer(3));
- primeList.add(new Integer(5));
- primeList.add(new Integer(7));
- primeList.add(new Integer(11));
+ primeList.add(2);
+ primeList.add(3);
+ primeList.add(5);
+ primeList.add(7);
+ primeList.add(11);
}
int np = primeList.size();
int p = primeList.get(np - 1).intValue();
while (np <= i) {
p = nextPrime(p);
- primeList.add(new Integer(p));
+ primeList.add(p);
np++;
}
return primeList.get(i).intValue();
@@ -3187,11 +3187,13 @@ class StringIntegerComparator implements Comparator<Object> {
if (line == null) break;
lines.add(line);
}
+ br.close();
File file1 = new File(outFilename);
FileWriter fw = new FileWriter(file1);
for (int i = lines.size() - 1; i >= 0; i--) {
fw.write(lines.get(i)+"\n");
}
+ fw.close();
}
}
=====================================
src/main/java/org/xmlcml/euclid/util/MultisetUtil.java deleted
=====================================
@@ -1,90 +0,0 @@
-/**
- * Copyright 2011 Peter Murray-Rust
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.xmlcml.euclid.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.xmlcml.euclid.IntRange;
-import org.xmlcml.xml.XMLUtil;
-
-import com.google.common.collect.ImmutableSortedMultiset;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Multiset.Entry;
-import com.google.common.collect.Multisets;
-
-import nu.xom.Node;
-
-/** mainly static tools.
- *
- * @author pm286
- *
- */
-public class MultisetUtil {
-
- /** sort entrySet by count.
- * convenience method.
- * @param wordSet
- * @return
- */
- public static Iterable<Multiset.Entry<String>> getEntriesSortedByCount(Multiset<String> wordSet) {
- return Multisets.copyHighestCountFirst(wordSet).entrySet();
- }
-
- public static Iterable<Entry<String>> getEntriesSortedByValue(Multiset<String> wordSet) {
- return ImmutableSortedMultiset.copyOf(wordSet).entrySet();
- }
-
-
- public static Iterable<Entry<Integer>> getIntegerEntriesSortedByValue(Multiset<Integer> integerSet) {
- return ImmutableSortedMultiset.copyOf(integerSet).entrySet();
- }
-
- public static Iterable<Multiset.Entry<Integer>> getIntegerEntriesSortedByCount(Multiset<Integer> integerSet) {
- return Multisets.copyHighestCountFirst(integerSet).entrySet();
- }
-
-
- public static Iterable<Entry<Double>> getDoubleEntriesSortedByValue(Multiset<Double> doubleSet) {
- return ImmutableSortedMultiset.copyOf(doubleSet).entrySet();
- }
-
- public static Iterable<Multiset.Entry<Double>> getDoubleEntriesSortedByCount(Multiset<Double> doubleSet) {
- return Multisets.copyHighestCountFirst(doubleSet).entrySet();
- }
-
-
-
-
- /** extracts a list of attribute values.
- *
- * @return
- */
- public static List<String> getAttributeValues(Node searchNode, String xpath) {
- List<Node> nodes = XMLUtil.getQueryNodes(searchNode, xpath);
- List<String> nodeValues = new ArrayList<String>();
- for (Node node : nodes) {
- String value = node.getValue();
- if (value != null && value.trim().length() != 0) {
- nodeValues.add(value);
- }
- }
- return nodeValues;
- }
-
-
-}
=====================================
src/main/java/org/xmlcml/stml/STMLArray.java
=====================================
@@ -82,7 +82,7 @@ public class STMLArray extends STMLElement implements HasUnits, HasArraySize,
* @return Node
*/
@Override
- public Node copy() {
+ public Element copy() {
return new STMLArray(this);
}
@@ -400,7 +400,7 @@ public class STMLArray extends STMLElement implements HasUnits, HasArraySize,
String[] ss = getSplitContent();
dd = new boolean[ss.length];
for (int i = 0; i < dd.length; i++) {
- dd[i] = new Boolean(ss[i]);
+ dd[i] = Boolean.parseBoolean(ss[i]);
}
}
return dd;
@@ -982,7 +982,7 @@ public class STMLArray extends STMLElement implements HasUnits, HasArraySize,
if (XSD_STRING.equals(dataType)) {
this.append(content);
} else if (XSD_BOOLEAN.equals(dataType)) {
- this.append(new Boolean(content).booleanValue());
+ this.append(Boolean.parseBoolean(content));
} else if (XSD_DATE.equals(dataType)) {
this.append(JodaDate.parseDate(content).toString());
} else if (XSD_DOUBLE.equals(dataType)) {
=====================================
src/main/java/org/xmlcml/stml/STMLAttribute.java
=====================================
@@ -15,13 +15,12 @@
*/
package org.xmlcml.stml;
-import nu.xom.Attribute;
-import nu.xom.NamespaceConflictException;
-import nu.xom.Node;
-
import org.apache.log4j.Logger;
import org.xmlcml.xml.XMLConstants;
+import nu.xom.Attribute;
+import nu.xom.NamespaceConflictException;
+
/**
* generic subclassed Attribute for CML elements. often further subclassed into
* strongly typed attributes
@@ -127,7 +126,7 @@ public class STMLAttribute extends Attribute implements XMLConstants {
* shallow copy as most fields are not mutable
* @return copy of node
*/
- public Node copy() {
+ public Attribute copy() {
STMLAttribute newAttribute = new STMLAttribute(this);
newAttribute.setValue(this.getValue());
return newAttribute;
=====================================
src/main/java/org/xmlcml/stml/STMLElement.java
=====================================
@@ -196,7 +196,7 @@ public class STMLElement extends Element implements XMLConstants {
*
* @return node
*/
- public Node copy() {
+ public Element copy() {
return new STMLElement(this);
}
=====================================
src/main/java/org/xmlcml/stml/STMLScalar.java
=====================================
@@ -17,8 +17,6 @@ package org.xmlcml.stml;
import java.text.ParseException;
-import nu.xom.Node;
-
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
import org.xmlcml.euclid.JodaDate;
@@ -30,6 +28,8 @@ import org.xmlcml.stml.interfacex.HasDictRef;
import org.xmlcml.stml.interfacex.HasScalar;
import org.xmlcml.stml.interfacex.HasUnits;
+import nu.xom.Element;
+
/**
* user-modifiable class supporting scalar. * autogenerated from schema use as a
* shell which can be edited
@@ -67,9 +67,9 @@ public class STMLScalar extends STMLElement implements HasUnits, HasScalar, HasD
/**
* copy node .
*
- * @return Node
+ * @return Element
*/
- public Node copy() {
+ public Element copy() {
return new STMLScalar(this);
}
@@ -133,7 +133,7 @@ public class STMLScalar extends STMLElement implements HasUnits, HasScalar, HasD
if (getDataType().equals(XSD_BOOLEAN)) {
String content = getXMLContent();
if (content != null) {
- result = new Boolean(content);
+ result = Boolean.parseBoolean(content);
}
}
return result;
=====================================
src/main/java/org/xmlcml/stml/attribute/DoubleArraySTAttribute.java
=====================================
@@ -90,7 +90,7 @@ public class DoubleArraySTAttribute extends STMLAttribute {
*
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new DoubleArraySTAttribute(this);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/DoubleSTAttribute.java
=====================================
@@ -91,7 +91,7 @@ public class DoubleSTAttribute extends STMLAttribute {
*
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new DoubleSTAttribute(this);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/IdAttribute.java
=====================================
@@ -57,7 +57,7 @@ public class IdAttribute extends StringSTAttribute {
/** copy constructor.
* @return IdAttribute copy
*/
- public Node copy() {
+ public Attribute copy() {
return new IdAttribute(this);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/IntArraySTAttribute.java
=====================================
@@ -78,7 +78,7 @@ public class IntArraySTAttribute extends STMLAttribute {
* uses copy constructor.
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new IntArraySTAttribute(this);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/IntSTAttribute.java
=====================================
@@ -66,14 +66,14 @@ public class IntSTAttribute extends STMLAttribute {
public IntSTAttribute(IntSTAttribute att) {
super(att);
if (att.i != null) {
- this.i = new Integer(att.i.intValue());
+ this.i = att.i.intValue();
}
}
/** copy.
* uses copy constructor.
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new IntSTAttribute(this);
}
@@ -115,7 +115,7 @@ public class IntSTAttribute extends STMLAttribute {
*/
public void setSTMLValue(int i) {
checkValue(i);
- this.i = new Integer(i);
+ this.i = i;
this.setValue(S_EMPTY + i);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/StringArraySTAttribute.java
=====================================
@@ -83,7 +83,7 @@ public class StringArraySTAttribute extends STMLAttribute {
* uses copy constructor.
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new StringArraySTAttribute(this);
}
=====================================
src/main/java/org/xmlcml/stml/attribute/StringSTAttribute.java
=====================================
@@ -70,7 +70,7 @@ public class StringSTAttribute extends STMLAttribute {
* uses copy constructor.
* @return copy
*/
- public Node copy() {
+ public Attribute copy() {
return new StringSTAttribute(this);
}
=====================================
src/test/java/org/xmlcml/euclid/test/RealComparatorTest.java
=====================================
@@ -43,11 +43,11 @@ public class RealComparatorTest {
@Test
public void comparatorTest1() {
RealComparator comparator = new RealComparator(0.01);
- Assert.assertEquals(0, comparator.compare(ONE, new Double(1.001)));
- Assert.assertEquals(0, comparator.compare(ONE, new Double(0.999)));
+ Assert.assertEquals(0, comparator.compare(ONE, 1.001));
+ Assert.assertEquals(0, comparator.compare(ONE, 0.999));
Assert.assertEquals(0, comparator.compare(THREE, SQR3*SQR3));
- Assert.assertEquals(1, comparator.compare(ONE, new Double(0.98)));
- Assert.assertEquals(-1, comparator.compare(ONE, new Double(1.02)));
+ Assert.assertEquals(1, comparator.compare(ONE, 0.98));
+ Assert.assertEquals(-1, comparator.compare(ONE, 1.02));
}
/** HashSet only works with exactness
@@ -56,8 +56,8 @@ public class RealComparatorTest {
@Test
public void testHashSet(){
Set<Double> set = new HashSet<Double>();
- set.add(new Double(1.0));
- set.add(new Double(1.0));
+ set.add(1.0);
+ set.add(1.0);
Assert.assertEquals(1, set.size());
}
@@ -67,8 +67,8 @@ public class RealComparatorTest {
@Test
public void testHashSet1(){
Set<Double> set = new HashSet<Double>();
- set.add(new Double(1.0));
- set.add(new Double((Math.sqrt(3.0)*Math.sqrt(3.0))/3.0));
+ set.add(1.0);
+ set.add((Math.sqrt(3.0)*Math.sqrt(3.0))/3.0);
Assert.assertEquals(2, set.size());
}
View it on GitLab: https://salsa.debian.org/java-team/libeuclid-java/-/commit/987f964df22863d8123fddc4a1e52cdf4e0d6f0f
--
View it on GitLab: https://salsa.debian.org/java-team/libeuclid-java/-/commit/987f964df22863d8123fddc4a1e52cdf4e0d6f0f
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20220106/a94b468e/attachment.htm>
More information about the pkg-java-commits
mailing list