From 840a067d63485de1e20ac9d9b751d05a3f20ee5d Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Sat, 18 Sep 2021 12:49:39 -0400 Subject: [PATCH] distribution bugfix (2.3.54 release) (#528) * updates `distl` to convert units with recent changes to astropy. See also the changes in 2.3.51 and 2.3.52. * fixes median introduced in 2.3.52 to act on distribution object instead of just arrays. --- README.md | 5 ++++ phoebe/__init__.py | 2 +- phoebe/dependencies/distl/distl.py | 38 +++++++++++++++++------------- phoebe/frontend/bundle.py | 5 ++-- setup.py | 6 ++--- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 20318e2d1..467cbd59c 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,11 @@ To understand how to use PHOEBE, please consult the [tutorials, scripts and manu CHANGELOG ---------- +### 2.3.54 - distribution bugfix + +* updates `distl` to convert units with recent changes to astropy. See also the changes in 2.3.51 and 2.3.52. +* fixes median introduced in 2.3.52 to act on distribution object instead of just arrays. + ### 2.3.53 - adopt_solution adopt_values bugfix * adopting a solution with `adopt_values=True` for a sampler solver will now adopt the median from the samples rather than the mean, to be consistent with the central values reported by the distributions themselves. diff --git a/phoebe/__init__.py b/phoebe/__init__.py index c74e98478..dd1800d32 100644 --- a/phoebe/__init__.py +++ b/phoebe/__init__.py @@ -17,7 +17,7 @@ """ -__version__ = '2.3.53' +__version__ = '2.3.54' import os as _os import sys as _sys diff --git a/phoebe/dependencies/distl/distl.py b/phoebe/dependencies/distl/distl.py index d100486d4..e3355e0a4 100644 --- a/phoebe/dependencies/distl/distl.py +++ b/phoebe/dependencies/distl/distl.py @@ -68,25 +68,29 @@ _builtin_attrs = ['unit', 'label', 'wrap_at', 'dimension', 'dist_constructor_argnames', 'dist_constructor_args', 'dist_constructor_func', 'dist_constructor_object'] _physical_types_to_solar = {'length': 'solRad', - 'mass': 'solMass', - 'temperature': 'solTeff', - 'power': 'solLum', - 'time': 'd', - 'speed': 'solRad/d', - 'angle': 'rad', - 'angular speed': 'rad/d', - 'dimensionless': ''} - -_physical_types_to_si = {'length': 'm', - 'mass': 'kg', - 'temperature': 'K', - 'power': 'W', - 'time': 's', - 'speed': 'm/s', + 'area': 'solRad2', + 'volume': 'solRad3', + 'mass': 'solMass', + 'temperature': 'solTeff', + 'power': 'solLum', + 'time': 'd', + 'speed': 'solRad/d', 'angle': 'rad', - 'angular speed': 'rad/s', + 'angular speed': 'rad/d', 'dimensionless': ''} +_physical_types_to_si = {'length': 'm', + 'area': 'm2', + 'volume': 'm3', + 'mass': 'kg', + 'temperature': 'K', + 'power': 'W', + 'time': 's', + 'speed': 'm/s', + 'angle': 'rad', + 'angular speed': 'rad/s', + 'dimensionless': ''} + def _uniqueid(n=20): return ''.join(_random.SystemRandom().choice( _string.ascii_uppercase +_string.ascii_lowercase) @@ -2102,7 +2106,7 @@ def to_solar(self, strip_units=False): ------------- * distribution object """ - physical_type = self.unit.physical_type + physical_type = str(self.unit.physical_type) if physical_type not in _physical_types_to_solar.keys(): raise NotImplementedError("cannot convert object with physical_type={} to solar units".format(physical_type)) diff --git a/phoebe/frontend/bundle.py b/phoebe/frontend/bundle.py index 22cea2599..09e14c858 100644 --- a/phoebe/frontend/bundle.py +++ b/phoebe/frontend/bundle.py @@ -12073,9 +12073,10 @@ def adopt_solution(self, solution=None, changed_params.append(param) if index is None: - param.set_value(value=np.median(dist.slice(i)), unit=dist.slice(i).unit) + # NOTE: .median() is necesary over np.median() since its acting on a distl object + param.set_value(value=dist.slice(i).median(), unit=dist.slice(i).unit) else: - param.set_index_value(index=index, value=np.median(dist.slice(i)), unit=dist.slice(i).unit) + param.set_index_value(index=index, value=dist.slice(i).median(), unit=dist.slice(i).unit) else: fitted_values = solution_ps.get_value(qualifier='fitted_values', **_skip_filter_checks) diff --git a/setup.py b/setup.py index fe6ca545c..9cbc1569f 100644 --- a/setup.py +++ b/setup.py @@ -346,8 +346,8 @@ def _env_variable_bool(key, default): long_description = "\n".join(long_description_s[long_description_s.index("INTRODUCTION"):]) setup (name = 'phoebe', - version = '2.3.53', - description = 'PHOEBE 2.3.53', + version = '2.3.54', + description = 'PHOEBE 2.3.54', long_description=long_description, author = 'PHOEBE development team', author_email = 'phoebe-devel@lists.sourceforge.net', @@ -367,7 +367,7 @@ def _env_variable_bool(key, default): 'Programming Language :: Python :: 3 :: Only', ], python_requires='>=3.6, <4', - download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.3.53', + download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.3.54', packages = ['phoebe', 'phoebe.parameters', 'phoebe.parameters.solver', 'phoebe.parameters.figure', 'phoebe.frontend', 'phoebe.constraints', 'phoebe.dynamics', 'phoebe.distortions', 'phoebe.algorithms', 'phoebe.atmospheres', 'phoebe.backend', 'phoebe.solverbackends', 'phoebe.solverbackends.ebai', 'phoebe.utils', 'phoebe.helpers', 'phoebe.pool', 'phoebe.dependencies', 'phoebe.dependencies.autofig', 'phoebe.dependencies.nparray', 'phoebe.dependencies.distl', 'phoebe.dependencies.unitsiau2015'], install_requires=['numpy>=1.12','scipy>=1.2','astropy>=1.0', 'corner', 'pytest', 'requests', 'python-socketio[client]']+['flask', 'flask-cors', 'flask-socketio==4.3.*', 'gevent-websocket'], package_data={'phoebe.atmospheres':['tables/wd/*', 'tables/passbands/*'],