Skip to content

Commit

Permalink
Change import paths; add supremely unnecessary printing for extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed Jan 7, 2025
1 parent db3a2fa commit ec4ce9a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyomo/contrib/pynumero/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

from ..dependencies import numpy_available, scipy_available
from pyomo.common.dependencies import numpy_available, scipy_available
30 changes: 26 additions & 4 deletions pyomo/contrib/pynumero/sparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,30 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

from ..dependencies import numpy_available, scipy_available
from pyomo.common.dependencies import numpy_available, scipy_available

if numpy_available and scipy_available:
from .block_vector import BlockVector, NotFullyDefinedBlockVectorError
from .block_matrix import BlockMatrix, NotFullyDefinedBlockMatrixError
try:
if numpy_available and scipy_available:
from .block_vector import BlockVector, NotFullyDefinedBlockVectorError
from .block_matrix import BlockMatrix, NotFullyDefinedBlockMatrixError
except ImportError as e:
print("IMPORT ERROR: ", e)
print("Current environment information...")
import sys
import platform
import pkg_resources

print(f"Python version: {platform.python_version()}")
print(f"Python executable: {sys.executable}")
print(f"Platform: {platform.system()} {platform.release()} ({platform.platform()})")

print("\nInstalled packages:")
installed_packages = pkg_resources.working_set
installed_packages_list = sorted(
[f"{pkg.key}=={pkg.version}" for pkg in installed_packages]
)
print("\n".join(installed_packages_list))

print("\nImported packages:")
imported_packages = sorted(sys.modules.keys())
print("\n".join(imported_packages))
2 changes: 1 addition & 1 deletion pyomo/contrib/pynumero/sparse/base_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# These classes are for checking types consistently and raising errors

from ..dependencies import numpy as np
from pyomo.common.dependencies import numpy as np


class BaseBlockVector(object):
Expand Down
4 changes: 2 additions & 2 deletions pyomo/contrib/pynumero/sparse/block_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@

import operator

from ..dependencies import numpy as np
from pyomo.common.dependencies import numpy as np
from .base_block import (
BaseBlockVector,
vec_unary_ufuncs,
Expand Down Expand Up @@ -621,7 +621,7 @@ def compress(self, condition, axis=None, out=None):
accum += nelements
return result
else:
if other.__class__.__name__ == 'MPIBlockVector':
if condition.__class__.__name__ == 'MPIBlockVector':
raise RuntimeError('Operation not supported by BlockVector')
raise NotImplementedError()

Expand Down

0 comments on commit ec4ce9a

Please sign in to comment.