Skip to content

Commit

Permalink
further bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed Nov 17, 2023
1 parent 2ed5e97 commit 68a0092
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/run-tests.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# This workflow runs tests for fdtd package.
name: Tests
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
paths-ignore:
- ".github/**"
- "!.github/workflows/main.yml"
- "docs/**"
- "*.md"
- ".git*"

name: fdtd tests

on: [push]
jobs:
build:
runs-on: ubuntu-latest
Expand Down
24 changes: 9 additions & 15 deletions fdtd/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ class Backend:
def __repr__(self):
return self.__class__.__name__

@staticmethod
def is_complex(x):
"""check if an object is a `ComplexFloat`"""
import torch
import numpy as np

return (
isinstance(x, complex)
or (isinstance(x, np.ndarray) and x.dtype in (np.complex64, np.complex128))
or (
isinstance(x, torch.Tensor)
and x.dtype in (torch.complex64, torch.complex128)
)
)


def _replace_float(func):
"""replace the default dtype a function is called with"""
Expand Down Expand Up @@ -204,6 +189,15 @@ def is_array(arr):
numpy = _replace_float(numpy.asarray)
""" convert the array to numpy array """

@staticmethod
def is_complex(x):
"""check if an object is a `ComplexFloat`"""

return isinstance(x, complex) or (
isinstance(x, numpy.ndarray)
and x.dtype in (numpy.complex64, numpy.complex128)
)


# Torch Backend
if TORCH_AVAILABLE:
Expand Down

0 comments on commit 68a0092

Please sign in to comment.