From 9d065e54e35352a89d3302d9ba9f373b561515c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petrus=20Hyv=C3=B6nen?= <petrus.hyvonen@sscspace.com> Date: Tue, 19 Mar 2024 22:30:29 +0100 Subject: [PATCH] Make numpy non-mandatory --- orekit_jpype/orekit_converters.py | 27 ++++++++++++++++----------- pyproject.toml | 3 +-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/orekit_jpype/orekit_converters.py b/orekit_jpype/orekit_converters.py index d07acf2..2a9a317 100644 --- a/orekit_jpype/orekit_converters.py +++ b/orekit_jpype/orekit_converters.py @@ -5,7 +5,7 @@ It is assumed that the JVM is running. Importing this file will automatically implement the changes. """ -import numpy as np + import datetime, math import orekit_jpype @@ -60,21 +60,26 @@ class _JAbsoluteDate(object): int(math.floor(seconds)), int(1000000.0 * (seconds - math.floor(seconds)))) +try: + import numpy as np -@JImplementationFor("double[][]") -class _JDouble2DArray(object): + @JImplementationFor("double[][]") + class _JDouble2DArray(object): - def to_numpy(self) -> np.ndarray: - """ - Get the Java Double 2D Array as a Python numpy array + def to_numpy(self) -> np.ndarray: + """ + Get the Java Double 2D Array as a Python numpy array - Returns: the Double Array as numpy 2D array + Returns: the Double Array as numpy 2D array - """ - return np.array(self) + """ + return np.array(self) + + def __repr__(self): + return f"<{self.getClass().getSimpleName()}: {np.array(self).__str__()}>" - def __repr__(self): - return f"<{self.getClass().getSimpleName()}: {np.array(self).__str__()}>" +except ImportError: + pass # @JImplementationFor("double[]") # class _JDoubleArray(object): diff --git a/pyproject.toml b/pyproject.toml index f76cf97..8ec741e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,8 +25,7 @@ classifiers = [ ] dependencies = [ - 'jpype1', - 'numpy' + 'Jpype1' ] [project.urls] -- GitLab