Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup imports #198

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions swiftsimio/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np

from swiftsimio import SWIFTMetadata
from swiftsimio.metadata.objects import SWIFTMetadata

from swiftsimio.objects import InvalidSnapshot

Expand Down Expand Up @@ -423,9 +423,6 @@ def constrain_index(self, index: int):
index : int
The index of the row to select.
"""
if not self.metadata.filetype == "SOAP":
warnings.warn("Not masking a SOAP catalogue, nothing constrained.")
return
for group_name in self.metadata.present_group_names:
setattr(self, group_name, np.array([[index, index + 1]]))
setattr(self, f"{group_name}_size", 1)
Expand Down
21 changes: 8 additions & 13 deletions swiftsimio/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,20 @@
+ SWIFTDataset, a container class for all of the above.
"""


from swiftsimio.accelerated import read_ranges_from_file
from swiftsimio.objects import cosmo_array, cosmo_factor, a
from swiftsimio.objects import cosmo_array, cosmo_factor

from swiftsimio.metadata.objects import (
metadata_discriminator,
SWIFTUnits,
SWIFTGroupMetadata,
SWIFTMetadata,
)

import re
import h5py
import unyt
import numpy as np
import warnings

from datetime import datetime
from pathlib import Path

from typing import Union, Callable, List, Optional
from typing import Union, List


def generate_getter(
Expand Down Expand Up @@ -181,9 +174,11 @@ def getter(self):
cosmo_array(
# Only use column data if array is multidimensional, otherwise
# we will crash here
handle[field][:, columns]
if handle[field].ndim > 1
else handle[field][:],
(
handle[field][:, columns]
if handle[field].ndim > 1
else handle[field][:]
),
unit,
cosmo_factor=cosmo_factor,
name=description,
Expand Down Expand Up @@ -316,7 +311,7 @@ def generate_empty_properties(self):
class __SWIFTNamedColumnDataset(object):
"""
Holder class for individual named datasets. Very similar to
__SWIFTGroupsDatasets but much simpler.
__SWIFTGroupDatasets but much simpler.
"""

def __init__(self, field_path: str, named_columns: List[str], name: str):
Expand Down
2 changes: 0 additions & 2 deletions swiftsimio/subset_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
it to a new file.
"""

from swiftsimio.reader import SWIFTUnits, SWIFTMetadata
from swiftsimio.masks import SWIFTMask
from swiftsimio.accelerated import read_ranges_from_file
import swiftsimio.metadata as metadata

import unyt
import h5py
import numpy as np
from typing import Optional, List
Expand Down
Loading