<commit_before>from .pattern import Path, Pattern, Port
from .passive import Box, Waveguide
from ..typing import *
from ..utils import _um_str

from collections import defaultdict

import numpy as np
import gdspy as gy

from shapely.geometry import Polygon, MultiPolygon, Point
from shapely.affinity import rotate, translate
from shapely.ops import cascaded_union
from descartes import PolygonPatch
import trimesh
from trimesh import creation, visual
from copy import deepcopy as copy

try:
    import plotly.graph_objects as go
except ImportError:
    pass
try:
    MEEP_IMPORTED = True
    import meep as mp
except ImportError:
    MEEP_IMPORTED = False
try:
    NAZCA_IMPORTED = True
    import nazca as nd
except ImportError:
    NAZCA_IMPORTED = False


class Multilayer:
    def __init__(self, pattern_to_layer: List[Tuple[Union[Pattern, Path, gy.Polygon, gy.FlexPath, Polygon],
                                                    Union[int, str]]] = None):
        self.pattern_to_layer = [] if pattern_to_layer is None else pattern_to_layer
        self.layer_to_pattern, self.port = self._init_multilayer()

    @classmethod
    def from_pattern(cls, pattern: Pattern, layer: str):
        return cls([(pattern, layer)])

    @classmethod
    def from_nazca_cell(cls, cell: nd.Cell):<commit_msg>fixing nd cell again<commit_after>from .pattern import Path, Pattern, Port
from .passive import Box, Waveguide
from ..typing import *
from ..utils import _um_str

from collections import defaultdict

import numpy as np
import gdspy as gy

from shapely.geometry import Polygon, MultiPolygon, Point
from shapely.affinity import rotate, translate
from shapely.ops import cascaded_union
from descartes import PolygonPatch
import trimesh
from trimesh import creation, visual
from copy import deepcopy as copy

try:
    import plotly.graph_objects as go
except ImportError:
    pass
try:
    MEEP_IMPORTED = True
    import meep as mp
except ImportError:
    MEEP_IMPORTED = False
try:
    NAZCA_IMPORTED = True
    import nazca as nd
except ImportError:
    NAZCA_IMPORTED = False


class Multilayer:
    def __init__(self, pattern_to_layer: List[Tuple[Union[Pattern, Path, gy.Polygon, gy.FlexPath, Polygon],
                                                    Union[int, str]]] = None):
        self.pattern_to_layer = [] if pattern_to_layer is None else pattern_to_layer
        self.layer_to_pattern, self.port = self._init_multilayer()

    @classmethod
    def from_pattern(cls, pattern: Pattern, layer: str):
        return cls([(pattern, layer)])

    @classmethod
    def from_nazca_cell(cls, cell: "nd.Cell"):
{'fraction_non_alphanumeric': 0.06725257928926251, 'fraction_numerical': 0.0, 'mean_word_length': 3.467576791808874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7222370', 'n_tokens_mistral': 790, 'n_tokens_neox': 788, 'n_words': 262}