Skip to content

Commit

Permalink
asdf: use asdf._compression to support asdf 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarrison committed Feb 29, 2024
1 parent b66eafe commit a176bed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
5 changes: 0 additions & 5 deletions abacusnbody/data/asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
from asdf.extension import Compressor, Extension


def _monkey_patch(*args,**kwargs):
raise Exception("Please use abacusnbody.data.asdf.set_nthreads(nthreads)")

asdf.compression.set_decompression_options = _monkey_patch

def set_nthreads(nthreads):
blosc.set_nthreads(nthreads)

Expand Down
8 changes: 6 additions & 2 deletions abacusnbody/data/compaso_halo_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
from pathlib import PurePath

import asdf
import asdf.compression
import astropy.table
import numba as nb
import numpy as np
from astropy.table import Table

try:
import asdf._compression as asdf_compression
except ImportError:
import asdf.compression as asdf_compression

from . import asdf as _asdf
from . import bitpacked

try:
asdf.compression.validate('blsc')
asdf_compression.validate('blsc')
except Exception as e:
raise Exception("Abacus ASDF extension not properly loaded! Try reinstalling abacusutils, or updating ASDF: `pip install asdf>=2.8`") from e

Expand Down
8 changes: 6 additions & 2 deletions abacusnbody/data/pipe_asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@
from timeit import default_timer as timer

import asdf
import asdf.compression
import numpy as np

try:
asdf.compression.validate('blsc')
import asdf._compression as asdf_compression
except ImportError:
import asdf.compression as asdf_compression

try:
asdf_compression.validate('blsc')
except Exception as e:
raise Exception("Abacus ASDF extension not properly loaded! Try reinstalling abacusutils, or updating ASDF: `pip install asdf>=2.8`") from e

Expand Down
9 changes: 7 additions & 2 deletions abacusnbody/data/read_abacus.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ def read_asdf(fn, load=None, colname=None, dtype=np.float32, verbose=True, **kwa
'''

import asdf
import asdf.compression

try:
import asdf._compression as asdf_compression
except ImportError:
import asdf.compression as asdf_compression

try:
asdf.compression.validate('blsc')
asdf_compression.validate('blsc')
except Exception as e:
raise Exception("Abacus ASDF extension not properly loaded! \
Try reinstalling abacusutils: `pip install 'abacusutils>=1'`, \
Expand Down

0 comments on commit a176bed

Please sign in to comment.