Skip to content

Commit

Permalink
rename collections to obj_collections
Browse files Browse the repository at this point in the history
to avoid conflict with builtin `collections`
  • Loading branch information
ioannis-vm committed Oct 9, 2023
1 parent 7ee95cf commit 839bdee
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
16 changes: 8 additions & 8 deletions src/osmg/component_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from dataclasses import dataclass, field
import numpy as np
import numpy.typing as npt
from . import collections
from .ops import element
from . import obj_collections


nparr = npt.NDArray[np.float64]
Expand Down Expand Up @@ -50,19 +50,19 @@ class ComponentAssembly:
"""

uid: int
parent_collection: collections.Collection[int, ComponentAssembly]
parent_collection: obj_collections.Collection[int, ComponentAssembly]
component_purpose: str
external_nodes: collections.NodeCollection = field(init=False)
internal_nodes: collections.NodeCollection = field(init=False)
external_nodes: obj_collections.NodeCollection = field(init=False)
internal_nodes: obj_collections.NodeCollection = field(init=False)
elements: (
collections.CollectionWithConnectivity[int, element.Element]
obj_collections.CollectionWithConnectivity[int, element.Element]
) = field(init=False)

def __post_init__(self):
self.external_nodes = collections.NodeCollection(self)
self.internal_nodes = collections.NodeCollection(self)
self.external_nodes = obj_collections.NodeCollection(self)
self.internal_nodes = obj_collections.NodeCollection(self)
self.elements = (
collections.CollectionWithConnectivity(self)
obj_collections.CollectionWithConnectivity(self)
)

def __srepr__(self):
Expand Down
8 changes: 4 additions & 4 deletions src/osmg/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from dataclasses import dataclass, field
from .collections import Collection
from .collections import NodeCollection
from .obj_collections import Collection
from .obj_collections import NodeCollection

if TYPE_CHECKING:
from .model import Model
Expand Down Expand Up @@ -47,9 +47,9 @@ class Level:
>>> level.elevation
0.0
>>> type(level.nodes)
<class 'osmg.collections.NodeCollection'>
<class 'osmg.obj_collections.NodeCollection'>
>>> type(level.components)
<class 'osmg.collections.Collection'>
<class 'osmg.obj_collections.Collection'>
"""

parent_model: Model = field(repr=False)
Expand Down
18 changes: 9 additions & 9 deletions src/osmg/load_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy.typing as npt
import pandas as pd
from . import transformations
from . import collections
from . import obj_collections
from .preprocessing.tributary_area_analysis import TributaryAreaAnaysis
from .preprocessing.rigid_diaphragm import RDAnalyzer
from .ops import element
Expand Down Expand Up @@ -186,22 +186,22 @@ class LoadCase:

name: str
parent_model: Model
node_loads: collections.Collection[int, PointLoadMass] = field(init=False)
node_mass: collections.Collection[int, PointLoadMass] = field(init=False)
line_element_udl: collections.Collection[int, LineElementUDL] = field(
node_loads: obj_collections.Collection[int, PointLoadMass] = field(init=False)
node_mass: obj_collections.Collection[int, PointLoadMass] = field(init=False)
line_element_udl: obj_collections.Collection[int, LineElementUDL] = field(
init=False
)
tributary_area_analysis: collections.Collection[
tributary_area_analysis: obj_collections.Collection[
int, TributaryAreaAnaysis
] = field(init=False)
parent_nodes: dict[int, Node] = field(default_factory=dict)
equaldof: Optional[int] = field(default=None)

def __post_init__(self):
self.node_loads = collections.Collection(self)
self.node_mass = collections.Collection(self)
self.line_element_udl = collections.Collection(self)
self.tributary_area_analysis = collections.Collection(self)
self.node_loads = obj_collections.Collection(self)
self.node_mass = obj_collections.Collection(self)
self.line_element_udl = obj_collections.Collection(self)
self.tributary_area_analysis = obj_collections.Collection(self)
# initialize loads and mass for each node and element
for node in self.parent_model.list_of_all_nodes():
self.node_loads[node.uid] = PointLoadMass()
Expand Down
22 changes: 11 additions & 11 deletions src/osmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from shapely.geometry import Point # type: ignore

from .gen.uid_gen import UIDGenerator
from . import collections
from . import obj_collections
from .level import Level

if TYPE_CHECKING:
Expand Down Expand Up @@ -118,28 +118,28 @@ class Model:
"""

name: str
levels: collections.CollectionActive[int, Level] = field(init=False)
elastic_sections: collections.Collection[int, ElasticSection] = field(
levels: obj_collections.CollectionActive[int, Level] = field(init=False)
elastic_sections: obj_collections.Collection[int, ElasticSection] = field(
init=False
)
fiber_sections: collections.Collection[int, FiberSection] = field(
fiber_sections: obj_collections.Collection[int, FiberSection] = field(
init=False
)
uniaxial_materials: collections.Collection[int, UniaxialMaterial] = field(
uniaxial_materials: obj_collections.Collection[int, UniaxialMaterial] = field(
init=False
)
physical_materials: collections.Collection[int, PhysicalMaterial] = field(
physical_materials: obj_collections.Collection[int, PhysicalMaterial] = field(
init=False
)
uid_generator: UIDGenerator = field(default_factory=UIDGenerator)
settings: Settings = field(default_factory=Settings)

def __post_init__(self):
self.levels = collections.CollectionActive(self)
self.elastic_sections = collections.Collection(self)
self.fiber_sections = collections.Collection(self)
self.uniaxial_materials = collections.Collection(self)
self.physical_materials = collections.Collection(self)
self.levels = obj_collections.CollectionActive(self)
self.elastic_sections = obj_collections.Collection(self)
self.fiber_sections = obj_collections.Collection(self)
self.uniaxial_materials = obj_collections.Collection(self)
self.physical_materials = obj_collections.Collection(self)

def __repr__(self):
res = ""
Expand Down
6 changes: 3 additions & 3 deletions src/osmg/collections.py → src/osmg/obj_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Collection(dict[TK, TV]):
parent: Object to which the Collection belongs.
Example:
>>> # collections require parent objects to which they belong
>>> # obj_collections require parent objects to which they belong
>>> parent = 52
>>> my_collection = Collection(parent=parent)
>>> my_collection.parent
Expand Down Expand Up @@ -80,7 +80,7 @@ class Collection(dict[TK, TV]):
>>>
>>>
>>>
>>> # Collections.retrieve_by_attr method:
>>> # obj_collections.retrieve_by_attr method:
>>>
>>> from osmg.ops.section import Section
>>> sec_collection = Collection(parent=None)
Expand All @@ -92,7 +92,7 @@ class Collection(dict[TK, TV]):
>>>
>>>
>>>
>>> # Collections.__srepr__ method:
>>> # obj_collections.__srepr__ method:
>>>
>>> sec_collection.__srepr__()
'[Collection of 2 items]'
Expand Down
5 changes: 4 additions & 1 deletion src/osmg/ops/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
#
# https://github.com/ioannis-vm/OpenSees_Model_Generator

from __future__ import annotations
from dataclasses import dataclass, field
from typing import Union
from typing import Optional
from typing import TYPE_CHECKING
import numpy as np
import numpy.typing as npt
from .uniaxial_material import UniaxialMaterial
Expand All @@ -23,7 +25,8 @@
from .section import FiberSection
from ..mesh import Mesh
from ..graphics.visibility import ElementVisibility
from ..component_assembly import ComponentAssembly
if TYPE_CHECKING:
from ..component_assembly import ComponentAssembly


nparr = npt.NDArray[np.float64]
Expand Down
2 changes: 1 addition & 1 deletion src/osmg/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from . import common
from .graphics import general_2d
from . import transformations
from .collections import Collection
from .obj_collections import Collection
from .gen.query import LoadCaseQuery
from .ops import uniaxial_material

Expand Down

0 comments on commit 839bdee

Please sign in to comment.